aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2000-04-16 05:16:02 +0000
committerEric S. Raymond <esr@thyrsus.com>2000-04-16 05:16:02 +0000
commitb9923882dd40ed3bc139ae0cf27bdc7b2d8ff560 (patch)
tree996955729e152f28ed95453a1d3123f3bf523ec6
parent37ffcb8777dc48327f697f9800876cf37934a6ea (diff)
downloadfetchmail-b9923882dd40ed3bc139ae0cf27bdc7b2d8ff560.tar.gz
fetchmail-b9923882dd40ed3bc139ae0cf27bdc7b2d8ff560.tar.bz2
fetchmail-b9923882dd40ed3bc139ae0cf27bdc7b2d8ff560.zip
Instrumentation to catch the re-poll bug.
svn path=/trunk/; revision=2874
-rw-r--r--imap.c86
1 files changed, 46 insertions, 40 deletions
diff --git a/imap.c b/imap.c
index 1a294abe..1ddf18d1 100644
--- a/imap.c
+++ b/imap.c
@@ -1084,6 +1084,8 @@ static int imap_getrange(int sock,
{
count = 0;
}
+ if (outlevel >= O_DEBUG)
+ report(stdout, "%d messages waiting after re-poll\n", count);
}
else
{
@@ -1095,57 +1097,61 @@ static int imap_getrange(int sock,
report(stderr, _("mailbox selection failed\n"));
return(ok);
}
+ else if (outlevel >= O_DEBUG)
+ report(stdout, "%d messages waiting after first poll\n", count);
}
*countp = count;
/* OK, now get a count of unseen messages and their indices */
+ if (!ctl->fetchall && count > 0)
+ {
+ if (unseen_messages)
+ free(unseen_messages);
+ unseen_messages = xmalloc(count * sizeof(unsigned int));
+ memset(unseen_messages, 0, count * sizeof(unsigned int));
+ unseen = 0;
+
+ gen_send(sock, "SEARCH UNSEEN");
+ do {
+ ok = gen_recv(sock, buf, sizeof(buf));
+ if (ok != 0)
+ {
+ report(stderr, _("search for unseen messages failed\n"));
+ return(PS_PROTOCOL);
+ }
+ else if ((cp = strstr(buf, "* SEARCH")))
+ {
+ char *ep;
- if (unseen_messages)
- free(unseen_messages);
- unseen_messages = xmalloc(count * sizeof(unsigned int));
- memset(unseen_messages, 0, count * sizeof(unsigned int));
- unseen = 0;
-
- gen_send(sock, "SEARCH UNSEEN");
- do {
- ok = gen_recv(sock, buf, sizeof(buf));
- if (ok != 0)
- {
- report(stderr, _("search for unseen messages failed\n"));
- return(PS_PROTOCOL);
- }
- else if ((cp = strstr(buf, "* SEARCH")))
- {
- char *ep;
-
- cp += 8; /* skip "* SEARCH" */
+ cp += 8; /* skip "* SEARCH" */
- while (*cp && unseen < count)
- {
- /* skip whitespace */
- while (*cp && isspace(*cp))
- cp++;
- if (*cp)
+ while (*cp && unseen < count)
{
- /*
- * Message numbers are between 1 and 2^32 inclusive,
- * so unsigned int is large enough.
- */
- unseen_messages[unseen]=(unsigned int)strtol(cp,&ep,10);
-
- if (outlevel >= O_DEBUG)
- report(stdout,
- _("%u is unseen\n"),
- unseen_messages[unseen]);
+ /* skip whitespace */
+ while (*cp && isspace(*cp))
+ cp++;
+ if (*cp)
+ {
+ /*
+ * Message numbers are between 1 and 2^32 inclusive,
+ * so unsigned int is large enough.
+ */
+ unseen_messages[unseen]=(unsigned int)strtol(cp,&ep,10);
+
+ if (outlevel >= O_DEBUG)
+ report(stdout,
+ _("%u is unseen\n"),
+ unseen_messages[unseen]);
- unseen++;
- cp = ep;
+ unseen++;
+ cp = ep;
+ }
}
}
- }
- } while
- (tag[0] != '\0' && strncmp(buf, tag, strlen(tag)));
+ } while
+ (tag[0] != '\0' && strncmp(buf, tag, strlen(tag)));
+ }
*newp = unseen;
expunged = 0;