aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-09-07 13:53:32 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-09-07 13:53:32 +0000
commitd7ecd863c855a53e263486e742a4adfb871d9127 (patch)
treed9ea1332db4276aca54a6c18510c863ab4b59776
parent87f3b26b3a17369c12f4f9a70d6845796f8648d6 (diff)
downloadbusybox-d7ecd863c855a53e263486e742a4adfb871d9127.tar.gz
syslogd: do not need to poll(), we can just block in read().
function old new delta syslogd_main 1206 1106 -100 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-100) Total: -100 bytes text data bss dec hex filename 769820 1051 10764 781635 bed43 busybox_old 769702 1051 10764 781517 beccd busybox_unstripped
-rw-r--r--sysklogd/syslogd.c53
1 files changed, 23 insertions, 30 deletions
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index ae3f1a2eb..f27bd8379 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -471,8 +471,7 @@ static void do_syslogd(void) ATTRIBUTE_NORETURN;
static void do_syslogd(void)
{
struct sockaddr_un sunx;
- struct pollfd pfd[1];
-#define sock_fd (pfd[0].fd)
+ int sock_fd;
char *dev_log_name;
/* Set up signal handlers */
@@ -526,40 +525,34 @@ static void do_syslogd(void)
(char*)"syslogd started: BusyBox v" BB_VER, 0);
for (;;) {
- /*pfd[0].fd = sock_fd;*/
- pfd[0].events = POLLIN;
- pfd[0].revents = 0;
- if (poll(pfd, 1, -1) < 0) { /* -1: no timeout */
- if (errno == EINTR) {
- /* alarm may have happened */
+ size_t sz;
+
+ sz = read(sock_fd, G.recvbuf, MAX_READ - 1);
+ if (sz <= 0) {
+ if (sz == 0)
+ continue; /* EOF from unix socket??? */
+ if (errno == EINTR) /* alarm may have happened */
continue;
- }
- bb_perror_msg_and_die("poll");
+ bb_perror_msg_and_die("read from /dev/log");
}
- if (pfd[0].revents) {
- int i;
- i = read(sock_fd, G.recvbuf, MAX_READ - 1);
- if (i <= 0)
- bb_perror_msg_and_die("UNIX socket error");
- /* TODO: maybe suppress duplicates? */
+ /* TODO: maybe suppress duplicates? */
#if ENABLE_FEATURE_REMOTE_LOG
- /* We are not modifying log messages in any way before send */
- /* Remote site cannot trust _us_ anyway and need to do validation again */
- if (G.remoteAddr) {
- if (-1 == G.remoteFD) {
- G.remoteFD = socket(G.remoteAddr->sa.sa_family, SOCK_DGRAM, 0);
- }
- if (-1 != G.remoteFD) {
- /* send message to remote logger, ignore possible error */
- sendto(G.remoteFD, G.recvbuf, i, MSG_DONTWAIT,
- &G.remoteAddr->sa, G.remoteAddr->len);
- }
+ /* We are not modifying log messages in any way before send */
+ /* Remote site cannot trust _us_ anyway and need to do validation again */
+ if (G.remoteAddr) {
+ if (-1 == G.remoteFD) {
+ G.remoteFD = socket(G.remoteAddr->sa.sa_family, SOCK_DGRAM, 0);
+ }
+ if (-1 != G.remoteFD) {
+ /* send message to remote logger, ignore possible error */
+ sendto(G.remoteFD, G.recvbuf, sz, MSG_DONTWAIT,
+ &G.remoteAddr->sa, G.remoteAddr->len);
}
-#endif
- G.recvbuf[i] = '\0';
- split_escape_and_log(G.recvbuf, i);
}
+#endif
+ G.recvbuf[sz] = '\0';
+ split_escape_and_log(G.recvbuf, sz);
} /* for */
}