diff options
author | Eric S. Raymond <esr@thyrsus.com> | 1997-07-03 15:45:19 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 1997-07-03 15:45:19 +0000 |
commit | 86c75af0c1cae1706b84b708c70e76a96ddc5641 (patch) | |
tree | 60664bf7a9a103667fbfea4dba0251e439f41f67 | |
parent | eb9b73194c24bd4e08b1bcaf254a5bbb8aa91c1f (diff) | |
download | fetchmail-86c75af0c1cae1706b84b708c70e76a96ddc5641.tar.gz fetchmail-86c75af0c1cae1706b84b708c70e76a96ddc5641.tar.bz2 fetchmail-86c75af0c1cae1706b84b708c70e76a96ddc5641.zip |
LOCKBUSY changes.
svn path=/trunk/; revision=1147
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | driver.c | 25 | ||||
-rw-r--r-- | fetchmail.c | 2 | ||||
-rw-r--r-- | fetchmail.h | 11 | ||||
-rw-r--r-- | fetchmail.man | 11 | ||||
-rw-r--r-- | pop3.c | 39 |
6 files changed, 73 insertions, 19 deletions
@@ -32,8 +32,10 @@ And about time, too, I've been hacking on this code for a year now! * Fixes for minor compilation glitches on non-Linux systems. * Progress messages now show total count as well as message number. * Removed the popclient backward-compatibility hacks. +* Leif Erlingsson <leif@lege.com> sent a patch to avoid colliding with + the busy-lock after authentication failure on a POP3 server. -There are 251 people on the fetchmail-friends list. +There are 252 people on the fetchmail-friends list. ------------------------------------------------------------------------------ pl 3.9.9 (Wed Jun 25 11:01:51 EDT 1997): @@ -1364,13 +1364,20 @@ const struct method *proto; /* protocol method table */ shroud = ctl->password; ok = (protocol->getauth)(sock, ctl, buf); shroud = (char *)NULL; - if (ok == PS_ERROR) - ok = PS_AUTHFAIL; if (ok != 0) { - error(0, -1, "Authorization failure on %s@%s", - ctl->remotename, - realname); + if (ok == PS_LOCKBUSY) + error(0, -1, "Lock Busy error on %s@%s", + ctl->remotename, + realname); + else + { + if (ok == PS_ERROR) + ok = PS_AUTHFAIL; + error(0, -1, "Authorization failure on %s@%s", + ctl->remotename, + realname); + } goto cleanUp; } set_timeout(ctl->server.timeout); @@ -1678,6 +1685,9 @@ const struct method *proto; /* protocol method table */ case PS_PROTOCOL: msg = "client/server protocol"; break; + case PS_LOCKBUSY: + msg = "lock busy on server"; + break; case PS_SMTP: msg = "SMTP transaction"; break; @@ -1685,8 +1695,9 @@ const struct method *proto; /* protocol method table */ error(0, 0, "undefined"); break; } - if (ok==PS_SOCKET || ok==PS_AUTHFAIL || ok==PS_SYNTAX || ok==PS_IOERR - || ok==PS_ERROR || ok==PS_PROTOCOL || ok==PS_SMTP) + if (ok==PS_SOCKET || ok==PS_AUTHFAIL || ok==PS_SYNTAX + || ok==PS_IOERR || ok==PS_ERROR || ok==PS_PROTOCOL + || ok==PS_LOCKBUSY || ok==PS_SMTP) error(0, -1, "%s error while fetching from %s", msg, ctl->server.names->id); closeUp: diff --git a/fetchmail.c b/fetchmail.c index da007d00..1232967c 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -786,7 +786,7 @@ static int query_host(struct query *ctl) for (i = 0; i < sizeof(autoprobe)/sizeof(autoprobe[0]); i++) { ctl->server.protocol = autoprobe[i]; - if ((st = query_host(ctl)) == PS_SUCCESS || st == PS_NOMAIL || st == PS_AUTHFAIL) + if ((st = query_host(ctl)) == PS_SUCCESS || st == PS_NOMAIL || st == PS_AUTHFAIL || st == PS_LOCKBUSY) break; } ctl->server.protocol = P_AUTO; diff --git a/fetchmail.h b/fetchmail.h index 30a5c0f8..8ebc0e43 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -36,11 +36,12 @@ #define PS_SYNTAX 5 /* command-line syntax error */ #define PS_IOERR 6 /* bad permissions on rc file */ #define PS_ERROR 7 /* protocol error */ -#define PS_EXCLUDE 8 /* exclusion error */ -#define PS_SMTP 9 /* SMTP error */ -#define PS_UNDEFINED 10 /* something I hadn't thought of */ -#define PS_TRANSIENT 11 /* transient failure (internal use) */ -#define PS_REFUSED 12 /* mail refused (internal use) */ +#define PS_EXCLUDE 8 /* client-side exclusion error */ +#define PS_LOCKBUSY 9 /* server responded lock busy */ +#define PS_SMTP 10 /* SMTP error */ +#define PS_UNDEFINED 11 /* something I hadn't thought of */ +#define PS_TRANSIENT 12 /* transient failure (internal use) */ +#define PS_REFUSED 13 /* mail refused (internal use) */ /* output noise level */ #define O_SILENT 0 /* mute, max squelch, etc. */ diff --git a/fetchmail.man b/fetchmail.man index 285101c0..636d1167 100644 --- a/fetchmail.man +++ b/fetchmail.man @@ -1080,15 +1080,22 @@ fire if .I fetchmail timed out while waiting for the server. .IP 8 -Exclusion error. This means +Client-side exclusion error. This means .I fetchmail either found another copy of itself already running, or failed in such a way that it isn't sure whether another copy is running. .IP 9 +The user authentication step failed because the server responded "lock +busy". Try again after a brief pause! This error is not implemented +for all protocols, nor for all servers. If not implemented for your +server, "3" will be returned instead, see above. May be returned when +talking to qpopper or other servers that can respond with "lock busy" +or some similar text containing the word "lock". +.IP 10 The .I fetchmail. run failed while trying to do an SMTP port open or transaction. -.IP 10 +.IP 11 Internal error. You should see a message on standard error with details. .PP @@ -21,6 +21,8 @@ #define PROTOCOL_ERROR {error(0, 0, "protocol error"); return(PS_ERROR);} +#define LOCKBUSY_ERROR {error(0, 0, "lock busy! Is another session active?"); return(PS_LOCKBUSY);} + extern char *strstr(); /* needed on sysV68 R3V7.1. */ static int last; @@ -47,7 +49,22 @@ int pop3_ok (int sock, char *argbuf) if (strcmp(buf,"+OK") == 0) ok = 0; else if (strcmp(buf,"-ERR") == 0) - ok = PS_ERROR; + { + /* + * We're checking for "lock busy", "unable to lock", + * "already locked" etc. here. This indicates that we + * have to wait for the server to clean up before we + * can poll again. + * + * PS_LOCKBUSY check empirically verified with two recent + * versions the Berkeley popper; QPOP (version 2.2) and + * QUALCOMM Pop server derived from UCB (version 2.1.4-R3) + */ + if (strstr(bufp,"lock")||strstr(bufp,"Lock")||strstr(bufp,"LOCK")) + ok = PS_LOCKBUSY; + else + ok = PS_ERROR; + } else ok = PS_PROTOCOL; @@ -61,6 +78,8 @@ int pop3_ok (int sock, char *argbuf) int pop3_getauth(int sock, struct query *ctl, char *greeting) /* apply for connection authorization */ { + int ok; + /* build MD5 digest from greeting timestamp + password */ if (ctl->server.protocol == P_APOP) { @@ -99,8 +118,21 @@ int pop3_getauth(int sock, struct query *ctl, char *greeting) if ((gen_transact(sock, "USER %s", ctl->remotename)) != 0) PROTOCOL_ERROR - if ((gen_transact(sock, "PASS %s", ctl->password)) != 0) + if ((ok = gen_transact(sock, "PASS %s", ctl->password)) != 0) + { + if (ok == PS_LOCKBUSY) + LOCKBUSY_ERROR PROTOCOL_ERROR + } + + /* + * Empirical experience shows some server/OS combinations + * may need a brief pause even after any lockfiles on the + * server are released, to give the server time to finish + * copying back very large mailfolders from the temp-file... + * this is only ever an issue with extremely large mailboxes. + */ + sleep(3); /* to be _really_ safe, probably need sleep(5)! */ break; case P_APOP: @@ -247,7 +279,7 @@ static int pop3_fetch(int sock, struct query *ctl, int number, int *lenp) /* * Look for "nnn octets" -- there may or may not be preceding cruft. - * It's OK to punt and return 0 as a failure indication here, as + * It's OK to punt and pass back -1 as a failure indication here, as * long as the force_getsizes flag has forced sizes to be preloaded. */ if ((cp = strstr(buf, " octets")) == (char *)NULL) @@ -258,6 +290,7 @@ static int pop3_fetch(int sock, struct query *ctl, int number, int *lenp) continue; *lenp = atoi(++cp); } + return(0); } |