From ae927535843d8a12ff7d337948b7fe6cbdc0795b Mon Sep 17 00:00:00 2001 From: Brenden Matthews Date: Thu, 25 Sep 2008 18:29:04 +0000 Subject: [PATCH] close socket before exiting thread git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@1259 7f574dfc-610e-0410-a909-a81674777703 --- src/conky.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/conky.c b/src/conky.c index 3aaa0921..d85db450 100644 --- a/src/conky.c +++ b/src/conky.c @@ -1839,10 +1839,11 @@ void *imap_thread(void *arg) FD_SET(sockfd, &fdset); FD_SET(threadfd, &fdset); res = pselect(MAX(sockfd + 1, threadfd + 1), &fdset, NULL, NULL, NULL, &oldmask); - if (timed_thread_test(mail->p_timed_thread)) { - timed_thread_exit(mail->p_timed_thread); - } - if ((res == -1 && errno == EINTR) || FD_ISSET(threadfd, &fdset)) { + if (timed_thread_test(mail->p_timed_thread) || (res == -1 && errno == EINTR) || FD_ISSET(threadfd, &fdset)) { + if ((fstat(sockfd, &stat_buf) == 0) && S_ISSOCK(stat_buf.st_mode)) { + /* if a valid socket, close it */ + close(sockfd); + } timed_thread_exit(mail->p_timed_thread); } else if (res > 0) { if ((numbytes = recv(sockfd, recvbuf, MAXDATASIZE - 1, 0)) == -1) {