[BusyBox] Single-threaded Syslogd
Gennady Feldman
gena01 at cachier.com
Wed Mar 7 18:51:34 UTC 2001
Here is my first somewhat working version of the patch which
changes syslogd not to fork itself when serving requests. It seems to work
on my test system. I would like other people to bang on it somewhat. I
didn't include any of my other changes yet, so don't commit this to cvs. I
am preparing a bigger patch which will address my TODO list. I still have
a few small things to fix up. Most of the stuff seems to be compiling
cleanly and working for me.
G.F.
-------------- next part --------------
Index: syslogd.c
===================================================================
RCS file: /var/cvs/busybox/syslogd.c,v
retrieving revision 1.58
diff -u -r1.58 syslogd.c
--- syslogd.c 2001/02/20 06:14:08 1.58
+++ syslogd.c 2001/03/07 18:34:51
@@ -362,113 +539,26 @@
--n_ready;
if (fd == sock_fd) {
-
int conn;
- pid_t pid;
+ //printf("New Connection request.\n");
if ((conn = accept (sock_fd, (struct sockaddr *) &sunx, &addrLength)) < 0) {
perror_msg_and_die ("accept error");
}
-
- pid = fork();
-
- if (pid < 0) {
- perror ("syslogd: fork");
- close (conn);
- continue;
- }
-
- if (pid == 0) {
- serveConnection (conn);
- close (conn);
- exit( TRUE);
- }
- close (conn);
- }
- }
- }
- }
+
+ FD_SET(conn, &fds);
+ //printf("conn: %i, set_size: %i\n",conn,FD_SETSIZE);
+ }else{
+ //printf("Serving connection: %i\n",fd);
+ serveConnection (fd);
+ close (fd);
+ FD_CLR(fd, &fds);
+ } /* fd == sock_fd */
+ }/* FD_ISSET() */
+ }/* for */
+ } /* for main loop */
}
More information about the busybox
mailing list