diff options
author | Matthias Andree <matthias.andree@gmx.de> | 2006-12-16 00:37:31 +0000 |
---|---|---|
committer | Matthias Andree <matthias.andree@gmx.de> | 2006-12-16 00:37:31 +0000 |
commit | 0f42d5f6936ccfa0358e385093c99fb9100afa48 (patch) | |
tree | 99fd558fe7ca01c12fca0246aea07358de47fc0d /imap.c | |
parent | 1834845f2c19d89d09d46b83760bfb18676274e6 (diff) | |
download | fetchmail-0f42d5f6936ccfa0358e385093c99fb9100afa48.tar.gz fetchmail-0f42d5f6936ccfa0358e385093c99fb9100afa48.tar.bz2 fetchmail-0f42d5f6936ccfa0358e385093c99fb9100afa48.zip |
Patch by Sunil Shetye:
Track IDLE start time for IMAP, some servers do not reset
their internal counters when sending information asynchronously.
svn path=/branches/BRANCH_6-3/; revision=4990
Diffstat (limited to 'imap.c')
-rw-r--r-- | imap.c | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -46,7 +46,8 @@ static unsigned int *unseen_messages; static int actual_deletions = 0; /* for "IMAP> IDLE" */ -static int saved_timeout = 0; +static int saved_timeout = 0, idle_timeout = 0; +static time_t idle_start_time = 0; static int imap_ok(int sock, char *argbuf) /* parse command response */ @@ -163,6 +164,15 @@ static int imap_ok(int sock, char *argbuf) return(PS_LOCKBUSY); } } + + if (stage == STAGE_IDLE) + { + /* reduce the timeout: servers may not reset their timeout + * when they send some information asynchronously */ + mytimeout = idle_timeout - (time((time_t *) NULL) - idle_start_time); + if (mytimeout <= 0) + return(PS_IDLETIMEOUT); + } } while (tag[0] != '\0' && strncmp(buf, tag, strlen(tag))); @@ -676,7 +686,8 @@ static int imap_idle(int sock) /* special timeout to terminate the IDLE and re-issue it * at least every 28 minutes: * (the server may have an inactivity timeout) */ - mytimeout = 1680; /* 28 min */ + mytimeout = idle_timeout = 1680; /* 28 min */ + time(&idle_start_time); stage = STAGE_IDLE; /* enter IDLE mode */ ok = gen_transact(sock, "IDLE"); @@ -704,7 +715,8 @@ static int imap_idle(int sock) * notification out of the blue. This is in compliance * with RFC 2060 section 5.3. Wait for that with a low * timeout */ - mytimeout = 28; + mytimeout = idle_timeout = 28; + time(&idle_start_time); stage = STAGE_IDLE; /* We are waiting for notification; no tag needed */ tag[0] = '\0'; |