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/04/17 18:36:28 UTC

cvs commit: httpd-2.0/server/mpm/winnt mpm_winnt.c service.c

wrowe       02/04/17 09:36:28

  Modified:    .        CHANGES
               include  http_log.h http_main.h
               server   log.c main.c
               server/mpm/winnt mpm_winnt.c service.c
  Log:
       Introduced -E startup_logfile_name option to httpd to allow admins
       to begin logging errors immediately.  This provides Win32 users
       an alternative to sending startup errors to the event viewer, and
       allows other daemon tool authors an alternative to logging to stderr.
  
  Revision  Changes    Path
  1.711     +6 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.710
  retrieving revision 1.711
  diff -u -r1.710 -r1.711
  --- CHANGES	17 Apr 2002 04:09:06 -0000	1.710
  +++ CHANGES	17 Apr 2002 16:36:27 -0000	1.711
  @@ -1,5 +1,11 @@
   Changes with Apache 2.0.36
   
  +  *) Introduced -E startup_logfile_name option to httpd to allow admins
  +     to begin logging errors immediately.  This provides Win32 users 
  +     an alternative to sending startup errors to the event viewer, and
  +     allows other daemon tool authors an alternative to logging to stderr.
  +     [William Rowe] 
  +     
     *) Fix subreqs with non-defined Content-Types being served improperly.
        [Justin Erenkrantz]
   
  
  
  
  1.34      +8 -0      httpd-2.0/include/http_log.h
  
  Index: http_log.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/include/http_log.h,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- http_log.h	13 Mar 2002 20:47:42 -0000	1.33
  +++ http_log.h	17 Apr 2002 16:36:27 -0000	1.34
  @@ -122,6 +122,14 @@
   AP_DECLARE(void) ap_open_stderr_log(apr_pool_t *p);
   
   /**
  + * Replace logging to stderr with logging to the given file.
  + * @param p The pool to allocate out of
  + * @param file Name of the file to log stderr output
  + */
  +AP_DECLARE(apr_status_t) ap_replace_stderr_log(apr_pool_t *p, 
  +                                               const char *file);
  +
  +/**
    * Open the error log and replace stderr with it.
    * @param s_main The main server
    * @param p The pool to allocate out of
  
  
  
  1.23      +1 -1      httpd-2.0/include/http_main.h
  
  Index: http_main.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/include/http_main.h,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- http_main.h	13 Mar 2002 20:47:42 -0000	1.22
  +++ http_main.h	17 Apr 2002 16:36:27 -0000	1.23
  @@ -63,7 +63,7 @@
    * in apr_getopt() format.  Use this for default'ing args that the MPM
    * can safely ignore and pass on from its rewrite_args() handler.
    */
  -#define AP_SERVER_BASEARGS "C:c:D:d:e:f:vVlLth?X"
  +#define AP_SERVER_BASEARGS "C:c:D:d:E:e:f:vVlLth?X"
   
   #ifdef __cplusplus
   extern "C" {
  
  
  
  1.116     +33 -0     httpd-2.0/server/log.c
  
  Index: log.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/log.c,v
  retrieving revision 1.115
  retrieving revision 1.116
  diff -u -r1.115 -r1.116
  --- log.c	17 Mar 2002 23:17:28 -0000	1.115
  +++ log.c	17 Apr 2002 16:36:28 -0000	1.116
  @@ -187,6 +187,39 @@
       apr_file_open_stderr(&stderr_log, p);
   }
   
  +AP_DECLARE(apr_status_t) ap_replace_stderr_log(apr_pool_t *p, 
  +                                               const char *fname)
  +{
  +    apr_file_t *stderr_file;
  +    apr_status_t rc;
  +    char *filename = ap_server_root_relative(p, fname);
  +    if (!filename) {
  +        ap_log_error(APLOG_MARK, APLOG_STARTUP|APLOG_CRIT,
  +                     APR_EBADPATH, NULL, "Invalid -E error log file %s",
  +                     fname);
  +        exit(1);
  +    }
  +    if ((rc = apr_file_open(&stderr_file, filename,
  +                            APR_APPEND | APR_READ | APR_WRITE | APR_CREATE,
  +                            APR_OS_DEFAULT, p)) != APR_SUCCESS) {
  +        ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL,
  +                     "%s: could not open error log file %s.",
  +                     ap_server_argv0, fname);
  +        return rc;
  +    }
  +    if ((rc = apr_file_open_stderr(&stderr_log, p)) == APR_SUCCESS) {
  +        apr_file_flush(stderr_log);
  +        if ((rc = apr_file_dup2(stderr_log, stderr_file, p)) == APR_SUCCESS) {
  +            apr_file_close(stderr_file);
  +        }
  +    }
  +    if (rc != APR_SUCCESS) {
  +        ap_log_error(APLOG_MARK, APLOG_CRIT, rc, NULL,
  +                     "unable to replace stderr with error_log");
  +        return rc;
  +    }
  +}
  +
   static int log_child(apr_pool_t *p, const char *progname,
                        apr_file_t **fpin)
   {
  
  
  
  1.127     +10 -0     httpd-2.0/server/main.c
  
  Index: main.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/main.c,v
  retrieving revision 1.126
  retrieving revision 1.127
  diff -u -r1.126 -r1.127
  --- main.c	13 Apr 2002 19:35:17 -0000	1.126
  +++ main.c	17 Apr 2002 16:36:28 -0000	1.127
  @@ -360,6 +360,8 @@
                    "  -e level          : show startup errors of level "
                    "(see LogLevel)");
       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
  +                 "  -E file           : log startup errors to file");
  +    ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
                    "  -v                : show version number");
       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
                    "  -V                : show compile settings");
  @@ -390,6 +392,7 @@
       int configtestonly = 0;
       const char *confname = SERVER_CONFIG_FILE;
       const char *def_server_root = HTTPD_ROOT;
  +    const char *temp_error_log = NULL;
       process_rec *process;
       server_rec *server_conf;
       apr_pool_t *pglobal;
  @@ -486,6 +489,10 @@
               }
               break;
   
  +        case 'E':
  +            temp_error_log = apr_pstrdup(process->pool, optarg);
  +            break;
  +
           case 'X':
               new = (char **)apr_array_push(ap_server_config_defines);
               *new = "DEBUG";
  @@ -539,6 +546,9 @@
        */
   
       ap_server_root = def_server_root;
  +    if (temp_error_log) {
  +        ap_replace_stderr_log(process->pool, temp_error_log);
  +    }
       server_conf = ap_read_config(process, ptemp, confname, &ap_conftree);
       if (ap_run_pre_config(pconf, plog, ptemp) != OK) {
           ap_log_error(APLOG_MARK, APLOG_STARTUP |APLOG_ERR| APLOG_NOERRNO, 0,
  
  
  
  1.264     +9 -1      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.263
  retrieving revision 1.264
  diff -u -r1.263 -r1.264
  --- mpm_winnt.c	10 Apr 2002 17:02:00 -0000	1.263
  +++ mpm_winnt.c	17 Apr 2002 16:36:28 -0000	1.264
  @@ -1975,6 +1975,7 @@
       char *pid;
       apr_getopt_t *opt;
       int running_as_service = 1;
  +    int errout = 0;
   
       osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
       GetVersionEx(&osver);
  @@ -2060,6 +2061,9 @@
           case 'k':
               signal_arg = optarg;
               break;
  +        case 'E':
  +            errout = 1;
  +            /* Fall through so the Apache main() handles the 'E' arg */
           default:
               *(const char **)apr_array_push(mpm_new_argv) =
                   apr_pstrdup(process->pool, optbuf);
  @@ -2106,7 +2110,11 @@
            * We hold the return value so that we can die in pre_config
            * after logging begins, and the failure can land in the log.
            */
  -        if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT) {
  +        if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT) 
  +        {
  +            if (!errout) {
  +                mpm_nt_eventlog_stderr_open(service_name, process->pool);
  +            }
               service_to_start_success = mpm_service_to_start(&service_name,
                                                               process->pool);
               if (service_to_start_success == APR_SUCCESS) {
  
  
  
  1.50      +0 -2      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.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- service.c	22 Mar 2002 01:28:01 -0000	1.49
  +++ service.c	17 Apr 2002 16:36:28 -0000	1.50
  @@ -708,8 +708,6 @@
       
       if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT)
       {
  -        mpm_nt_eventlog_stderr_open(mpm_display_name, p);
  -
           globdat.service_init = CreateEvent(NULL, FALSE, FALSE, NULL);
           globdat.service_term = CreateMutex(NULL, TRUE, NULL);
           if (!globdat.service_init || !globdat.service_term) {