From 9cb888960d9191a2442bd194e84f3e56ac809eed Mon Sep 17 00:00:00 2001
From: "Eric S. Raymond"
Date: Fri, 28 Feb 2003 11:02:53 +0000
Subject: IDLE implementation.
svn path=/trunk/; revision=3794
---
NEWS | 4 ++++
fetchmail.h | 2 ++
fetchmail.man | 2 +-
imap.c | 26 ++++++++++++++++++++++++--
socket.c | 2 ++
todo.html | 12 ++----------
transact.c | 5 ++++-
7 files changed, 39 insertions(+), 14 deletions(-)
diff --git a/NEWS b/NEWS
index f52f1035..58a1221c 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,10 @@
STARTTLS negotiation.
* Sunil's patch to make handling of failed STARTTLS more graceful.
* Sunil's JF2 fix patch for .fetchmailrc security fix.
+* Christophe GIAUME finished the implementation
+ of RFC2177 IDLE.
+* Jason Tishler's fix patch for Cygwin.
+* Spanish and Polish translations updated.
fetchmail-6.2.1 (Tue Jan 14 08:17:19 EST 2003), 22219 lines:
diff --git a/fetchmail.h b/fetchmail.h
index 309e611c..df6563c2 100644
--- a/fetchmail.h
+++ b/fetchmail.h
@@ -94,6 +94,7 @@
#define PS_BSMTP 12 /* output batch could not be opened */
#define PS_MAXFETCH 13 /* poll ended by fetch limit */
#define PS_SERVBUSY 14 /* server is busy */
+#define PS_IDLETIMEOUT 15 /* timeout on imap IDLE */
/* leave space for more codes */
#define PS_UNDEFINED 23 /* something I hadn't thought of */
#define PS_TRANSIENT 24 /* transient failure (internal use) */
@@ -426,6 +427,7 @@ void report_at_line ();
/* driver.c -- main driver loop */
void set_timeout(int);
+int isidletimeout(void);
int do_protocol(struct query *, const struct method *);
/* transact.c: transaction support */
diff --git a/fetchmail.man b/fetchmail.man
index 3a5e29bb..3d707a9d 100644
--- a/fetchmail.man
+++ b/fetchmail.man
@@ -1240,7 +1240,7 @@ T}
set syslog \& T{
Do error logging through syslog(3).
T}
-set nosyslog \& T{
+set no syslog \& T{
Turn off error logging through syslog(3).
T}
set properties \& T{
diff --git a/imap.c b/imap.c
index 9d4a506d..96a6685d 100644
--- a/imap.c
+++ b/imap.c
@@ -544,11 +544,33 @@ static int internal_expunge(int sock)
static int imap_idle(int sock)
/* start an RFC2177 IDLE */
{
+ int ok;
+
+ /* special timeout to terminate the IDLE and re-issue it
+ * at least every 28 minutes:
+ * (the server may have an inactivity timeout) */
stage = STAGE_IDLE;
saved_timeout = mytimeout;
- mytimeout = 0;
+ mytimeout = 1680; /* 28 min */
+
+ /* enter IDLE mode */
+ ok = gen_transact(sock, "IDLE");
- return (gen_transact(sock, "IDLE"));
+ if(ok == PS_IDLETIMEOUT) {
+ /* send "DONE" continuation */
+ SockWrite(sock, "DONE\r\n", 6);
+ if (outlevel >= O_MONITOR)
+ report(stdout, "IMAP> DONE\n");
+
+ /* restore normal timeout value */
+ mytimeout = saved_timeout;
+ stage = STAGE_FETCH;
+
+ /* get OK IDLE message */
+ return imap_ok(sock, NULL);
+ } else
+ /* not idle timeout */
+ return ok;
}
static int imap_getrange(int sock,
diff --git a/socket.c b/socket.c
index bef0deea..47f074dd 100644
--- a/socket.c
+++ b/socket.c
@@ -1018,6 +1018,8 @@ static ssize_t cygwin_read(int sock, void *buf, size_t count)
return(-1);
}
}
+
+ return count;
}
#endif /* __CYGWIN__ */
diff --git a/todo.html b/todo.html
index 47d4c186..4a64aac1 100644
--- a/todo.html
+++ b/todo.html
@@ -19,7 +19,7 @@ content="Known bugs and to-do items in fetchmail" />
Back to Eric's Home Page |
Up to Site Map |
-$Date: 2002/09/17 09:36:00 $ |
+$Date: 2003/02/28 11:02:51 $ |
@@ -31,14 +31,6 @@ fetchmail is now pretty mature and I have many other projects, so I
don't personally chase obscure or marginal problems. Help with any
of these will be cheerfully accepted.
-IDLE is not fully implemented. Fetchmail does not time out the
-idle connection every 30 minutes or less as required by RFC2177.
-Some servers (including UW IMAPD compiled without the
-MICROSOFT_BRAIN_DAMAGE option, as is the default) will drop the
-connection after 30 minutes, resulting in a spurious socket error
-in your logs and no mail being picked up until the next poll
-cycle.
-
POP3 can't presently distinguish a wedged or down server from an
authentication failure. Possible fix: after issuing a PASS command.
wait 300 (xx) seconds for a "-ERR" or a "+OK" . If nothing comes
@@ -79,7 +71,7 @@ reports.
Back to Eric's Home Page |
Up to Site Map |
-$Date: 2002/09/17 09:36:00 $ |
+$Date: 2003/02/28 11:02:51 $ |
diff --git a/transact.c b/transact.c
index 6fbe1879..6674a3ff 100644
--- a/transact.c
+++ b/transact.c
@@ -1446,7 +1446,10 @@ int size; /* length of buffer */
{
set_timeout(0);
phase = oldphase;
- return(PS_SOCKET);
+ if(isidletimeout())
+ return(PS_IDLETIMEOUT);
+ else
+ return(PS_SOCKET);
}
else
{
--
cgit v1.2.3