apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stri...@apache.org
Subject cvs commit: apr/threadproc/unix proc.c thread.c threadpriv.c
Date Tue, 19 Mar 2002 18:31:08 GMT
striker     02/03/19 10:31:08

  Modified:    threadproc/unix proc.c thread.c threadpriv.c
  Log:
  Style Police writes some more tickets...
  
  Revision  Changes    Path
  1.59      +92 -47    apr/threadproc/unix/proc.c
  
  Index: proc.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/unix/proc.c,v
  retrieving revision 1.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- proc.c	19 Mar 2002 17:54:00 -0000	1.58
  +++ proc.c	19 Mar 2002 18:31:08 -0000	1.59
  @@ -57,7 +57,8 @@
   #include "apr_portable.h"
   #include "apr_signal.h"
   
  -APR_DECLARE(apr_status_t) apr_procattr_create(apr_procattr_t **new, apr_pool_t *pool)
  +APR_DECLARE(apr_status_t) apr_procattr_create(apr_procattr_t **new,
  +                                              apr_pool_t *pool)
   {
       (*new) = (apr_procattr_t *)apr_pcalloc(pool, sizeof(apr_procattr_t));
   
  @@ -69,15 +70,18 @@
       return APR_SUCCESS;
   }
   
  -APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr, apr_int32_t in, 
  -                                              apr_int32_t out, apr_int32_t err)
  +APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr,
  +                                              apr_int32_t in,
  +                                              apr_int32_t out,
  +                                              apr_int32_t err)
   {
       apr_status_t status;
       if (in != 0) {
  -        if ((status = apr_file_pipe_create(&attr->child_in, &attr->parent_in,

  -                                   attr->pool)) != APR_SUCCESS) {
  +        if ((status = apr_file_pipe_create(&attr->child_in, &attr->parent_in,
  +                                           attr->pool)) != APR_SUCCESS) {
               return status;
           }
  +
           switch (in) {
           case APR_FULL_BLOCK:
               break;
  @@ -91,12 +95,14 @@
               apr_file_pipe_timeout_set(attr->child_in, 0);
               apr_file_pipe_timeout_set(attr->parent_in, 0);
           }
  -    } 
  +    }
  +
       if (out) {
  -        if ((status = apr_file_pipe_create(&attr->parent_out, &attr->child_out,

  -                                   attr->pool)) != APR_SUCCESS) {
  +        if ((status = apr_file_pipe_create(&attr->parent_out, &attr->child_out,
  +                                           attr->pool)) != APR_SUCCESS) {
               return status;
           }
  +
           switch (out) {
           case APR_FULL_BLOCK:
               break;
  @@ -110,12 +116,14 @@
               apr_file_pipe_timeout_set(attr->child_out, 0);
               apr_file_pipe_timeout_set(attr->parent_out, 0);
           }
  -    } 
  +    }
  +
       if (err) {
  -        if ((status = apr_file_pipe_create(&attr->parent_err, &attr->child_err,

  -                                   attr->pool)) != APR_SUCCESS) {
  +        if ((status = apr_file_pipe_create(&attr->parent_err, &attr->child_err,
  +                                           attr->pool)) != APR_SUCCESS) {
               return status;
           }
  +
           switch (err) {
           case APR_FULL_BLOCK:
               break;
  @@ -129,12 +137,14 @@
               apr_file_pipe_timeout_set(attr->child_err, 0);
               apr_file_pipe_timeout_set(attr->parent_err, 0);
           }
  -    } 
  +    }
  +
       return APR_SUCCESS;
   }
   
   
  -APR_DECLARE(apr_status_t) apr_procattr_child_in_set(apr_procattr_t *attr, apr_file_t *child_in,
  +APR_DECLARE(apr_status_t) apr_procattr_child_in_set(apr_procattr_t *attr,
  +                                                    apr_file_t *child_in,
                                                       apr_file_t *parent_in)
   {
       if (attr->child_in == NULL && attr->parent_in == NULL)
  @@ -150,7 +160,8 @@
   }
   
   
  -APR_DECLARE(apr_status_t) apr_procattr_child_out_set(apr_procattr_t *attr, apr_file_t *child_out,
  +APR_DECLARE(apr_status_t) apr_procattr_child_out_set(apr_procattr_t *attr,
  +                                                     apr_file_t *child_out,
                                                        apr_file_t *parent_out)
   {
       if (attr->child_out == NULL && attr->parent_out == NULL)
  @@ -166,7 +177,8 @@
   }
   
   
  -APR_DECLARE(apr_status_t) apr_procattr_child_err_set(apr_procattr_t *attr, apr_file_t *child_err,
  +APR_DECLARE(apr_status_t) apr_procattr_child_err_set(apr_procattr_t *attr,
  +                                                     apr_file_t *child_err,
                                                        apr_file_t *parent_err)
   {
       if (attr->child_err == NULL && attr->parent_err == NULL)
  @@ -182,25 +194,26 @@
   }
   
   
  -APR_DECLARE(apr_status_t) apr_procattr_dir_set(apr_procattr_t *attr, 
  -                                               const char *dir) 
  +APR_DECLARE(apr_status_t) apr_procattr_dir_set(apr_procattr_t *attr,
  +                                               const char *dir)
   {
       attr->currdir = apr_pstrdup(attr->pool, dir);
       if (attr->currdir) {
           return APR_SUCCESS;
       }
  +
       return APR_ENOMEM;
   }
   
   APR_DECLARE(apr_status_t) apr_procattr_cmdtype_set(apr_procattr_t *attr,
  -                                                   apr_cmdtype_e cmd) 
  +                                                   apr_cmdtype_e cmd)
   {
       attr->cmdtype = cmd;
       return APR_SUCCESS;
   }
   
  -APR_DECLARE(apr_status_t) apr_procattr_detach_set(apr_procattr_t *attr, 
  -                                                  apr_int32_t detach) 
  +APR_DECLARE(apr_status_t) apr_procattr_detach_set(apr_procattr_t *attr,
  +                                                  apr_int32_t detach)
   {
       attr->detached = detach;
       return APR_SUCCESS;
  @@ -209,21 +222,24 @@
   APR_DECLARE(apr_status_t) apr_proc_fork(apr_proc_t *proc, apr_pool_t *pool)
   {
       int pid;
  -    
  +
       if ((pid = fork()) < 0) {
           return errno;
       }
       else if (pid == 0) {
           proc->pid = pid;
  -        proc->in = NULL; 
  -        proc->out = NULL; 
  -        proc->err = NULL; 
  +        proc->in = NULL;
  +        proc->out = NULL;
  +        proc->err = NULL;
  +
           return APR_INCHILD;
       }
  +
       proc->pid = pid;
  -    proc->in = NULL; 
  -    proc->out = NULL; 
  -    proc->err = NULL; 
  +    proc->in = NULL;
  +    proc->out = NULL;
  +    proc->err = NULL;
  +
       return APR_INPARENT;
   }
   
  @@ -272,10 +288,12 @@
       return APR_SUCCESS;
   }
   
  -APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, const char *progname, 
  +APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new,
  +                                          const char *progname,
                                             const char * const *args,
                                             const char * const *env,
  -                                          apr_procattr_t *attr, apr_pool_t *pool)
  +                                          apr_procattr_t *attr,
  +                                          apr_pool_t *pool)
   {
       int i;
       const char **newargs;
  @@ -283,16 +301,17 @@
       new->in = attr->parent_in;
       new->err = attr->parent_err;
       new->out = attr->parent_out;
  +
       if ((new->pid = fork()) < 0) {
           return errno;
       }
  -    else if (new->pid == 0) { 
  +    else if (new->pid == 0) {
           int status;
           /* child process */
   
           /*
  -         * If we do exec cleanup before the dup2() calls to set up pipes 
  -         * on 0-2, we accidentally close the pipes used by programs like 
  +         * If we do exec cleanup before the dup2() calls to set up pipes
  +         * on 0-2, we accidentally close the pipes used by programs like
            * mod_cgid.
            *
            * If we do exec cleanup after the dup2() calls, cleanup can accidentally
  @@ -304,13 +323,15 @@
            */
   
           if (attr->child_in) {
  -            apr_pool_cleanup_kill(apr_file_pool_get(attr->child_in), 
  +            apr_pool_cleanup_kill(apr_file_pool_get(attr->child_in),
                                     attr->child_in, apr_unix_file_cleanup);
           }
  +
           if (attr->child_out) {
               apr_pool_cleanup_kill(apr_file_pool_get(attr->child_out),
                                     attr->child_out, apr_unix_file_cleanup);
           }
  +
           if (attr->child_err) {
               apr_pool_cleanup_kill(apr_file_pool_get(attr->child_err),
                                     attr->child_err, apr_unix_file_cleanup);
  @@ -323,18 +344,20 @@
               dup2(attr->child_in->filedes, STDIN_FILENO);
               apr_file_close(attr->child_in);
           }
  +
           if (attr->child_out) {
               apr_file_close(attr->parent_out);
               dup2(attr->child_out->filedes, STDOUT_FILENO);
               apr_file_close(attr->child_out);
           }
  +
           if (attr->child_err) {
               apr_file_close(attr->parent_err);
               dup2(attr->child_err->filedes, STDERR_FILENO);
               apr_file_close(attr->child_err);
           }
  -        
  -        apr_signal(SIGCHLD, SIG_DFL); /*not sure if this is needed or not */
  +
  +        apr_signal(SIGCHLD, SIG_DFL); /* not sure if this is needed or not */
   
           if (attr->currdir != NULL) {
               if (chdir(attr->currdir) == -1) {
  @@ -351,31 +374,37 @@
               while (args[i]) {
                   i++;
               }
  -            newargs =
  -               (const char **) apr_palloc(pool, sizeof (char *) * (i + 3));
  +
  +            newargs = (const char **)apr_palloc(pool, sizeof (char *) * (i + 3));
               newargs[0] = SHELL_PATH;
               newargs[1] = "-c";
  +
               i = 0;
               while (args[i]) {
  -                newargs[i + 2] = args[i]; 
  +                newargs[i + 2] = args[i];
                   i++;
               }
  +
               newargs[i + 2] = NULL;
  +
               if (attr->detached) {
                   apr_proc_detach(APR_PROC_DETACH_DAEMONIZE);
               }
  +
               execve(SHELL_PATH, (char * const *) newargs, (char * const *)env);
           }
           else if (attr->cmdtype == APR_PROGRAM) {
               if (attr->detached) {
                   apr_proc_detach(APR_PROC_DETACH_DAEMONIZE);
               }
  +
               execve(progname, (char * const *)args, (char * const *)env);
           }
           else if (attr->cmdtype == APR_PROGRAM_ENV) {
               if (attr->detached) {
                   apr_proc_detach(APR_PROC_DETACH_DAEMONIZE);
               }
  +
               execv(progname, (char * const *)args);
           }
           else {
  @@ -383,35 +412,40 @@
               if (attr->detached) {
                   apr_proc_detach(APR_PROC_DETACH_DAEMONIZE);
               }
  +
               execvp(progname, (char * const *)args);
           }
  -        exit(-1);  /* if we get here, there is a problem, so exit with an */ 
  -                   /* error code. */
  +        exit(-1);  /* if we get here, there is a problem, so exit with an
  +                    * error code. */
       }
  +
       /* Parent process */
       if (attr->child_in) {
           apr_file_close(attr->child_in);
       }
  +
       if (attr->child_out) {
           apr_file_close(attr->child_out);
       }
  +
       if (attr->child_err) {
           apr_file_close(attr->child_err);
       }
  +
       return APR_SUCCESS;
   }
   
  -APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc, 
  +APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc,
                                                     int *exitcode,
                                                     apr_exit_why_e *exitwhy,
  -                                                  apr_wait_how_e waithow, 
  +                                                  apr_wait_how_e waithow,
                                                     apr_pool_t *p)
   {
       proc->pid = -1;
       return apr_proc_wait(proc, exitcode, exitwhy, waithow);
  -} 
  +}
   
  -APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, 
  +APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc,
                                           int *exitcode, apr_exit_why_e *exitwhy,
                                           apr_wait_how_e waithow)
   {
  @@ -424,6 +458,7 @@
       if (exitcode == NULL) {
           exitcode = &ignore;
       }
  +
       if (exitwhy == NULL) {
           exitwhy = &ignorewhy;
       }
  @@ -431,35 +466,41 @@
       if (waithow != APR_WAIT) {
           waitpid_options |= WNOHANG;
       }
  -    
  +
       if ((pstatus = waitpid(proc->pid, &exit_int, waitpid_options)) > 0) {
           proc->pid = pstatus;
  +
           if (WIFEXITED(exit_int)) {
               *exitwhy = APR_PROC_EXIT;
               *exitcode = WEXITSTATUS(exit_int);
           }
           else if (WIFSIGNALED(exit_int)) {
               *exitwhy = APR_PROC_SIGNAL;
  +
   #ifdef WCOREDUMP
               if (WCOREDUMP(exit_int)) {
                   *exitwhy |= APR_PROC_SIGNAL_CORE;
               }
   #endif
  +
               *exitcode = WTERMSIG(exit_int);
           }
           else {
               /* unexpected condition */
               return APR_EGENERAL;
           }
  +
           return APR_CHILD_DONE;
       }
       else if (pstatus == 0) {
           return APR_CHILD_NOTDONE;
       }
  +
       return errno;
  -} 
  +}
   
  -APR_DECLARE(apr_status_t) apr_procattr_limit_set(apr_procattr_t *attr, apr_int32_t what,

  +APR_DECLARE(apr_status_t) apr_procattr_limit_set(apr_procattr_t *attr,
  +                                                 apr_int32_t what,
                                                    struct rlimit *limit)
   {
       switch(what) {
  @@ -470,6 +511,7 @@
   #else
               return APR_ENOTIMPL;
   #endif
  +
           case APR_LIMIT_MEM:
   #if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS)
               attr->limit_mem = limit;
  @@ -477,6 +519,7 @@
   #else
               return APR_ENOTIMPL;
   #endif
  +
           case APR_LIMIT_NPROC:
   #ifdef RLIMIT_NPROC
               attr->limit_nproc = limit;
  @@ -484,6 +527,8 @@
   #else
               return APR_ENOTIMPL;
   #endif
  +
       }
  +
       return APR_SUCCESS;
   }
  
  
  
  1.52      +39 -19    apr/threadproc/unix/thread.c
  
  Index: thread.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/unix/thread.c,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- thread.c	19 Mar 2002 17:54:00 -0000	1.51
  +++ thread.c	19 Mar 2002 18:31:08 -0000	1.52
  @@ -59,10 +59,11 @@
   #if APR_HAS_THREADS
   
   #if APR_HAVE_PTHREAD_H
  -APR_DECLARE(apr_status_t) apr_threadattr_create(apr_threadattr_t **new, apr_pool_t *pool)
  +APR_DECLARE(apr_status_t) apr_threadattr_create(apr_threadattr_t **new,
  +                                                apr_pool_t *pool)
   {
       apr_status_t stat;
  -  
  +
       (*new) = (apr_threadattr_t *)apr_pcalloc(pool, sizeof(apr_threadattr_t));
       (*new)->attr = (pthread_attr_t *)apr_pcalloc(pool, sizeof(pthread_attr_t));
   
  @@ -79,10 +80,12 @@
   #ifdef PTHREAD_SETS_ERRNO
       stat = errno;
   #endif
  +
       return stat;
   }
   
  -APR_DECLARE(apr_status_t) apr_threadattr_detach_set(apr_threadattr_t *attr, apr_int32_t
on)
  +APR_DECLARE(apr_status_t) apr_threadattr_detach_set(apr_threadattr_t *attr,
  +                                                    apr_int32_t on)
   {
       apr_status_t stat;
   #ifdef PTHREAD_ATTR_SETDETACHSTATE_ARG2_ADDR
  @@ -92,12 +95,14 @@
   #else
       if ((stat = pthread_attr_setdetachstate(attr->attr, on)) == 0) {
   #endif
  +
           return APR_SUCCESS;
       }
       else {
   #ifdef PTHREAD_SETS_ERRNO
           stat = errno;
   #endif
  +
           return stat;
       }
   }
  @@ -122,13 +127,15 @@
       return thread->func(thread, thread->data);
   }
   
  -APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new, apr_threadattr_t *attr,

  -                                            apr_thread_start_t func, void *data, 
  +APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new,
  +                                            apr_threadattr_t *attr,
  +                                            apr_thread_start_t func,
  +                                            void *data,
                                               apr_pool_t *pool)
   {
       apr_status_t stat;
       pthread_attr_t *temp;
  - 
  +
       (*new) = (apr_thread_t *)apr_pcalloc(pool, sizeof(apr_thread_t));
   
       if ((*new) == NULL) {
  @@ -144,7 +151,7 @@
       (*new)->pool = pool;
       (*new)->data = data;
       (*new)->func = func;
  -    
  +
       if (attr)
           temp = attr->attr;
       else
  @@ -162,8 +169,9 @@
   #ifdef PTHREAD_SETS_ERRNO
           stat = errno;
   #endif
  +
           return stat;
  -    } 
  +    }
   }
   
   APR_DECLARE(apr_os_thread_t) apr_os_thread_current(void)
  @@ -171,12 +179,14 @@
       return pthread_self();
   }
   
  -APR_DECLARE(int) apr_os_thread_equal(apr_os_thread_t tid1, apr_os_thread_t tid2)
  +APR_DECLARE(int) apr_os_thread_equal(apr_os_thread_t tid1,
  +                                     apr_os_thread_t tid2)
   {
       return pthread_equal(tid1, tid2);
   }
   
  -APR_DECLARE(apr_status_t) apr_thread_exit(apr_thread_t *thd, apr_status_t retval)
  +APR_DECLARE(apr_status_t) apr_thread_exit(apr_thread_t *thd,
  +                                          apr_status_t retval)
   {
       thd->exitval = retval;
       apr_pool_destroy(thd->pool);
  @@ -184,7 +194,8 @@
       return APR_SUCCESS;
   }
   
  -APR_DECLARE(apr_status_t) apr_thread_join(apr_status_t *retval, apr_thread_t *thd)
  +APR_DECLARE(apr_status_t) apr_thread_join(apr_status_t *retval,
  +                                          apr_thread_t *thd)
   {
       apr_status_t stat;
       apr_status_t *thread_stat;
  @@ -197,6 +208,7 @@
   #ifdef PTHREAD_SETS_ERRNO
           stat = errno;
   #endif
  +
           return stat;
       }
   }
  @@ -210,12 +222,14 @@
   #else
       if ((stat = pthread_detach(*thd->td)) == 0) {
   #endif
  +
           return APR_SUCCESS;
       }
       else {
   #ifdef PTHREAD_SETS_ERRNO
           stat = errno;
   #endif
  +
           return stat;
       }
   }
  @@ -224,34 +238,39 @@
   {
   }
   
  -APR_DECLARE(apr_status_t) apr_thread_data_get(void **data, const char *key, apr_thread_t
*thread)
  +APR_DECLARE(apr_status_t) apr_thread_data_get(void **data, const char *key,
  +                                              apr_thread_t *thread)
   {
       return apr_pool_userdata_get(data, key, thread->pool);
   }
   
   APR_DECLARE(apr_status_t) apr_thread_data_set(void *data, const char *key,
  -                              apr_status_t (*cleanup) (void *),
  +                              apr_status_t (*cleanup)(void *),
                                 apr_thread_t *thread)
   {
       return apr_pool_userdata_set(data, key, cleanup, thread->pool);
   }
   
  -APR_DECLARE(apr_status_t) apr_os_thread_get(apr_os_thread_t **thethd, apr_thread_t *thd)
  +APR_DECLARE(apr_status_t) apr_os_thread_get(apr_os_thread_t **thethd,
  +                                            apr_thread_t *thd)
   {
       *thethd = thd->td;
       return APR_SUCCESS;
   }
   
  -APR_DECLARE(apr_status_t) apr_os_thread_put(apr_thread_t **thd, apr_os_thread_t *thethd,

  -                             apr_pool_t *pool)
  +APR_DECLARE(apr_status_t) apr_os_thread_put(apr_thread_t **thd,
  +                                            apr_os_thread_t *thethd,
  +                                            apr_pool_t *pool)
   {
       if (pool == NULL) {
           return APR_ENOPOOL;
       }
  +
       if ((*thd) == NULL) {
           (*thd) = (apr_thread_t *)apr_pcalloc(pool, sizeof(apr_thread_t));
           (*thd)->pool = pool;
       }
  +
       (*thd)->td = thethd;
       return APR_SUCCESS;
   }
  @@ -266,7 +285,7 @@
       return APR_SUCCESS;
   }
   
  -APR_DECLARE(apr_status_t) apr_thread_once(apr_thread_once_t *control, 
  +APR_DECLARE(apr_status_t) apr_thread_once(apr_thread_once_t *control,
                                             void (*func)(void))
   {
       return pthread_once(&control->once, func);
  @@ -279,9 +298,10 @@
   
   #if !APR_HAS_THREADS
   
  -APR_DECLARE(apr_status_t) apr_os_thread_get(void); /* avoid warning for no prototype */
  +/* avoid warning for no prototype */
  +APR_DECLARE(apr_status_t) apr_os_thread_get(void);
   
  -APR_DECLARE(apr_status_t) apr_os_thread_get(void) 
  +APR_DECLARE(apr_status_t) apr_os_thread_get(void)
   {
       return APR_ENOTIMPL;
   }
  
  
  
  1.36      +27 -14    apr/threadproc/unix/threadpriv.c
  
  Index: threadpriv.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/unix/threadpriv.c,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- threadpriv.c	19 Mar 2002 17:54:00 -0000	1.35
  +++ threadpriv.c	19 Mar 2002 18:31:08 -0000	1.36
  @@ -59,8 +59,9 @@
   #if APR_HAS_THREADS
   
   #if APR_HAVE_PTHREAD_H
  -APR_DECLARE(apr_status_t) apr_threadkey_private_create(apr_threadkey_t **key, 
  -                                                void (*dest)(void *), apr_pool_t *pool)
  +APR_DECLARE(apr_status_t) apr_threadkey_private_create(apr_threadkey_t **key,
  +                                                       void (*dest)(void *),
  +                                                       apr_pool_t *pool)
   {
       (*key) = (apr_threadkey_t *)apr_pcalloc(pool, sizeof(apr_threadkey_t));
   
  @@ -74,20 +75,23 @@
   
   }
   
  -APR_DECLARE(apr_status_t) apr_threadkey_private_get(void **new, apr_threadkey_t *key)
  +APR_DECLARE(apr_status_t) apr_threadkey_private_get(void **new,
  +                                                    apr_threadkey_t *key)
   {
   #ifdef PTHREAD_GETSPECIFIC_TAKES_TWO_ARGS
       if (pthread_getspecific(key->key,new))
          *new = NULL;
  -#else  
  +#else
       (*new) = pthread_getspecific(key->key);
   #endif
       return APR_SUCCESS;
   }
   
  -APR_DECLARE(apr_status_t) apr_threadkey_private_set(void *priv, apr_threadkey_t *key)
  +APR_DECLARE(apr_status_t) apr_threadkey_private_set(void *priv,
  +                                                    apr_threadkey_t *key)
   {
       apr_status_t stat;
  +
       if ((stat = pthread_setspecific(key->key, priv)) == 0) {
           return APR_SUCCESS;
       }
  @@ -100,53 +104,62 @@
   APR_DECLARE(apr_status_t) apr_threadkey_private_delete(apr_threadkey_t *key)
   {
       apr_status_t stat;
  +
       if ((stat = pthread_key_delete(key->key)) == 0) {
  -        return APR_SUCCESS; 
  +        return APR_SUCCESS;
       }
  +
       return stat;
   }
   #endif
   
   APR_DECLARE(apr_status_t) apr_threadkey_data_get(void **data, const char *key,
  -                                 apr_threadkey_t *threadkey)
  +                                                 apr_threadkey_t *threadkey)
   {
       return apr_pool_userdata_get(data, key, threadkey->pool);
   }
   
   APR_DECLARE(apr_status_t) apr_threadkey_data_set(void *data, const char *key,
  -                                         apr_status_t (*cleanup) (void *),
  -                                         apr_threadkey_t *threadkey)
  +                              apr_status_t (*cleanup)(void *),
  +                              apr_threadkey_t *threadkey)
   {
       return apr_pool_userdata_set(data, key, cleanup, threadkey->pool);
   }
   
  -APR_DECLARE(apr_status_t) apr_os_threadkey_get(apr_os_threadkey_t *thekey, apr_threadkey_t
*key)
  +APR_DECLARE(apr_status_t) apr_os_threadkey_get(apr_os_threadkey_t *thekey,
  +                                               apr_threadkey_t *key)
   {
       *thekey = key->key;
       return APR_SUCCESS;
   }
   
  -APR_DECLARE(apr_status_t) apr_os_threadkey_put(apr_threadkey_t **key, 
  -                                     apr_os_threadkey_t *thekey, apr_pool_t *pool)
  +APR_DECLARE(apr_status_t) apr_os_threadkey_put(apr_threadkey_t **key,
  +                                               apr_os_threadkey_t *thekey,
  +                                               apr_pool_t *pool)
   {
       if (pool == NULL) {
           return APR_ENOPOOL;
       }
  +
       if ((*key) == NULL) {
           (*key) = (apr_threadkey_t *)apr_pcalloc(pool, sizeof(apr_threadkey_t));
           (*key)->pool = pool;
       }
  +
       (*key)->key = *thekey;
       return APR_SUCCESS;
  -}           
  +}
   #endif /* APR_HAVE_PTHREAD_H */
   #endif /* APR_HAS_THREADS */
   
   #if !APR_HAS_THREADS
  -APR_DECLARE(apr_status_t) apr_os_threadkey_get(void); /* avoid warning for no prototype
*/
  +
  +/* avoid warning for no prototype */
  +APR_DECLARE(apr_status_t) apr_os_threadkey_get(void);
   
   APR_DECLARE(apr_status_t) apr_os_threadkey_get(void)
   {
       return APR_ENOTIMPL;
   }
  +
   #endif
  
  
  

Mime
View raw message