1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-18 02:55:12 +00:00

Improve failure handling in mail threads.

When we have a failure in the mail thread, lookup the hostname again in
case the failure is due odd to DNS changes, or some other madness.
This commit is contained in:
Brenden Matthews 2010-09-09 10:48:57 -07:00
parent 5e6a5fdb3c
commit d0a20850c8

View File

@ -671,6 +671,11 @@ static void imap_thread(thread_handle &handle, struct mail_s *mail)
int res; int res;
fd_set fdset; fd_set fdset;
if (fail > 0) {
NORM_ERR("Trying IMAP connection again for %s@%s (try %u/%u)",
mail->user, mail->host, fail + 1, mail->retries);
resolved_host = 0; /* force us to resolve the hostname again */
}
if (!resolved_host) { if (!resolved_host) {
memset(&hints, 0, sizeof(struct addrinfo)); memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC; hints.ai_family = AF_UNSPEC;
@ -687,10 +692,6 @@ static void imap_thread(thread_handle &handle, struct mail_s *mail)
} }
resolved_host = 1; resolved_host = 1;
} }
if (fail > 0) {
NORM_ERR("Trying IMAP connection again for %s@%s (try %u/%u)",
mail->user, mail->host, fail + 1, mail->retries);
}
do { do {
for (rp = ai; rp != NULL; rp = rp->ai_next) { for (rp = ai; rp != NULL; rp = rp->ai_next) {
sockfd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); sockfd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
@ -1014,6 +1015,12 @@ static void pop3_thread(thread_handle &handle, struct mail_s *mail)
struct timeval fetchtimeout; struct timeval fetchtimeout;
int res; int res;
fd_set fdset; fd_set fdset;
if (fail > 0) {
NORM_ERR("Trying POP3 connection again for %s@%s (try %u/%u)",
mail->user, mail->host, fail + 1, mail->retries);
resolved_host = 0; /* force us to resolve the hostname again */
}
if (!resolved_host) { if (!resolved_host) {
memset(&hints, 0, sizeof(struct addrinfo)); memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC; hints.ai_family = AF_UNSPEC;
@ -1028,11 +1035,7 @@ static void pop3_thread(thread_handle &handle, struct mail_s *mail)
fail++; fail++;
break; break;
} }
resolved_host = 1; resolved_host = 1;
}
if (fail > 0) {
NORM_ERR("Trying POP3 connection again for %s@%s (try %u/%u)",
mail->user, mail->host, fail + 1, mail->retries);
} }
do { do {
for (rp = ai; rp != NULL; rp = rp->ai_next) { for (rp = ai; rp != NULL; rp = rp->ai_next) {