You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by tr...@apache.org on 2003/02/06 19:50:31 UTC

cvs commit: apr/threadproc/win32 proc.c

trawick     2003/02/06 10:50:31

  Modified:    .        CHANGES
               include  apr_thread_proc.h
               include/arch/unix apr_arch_threadproc.h
               threadproc/beos proc.c
               threadproc/netware proc.c
               threadproc/os2 proc.c
               threadproc/unix proc.c
               threadproc/win32 proc.c
  Log:
  Allow apr_proc_create() to call an app-provided error reporting
  function when apr_proc_create() fails in the new child process
  after fork().  The app-provided error reporting function will only
  be called on platforms where apr_proc_create() first calls
  fork() to create the new process.
  
  Revision  Changes    Path
  1.374     +6 -0      apr/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr/CHANGES,v
  retrieving revision 1.373
  retrieving revision 1.374
  diff -u -r1.373 -r1.374
  --- CHANGES	4 Feb 2003 20:56:15 -0000	1.373
  +++ CHANGES	6 Feb 2003 18:50:30 -0000	1.374
  @@ -1,5 +1,11 @@
   Changes with APR 0.9.2
   
  +  *) Allow apr_proc_create() to call an app-provided error reporting
  +     function when apr_proc_create() fails in the new child process
  +     after fork().  The app-provided error reporting function will only
  +     be called on platforms where apr_proc_create() first calls
  +     fork() to create the new process.  [Jeff Trawick]
  +
     *) Rename rules.mk to apr_rules.mk and make apr_rules.mk be installed.
        [Thom May]
        
  
  
  
  1.91      +25 -0     apr/include/apr_thread_proc.h
  
  Index: apr_thread_proc.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_thread_proc.h,v
  retrieving revision 1.90
  retrieving revision 1.91
  diff -u -r1.90 -r1.91
  --- apr_thread_proc.h	4 Feb 2003 20:10:34 -0000	1.90
  +++ apr_thread_proc.h	6 Feb 2003 18:50:30 -0000	1.91
  @@ -177,6 +177,19 @@
   #endif
   };
   
  +/**
  + * The prototype for APR child errfn functions.  (See the description
  + * of apr_procattr_child_errfn_set() for more information.)
  + * It is passed the following parameters:
  + * @param pool Pool associated with the apr_proc_t.  If your child
  + *             error function needs user data, associate it with this
  + *             pool.
  + * @param err APR error code describing the error
  + * @param description Text description of type of processing which failed
  + */
  +typedef void (apr_child_errfn_t)(apr_pool_t *proc, apr_status_t err,
  +                                 const char *description);
  +
   /** Opaque Thread structure. */
   typedef struct apr_thread_t           apr_thread_t;
   /** Opaque Thread attributes structure. */
  @@ -486,6 +499,18 @@
                                                   apr_int32_t what,
                                                   struct rlimit *limit);
   #endif
  +
  +/**
  + * Specify an error function to be called in the child process if APR
  + * encounters an error in the child prior to running the specified program.
  + * @param child_errfn The function to call in the child process.
  + * @param userdata Parameter to be passed to errfn.
  + * @remark At the present time, it will only be called from apr_proc_create()
  + *         on platforms where fork() is used.  It will never be called on other
  + *         platforms.
  + */
  +APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr,
  +                                                       apr_child_errfn_t *errfn);
   
   #if APR_HAS_FORK
   /**
  
  
  
  1.4       +1 -0      apr/include/arch/unix/apr_arch_threadproc.h
  
  Index: apr_arch_threadproc.h
  ===================================================================
  RCS file: /home/cvs/apr/include/arch/unix/apr_arch_threadproc.h,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- apr_arch_threadproc.h	7 Jan 2003 00:52:54 -0000	1.3
  +++ apr_arch_threadproc.h	6 Feb 2003 18:50:30 -0000	1.4
  @@ -134,6 +134,7 @@
   #ifdef RLIMIT_NOFILE
       struct rlimit *limit_nofile;
   #endif
  +    apr_child_errfn_t *errfn;
   };
   
   #endif  /* ! THREAD_PROC_H */
  
  
  
  1.49      +6 -0      apr/threadproc/beos/proc.c
  
  Index: proc.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/beos/proc.c,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- proc.c	6 Jan 2003 23:44:37 -0000	1.48
  +++ proc.c	6 Feb 2003 18:50:30 -0000	1.49
  @@ -203,6 +203,12 @@
       return APR_INPARENT;
   }
   
  +APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr,
  +                                                       apr_child_errfn_t *errfn)
  +{
  +    /* won't ever be called on this platform, so don't save the function pointer */
  +    return APR_SUCCESS;
  +}
   
   APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, const char *progname, 
                                             const char * const *args,
  
  
  
  1.21      +7 -0      apr/threadproc/netware/proc.c
  
  Index: proc.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/netware/proc.c,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- proc.c	14 Jan 2003 18:35:39 -0000	1.20
  +++ proc.c	6 Feb 2003 18:50:30 -0000	1.21
  @@ -283,6 +283,13 @@
       return APR_SUCCESS;
   }
   
  +APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr,
  +                                                       apr_child_errfn_t *errfn)
  +{
  +    /* won't ever be called on this platform, so don't save the function pointer */
  +    return APR_SUCCESS;
  +}
  +
   APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *newproc,
   									const char *progname, 
   									const char * const *args, 
  
  
  
  1.56      +9 -0      apr/threadproc/os2/proc.c
  
  Index: proc.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/os2/proc.c,v
  retrieving revision 1.55
  retrieving revision 1.56
  diff -u -r1.55 -r1.56
  --- proc.c	7 Jan 2003 00:52:57 -0000	1.55
  +++ proc.c	6 Feb 2003 18:50:30 -0000	1.56
  @@ -278,6 +278,15 @@
   
   
   
  +APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr,
  +                                                       apr_child_errfn_t *errfn)
  +{
  +    /* won't ever be called on this platform, so don't save the function pointer */
  +    return APR_SUCCESS;
  +}
  +
  +
  +
   APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *proc, const char *progname,
                                             const char * const *args,
                                             const char * const *env,
  
  
  
  1.64      +21 -0     apr/threadproc/unix/proc.c
  
  Index: proc.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/unix/proc.c,v
  retrieving revision 1.63
  retrieving revision 1.64
  diff -u -r1.63 -r1.64
  --- proc.c	4 Feb 2003 20:12:29 -0000	1.63
  +++ proc.c	6 Feb 2003 18:50:30 -0000	1.64
  @@ -295,6 +295,13 @@
       return APR_SUCCESS;
   }
   
  +APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr,
  +                                                       apr_child_errfn_t *errfn)
  +{
  +    attr->errfn = errfn;
  +    return APR_SUCCESS;
  +}
  +
   APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new,
                                             const char *progname,
                                             const char * const *args,
  @@ -368,11 +375,17 @@
   
           if (attr->currdir != NULL) {
               if (chdir(attr->currdir) == -1) {
  +                if (attr->errfn) {
  +                    attr->errfn(pool, errno, "change of working directory failed");
  +                }
                   exit(-1);   /* We have big problems, the child should exit. */
               }
           }
   
           if ((status = limit_proc(attr)) != APR_SUCCESS) {
  +            if (attr->errfn) {
  +                attr->errfn(pool, errno, "setting of resource limits failed");
  +            }
               exit(-1);   /* We have big problems, the child should exit. */
           }
   
  @@ -422,6 +435,14 @@
   
               execvp(progname, (char * const *)args);
           }
  +        if (attr->errfn) {
  +            char *desc;
  +
  +            desc = apr_psprintf(pool, "exec of '%s' failed",
  +                                progname);
  +            attr->errfn(pool, errno, desc);
  +        }
  +
           exit(-1);  /* if we get here, there is a problem, so exit with an
                       * error code. */
       }
  
  
  
  1.87      +7 -0      apr/threadproc/win32/proc.c
  
  Index: proc.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/win32/proc.c,v
  retrieving revision 1.86
  retrieving revision 1.87
  diff -u -r1.86 -r1.87
  --- proc.c	24 Jan 2003 17:15:56 -0000	1.86
  +++ proc.c	6 Feb 2003 18:50:30 -0000	1.87
  @@ -281,6 +281,13 @@
       return cmd;
   }
   
  +APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr,
  +                                                       apr_child_errfn_t *errfn)
  +{
  +    /* won't ever be called on this platform, so don't save the function pointer */
  +    return APR_SUCCESS;
  +}
  +
   APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new,
                                             const char *progname,
                                             const char * const *args,
  
  
  

Re: cvs commit: apr/threadproc/win32 proc.c

Posted by Jeff Trawick <tr...@attglobal.net>.
trawick@apache.org wrote:

> trawick     2003/02/06 10:50:31
>   Log:
>   Allow apr_proc_create() to call an app-provided error reporting
>   function when apr_proc_create() fails in the new child process
>   after fork().  The app-provided error reporting function will only
>   be called on platforms where apr_proc_create() first calls
>   fork() to create the new process.
>   Index: apr_thread_proc.h
>   ===================================================================
>   +/**
>   + * The prototype for APR child errfn functions.  (See the description
>   + * of apr_procattr_child_errfn_set() for more information.)
>   + * It is passed the following parameters:
>   + * @param pool Pool associated with the apr_proc_t.  If your child
>   + *             error function needs user data, associate it with this
>   + *             pool.
>   + * @param err APR error code describing the error
>   + * @param description Text description of type of processing which 
> failed
>   + */
>   +typedef void (apr_child_errfn_t)(apr_pool_t *proc, apr_status_t err,
>   +                                 const char *description);


I may have had a change of heart on providing this information (text or 
enum or whatever) about which step in processing actually failed :)

We don't actually give this info in the rest of APR.  Not that more info 
is bad per se, but making promises in one small place that are woefuly 
unfullfilled everywhere else is a little disturbing.