You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by pc...@hyperreal.org on 1998/03/25 11:07:57 UTC
cvs commit: apache-1.3/src/main http_main.c http_protocol.c
pcs 98/03/25 02:07:57
Modified: src/main http_main.c http_protocol.c
Log:
On Win32 it is not valid to check whether the socket descriptor is
less than FD_SETSIZE.
Also, in http_main.c check that listenmaxfd is not -1 (which would
indicate that no sockets are available, and causes select() to fail
rather badly, i.e. it does not set a valid errno). Instead we should exit.
Add some more comments about how child/parent signalling works.
Fixup a couple of incorrect calls to the child_exit_modules before
child_init_modules had been called (this would only occur in a couple of
rare error conditions).
Revision Changes Path
1.311 +35 -4 apache-1.3/src/main/http_main.c
Index: http_main.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/main/http_main.c,v
retrieving revision 1.310
retrieving revision 1.311
diff -u -r1.310 -r1.311
--- http_main.c 1998/03/25 02:57:23 1.310
+++ http_main.c 1998/03/25 10:07:50 1.311
@@ -2205,6 +2205,15 @@
static int volatile generation;
#ifdef WIN32
+/*
+ * signal_parent() tells the parent process to wake up and do something.
+ * Once woken it will look at shutdown_pending and restart_pending to decide
+ * what to do. If neither variable is set, it will do a shutdown. This function
+ * if called by start_shutdown() or start_restart() in the parent's process
+ * space, so that the variables get set. However it can also be called
+ * by child processes to force the parent to exit in an emergency.
+ */
+
static void signal_parent(void)
{
HANDLE e;
@@ -2215,6 +2224,10 @@
* "apache-signal" event here.
*/
+ if (one_process) {
+ return;
+ }
+
APD1("*** SIGNAL_PARENT SET ***");
e = OpenEvent(EVENT_ALL_ACCESS, FALSE, "apache-signal");
@@ -2243,6 +2256,14 @@
* but we want to be able to start a shutdown/restart from other sources --
* e.g. on Win32, from the service manager. Now the service manager can
* call start_shutdown() or start_restart() as appropiate.
+ *
+ * These should only be called from the parent process itself, since the
+ * parent process will use the shutdown_pending and restart_pending variables
+ * to determine whether to shutdown or restart. The child process should
+ * call signal_parent() directly to tell the parent to die -- this will
+ * cause neither of those variable to be set, which the parent will
+ * assume means something serious is wrong (which it will be, for the
+ * child to force an exit) and so do an exit anyway.
*/
void start_shutdown(void)
@@ -2698,6 +2719,7 @@
#endif
unblock_alarms();
+#ifndef WIN32
/* protect various fd_sets */
if (s >= FD_SETSIZE) {
aplog_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, NULL,
@@ -2708,6 +2730,8 @@
close(s);
return -1;
}
+#endif
+
return s;
}
@@ -4483,23 +4507,30 @@
aplog_error(APLOG_MARK,APLOG_ERR|APLOG_WIN32ERROR, server_conf,
"Waiting for start_mutex or exit_event -- process will exit");
- child_exit_modules(pconf, server_conf);
destroy_pool(pchild);
-
cleanup_scoreboard();
exit(0);
}
if (rv == WAIT_OBJECT_0 + 1) {
/* exit event signalled - exit now */
- child_exit_modules(pconf, server_conf);
destroy_pool(pchild);
-
cleanup_scoreboard();
exit(0);
}
/* start_mutex obtained, continue into the select() loop */
setup_listeners(pconf);
+ if (listenmaxfd == -1) {
+ /* Help, no sockets were made, better log something and exit */
+ aplog_error(APLOG_MARK, APLOG_CRIT|APLOG_NOERRNO, NULL,
+ "No sockets were created for listening");
+
+ signal_parent(); /* tell parent to die */
+
+ destroy_pool(pchild);
+ cleanup_scoreboard();
+ exit(0);
+ }
set_signals();
/*
1.203 +2 -0 apache-1.3/src/main/http_protocol.c
Index: http_protocol.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/main/http_protocol.c,v
retrieving revision 1.202
retrieving revision 1.203
diff -u -r1.202 -r1.203
--- http_protocol.c 1998/03/25 02:57:26 1.202
+++ http_protocol.c 1998/03/25 10:07:55 1.203
@@ -1663,6 +1663,7 @@
bsetflag(fb, B_RD, 0);
bnonblock(fb, B_RD);
fd = bfileno(fb, B_RD);
+#ifndef WIN32
if (fd >= FD_SETSIZE) {
aplog_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, NULL,
"send body: filedescriptor (%u) larger than FD_SETSIZE (%u) "
@@ -1670,6 +1671,7 @@
"larger FD_SETSIZE", fd, FD_SETSIZE);
return 0;
}
+#endif
soft_timeout("send body", r);
Re: cvs commit: apache-1.3/src/main http_main.c http_protocol.c
Posted by Marc Slemko <ma...@worldgate.com>.
On Wed, 25 Mar 1998, Dean Gaudet wrote:
>
>
> On 25 Mar 1998 pcs@hyperreal.org wrote:
>
> > pcs 98/03/25 02:07:57
> >
> > Modified: src/main http_main.c http_protocol.c
> > Log:
> > On Win32 it is not valid to check whether the socket descriptor is
> > less than FD_SETSIZE.
>
> Does this mean that the fd_set macros on win32 manipulate linked lists or
> something? 'cause they seem to be used in buff.c...
See:
http://premium.microsoft.com/msdn/library/specs/platfrm2/d1/s11964.htm
The idea is that it uses a SOCKET type instead; INVALID_SOCKET is the
error return, and anything from 0 to INVALID_SOCKET-1 is a valid socket.
fd_set is an array of SOCKETs. SOCKETs are not assigned in any
low-numbered order like Unix sockets are, and since it uses an array
FD_SETSIZE only means how many fds you can have in a fd_set, not the max.
Re: cvs commit: apache-1.3/src/main http_main.c http_protocol.c
Posted by Dean Gaudet <dg...@arctic.org>.
On 25 Mar 1998 pcs@hyperreal.org wrote:
> pcs 98/03/25 02:07:57
>
> Modified: src/main http_main.c http_protocol.c
> Log:
> On Win32 it is not valid to check whether the socket descriptor is
> less than FD_SETSIZE.
Does this mean that the fd_set macros on win32 manipulate linked lists or
something? 'cause they seem to be used in buff.c...
Dean