You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by wr...@apache.org on 2002/06/23 12:24:08 UTC
cvs commit: httpd-2.0/server/mpm/winnt mpm_winnt.c mpm_winnt.h service.c
wrowe 2002/06/23 03:24:08
Modified: os/win32 os.h
server/mpm/winnt mpm_winnt.c mpm_winnt.h service.c
Log:
Finish the -w keep-console-open-on-error patch.
Revision Changes Path
1.51 +16 -3 httpd-2.0/os/win32/os.h
Index: os.h
===================================================================
RCS file: /home/cvs/httpd-2.0/os/win32/os.h,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- os.h 13 Mar 2002 20:47:59 -0000 1.50
+++ os.h 23 Jun 2002 10:24:07 -0000 1.51
@@ -69,8 +69,8 @@
* windows.h prior to any other Apache header files.
*/
-#ifndef _WIN32
-#define _WIN32
+#ifndef ap_os_h
+#define ap_os_h
#endif
#include <io.h>
@@ -87,4 +87,17 @@
#include <stddef.h>
-#endif /* ! APACHE_OS_H */
+/* BIG RED WARNING: exit() is mapped to allow us to capture the exit
+ * status. This header must only be included from modules linked into
+ * the ApacheCore.dll - since it's a horrible behavior to exit() from
+ * any module outside the main() block, and we -will- assume it's a
+ * fatal error. No dynamically linked module will ever be able to find
+ * the real_exit_code, and _will_ GP fault if it tries this macro.
+ */
+
+AP_DECLARE_DATA extern int real_exit_code;
+
+#define exit(status) ((exit)((real_exit_code==2) ? (real_exit_code = (status)) \
+ : ((real_exit_code = 0), (status))))
+
+#endif /* ! ap_os_h */
1.278 +19 -2 httpd-2.0/server/mpm/winnt/mpm_winnt.c
Index: mpm_winnt.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/winnt/mpm_winnt.c,v
retrieving revision 1.277
retrieving revision 1.278
diff -u -r1.277 -r1.278
--- mpm_winnt.c 6 Jun 2002 03:28:37 -0000 1.277
+++ mpm_winnt.c 23 Jun 2002 10:24:07 -0000 1.278
@@ -2082,6 +2082,9 @@
my_pid = GetCurrentProcessId();
parent_pid = (DWORD) atol(pid);
+ /* Prevent holding open the (nonexistant) console */
+ real_exit_code = 0;
+
/* The parent is responsible for providing the
* COMPLETE ARGUMENTS REQUIRED to the child.
*
@@ -2145,16 +2148,27 @@
optbuf[2] = '\0';
apr_getopt_init(&opt, process->pool, process->argc, (char**) process->argv);
opt->errfn = NULL;
- while ((rv = apr_getopt(opt, "n:k:iu" AP_SERVER_BASEARGS,
+ while ((rv = apr_getopt(opt, "wn:k:" AP_SERVER_BASEARGS,
optbuf + 1, &optarg)) == APR_SUCCESS) {
switch (optbuf[1]) {
+
+ /* Shortcuts; include the -w option to hold the window open on error.
+ * This must not be toggled once we reset real_exit_code to 0!
+ */
+ case 'w':
+ if (real_exit_code)
+ real_exit_code = 2;
+ break;
+
case 'n':
service_set = mpm_service_set_name(process->pool, &service_name,
optarg);
break;
+
case 'k':
signal_arg = optarg;
break;
+
case 'E':
errout = 1;
/* Fall through so the Apache main() handles the 'E' arg */
@@ -2307,7 +2321,10 @@
/* Initialize shared static objects.
*/
pconf = pconf_;
-
+
+ /* This behavior is voided by setting real_exit_code to 0 */
+ atexit(hold_console_open_on_error);
+
if (ap_exists_config_define("ONE_PROCESS") ||
ap_exists_config_define("DEBUG"))
one_process = -1;
1.37 +1 -0 httpd-2.0/server/mpm/winnt/mpm_winnt.h
Index: mpm_winnt.h
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/winnt/mpm_winnt.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- mpm_winnt.h 1 Apr 2002 18:55:46 -0000 1.36
+++ mpm_winnt.h 23 Jun 2002 10:24:07 -0000 1.37
@@ -212,4 +212,5 @@
AP_DECLARE(PCOMP_CONTEXT) mpm_get_completion_context(void);
AP_DECLARE(void) mpm_recycle_completion_context(PCOMP_CONTEXT pCompContext);
AP_DECLARE(apr_status_t) mpm_post_completion_context(PCOMP_CONTEXT pCompContext, io_state_e state);
+void hold_console_open_on_error(void);
#endif /* APACHE_MPM_WINNT_H */
1.54 +4 -1 httpd-2.0/server/mpm/winnt/service.c
Index: service.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/winnt/service.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- service.c 5 Jun 2002 15:46:30 -0000 1.53
+++ service.c 23 Jun 2002 10:24:07 -0000 1.54
@@ -118,7 +118,7 @@
* behavior on exit. All service and child processes are expected to
* reset this flag to zero to avoid undesireable side effects.
*/
-int real_exit_code = 1;
+AP_DECLARE_DATA int real_exit_code = 1;
void hold_console_open_on_error(void)
{
@@ -697,6 +697,9 @@
HANDLE hProc = GetCurrentProcess();
HANDLE hThread = GetCurrentThread();
HANDLE waitfor[2];
+
+ /* Prevent holding open the (hidden) console */
+ real_exit_code = 0;
/* GetCurrentThread returns a psuedo-handle, we need
* a real handle for another thread to wait upon.