From 20f66c9f65245fc0f912f48ba9ef0dfd4b28749f Mon Sep 17 00:00:00 2001 From: "William A. Rowe Jr" Date: Mon, 5 Jun 2000 22:39:03 +0000 Subject: [PATCH] PR: Obtained from: Submitted by: Reviewed by: Unbind the old main_win32.c code and rebind to the new mpm logic in the modules/mpm/winnt directory. Includes some simple cleanups. The old sources in os/win32 will disappear at the end of this week. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85430 13f79535-47bb-0310-9956-ffa450edef68 --- Apache.dsp | 65 ++++++------------------------------ ApacheCore.def | 3 +- ApacheCore.dsp | 24 +++++++------ httpd.dsp | 24 +++++++------ libhttpd.def | 3 +- server/main.c | 8 +---- server/mpm/winnt/mpm_winnt.c | 17 +++++++--- server/mpm/winnt/service.c | 24 +++++++++---- 8 files changed, 71 insertions(+), 97 deletions(-) diff --git a/Apache.dsp b/Apache.dsp index 5d92f33667..90405e0ac3 100644 --- a/Apache.dsp +++ b/Apache.dsp @@ -41,8 +41,8 @@ RSC=rc.exe # PROP Intermediate_Dir ".\ApacheR" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "./include" /I "./os/win32" /I "./lib/apr/include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "SHARED_MODULE" /FD /c +# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c +# ADD CPP /nologo /MD /W3 /GX /O2 /I "./include" /I "./os/win32" /I "./lib/apr/include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" @@ -50,8 +50,8 @@ BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 aprlib.lib ApacheCore.lib kernel32.lib advapi32.lib /nologo /subsystem:console /map /machine:I386 /libpath:"lib\apr\Release" /libpath:"CoreR" -# ADD LINK32 aprlib.lib ApacheCore.lib kernel32.lib advapi32.lib user32.lib /nologo /subsystem:console /map /machine:I386 /libpath:"lib\apr\Release" /libpath:"CoreR" +# ADD BASE LINK32 kernel32.lib user32.lib advapi32.lib ws2_32.lib mswsock.lib /nologo /subsystem:console /map /machine:I386 +# ADD LINK32 kernel32.lib user32.lib advapi32.lib ws2_32.lib mswsock.lib /nologo /subsystem:console /map /machine:I386 !ELSEIF "$(CFG)" == "Apache - Win32 Debug" @@ -66,8 +66,8 @@ LINK32=link.exe # PROP Intermediate_Dir ".\ApacheD" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "./include" /I "./os/win32" /I "./lib/apr/include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "SHARED_MODULE" /FD /c +# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "./include" /I "./os/win32" /I "./lib/apr/include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" @@ -75,8 +75,8 @@ BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 aprlib.lib ApacheCore.lib kernel32.lib advapi32.lib /nologo /subsystem:console /map /debug /machine:I386 /libpath:"lib\apr\debug" /libpath:"CoreD" -# ADD LINK32 aprlib.lib ApacheCore.lib kernel32.lib advapi32.lib user32.lib /nologo /subsystem:console /debug /machine:I386 /libpath:"lib\apr\debug" /libpath:"CoreD" +# ADD BASE LINK32 kernel32.lib user32.lib advapi32.lib ws2_32.lib mswsock.lib /nologo /subsystem:console /map /debug /machine:I386 +# ADD LINK32 kernel32.lib user32.lib advapi32.lib ws2_32.lib mswsock.lib /nologo /subsystem:console /debug /machine:I386 # SUBTRACT LINK32 /incremental:no /map !ENDIF @@ -85,45 +85,6 @@ LINK32=link.exe # Name "Apache - Win32 Release" # Name "Apache - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90" -# Begin Source File - -SOURCE=.\main\http_main.c -# End Source File -# Begin Source File - -SOURCE=.\os\win32\main_win32.c -# End Source File -# Begin Source File - -SOURCE=.\os\win32\registry.c -# End Source File -# Begin Source File - -SOURCE=.\os\win32\service.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd" -# Begin Source File - -SOURCE=.\OS\WIN32\main_win32.h -# End Source File -# Begin Source File - -SOURCE=.\os\win32\registry.h -# End Source File -# Begin Source File - -SOURCE=.\os\win32\service.h -# End Source File -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" # Begin Source File SOURCE=.\os\win32\apache.ico @@ -131,14 +92,10 @@ SOURCE=.\os\win32\apache.ico # Begin Source File SOURCE=.\os\win32\apache.rc +# End Source File +# Begin Source File -!IF "$(CFG)" == "Apache - Win32 Release" - -!ELSEIF "$(CFG)" == "Apache - Win32 Debug" - -!ENDIF - +SOURCE=.\main\http_main.c # End Source File -# End Group # End Target # End Project diff --git a/ApacheCore.def b/ApacheCore.def index c032629c7b..837810f489 100644 --- a/ApacheCore.def +++ b/ApacheCore.def @@ -399,8 +399,7 @@ EXPORTS ap_run_http_method @394 ap_bread_core @395 ap_bwrite_core @396 - ap_mpm_init_complete @397 - + ; Exclusively provided for http_main.c ap_register_hooks @398 ap_prelinked_modules @399 diff --git a/ApacheCore.dsp b/ApacheCore.dsp index 91db90b7c6..e087cb38f4 100644 --- a/ApacheCore.dsp +++ b/ApacheCore.dsp @@ -53,8 +53,8 @@ BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 aprlib.lib ap.lib pcreposix.lib pcre.lib kernel32.lib advapi32.lib ws2_32.lib mswsock.lib /nologo /subsystem:windows /dll /map /machine:I386 /libpath:"lib\apr\Release" /libpath:"regex\release" /libpath:"ap\Release" /base:@"os\win32\BaseAddr.ref",ApacheCore -# ADD LINK32 kernel32.lib advapi32.lib ws2_32.lib mswsock.lib /nologo /subsystem:windows /dll /map /machine:I386 /base:@"os\win32\BaseAddr.ref",ApacheCore +# ADD BASE LINK32 kernel32.lib user32.lib advapi32.lib ws2_32.lib mswsock.lib /nologo /subsystem:windows /dll /map /machine:I386 /base:@"os\win32\BaseAddr.ref",ApacheCore +# ADD LINK32 kernel32.lib user32.lib advapi32.lib ws2_32.lib mswsock.lib /nologo /subsystem:windows /dll /map /machine:I386 /base:@"os\win32\BaseAddr.ref",ApacheCore !ELSEIF "$(CFG)" == "ApacheCore - Win32 Debug" @@ -80,8 +80,8 @@ BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 aprlib.lib regex.lib ap.lib pcreposix.lib pcre.lib kernel32.lib advapi32.lib ws2_32.lib mswsock.lib /nologo /subsystem:windows /dll /map /debug /machine:I386 /libpath:"lib\apr\debug" /libpath:"regex\debug" /libpath:"ap\Debug" /base:@"os\win32\BaseAddr.ref",ApacheCore -# ADD LINK32 aprlib.lib ap.lib pcre.lib pcreposix.lib kernel32.lib advapi32.lib ws2_32.lib mswsock.lib /nologo /subsystem:windows /dll /debug /machine:I386 /libpath:"lib\apr\debug" /libpath:"lib\pcre\LibD" /libpath:"ap\Debug" /base:@"os\win32\BaseAddr.ref",ApacheCore +# ADD BASE LINK32 kernel32.lib user32.lib advapi32.lib ws2_32.lib mswsock.lib /nologo /subsystem:windows /dll /map /debug /machine:I386 /base:@"os\win32\BaseAddr.ref",ApacheCore +# ADD LINK32 kernel32.lib user32.lib advapi32.lib ws2_32.lib mswsock.lib /nologo /subsystem:windows /dll /debug /machine:I386 /base:@"os\win32\BaseAddr.ref",ApacheCore # SUBTRACT LINK32 /incremental:no /map !ENDIF @@ -235,10 +235,18 @@ SOURCE=.\os\win32\modules.c # End Source File # Begin Source File +SOURCE=.\modules\mpm\winnt\registry.c +# End Source File +# Begin Source File + SOURCE=.\main\rfc1413.c # End Source File # Begin Source File +SOURCE=.\modules\mpm\winnt\service.c +# End Source File +# Begin Source File + SOURCE=.\main\util.c # End Source File # Begin Source File @@ -267,7 +275,7 @@ SOURCE=.\os\win32\util_win32.c # End Source File # Begin Source File -SOURCE=.\modules\mpm\winnt\winnt.c +SOURCE=.\modules\mpm\winnt\mpm_winnt.c # End Source File # End Group # Begin Group "Header Files" @@ -411,13 +419,9 @@ SOURCE=.\include\util_uri.h # End Source File # Begin Source File -SOURCE=.\modules\mpm\winnt\winnt.h +SOURCE=.\modules\mpm\winnt\mpm_winnt.h # End Source File # End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" -# End Group # Begin Group "Generated Files" # PROP Default_Filter "" diff --git a/httpd.dsp b/httpd.dsp index 91db90b7c6..e087cb38f4 100644 --- a/httpd.dsp +++ b/httpd.dsp @@ -53,8 +53,8 @@ BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 aprlib.lib ap.lib pcreposix.lib pcre.lib kernel32.lib advapi32.lib ws2_32.lib mswsock.lib /nologo /subsystem:windows /dll /map /machine:I386 /libpath:"lib\apr\Release" /libpath:"regex\release" /libpath:"ap\Release" /base:@"os\win32\BaseAddr.ref",ApacheCore -# ADD LINK32 kernel32.lib advapi32.lib ws2_32.lib mswsock.lib /nologo /subsystem:windows /dll /map /machine:I386 /base:@"os\win32\BaseAddr.ref",ApacheCore +# ADD BASE LINK32 kernel32.lib user32.lib advapi32.lib ws2_32.lib mswsock.lib /nologo /subsystem:windows /dll /map /machine:I386 /base:@"os\win32\BaseAddr.ref",ApacheCore +# ADD LINK32 kernel32.lib user32.lib advapi32.lib ws2_32.lib mswsock.lib /nologo /subsystem:windows /dll /map /machine:I386 /base:@"os\win32\BaseAddr.ref",ApacheCore !ELSEIF "$(CFG)" == "ApacheCore - Win32 Debug" @@ -80,8 +80,8 @@ BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 aprlib.lib regex.lib ap.lib pcreposix.lib pcre.lib kernel32.lib advapi32.lib ws2_32.lib mswsock.lib /nologo /subsystem:windows /dll /map /debug /machine:I386 /libpath:"lib\apr\debug" /libpath:"regex\debug" /libpath:"ap\Debug" /base:@"os\win32\BaseAddr.ref",ApacheCore -# ADD LINK32 aprlib.lib ap.lib pcre.lib pcreposix.lib kernel32.lib advapi32.lib ws2_32.lib mswsock.lib /nologo /subsystem:windows /dll /debug /machine:I386 /libpath:"lib\apr\debug" /libpath:"lib\pcre\LibD" /libpath:"ap\Debug" /base:@"os\win32\BaseAddr.ref",ApacheCore +# ADD BASE LINK32 kernel32.lib user32.lib advapi32.lib ws2_32.lib mswsock.lib /nologo /subsystem:windows /dll /map /debug /machine:I386 /base:@"os\win32\BaseAddr.ref",ApacheCore +# ADD LINK32 kernel32.lib user32.lib advapi32.lib ws2_32.lib mswsock.lib /nologo /subsystem:windows /dll /debug /machine:I386 /base:@"os\win32\BaseAddr.ref",ApacheCore # SUBTRACT LINK32 /incremental:no /map !ENDIF @@ -235,10 +235,18 @@ SOURCE=.\os\win32\modules.c # End Source File # Begin Source File +SOURCE=.\modules\mpm\winnt\registry.c +# End Source File +# Begin Source File + SOURCE=.\main\rfc1413.c # End Source File # Begin Source File +SOURCE=.\modules\mpm\winnt\service.c +# End Source File +# Begin Source File + SOURCE=.\main\util.c # End Source File # Begin Source File @@ -267,7 +275,7 @@ SOURCE=.\os\win32\util_win32.c # End Source File # Begin Source File -SOURCE=.\modules\mpm\winnt\winnt.c +SOURCE=.\modules\mpm\winnt\mpm_winnt.c # End Source File # End Group # Begin Group "Header Files" @@ -411,13 +419,9 @@ SOURCE=.\include\util_uri.h # End Source File # Begin Source File -SOURCE=.\modules\mpm\winnt\winnt.h +SOURCE=.\modules\mpm\winnt\mpm_winnt.h # End Source File # End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" -# End Group # Begin Group "Generated Files" # PROP Default_Filter "" diff --git a/libhttpd.def b/libhttpd.def index c032629c7b..837810f489 100644 --- a/libhttpd.def +++ b/libhttpd.def @@ -399,8 +399,7 @@ EXPORTS ap_run_http_method @394 ap_bread_core @395 ap_bwrite_core @396 - ap_mpm_init_complete @397 - + ; Exclusively provided for http_main.c ap_register_hooks @398 ap_prelinked_modules @399 diff --git a/server/main.c b/server/main.c index d296012951..1dfe4726f9 100644 --- a/server/main.c +++ b/server/main.c @@ -278,11 +278,7 @@ static void usage(process_rec *process) destroy_and_exit_process(process, 1); } -#ifdef WIN32 -int apache_main(int argc, char *argv[]) -#else -API_EXPORT(int) main(int argc, char *argv[]) -#endif +int main(int argc, char *argv[]) { int c; int configtestonly = 0; @@ -298,9 +294,7 @@ API_EXPORT(int) main(int argc, char *argv[]) module **mod; ap_directive_t *conftree = NULL; -#ifndef WIN32 /* done in main_win32.c */ ap_initialize(); -#endif process = create_process(argc, (char *const *)argv); pglobal = process->pool; pconf = process->pconf; diff --git a/server/mpm/winnt/mpm_winnt.c b/server/mpm/winnt/mpm_winnt.c index 8ed685bf39..fac7a15087 100644 --- a/server/mpm/winnt/mpm_winnt.c +++ b/server/mpm/winnt/mpm_winnt.c @@ -1931,7 +1931,7 @@ void winnt_rewrite_args(process_rec *process) } else { - ap_log_error(APLOG_MARK,APLOG_ERR, APR_BADARG, NULL, + ap_log_error(APLOG_MARK,APLOG_ERR, 0, NULL, "%s: No installed service by that name.", display_name); exit(1); } @@ -1940,7 +1940,7 @@ void winnt_rewrite_args(process_rec *process) { if (service_named == APR_SUCCESS) { - ap_log_error(APLOG_MARK,APLOG_ERR, APR_BADARG, NULL, + ap_log_error(APLOG_MARK,APLOG_ERR, 0, NULL, "%s: Service is already installed.", display_name); exit(1); } @@ -2031,6 +2031,12 @@ static void winnt_post_config(ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t *ptem // TODO: This Stinks - but we needed the ap_pid_fname entry from // the config!?! Find a clean way to get the egg back into // into the chicken and shove this signal into pre_config + // + // src/os/win32/main_win32.c had some (possibly buggy) code to + // search for just the PidFile entry, but this sounds like a + // universally useful function that we ought to wrap into the + // main server, not just the Win32 MPM. + // if (!strcasecmp(signal_arg, "stop")) { mpm_signal_service(ptemp, ap_pid_fname, 0); exit(0); @@ -2041,7 +2047,7 @@ static void winnt_post_config(ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t *ptem if (restart_num++ == 1) { /* This code should be run once in the parent and not run - * accross a restart + * across a restart */ PSECURITY_ATTRIBUTES sa = GetNullACL(); /* returns NULL if invalid (Win95?) */ setup_signal_names(ap_psprintf(pconf,"ap%d", parent_pid)); @@ -2104,9 +2110,10 @@ static void winnt_post_config(ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t *ptem } } } - else + else /* ! -k runservice */ + { mpm_start_console_handler(); - + } /* Create the start mutex, apPID, where PID is the parent Apache process ID. * Ths start mutex is used during a restart to prevent more than one diff --git a/server/mpm/winnt/service.c b/server/mpm/winnt/service.c index 8ead0fbc08..98b401eb00 100644 --- a/server/mpm/winnt/service.c +++ b/server/mpm/winnt/service.c @@ -253,6 +253,10 @@ static void stop_console_handler(void) void mpm_start_console_handler(void) { + // TODO: Win9x will ignore the CLOSE and SHUTDOWN events, + // we don't get to see them... possible solution in + // psdk docs "Reading Input Buffer Events", by using + // the menu item therein. SetConsoleCtrlHandler(console_control_handler, TRUE); atexit(stop_console_handler); } @@ -289,11 +293,6 @@ static BOOL CALLBACK child_control_handler(DWORD ctrl_type) return FALSE; } -// TODO: We really need to play the RegisterServiceProcess game -// if this is the child of the Win9x service process... -// and if that isn't bad enought... a shutdown thread window -// is really the ticket... ick. - static void stop_child_console_handler(void) { SetConsoleCtrlHandler(child_control_handler, FALSE); @@ -301,8 +300,19 @@ static void stop_child_console_handler(void) void mpm_start_child_console_handler(void) { - SetConsoleCtrlHandler(child_control_handler, TRUE); - atexit(stop_child_console_handler); + if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT) { + FreeConsole(); + } + else + { + // TODO: We really need to play the RegisterServiceProcess + // game if this is the child of a Win9x service process + // We also have a huge problem here. This won't handle + // the close window, but if we FreeConsole() to detach, + // the Win9x console will ALWAYS close. ick. + SetConsoleCtrlHandler(child_control_handler, TRUE); + atexit(stop_child_console_handler); + } } -- 2.40.0