diff options
author | Eric Andersen <andersen@codepoet.org> | 2002-08-05 11:56:25 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2002-08-05 11:56:25 +0000 |
commit | 74b007f7cc1da527ee38be5c60e51d9882c6838a (patch) | |
tree | 1ab06da759c561ac41600261a96bc73f6ac13b6e /sysklogd | |
parent | c59716ff4c2b17c8f8137eac14bc498d640c5f63 (diff) | |
download | busybox-w32-74b007f7cc1da527ee38be5c60e51d9882c6838a.tar.gz busybox-w32-74b007f7cc1da527ee38be5c60e51d9882c6838a.tar.bz2 busybox-w32-74b007f7cc1da527ee38be5c60e51d9882c6838a.zip |
Oops. Code things so it actually works this time around...
-Erik
Diffstat (limited to 'sysklogd')
-rw-r--r-- | sysklogd/syslogd.c | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index fc5922562..aac37b11e 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c | |||
@@ -129,6 +129,8 @@ static inline void sem_down(int semid) | |||
129 | perror_msg_and_die("semop[SMwdn]"); | 129 | perror_msg_and_die("semop[SMwdn]"); |
130 | } | 130 | } |
131 | 131 | ||
132 | #define MAXLINE 1024 /* maximum line length */ | ||
133 | |||
132 | 134 | ||
133 | void ipcsyslog_cleanup(void){ | 135 | void ipcsyslog_cleanup(void){ |
134 | printf("Exiting Syslogd!\n"); | 136 | printf("Exiting Syslogd!\n"); |
@@ -398,14 +400,10 @@ static void domark(int sig) | |||
398 | /* This must be a #define, since when DODEBUG and BUFFERS_GO_IN_BSS are | 400 | /* This must be a #define, since when DODEBUG and BUFFERS_GO_IN_BSS are |
399 | * enabled, we otherwise get a "storage size isn't constant error. */ | 401 | * enabled, we otherwise get a "storage size isn't constant error. */ |
400 | #define BUFSIZE 1023 | 402 | #define BUFSIZE 1023 |
401 | static int serveConnection (int conn) | 403 | static int serveConnection (char* tmpbuf, int n_read) |
402 | { | 404 | { |
403 | RESERVE_CONFIG_BUFFER(tmpbuf, BUFSIZE + 1); | ||
404 | int n_read; | ||
405 | char *p = tmpbuf; | 405 | char *p = tmpbuf; |
406 | 406 | ||
407 | n_read = read (conn, tmpbuf, BUFSIZE ); | ||
408 | |||
409 | while (p < tmpbuf + n_read) { | 407 | while (p < tmpbuf + n_read) { |
410 | 408 | ||
411 | int pri = (LOG_USER | LOG_NOTICE); | 409 | int pri = (LOG_USER | LOG_NOTICE); |
@@ -415,8 +413,6 @@ static int serveConnection (int conn) | |||
415 | 413 | ||
416 | char *q = line; | 414 | char *q = line; |
417 | 415 | ||
418 | tmpbuf[ n_read - 1 ] = '\0'; | ||
419 | |||
420 | while (p && (c = *p) && q < &line[ sizeof (line) - 1 ]) { | 416 | while (p && (c = *p) && q < &line[ sizeof (line) - 1 ]) { |
421 | if ((c == '<') && !gotpri && isdigit(p[1])) { | 417 | if ((c == '<') && !gotpri && isdigit(p[1])) { |
422 | /* Parse the magic priority number. */ | 418 | /* Parse the magic priority number. */ |
@@ -443,7 +439,6 @@ static int serveConnection (int conn) | |||
443 | /* Now log it */ | 439 | /* Now log it */ |
444 | logMessage (pri, line); | 440 | logMessage (pri, line); |
445 | } | 441 | } |
446 | RELEASE_CONFIG_BUFFER (tmpbuf); | ||
447 | return n_read; | 442 | return n_read; |
448 | } | 443 | } |
449 | 444 | ||
@@ -555,21 +550,19 @@ static void doSyslogd (void) | |||
555 | --n_ready; | 550 | --n_ready; |
556 | 551 | ||
557 | if (fd == sock_fd) { | 552 | if (fd == sock_fd) { |
558 | int conn; | 553 | int i; |
559 | 554 | RESERVE_CONFIG_BUFFER(tmpbuf, BUFSIZE + 1); | |
560 | //printf("New Connection request.\n"); | 555 | |
561 | if ((conn = accept (sock_fd, (struct sockaddr *) &sunx, &addrLength)) < 0) { | 556 | memset(tmpbuf, '\0', BUFSIZE+1); |
562 | perror_msg_and_die ("accept error"); | 557 | if ( (i = recv(fd, tmpbuf, MAXLINE - 2, 0)) > 0) { |
558 | if ( serveConnection(tmpbuf, i) <= 0 ) { | ||
559 | close (fd); | ||
560 | FD_CLR(fd, &fds); | ||
561 | } | ||
562 | } else { | ||
563 | perror_msg_and_die ("UNIX socket error"); | ||
563 | } | 564 | } |
564 | 565 | RELEASE_CONFIG_BUFFER (tmpbuf); | |
565 | FD_SET(conn, &fds); | ||
566 | //printf("conn: %i, set_size: %i\n",conn,FD_SETSIZE); | ||
567 | } else { | ||
568 | //printf("Serving connection: %i\n",fd); | ||
569 | if ( serveConnection(fd) <= 0 ) { | ||
570 | close (fd); | ||
571 | FD_CLR(fd, &fds); | ||
572 | } | ||
573 | } /* fd == sock_fd */ | 566 | } /* fd == sock_fd */ |
574 | }/* FD_ISSET() */ | 567 | }/* FD_ISSET() */ |
575 | }/* for */ | 568 | }/* for */ |