(fwd) [BusyBox] bug#1138: syslogd hoses up the system
Gennady Feldman
gena01 at cachier.com
Tue Mar 27 18:29:36 UTC 2001
Hello Erik.
Here is the proposed fix for the single-threaded syslogd problem.
It seems that I left some code as it was written. In serveConnection() it
used while (read() > ) {} instead of doing a single read. This would block
indefinitely until the connection was closed. Here is a rather simple fix
which should resolve the problem.
P.S. Erik, could you ask that person to try booting the machine again and
testing it out to see if the problem goes away? Thanx for reporting this.
G.F.
-------------- next part --------------
Index: syslogd.c
===================================================================
RCS file: /var/cvs/busybox/syslogd.c,v
retrieving revision 1.63
diff -u -r1.63 syslogd.c
--- syslogd.c 2001/03/23 17:07:24 1.63
+++ syslogd.c 2001/03/27 18:18:39
@@ -393,8 +393,10 @@
RESERVE_BB_BUFFER(tmpbuf, BUFSIZE + 1);
int n_read;
- while ((n_read = read (conn, tmpbuf, BUFSIZE )) > 0) {
+ n_read = read (conn, tmpbuf, BUFSIZE );
+ if (n_read > 0) {
+
int pri = (LOG_USER | LOG_NOTICE);
char line[ BUFSIZE + 1 ];
unsigned char c;
@@ -427,7 +429,7 @@
/* Now log it */
logMessage (pri, line);
}
- return (0);
+ return n_read;
}
@@ -439,7 +441,7 @@
int len = sizeof(remoteaddr);
bzero(&remoteaddr, len);
-
+
remotefd = socket(AF_INET, SOCK_DGRAM, 0);
if (remotefd < 0) {
@@ -548,11 +550,12 @@
FD_SET(conn, &fds);
//printf("conn: %i, set_size: %i\n",conn,FD_SETSIZE);
- } else {
+ } else {
//printf("Serving connection: %i\n",fd);
- serveConnection (fd);
- close (fd);
- FD_CLR(fd, &fds);
+ if ( serveConnection(fd) <= 0 ) {
+ close (fd);
+ FD_CLR(fd, &fds);
+ }
} /* fd == sock_fd */
}/* FD_ISSET() */
}/* for */
@@ -593,7 +596,7 @@
if ( (p = strchr(RemoteHost, ':'))){
RemotePort = atoi(p+1);
*p = '\0';
- }
+ }
doRemoteLog = TRUE;
break;
case 'L':
More information about the busybox
mailing list