aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--driver.c15
-rw-r--r--fetchmail.h2
-rw-r--r--imap.c9
3 files changed, 20 insertions, 6 deletions
diff --git a/driver.c b/driver.c
index 9c8c6159..06eb6460 100644
--- a/driver.c
+++ b/driver.c
@@ -82,6 +82,7 @@ flag peek_capable; /* can we peek for better error recovery? */
int pass; /* how many times have we re-polled? */
int stage; /* where are we? */
int phase; /* where are we, for error-logging purposes? */
+int mytimeout; /* value of nonreponse timeout */
static const struct method *protocol;
static jmp_buf restart;
@@ -91,7 +92,6 @@ static int tagnum;
#define GENSYM (sprintf(tag, "A%04d", ++tagnum % TAGMOD), tag)
static char shroud[PASSWORDLEN]; /* string to shroud in debug output */
-static int mytimeout; /* value of nonreponse timeout */
static int timeoutcount; /* count consecutive timeouts */
static int msglen; /* actual message length */
@@ -1513,8 +1513,10 @@ const int maxfetch; /* maximum number of messages to fetch */
/*
* If we've exceeded our threshold for consecutive timeouts,
* try to notify the user, then mark the connection wedged.
+ * Don't do this if the connection can idle, though; idle
+ * timeouts just mean the frequency of mail is low.
*/
- if (timeoutcount > MAX_TIMEOUTS
+ if (!ctl->idle && timeoutcount > MAX_TIMEOUTS
&& !open_warning_by_mail(ctl, (struct msgblk *)NULL))
{
stuff_warning(ctl,
@@ -1755,6 +1757,9 @@ const int maxfetch; /* maximum number of messages to fetch */
dispatches = 0;
++pass;
+ /* reset timeout, in case we did an IDLE */
+ mytimeout = ctl->server.timeout;
+
if (outlevel >= O_DEBUG)
{
if (idp->id)
@@ -2196,11 +2201,11 @@ const int maxfetch; /* maximum number of messages to fetch */
}
} while
/*
- * Only re-poll if we had some actual forwards, allowed
- * deletions and had no errors.
+ * Only re-poll if we either had some actual forwards or,
+ * are idling, and allowed deletions and had no errors.
* Otherwise it is far too easy to get into infinite loops.
*/
- (dispatches && protocol->retry && !ctl->keep && !ctl->errcount);
+ ((dispatches || ctl->idle) && protocol->retry && !ctl->keep && !ctl->errcount);
}
no_error:
diff --git a/fetchmail.h b/fetchmail.h
index d469d3c2..605c469b 100644
--- a/fetchmail.h
+++ b/fetchmail.h
@@ -404,6 +404,8 @@ extern int phase;
#define STAGE_LOGOUT 4
extern int stage;
+extern int mytimeout;
+
/* mark values for name lists */
#define XMIT_ACCEPT 1 /* accepted; matches local domain or name */
#define XMIT_REJECT 2 /* rejected; no match */
diff --git a/imap.c b/imap.c
index fe8bffe7..9926dad2 100644
--- a/imap.c
+++ b/imap.c
@@ -100,7 +100,11 @@ int imap_ok(int sock, char *argbuf)
*/
if (idling)
{
- gen_send(sock, "DONE");
+ /* we do our own write and report here to disable tagging */
+ SockWrite(sock, "DONE\r\n", 6);
+ if (outlevel >= O_MONITOR)
+ report(stdout, "IMAP> DONE\n");
+
idling = FALSE;
}
}
@@ -1081,6 +1085,9 @@ static int imap_getrange(int sock,
ok = internal_expunge(sock);
count = -1;
idling = do_idle;
+ if (idling)
+ /* this is the RFC2177-recommended timeout for an IDLE */
+ mytimeout = 29 * 60;
if (ok || gen_transact(sock, do_idle ? "IDLE" : "NOOP"))
{
report(stderr, _("re-poll failed\n"));