diff options
author | Mark Whitley <markw@lineo.com> | 2001-03-27 20:17:58 +0000 |
---|---|---|
committer | Mark Whitley <markw@lineo.com> | 2001-03-27 20:17:58 +0000 |
commit | bff6b18bf9056793caa80db7cd664b514068f7ee (patch) | |
tree | b87b6daf4d03359c488d6a094bcce187080ebc99 /syslogd.c | |
parent | 2b549c3be0cadb5617dc1bb2984cb26c0e085147 (diff) | |
download | busybox-w32-bff6b18bf9056793caa80db7cd664b514068f7ee.tar.gz busybox-w32-bff6b18bf9056793caa80db7cd664b514068f7ee.tar.bz2 busybox-w32-bff6b18bf9056793caa80db7cd664b514068f7ee.zip |
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.
Diffstat (limited to '')
-rw-r--r-- | syslogd.c | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -393,7 +393,9 @@ static int serveConnection (int conn) | |||
393 | RESERVE_BB_BUFFER(tmpbuf, BUFSIZE + 1); | 393 | RESERVE_BB_BUFFER(tmpbuf, BUFSIZE + 1); |
394 | int n_read; | 394 | int n_read; |
395 | 395 | ||
396 | while ((n_read = read (conn, tmpbuf, BUFSIZE )) > 0) { | 396 | n_read = read (conn, tmpbuf, BUFSIZE ); |
397 | |||
398 | if (n_read > 0) { | ||
397 | 399 | ||
398 | int pri = (LOG_USER | LOG_NOTICE); | 400 | int pri = (LOG_USER | LOG_NOTICE); |
399 | char line[ BUFSIZE + 1 ]; | 401 | char line[ BUFSIZE + 1 ]; |
@@ -427,7 +429,7 @@ static int serveConnection (int conn) | |||
427 | /* Now log it */ | 429 | /* Now log it */ |
428 | logMessage (pri, line); | 430 | logMessage (pri, line); |
429 | } | 431 | } |
430 | return (0); | 432 | return n_read; |
431 | } | 433 | } |
432 | 434 | ||
433 | 435 | ||
@@ -439,7 +441,7 @@ static void init_RemoteLog (void){ | |||
439 | int len = sizeof(remoteaddr); | 441 | int len = sizeof(remoteaddr); |
440 | 442 | ||
441 | bzero(&remoteaddr, len); | 443 | bzero(&remoteaddr, len); |
442 | 444 | ||
443 | remotefd = socket(AF_INET, SOCK_DGRAM, 0); | 445 | remotefd = socket(AF_INET, SOCK_DGRAM, 0); |
444 | 446 | ||
445 | if (remotefd < 0) { | 447 | if (remotefd < 0) { |
@@ -548,11 +550,12 @@ static void doSyslogd (void) | |||
548 | 550 | ||
549 | FD_SET(conn, &fds); | 551 | FD_SET(conn, &fds); |
550 | //printf("conn: %i, set_size: %i\n",conn,FD_SETSIZE); | 552 | //printf("conn: %i, set_size: %i\n",conn,FD_SETSIZE); |
551 | } else { | 553 | } else { |
552 | //printf("Serving connection: %i\n",fd); | 554 | //printf("Serving connection: %i\n",fd); |
553 | serveConnection (fd); | 555 | if ( serveConnection(fd) <= 0 ) { |
554 | close (fd); | 556 | close (fd); |
555 | FD_CLR(fd, &fds); | 557 | FD_CLR(fd, &fds); |
558 | } | ||
556 | } /* fd == sock_fd */ | 559 | } /* fd == sock_fd */ |
557 | }/* FD_ISSET() */ | 560 | }/* FD_ISSET() */ |
558 | }/* for */ | 561 | }/* for */ |
@@ -593,7 +596,7 @@ extern int syslogd_main(int argc, char **argv) | |||
593 | if ( (p = strchr(RemoteHost, ':'))){ | 596 | if ( (p = strchr(RemoteHost, ':'))){ |
594 | RemotePort = atoi(p+1); | 597 | RemotePort = atoi(p+1); |
595 | *p = '\0'; | 598 | *p = '\0'; |
596 | } | 599 | } |
597 | doRemoteLog = TRUE; | 600 | doRemoteLog = TRUE; |
598 | break; | 601 | break; |
599 | case 'L': | 602 | case 'L': |