httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject cvs commit: httpd-2.0/server log.c
Date Mon, 10 Feb 2003 16:27:28 GMT
trawick     2003/02/10 08:27:28

  Modified:    .        CHANGES
               server   log.c
  Log:
  Fix an existing problem with error handling in piped_log_spawn().
  
  Use new APR apr_proc_create() features to prevent Apache from starting
  on Unix* in most cases where a piped log program can be started,
  and add log messages for the other situations.  *Other platforms
  already failed Apache initialization if a piped log program
  couldn't be started.
  
  PR:         15761
  
  Revision  Changes    Path
  1.1058    +7 -2      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.1057
  retrieving revision 1.1058
  diff -u -r1.1057 -r1.1058
  --- CHANGES	10 Feb 2003 14:26:34 -0000	1.1057
  +++ CHANGES	10 Feb 2003 16:27:27 -0000	1.1058
  @@ -7,8 +7,13 @@
        for easier debugging. PR 5381, 7638, 8255, 10773.  [André Malo]
   
     *) Try to log an error if a piped log program fails.  Try to
  -     restart a piped log program in more failure situations.  PR 15761
  -     [Jeff Trawick]
  +     restart a piped log program in more failure situations.  Fix an
  +     existing problem with error handling in piped_log_spawn().  Use
  +     new APR apr_proc_create() features to prevent Apache from starting
  +     on Unix* in most cases where a piped log program can be started,
  +     and add log messages for the other situations.  *Other platforms
  +     already failed Apache initialization if a piped log program
  +     couldn't be started.  PR 15761  [Jeff Trawick]
   
     *) Fix mod_cern_meta to not create empty metafiles when the
        metafile searched for does not exist.  PR 12353
  
  
  
  1.130     +27 -11    httpd-2.0/server/log.c
  
  Index: log.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/log.c,v
  retrieving revision 1.129
  retrieving revision 1.130
  diff -u -r1.129 -r1.130
  --- log.c	4 Feb 2003 17:21:50 -0000	1.129
  +++ log.c	10 Feb 2003 16:27:28 -0000	1.130
  @@ -220,6 +220,13 @@
       return rc;
   }
   
  +static void log_child_errfn(apr_pool_t *pool, apr_status_t err,
  +                            const char *description)
  +{
  +    ap_log_error(APLOG_MARK, APLOG_ERR, err, NULL,
  +                 "%s", description);
  +}
  +
   static int log_child(apr_pool_t *p, const char *progname,
                        apr_file_t **fpin)
   {
  @@ -235,7 +242,9 @@
           && ((rc = apr_procattr_io_set(procattr,
                                         APR_FULL_BLOCK,
                                         APR_NO_PIPE,
  -                                      APR_NO_PIPE)) == APR_SUCCESS)) {
  +                                      APR_NO_PIPE)) == APR_SUCCESS)
  +        && ((rc = apr_procattr_error_check_set(procattr, 1)) == APR_SUCCESS)
  +        && ((rc = apr_procattr_child_errfn_set(procattr, log_child_errfn)) == APR_SUCCESS))
{
           char **args;
           const char *pname;
   
  @@ -725,7 +734,7 @@
   
   static int piped_log_spawn(piped_log *pl)
   {
  -    int rc;
  +    int rc = 0;
       apr_procattr_t *procattr;
       apr_proc_t *procnew = NULL;
       apr_status_t status;
  @@ -734,7 +743,10 @@
           ((status = apr_procattr_child_in_set(procattr,
                                                ap_piped_log_read_fd(pl),
                                                ap_piped_log_write_fd(pl)))
  -        != APR_SUCCESS)) {
  +        != APR_SUCCESS) ||
  +        ((status = apr_procattr_child_errfn_set(procattr, log_child_errfn))
  +         != APR_SUCCESS) ||
  +        ((status = apr_procattr_error_check_set(procattr, 1)) != APR_SUCCESS)) {
           char buf[120];
           /* Something bad happened, give up and go away. */
           ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
  @@ -749,22 +761,26 @@
           apr_tokenize_to_argv(pl->program, &args, pl->p);
           pname = apr_pstrdup(pl->p, args[0]);
           procnew = apr_pcalloc(pl->p, sizeof(apr_proc_t));
  -        rc = apr_proc_create(procnew, pname, (const char * const *) args,
  -                             NULL, procattr, pl->p);
  +        status = apr_proc_create(procnew, pname, (const char * const *) args,
  +                                 NULL, procattr, pl->p);
   
  -        if (rc == APR_SUCCESS) {
  -            /* pjr - This no longer happens inside the child, */
  -            /*   I am assuming that if apr_proc_create was  */
  -            /*   successful that the child is running.        */
  -            RAISE_SIGSTOP(PIPED_LOG_SPAWN);
  +        if (status == APR_SUCCESS) {
               pl->pid = procnew;
               ap_piped_log_write_fd(pl) = procnew->in;
               apr_proc_other_child_register(procnew, piped_log_maintenance, pl,
                                             ap_piped_log_write_fd(pl), pl->p);
           }
  +        else {
  +            char buf[120];
  +            /* Something bad happened, give up and go away. */
  +            ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
  +                         "unable to start piped log program '%s': %s",
  +                         pl->program, apr_strerror(status, buf, sizeof(buf)));
  +            rc = -1;
  +        }
       }
   
  -    return 0;
  +    return rc;
   }
   
   
  
  
  

Mime
View raw message