Hi,

Another round of fixes to httpd for no-MMU.
httpd can't work in non-inetd mode since it is required to fork for each 
connection.
There are 2 approaches I can think of:
1. The correct one: on connection, the parent vforks and the child reexecs 
itself to
serve the connection.
2. The easy one: require -i (inetd mode) and #ifdef the code that prevents 
compilation on
no-mmu (the code running bb_daemonize).

The attached patch goes the second way for 2 reasons. First, the second way is 
much
easier, so we get a working httpd. Second, I'm not sure that it's benefiting to 
reexec
httpd on every connection, since inetd does exactly that. And, of course, the 
most
important reason: I'm lazy ;-)

Alex

P.S. On compilation a warning shows telling that openServer() is defined but 
not used.
This function is used only in non-inetd mode. I did not wrap it in #if !BB_MMU 
since if
later someone goes with way 1 (above), he'll need it, and since it's static, it 
does not
reach the .o file.


 
____________________________________________________________________________________
8:00? 8:25? 8:40? Find a flick in no time 
with the Yahoo! Search movie showtime shortcut.
http://tools.search.yahoo.com/shortcuts/#news
Index: networking/httpd.c
===================================================================
--- networking/httpd.c	(revision 18873)
+++ networking/httpd.c	(working copy)
@@ -1821,6 +1821,7 @@
 	close(accepted_socket);
 }
 
+#if BB_MMU
 /****************************************************************************
  *
  > $Function: miniHttpd()
@@ -1900,6 +1901,7 @@
 	} /* while (1) */
 	return 0;
 }
+#endif
 
 /* from inetd */
 static int miniHttpd_inetd(void)
@@ -2033,6 +2035,7 @@
 
 	xchdir(home_httpd);
 	if (!(opt & OPT_INETD)) {
+#if BB_MMU
 		signal(SIGCHLD, SIG_IGN);
 		server_socket = openServer();
 #if ENABLE_FEATURE_HTTPD_SETUID
@@ -2046,6 +2049,9 @@
 			xsetuid(ugid.uid);
 		}
 #endif
+#else	/* BB_MMU */
+		bb_error_msg_and_die("-i is required");
+#endif
 	}
 
 #if ENABLE_FEATURE_HTTPD_CGI
@@ -2069,7 +2075,11 @@
 	if (opt & OPT_INETD)
 		return miniHttpd_inetd();
 
+#if BB_MMU
 	if (!(opt & OPT_FOREGROUND))
 		bb_daemonize(0);     /* don't change current directory */
 	return miniHttpd(server_socket);
+#else
+	return 0;				/* not reached */
+#endif
 }
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to