diff options
author | Eric Andersen <andersen@codepoet.org> | 2002-08-05 15:56:25 +0400 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2002-08-05 15:56:25 +0400 |
commit | 74b007f7cc1da527ee38be5c60e51d9882c6838a (patch) | |
tree | 1ab06da759c561ac41600261a96bc73f6ac13b6e /sysklogd | |
parent | c59716ff4c2b17c8f8137eac14bc498d640c5f63 (diff) |
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) perror_msg_and_die("semop[SMwdn]"); } +#define MAXLINE 1024 /* maximum line length */ + void ipcsyslog_cleanup(void){ printf("Exiting Syslogd!\n"); @@ -398,14 +400,10 @@ static void domark(int sig) /* This must be a #define, since when DODEBUG and BUFFERS_GO_IN_BSS are * enabled, we otherwise get a "storage size isn't constant error. */ #define BUFSIZE 1023 -static int serveConnection (int conn) +static int serveConnection (char* tmpbuf, int n_read) { - RESERVE_CONFIG_BUFFER(tmpbuf, BUFSIZE + 1); - int n_read; char *p = tmpbuf; - n_read = read (conn, tmpbuf, BUFSIZE ); - while (p < tmpbuf + n_read) { int pri = (LOG_USER | LOG_NOTICE); @@ -415,8 +413,6 @@ static int serveConnection (int conn) char *q = line; - tmpbuf[ n_read - 1 ] = '\0'; - while (p && (c = *p) && q < &line[ sizeof (line) - 1 ]) { if ((c == '<') && !gotpri && isdigit(p[1])) { /* Parse the magic priority number. */ @@ -443,7 +439,6 @@ static int serveConnection (int conn) /* Now log it */ logMessage (pri, line); } - RELEASE_CONFIG_BUFFER (tmpbuf); return n_read; } @@ -555,21 +550,19 @@ static void doSyslogd (void) --n_ready; if (fd == sock_fd) { - int conn; - - //printf("New Connection request.\n"); - if ((conn = accept (sock_fd, (struct sockaddr *) &sunx, &addrLength)) < 0) { - perror_msg_and_die ("accept error"); + int i; + RESERVE_CONFIG_BUFFER(tmpbuf, BUFSIZE + 1); + + memset(tmpbuf, '\0', BUFSIZE+1); + if ( (i = recv(fd, tmpbuf, MAXLINE - 2, 0)) > 0) { + if ( serveConnection(tmpbuf, i) <= 0 ) { + close (fd); + FD_CLR(fd, &fds); + } + } else { + perror_msg_and_die ("UNIX socket error"); } - - FD_SET(conn, &fds); - //printf("conn: %i, set_size: %i\n",conn,FD_SETSIZE); - } else { - //printf("Serving connection: %i\n",fd); - if ( serveConnection(fd) <= 0 ) { - close (fd); - FD_CLR(fd, &fds); - } + RELEASE_CONFIG_BUFFER (tmpbuf); } /* fd == sock_fd */ }/* FD_ISSET() */ }/* for */ |