[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[leafnode-list] SIGCHLD, read EOF, and checking EINTR
Below is a patch to getline.c for 2.08b_ma10pre2 (though getline.c hasn't
changed in a while so the patch will apply to older versions).
The purpose of the patch is to fix a long standing bug of a
fetchnews run causing leafnode to incorrectly think that a connected
client has gone away. That is, there is a getc loop in getline that
treats an EOF as the client haven gone away. However, an EOF can also
occur if there was a signal (say a SIGCHLD) at which point the EOF will be
accompanied by an errno of EINT. (see read(2)).
So this patch (originally contributed by a pine developer, but slightly
modified by me to keep up with recent versions of getline.c) simply wraps
that loop in a test of errno == EINTR, so as not to consider the client
dead on an EOF after an signal.
I would really appreciate it if this patch made it into Mattias's
development thread so I (and others) wouldn't have to re-apply it for each
new verions.
PS: I really appreciate the most recent change in debugging output. That
makes my cron jobs run more smoothly.
Cheers,
-j
--
Jeffrey Goldberg http://www.goldmark.org/jeff/
Relativism is the triumph of authority over truth, convention over justice
--- getline.c-orig Mon Feb 4 22:09:32 2002
+++ getline.c Mon Feb 4 22:13:05 2002
@@ -22,6 +22,8 @@
#ifdef WITH_DMALLOC
#include <dmalloc.h>
#endif
+#include "errno.h"
+extern int errno;
ssize_t
_getline( /*@out@*/ char *to, size_t size, FILE * stream)
@@ -32,13 +34,19 @@
if (1 > size)
return -1;
size--;
- while (size > 0 && ((c = getc(stream)) != EOF)) {
- *to = (unsigned char)c;
- to++;
- i++;
- if (c == (int)'\n')
- break;
- size--;
+ for(errno = 0; size > 0 && !errno; ) {
+ if((c = getc(stream)) != EOF) {
+ *to=(unsigned char)c;
+ to++;
+ i++;
+ if(c == (int)'\n')
+ break;
+ size --;
+ }
+ else if(errno == EINTR) {
+ clearerr(stream);
+ errno = 0;
+ }
}
*to = '\0';
if (ferror(stream))
--
leafnode-list@xxxxxxxxxxxxxxxxxxxxxxxxxxxx -- mailing list for leafnode
To unsubscribe, send mail with "unsubscribe" in the subject to the list