From fd1ddc79d9205c3101529654fe73a3bd346f2358 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 27 Dec 1999 08:07:10 +0000 Subject: Minor optimizations from Federico. svn path=/trunk/; revision=2690 --- NEWS | 2 ++ uid.c | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/NEWS b/NEWS index 719a60aa..d9b25762 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,8 @@ a Certifying Authority we recognize?). (The `lines' figures total .c, .h, .l, and .y files under version control.) +* Ken Estes's patch to check for unreachable UIDL file due to bad NFS mount. + fetchmail-5.2.2 (Sun Dec 26 09:31:07 EST 1999), 18365 lines: * Arrange for fetchmail to restart itself quietly when the rc file is touched. * Improvements to IPv6 code from Jun-ichiro itojun Hagino . diff --git a/uid.c b/uid.c index 9a132606..8b956fc1 100644 --- a/uid.c +++ b/uid.c @@ -6,6 +6,8 @@ #include "config.h" +#include +#include #include #include #if defined(STDC_HEADERS) @@ -70,6 +72,7 @@ static struct idlist *scratchlist; void initialize_saved_lists(struct query *hostlist, const char *idfile) /* read file of saved IDs and attach to each host */ { + struct stat statbuf; FILE *tmpfp; struct query *ctl; @@ -77,6 +80,24 @@ void initialize_saved_lists(struct query *hostlist, const char *idfile) for (ctl = hostlist; ctl; ctl = ctl->next) ctl->skipped = ctl->oldsaved = ctl->newsaved = (struct idlist *)NULL; + errno = 0; + + /* + * Croak if the uidl directory does not exist. + * This probably means an NFS mount failed and we can't + * see a uidl file that ought to be there. + * Question: is this a portable check? It's not clear + * that all implementations of lstat() will return ENOTDIR + * rather than plain ENOENT in this case... + */ + if (lstat(idfile, &statbuf) < 0) { + if (errno == ENOTDIR) + { + report(stderr, "lstat: %s: %s\n", idfile, strerror(errno)); + exit(PS_IOERR); + } + } + /* let's get stored message UIDs from previous queries */ if ((tmpfp = fopen(idfile, "r")) != (FILE *)NULL) { -- cgit v1.2.3