1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-23 19:39:06 +00:00

close pop3/imap sockets

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@811 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Philip Kovacs 2006-12-11 19:04:58 +00:00
parent 09fda8a54f
commit 4e8212d978
3 changed files with 17 additions and 5 deletions

View File

@ -1,5 +1,8 @@
# $Id$
2006-12-11
* Close pop3/imap sockets.
2006-12-10
* Fix peek table bug with new portmon code.

View File

@ -38,13 +38,16 @@
#include <netinet/in.h>
#include <netdb.h>
#ifdef HAVE_ICONV
#include <iconv.h>
#endif
#include "build.h"
#ifndef S_ISSOCK
#define S_ISSOCK(x) ((x & S_IFMT) == S_IFSOCK)
#endif
#define CONFIG_FILE "$HOME/.conkyrc"
#define MAIL_FILE "$MAIL"
#define MAX_IF_BLOCK_DEPTH 5
@ -1272,6 +1275,7 @@ void *imap_thread(struct mail_s* mail)
int fail = 0;
unsigned int old_unseen = UINT_MAX;
unsigned int old_messages = UINT_MAX;
struct stat stat_buf;
struct hostent *he;
struct sockaddr_in their_addr; // connector's address information
if ((he = gethostbyname(mail->host)) == NULL) { // get the host info
@ -1430,7 +1434,6 @@ void *imap_thread(struct mail_s* mail)
fail++;
goto next_iteration;
}
close(sockfd);
if (strlen(mail->command) > 1 && (mail->unseen > old_unseen || (mail->messages > old_messages && mail->unseen > 0))) { // new mail goodie
if (system(mail->command) == -1) {
perror("system()");
@ -1440,6 +1443,9 @@ void *imap_thread(struct mail_s* mail)
old_unseen = mail->unseen;
old_messages = mail->messages;
next_iteration:
if ((fstat(sockfd, &stat_buf)==0) && S_ISSOCK(stat_buf.st_mode))
/* if a valid socket, close it */
close(sockfd);
if (timed_thread_test (mail->p_timed_thread))
timed_thread_exit (mail->p_timed_thread);
}
@ -1454,6 +1460,7 @@ void *pop3_thread(struct mail_s *mail)
char *reply;
int fail = 0;
unsigned int old_unseen = UINT_MAX;
struct stat stat_buf;
struct hostent *he;
struct sockaddr_in their_addr; // connector's address information
if ((he = gethostbyname(mail->host)) == NULL) { // get the host info
@ -1631,7 +1638,6 @@ void *pop3_thread(struct mail_s *mail)
fail++;
goto next_iteration;
}
close(sockfd);
if (strlen(mail->command) > 1 && mail->unseen > old_unseen) { // new mail goodie
if (system(mail->command) == -1) {
perror("system()");
@ -1640,6 +1646,9 @@ void *pop3_thread(struct mail_s *mail)
fail = 0;
old_unseen = mail->unseen;
next_iteration:
if ((fstat(sockfd, &stat_buf)==0) && S_ISSOCK(stat_buf.st_mode))
/* if a valid socket, close it */
close(sockfd);
if (timed_thread_test (mail->p_timed_thread))
timed_thread_exit (mail->p_timed_thread);
}

View File

@ -185,8 +185,8 @@ void show_connection_to_tcp_port_monitor(
* the monitor's port range of interest. Connections of interest are first
* looked up in the hash to see if they are already there. If they are, we
* reset the age of the connection so it is not deleted. If the connection
* is not in the hash, we add it, but only if the hash is not saturated.
* The function takes O(1) time. */
* is not in the hash, we add it, but only if we haven't exceeded the maximum
* connection limit for the monitor. The function takes O(1) time. */
tcp_connection_node_t *p_node;
tcp_connection_t *p_connection, *p_conn_hash;