aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1998-02-17 22:58:54 +0000
committerEric S. Raymond <esr@thyrsus.com>1998-02-17 22:58:54 +0000
commit38528f8329458e9faf675677bc7a2e4524af3aa4 (patch)
tree0508254c0a10dd52d2773e36b648071ab6258192
parent2087cffd2b5bb197d12c2195ad1c054797abfdd1 (diff)
downloadfetchmail-38528f8329458e9faf675677bc7a2e4524af3aa4.tar.gz
fetchmail-38528f8329458e9faf675677bc7a2e4524af3aa4.tar.bz2
fetchmail-38528f8329458e9faf675677bc7a2e4524af3aa4.zip
Fix bad UID/fetchlimit interaction.
svn path=/trunk/; revision=1645
-rw-r--r--NEWS1
-rw-r--r--driver.c6
-rw-r--r--fetchmail.h15
-rw-r--r--uid.c25
4 files changed, 30 insertions, 17 deletions
diff --git a/NEWS b/NEWS
index f5d2afd2..9cba63db 100644
--- a/NEWS
+++ b/NEWS
@@ -51,6 +51,7 @@ fetchmail-4.3.7 ()
* Minor port patches from Philippe De Muyter.
* Patch by Chun-Chung Chen <cjj@u.washington.edu> to handle quotes in .netrc
* IPv6 and IPSEC support patches from Craig Metz.
+* Fix bad interaction between UID handling and fetchmail.
fetchmail-4.3.6 (Fri Jan 23 00:25:57 EST 1998)
* Improved RPM packaging with correct grouping and an icon.
diff --git a/driver.c b/driver.c
index cdfa866d..7afe9d3d 100644
--- a/driver.c
+++ b/driver.c
@@ -2069,6 +2069,12 @@ const struct method *proto; /* protocol method table */
* now.
*/
+ /* tell the UID code we've seen this */
+ if (ctl->newsaved)
+ for (idp = ctl->newsaved; idp; idp = idp->next)
+ if (idp->val.num == num)
+ MARK_SEEN(idp->val.num);
+
/* maybe we delete this message now? */
if (retained)
{
diff --git a/fetchmail.h b/fetchmail.h
index 50ce5640..3347889f 100644
--- a/fetchmail.h
+++ b/fetchmail.h
@@ -159,10 +159,6 @@ struct query
int batchlimit; /* max # msgs to pass in single SMTP session */
int expunge; /* max # msgs to pass between expunges */
- /* unseen, previous state of mailbox (initially from .fetchids) */
-#define UID_KEPT 0 /* this was remembered from a previous run */
-#define UID_DELETED -1 /* this message has been deleted */
-#define UID_EXPUNGED -2 /* this message has been expunged */
struct idlist *oldsaved, *newsaved;
/* internal use */
@@ -175,6 +171,17 @@ struct query
};
/*
+ * UID-index information. If the sign bit is on, this means the
+ * message UID has been seen or expunged and should be written
+ * out to .fetchids at end of run.
+ */
+#define UID_KEPT 0 /* remembered from a previous run */
+#define UID_DELETED INT_MIN /* this message has been deleted */
+#define UID_EXPUNGED INT_MAX /* this message has been expunged */
+#define SAVE_UID(n) ((n) < 0) /* must this UID be saved? */
+#define MARK_SEEN(n) n *= -1 /* mark a UID seen */
+
+/*
* Numeric option handling. Numeric option value of zero actually means
* it's unspecified. Value less than zero is zero.
*/
diff --git a/uid.c b/uid.c
index 54d41589..1a904656 100644
--- a/uid.c
+++ b/uid.c
@@ -7,6 +7,7 @@
#include "config.h"
#include <stdio.h>
+#include <limits.h>
#if defined(STDC_HEADERS)
#include <stdlib.h>
#include <string.h>
@@ -44,6 +45,8 @@
* Each time a message is fetched, we can check its UID against the
* `oldsaved' list to see if it is old.
*
+ * Each time a message-id is seen, we mark it with MARK_SEEN.
+ *
* Each time a message is deleted, we mark its id UID_DELETED in the
* `newsaved' member. When we want to assert that an expunge has been
* done on the server, we call expunge_uid() to register that all
@@ -52,13 +55,9 @@
* At the end of the query, the `newsaved' member becomes the
* `oldsaved' list. The old `oldsaved' list is freed.
*
- * At the end of the fetchmail run, non-EXPUNGED members of all
+ * At the end of the fetchmail run, seen and non-EXPUNGED members of all
* current `oldsaved' lists are flushed out to the .fetchids file to
- * be picked up by the next run. (The UID_EXPUNGED test means that a
- * message marked UID_DELETED may still have its ID go to disk if
- * there has been no intervening expunge operation. This typically
- * comes up if the query was aborted by a line hit before a quit or
- * expunge was sent to the server.) If there are no un-expunged
+ * be picked up by the next run. If there are no un-expunged
* messages, the file is deleted.
*
* Note: all comparisons are caseblind!
@@ -195,8 +194,8 @@ int str_nr_in_list( struct idlist **idl, const char *str )
return -1;
}
-int str_nr_last_in_list( struct idlist **idl, const char *str )
- /* return the last position of str in idl */
+int str_nr_last_in_list( struct idlist **idl, const char *str)
+/* return the last position of str in idl */
{
int nr, ret = -1;
struct idlist *walk;
@@ -208,16 +207,16 @@ int str_nr_last_in_list( struct idlist **idl, const char *str )
return ret;
}
-int count_list( struct idlist **idl )
- /* count the number of elements in the list */
+int count_list( struct idlist **idl)
+/* count the number of elements in the list */
{
if( !*idl )
return 0;
return 1 + count_list( &(*idl)->next );
}
-char* str_from_nr_list( struct idlist **idl, int number )
- /* return the number'th string in idl */
+char *str_from_nr_list(struct idlist **idl, int number)
+/* return the number'th string in idl */
{
if( !*idl || number < 0)
return 0;
@@ -331,7 +330,7 @@ void write_saved_lists(struct query *hostlist, const char *idfile)
if ((tmpfp = fopen(idfile, "w")) != (FILE *)NULL) {
for (ctl = hostlist; ctl; ctl = ctl->next) {
for (idp = ctl->oldsaved; idp; idp = idp->next)
- if (idp->val.num != UID_EXPUNGED)
+ if (SAVE_UID(idp->val.num))
fprintf(tmpfp, "%s@%s %s\n",
ctl->remotename, ctl->server.truename, idp->id);
}