rbb         01/04/12 11:46:33

  Modified:    server/mpm/perchild perchild.c
               server/mpm/threaded threaded.c
               include  apr_thread_proc.h
               threadproc/unix signals.c
  Log:
  Convert the apr_create_signal_thread to apr_signal_thread.  The main
  difference, is that instead of creating a separate thread to listen for
  signals, the thread that calls this function does the listening.  Many
  platforms have issues when the main thread isn't the thread that is
  listening for signals.  Even more platforms complain when the main thread
  dies, but the process doesn't.  This gets the main thread back to being
  the signal handling thread.
  
  Revision  Changes    Path
  1.60      +1 -4      httpd-2.0/server/mpm/perchild/perchild.c
  
  Index: perchild.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/perchild/perchild.c,v
  retrieving revision 1.59
  retrieving revision 1.60
  diff -u -d -b -w -u -r1.59 -r1.60
  --- perchild.c        2001/04/11 02:01:14     1.59
  +++ perchild.c        2001/04/12 18:46:31     1.60
  @@ -918,7 +918,6 @@
   
       apr_threadattr_create(&worker_thread_attr, pchild);
       apr_threadattr_detach_set(worker_thread_attr, 1);                        
             
  -    apr_create_signal_thread(&thread, worker_thread_attr, check_signal, 
pchild);
   
       /* We are creating worker threads right now */
       for (i=0; i < threads_to_start; i++) {
  @@ -928,9 +927,7 @@
           }
       }
   
  -    /* This thread will be be a worker thread too. */
  -    worker_thread(&worker_thread_free_ids[max_threads - 1]);
  -
  +    apr_signal_thread_func(check_signal);
   }
   
   static int make_child(server_rec *s, int slot)
  
  
  
  1.21      +2 -22     httpd-2.0/server/mpm/threaded/threaded.c
  
  Index: threaded.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/threaded/threaded.c,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -d -b -w -u -r1.20 -r1.21
  --- threaded.c        2001/04/11 02:01:16     1.20
  +++ threaded.c        2001/04/12 18:46:32     1.21
  @@ -650,7 +650,6 @@
        listensocks[i]=lr->sd;
   
       /* Setup worker threads */
  -
       worker_thread_count = 0;
       apr_lock_create(&worker_thread_count_mutex, APR_MUTEX, APR_INTRAPROCESS,
                       NULL, pchild);
  @@ -658,15 +657,8 @@
                       NULL, pchild);
       apr_threadattr_create(&thread_attr, pchild);
       apr_threadattr_detach_set(thread_attr, 1);
  -
  -    rv = apr_create_signal_thread(&thread, thread_attr, check_signal, 
pchild);
  -    if (rv != APR_SUCCESS) {
  -        ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf,
  -                     "Couldn't create signal thread");
  -        clean_child_exit(APEXIT_CHILDFATAL);
  -    }
   
  -    for (i=0; i < ap_threads_per_child - 1; i++) {
  +    for (i=0; i < ap_threads_per_child; i++) {
   
        my_info = (proc_info *)malloc(sizeof(proc_info));
           if (my_info == NULL) {
  @@ -694,20 +686,8 @@
        /* We let each thread update it's own scoreboard entry.  This is done
         * because it let's us deal with tid better.
         */
  -    }
  -    my_info = (proc_info *)malloc(sizeof(proc_info));
  -    if (my_info == NULL) {
  -        ap_log_error(APLOG_MARK, APLOG_ALERT, errno, ap_server_conf,
  -                    "malloc: out of memory");
  -        clean_child_exit(APEXIT_CHILDFATAL);
       }
  -    my_info->pid = my_child_num;
  -    my_info->tid = i;
  -    my_info->sd = 0;
  -    apr_pool_create(&my_info->tpool, pchild);
  -    ap_update_child_status(my_child_num, i, SERVER_STARTING, 
  -                           (request_rec *) NULL);
  -    worker_thread(my_info);
  +    apr_signal_thread(check_signal);
   }
   
   static int make_child(server_rec *s, int slot) 
  
  
  
  1.62      +3 -9      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.61
  retrieving revision 1.62
  diff -u -d -b -w -u -r1.61 -r1.62
  --- apr_thread_proc.h 2001/04/11 02:01:17     1.61
  +++ apr_thread_proc.h 2001/04/12 18:46:32     1.62
  @@ -598,19 +598,13 @@
   APR_DECLARE(apr_status_t) apr_setup_signal_thread(void);
   
   /**
  - * Create a thread that will listen for signals.  The thread will loop
  + * Make the current thread listen for signals.  This thread will loop
    * forever, calling a provided function whenever it receives a signal.  That
    * functions should return 1 if the signal has been handled, 0 otherwise.
  - * @param td The newly created thread
  - * @param tattr The threadattr to use when creating the thread
    * @param signal_handler The function to call when a signal is received
  - * @param p The pool to use when creating the thread
  - * @deffunc apr_status_t apr_create_signal_thread(apr_thread_t **td, 
apr_threadattr_t *tattr, int (*signal_handler)(int signum), apr_pool_t *p)
  + * apr_status_t apr_signal_thread((int)(*signal_handler)(int signum))
    */
  -APR_DECLARE(apr_status_t) apr_create_signal_thread(apr_thread_t **td,
  -                                                   apr_threadattr_t *tattr,
  -                                              int (*signal_handler)(int 
signum),
  -                                                   apr_pool_t *p);
  +APR_DECLARE(apr_status_t) apr_signal_thread(int(*signal_handler)(int 
signum));
   #endif /* APR_HAS_THREADS */
   
   #ifdef __cplusplus
  
  
  
  1.33      +2 -10     apr/threadproc/unix/signals.c
  
  Index: signals.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/unix/signals.c,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -d -b -w -u -r1.32 -r1.33
  --- signals.c 2001/04/12 16:54:50     1.32
  +++ signals.c 2001/04/12 18:46:32     1.33
  @@ -268,7 +268,7 @@
   #endif /* SYS_SIGLIST_DECLARED */
   
   #if APR_HAS_THREADS && (HAVE_SIGSUSPEND || APR_HAVE_SIGWAIT) && !defined(OS2)
  -static void *signal_thread_func(void *signal_handler)
  +APR_DECLARE(apr_status_t) apr_signal_thread(int(*signal_handler)(int signum))
   {
       sigset_t sig_mask;
       int (*sig_func)(int signum) = (int (*)(int))signal_handler;
  @@ -312,7 +312,7 @@
           }
           
           if (sig_func(signal_received) == 1) {
  -            return NULL;
  +            return APR_SUCCESS;
           }
   #elif HAVE_SIGSUSPEND
        sigsuspend(&sig_mask);
  @@ -340,14 +340,6 @@
       }
   #endif
       return rv;
  -}
  -
  -APR_DECLARE(apr_status_t) apr_create_signal_thread(apr_thread_t **td, 
  -                                                   apr_threadattr_t *tattr,
  -                                              int (*signal_handler)(int 
signum),
  -                                                   apr_pool_t *p)
  -{
  -    return apr_thread_create(td, tattr, signal_thread_func, (void 
*)signal_handler, p);
   }
   
   #endif
  
  
  

Reply via email to