httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@locus.apache.org
Subject cvs commit: apache-1.3/src/main http_main.c
Date Wed, 13 Dec 2000 22:26:00 GMT
wrowe       00/12/13 14:25:59

  Modified:    src      CHANGES
               src/os/win32 service.c service.h
               src/main http_main.c
  Log:
    Solve several potential stability issues with Apache on NT/2K as a
    service ... resolve the true argv[0], append the service name as
    args[n..n+1] (-n ServiceName), and run through apache_main() as our
    service process.  Resolves Windows2K's failure to NULL terminate
    the argv[] list for the service process.  And finally, this patch
    allows the user to pass the service manager startup args (e.g. -D FOO)
    or the operator to do so using the "Start Parameters" field of the
    service control panel.
  
    Also, added the -k install / -k uninstall compatibility with 2.0, as
    many users will be adopting and using both for the near future.
  
  Revision  Changes    Path
  1.1607    +8 -0      apache-1.3/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/CHANGES,v
  retrieving revision 1.1606
  retrieving revision 1.1607
  diff -u -r1.1606 -r1.1607
  --- CHANGES	2000/12/13 18:01:19	1.1606
  +++ CHANGES	2000/12/13 22:25:54	1.1607
  @@ -1,5 +1,13 @@
   Changes with Apache 1.3.15
   
  +  *) WinNT/2K can be started from the Services control panel adding
  +     whatever args are desired (e.g. -D ARG) in the 'Start Parameters'
  +     box of the start service dialog.  These will be passed on and
  +     recognized by the service as it starts.  [William Rowe]
  +
  +  *) Support -k install/-k uninstall on Win32 for compatibility with 
  +     Apache 2.0.  [William Rowe]
  +
     *) mod_cgi on Win32 and Netware now does a more effective job of
        capturing all stderr output from user's scripts.  PR6161
        [Hardy Braunsdorf <hardy.braunsdorf@metechnology.com>, Will Rowe]
  
  
  
  1.35      +15 -7     apache-1.3/src/os/win32/service.c
  
  Index: service.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/os/win32/service.c,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- service.c	2000/12/12 06:01:57	1.34
  +++ service.c	2000/12/13 22:25:57	1.35
  @@ -394,9 +394,15 @@
           { NULL, NULL }
       };
   
  -    /* Prevent holding open the (nonexistant) console */
  +    /* Prevent holding open the (nonexistant) console and allow us past
  +     * the first NT service to parse the service's args in apache_main() 
  +     */
  +	ap_server_argv0 = argv[0];
       real_exit_code = 0;
   
  +    /* keep the server from going to any real effort, since we know */
  +    is_service = 1;
  +
       globdat.main_fn = main_fn;
       globdat.stop_event = create_event(0, 0, "apache-signal");
       globdat.connected = 1;
  @@ -502,9 +508,13 @@
       DWORD  threadid;
       SECURITY_ATTRIBUTES sa = {0};  
       
  -    ap_server_argv0 = globdat.name = argv[0];
  -
  -    is_service = 1;
  +	argv = (char**) memcpy(malloc((argc + 3) * sizeof(char*)), 
  +		                   argv, argc * sizeof(char*));
  +	argv[argc++] = "-n";
  +	argv[argc++] = argv[0];
  +	argv[argc] = NULL;
  +    argv[0] = ap_server_argv0;
  +	ap_server_argv0 = globdat.name = argv[0];
   
       if(!(globdat.hServiceStatus = RegisterServiceCtrlHandler(globdat.name, 
                                                                service_ctrl)))
  @@ -560,9 +570,7 @@
       }
   
       service_cd();
  -    if( service_init() ) 
  -        /* Arguments are ok except for \! */
  -        globdat.exit_status = (*globdat.main_fn)( argc, argv );
  +    globdat.exit_status = globdat.main_fn( argc, argv );
   
       if (hPipeWrite)
           CloseHandle(hPipeWrite);
  
  
  
  1.13      +0 -1      apache-1.3/src/os/win32/service.h
  
  Index: service.h
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/os/win32/service.h,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- service.h	2000/11/22 02:46:29	1.12
  +++ service.h	2000/12/13 22:25:57	1.13
  @@ -81,7 +81,6 @@
   BOOL isValidService(char *display_name);
   void InstallService(char *display_name, char *conf);
   void RemoveService(char *display_name);
  -int service_init();
   int send_signal_to_service(char *display_name, char *sig);
   BOOL isWindowsNT(void);
   void ap_start_console_monitor(void);
  
  
  
  1.517     +20 -19    apache-1.3/src/main/http_main.c
  
  Index: http_main.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/main/http_main.c,v
  retrieving revision 1.516
  retrieving revision 1.517
  diff -u -r1.516 -r1.517
  --- http_main.c	2000/11/22 02:46:27	1.516
  +++ http_main.c	2000/12/13 22:25:58	1.517
  @@ -2836,6 +2836,7 @@
        * "apache-signal" event here.
        */
   
  +    /* XXX: This is no good, can't we please die in -X mode :-? */
       if (one_process) {
   	return;
       }
  @@ -6633,22 +6634,6 @@
       set_group_privs();
   }
   
  -int service_init()
  -{
  -    common_init();
  - 
  -    ap_cpystrn(ap_server_root, HTTPD_ROOT, sizeof(ap_server_root));
  -    if (ap_registry_get_service_conf(pconf, ap_server_confname, sizeof(ap_server_confname),
  -                                     ap_server_argv0))
  -        return FALSE;
  -
  -    ap_setup_prelinked_modules();
  -    server_conf = ap_read_config(pconf, ptrans, ap_server_confname);
  -    ap_log_pid(pconf, ap_pid_fname);
  -    post_parse_init();
  -    return TRUE;
  -}
  -
   
   #ifdef NETWARE
   extern char *optarg;
  @@ -6690,13 +6675,15 @@
       int is_child_of_service = 0;
       char *signal_to_send = NULL;
   
  -    /* Service application under WinNT */
  -    if (isWindowsNT()) 
  +    /* Service application under WinNT the first time through only...
  +     * service_main immediately resets real_exit_code to zero
  +     */
  +    if (real_exit_code && isWindowsNT()) 
       {
           if (((argc == 1) && isProcessService()) 
               || ((argc == 2) && !strcmp(argv[1], "--ntservice")))
           {
  -            service_main(master_main, argc, argv);
  +            service_main(apache_main, argc, argv);
               clean_parent_exit(0);
           }
       }
  @@ -6789,6 +6776,10 @@
   	case 'k':
               if (!strcasecmp(optarg, "stop"))
                   signal_to_send = "shutdown";
  +            else if (!strcasecmp(optarg, "install"))
  +                install = 1;
  +            else if (!strcasecmp(optarg, "uninstall"))
  +                install = -1;
               else
                   signal_to_send = optarg;
   	    break;
  @@ -6873,6 +6864,7 @@
       }       /* while  */
   
   #ifdef WIN32
  +
       if (!service_name && install) {
           service_name = DEFAULTSERVICENAME;
       }
  @@ -7031,12 +7023,21 @@
   #ifdef WIN32
           if (child)
               ap_start_child_console(is_child_of_service);
  +        else
  +            ap_start_console_monitor();
   #endif
   	worker_main();
   	ap_destroy_mutex(start_mutex);
   	destroy_event(exit_event);
       } 
   #ifdef WIN32
  +    /* Windows NT service second time around ... we have all the overrides 
  +     * from the NT SCM, so go to town and return to the SCM when we quit.
  +     */
  +    if (isWindowsNT() && isProcessService())
  +    {
  +        master_main(argc, argv);
  +    }
       else if (service_name && signal_to_send && !isWindowsNT()
                && !strcasecmp(signal_to_send, "start")) {
           /* service95_main will call master_main() */
  
  
  

Mime
View raw message