mirror of https://github.com/mirror/busybox.git
Applied patch from Gennady Feldman to fix a single-threaded syslogd bug that
turned up. This code needs to be tested on an embedded system, since that's where the bug turned up in the first place.1_00_stable_10817
parent
2b549c3be0
commit
bff6b18bf9
|
@ -393,7 +393,9 @@ static int serveConnection (int conn)
|
||||||
RESERVE_BB_BUFFER(tmpbuf, BUFSIZE + 1);
|
RESERVE_BB_BUFFER(tmpbuf, BUFSIZE + 1);
|
||||||
int n_read;
|
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);
|
int pri = (LOG_USER | LOG_NOTICE);
|
||||||
char line[ BUFSIZE + 1 ];
|
char line[ BUFSIZE + 1 ];
|
||||||
|
@ -427,7 +429,7 @@ static int serveConnection (int conn)
|
||||||
/* Now log it */
|
/* Now log it */
|
||||||
logMessage (pri, line);
|
logMessage (pri, line);
|
||||||
}
|
}
|
||||||
return (0);
|
return n_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -439,7 +441,7 @@ static void init_RemoteLog (void){
|
||||||
int len = sizeof(remoteaddr);
|
int len = sizeof(remoteaddr);
|
||||||
|
|
||||||
bzero(&remoteaddr, len);
|
bzero(&remoteaddr, len);
|
||||||
|
|
||||||
remotefd = socket(AF_INET, SOCK_DGRAM, 0);
|
remotefd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
|
|
||||||
if (remotefd < 0) {
|
if (remotefd < 0) {
|
||||||
|
@ -548,11 +550,12 @@ static void doSyslogd (void)
|
||||||
|
|
||||||
FD_SET(conn, &fds);
|
FD_SET(conn, &fds);
|
||||||
//printf("conn: %i, set_size: %i\n",conn,FD_SETSIZE);
|
//printf("conn: %i, set_size: %i\n",conn,FD_SETSIZE);
|
||||||
} else {
|
} else {
|
||||||
//printf("Serving connection: %i\n",fd);
|
//printf("Serving connection: %i\n",fd);
|
||||||
serveConnection (fd);
|
if ( serveConnection(fd) <= 0 ) {
|
||||||
close (fd);
|
close (fd);
|
||||||
FD_CLR(fd, &fds);
|
FD_CLR(fd, &fds);
|
||||||
|
}
|
||||||
} /* fd == sock_fd */
|
} /* fd == sock_fd */
|
||||||
}/* FD_ISSET() */
|
}/* FD_ISSET() */
|
||||||
}/* for */
|
}/* for */
|
||||||
|
@ -593,7 +596,7 @@ extern int syslogd_main(int argc, char **argv)
|
||||||
if ( (p = strchr(RemoteHost, ':'))){
|
if ( (p = strchr(RemoteHost, ':'))){
|
||||||
RemotePort = atoi(p+1);
|
RemotePort = atoi(p+1);
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
}
|
}
|
||||||
doRemoteLog = TRUE;
|
doRemoteLog = TRUE;
|
||||||
break;
|
break;
|
||||||
case 'L':
|
case 'L':
|
||||||
|
|
19
syslogd.c
19
syslogd.c
|
@ -393,7 +393,9 @@ static int serveConnection (int conn)
|
||||||
RESERVE_BB_BUFFER(tmpbuf, BUFSIZE + 1);
|
RESERVE_BB_BUFFER(tmpbuf, BUFSIZE + 1);
|
||||||
int n_read;
|
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);
|
int pri = (LOG_USER | LOG_NOTICE);
|
||||||
char line[ BUFSIZE + 1 ];
|
char line[ BUFSIZE + 1 ];
|
||||||
|
@ -427,7 +429,7 @@ static int serveConnection (int conn)
|
||||||
/* Now log it */
|
/* Now log it */
|
||||||
logMessage (pri, line);
|
logMessage (pri, line);
|
||||||
}
|
}
|
||||||
return (0);
|
return n_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -439,7 +441,7 @@ static void init_RemoteLog (void){
|
||||||
int len = sizeof(remoteaddr);
|
int len = sizeof(remoteaddr);
|
||||||
|
|
||||||
bzero(&remoteaddr, len);
|
bzero(&remoteaddr, len);
|
||||||
|
|
||||||
remotefd = socket(AF_INET, SOCK_DGRAM, 0);
|
remotefd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
|
|
||||||
if (remotefd < 0) {
|
if (remotefd < 0) {
|
||||||
|
@ -548,11 +550,12 @@ static void doSyslogd (void)
|
||||||
|
|
||||||
FD_SET(conn, &fds);
|
FD_SET(conn, &fds);
|
||||||
//printf("conn: %i, set_size: %i\n",conn,FD_SETSIZE);
|
//printf("conn: %i, set_size: %i\n",conn,FD_SETSIZE);
|
||||||
} else {
|
} else {
|
||||||
//printf("Serving connection: %i\n",fd);
|
//printf("Serving connection: %i\n",fd);
|
||||||
serveConnection (fd);
|
if ( serveConnection(fd) <= 0 ) {
|
||||||
close (fd);
|
close (fd);
|
||||||
FD_CLR(fd, &fds);
|
FD_CLR(fd, &fds);
|
||||||
|
}
|
||||||
} /* fd == sock_fd */
|
} /* fd == sock_fd */
|
||||||
}/* FD_ISSET() */
|
}/* FD_ISSET() */
|
||||||
}/* for */
|
}/* for */
|
||||||
|
@ -593,7 +596,7 @@ extern int syslogd_main(int argc, char **argv)
|
||||||
if ( (p = strchr(RemoteHost, ':'))){
|
if ( (p = strchr(RemoteHost, ':'))){
|
||||||
RemotePort = atoi(p+1);
|
RemotePort = atoi(p+1);
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
}
|
}
|
||||||
doRemoteLog = TRUE;
|
doRemoteLog = TRUE;
|
||||||
break;
|
break;
|
||||||
case 'L':
|
case 'L':
|
||||||
|
|
Loading…
Reference in New Issue