httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@hyperreal.org
Subject cvs commit: apache-apr/pthreads/src/main fdqueue.c http_main.c
Date Fri, 12 Feb 1999 20:37:00 GMT
rbb         99/02/12 12:37:00

  Modified:    pthreads/src/main fdqueue.c http_main.c
  Log:
  Bug fixes for graceful restart.  Now, we return -1 for empty queue.  This was
  needed for the graceful restart which is also included in this patch.  Most
  of the changes from the last two patches were removing debugging code, and
  bounds checking.  Also changed to using SIGWINCH instead of SIGUSR1, because
  of annoying Linux 2.0 threads.  Removed sleep during graceful restart, to
  remove zombie processes.
  Submitted by: Ryan Bloom and Manoj Kasichainula
  
  Revision  Changes    Path
  1.5       +5 -2      apache-apr/pthreads/src/main/fdqueue.c
  
  Index: fdqueue.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/pthreads/src/main/fdqueue.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- fdqueue.c	1999/02/12 18:30:22	1.4
  +++ fdqueue.c	1999/02/12 20:36:59	1.5
  @@ -4,18 +4,20 @@
   /* Assumption: increment and decrement are atomic on int */
   
   int queue_init(FDQueue *queue, size_t bounds, pool *a) {
  +    int i;
       pthread_mutex_init(&queue->one_big_mutex, NULL);
       pthread_cond_init(&queue->not_empty, NULL);
       pthread_cond_init(&queue->not_full, NULL);
       queue->head = queue->tail = 0;
  -    queue->data = ap_palloc(a, bounds * sizeof(FDQueueElement));
  +    queue->data = ap_palloc(a, (++bounds) * sizeof(FDQueueElement));
       queue->bounds = bounds;
       ap_register_cleanup(a, queue, (void (*)(void *))queue_destroy, ap_null_cleanup);
  +    for (i=0; i < bounds; ++i)
  +        queue->data[i].fd = -1;
       return FD_QUEUE_SUCCESS;
   }
   
   void *queue_destroy(FDQueue *queue) {
  -    free(queue->data);
       /* Ignore errors here, we can't do anything about them anyway */
       pthread_cond_destroy(&queue->not_empty);
       pthread_cond_destroy(&queue->not_full);
  @@ -51,6 +53,7 @@
       
       fd = queue->data[queue->head].fd;
       *addr = queue->data[queue->head].addr;
  +    queue->data[queue->head].fd = -1;
       /* If the queue was full, signal that it no longer is */
       if (queue->head == ((queue->tail + 1) % queue->bounds)) {
           pthread_cond_signal(&queue->not_full);
  
  
  
  1.19      +11 -34    apache-apr/pthreads/src/main/http_main.c
  
  Index: http_main.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/pthreads/src/main/http_main.c,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- http_main.c	1999/02/12 18:30:22	1.18
  +++ http_main.c	1999/02/12 20:36:59	1.19
  @@ -497,7 +497,6 @@
           close(lr->fd);
   	lr= lr->next;
       }
  -    pthread_exit(NULL);
   }
   
   static int find_child_by_pid(pid_t pid) /* ZZZ */
  @@ -1354,7 +1353,7 @@
   static void restart(int sig)
   {
   #ifndef WIN32
  -    ap_start_restart(sig == SIGUSR1);
  +    ap_start_restart(sig == SIGWINCH);
   #else
       ap_start_restart(1);
   #endif
  @@ -1413,18 +1412,14 @@
   	ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGXFSZ)");
   #endif
   
  -    /* we want to ignore HUPs and USR1 while we're busy processing one */
  +    /* we want to ignore HUPs and WINCH while we're busy processing one */
       sigaddset(&sa.sa_mask, SIGHUP);
  -#ifndef LINUX
  -    sigaddset(&sa.sa_mask, SIGUSR1);
  -#endif
  +    sigaddset(&sa.sa_mask, SIGWINCH);
       sa.sa_handler = restart;
       if (sigaction(SIGHUP, &sa, NULL) < 0)
   	ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGHUP)");
  -#ifndef LINUX    
  -    if (sigaction(SIGUSR1, &sa, NULL) < 0)
  -	ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGUSR1)");
  -#endif
  +    if (sigaction(SIGWINCH, &sa, NULL) < 0)
  +	ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGWINCH)");
   #else
       if (!one_process) {
   	signal(SIGSEGV, sig_coredump);
  @@ -1452,12 +1447,10 @@
   #ifdef SIGHUP
       signal(SIGHUP, restart);
   #endif /* SIGHUP */
  -#ifndef LINUX
   #ifdef SIGUSR1
  -    signal(SIGUSR1, restart);
  +    signal(SIGWINCH, restart);
   #endif /* SIGUSR1 */
   #endif
  -#endif
   }
   
   /*****************************************************************
  @@ -2064,15 +2057,11 @@
   	      /*	        ap_log_error*/
   	    }  
   	 } else{
  -	   perror("ARGH\n");
  -	   exit(0);
  -
   	   /*	    ap_log_error()*/
   	 }
       }
       ap_update_child_status(my_pid, my_tid, SERVER_DEAD, (request_rec *) NULL);
       pthread_once(&firstcall, graceful_killer);
  -
       pthread_exit(NULL);
   }
   
  @@ -2263,17 +2252,6 @@
   
       /* We don't want to have to pthread_wait on these threads */
       pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED);
  -#if 0
  -    /* Set signal masks for threads to basically nothing */
  -    sigemptyset(&sig_mask);
  -#ifdef LINUX
  -    sigaddset(&sig_mask, SIGUSR1);
  -    sigaddset(&sig_mask, SIGUSR2);
  -#endif
  -    if ((ret = pthread_sigmask(SIG_SETMASK, &sig_mask, NULL)) != 0) {
  -        ap_log_error(APLOG_MARK, APLOG_ALERT, server_conf, "pthread_sigmask failed");
  -    }
  -#endif
   
       /* Setup worker threads */
       for (i=0; i < ap_threads_per_child; i++) {
  @@ -2416,7 +2394,7 @@
           RAISE_SIGSTOP(MAKE_CHILD);
           MONCONTROL(1);
   
  -        signal(SIGHUP, graceful_sig_handler);
  +        signal(SIGWINCH, graceful_sig_handler);
           signal(SIGTERM, just_die);
   	child_main(slot);
   
  @@ -2521,7 +2499,7 @@
       }
       max_daemons_limit = last_non_dead + 1;
       if (idle_count > ap_daemons_max_free) {
  -        /* kill off one child... we use SIGUSR1 because that'll cause it to
  +        /* kill off one child... we use SIGHUP because that'll cause it to
   	 * shut down gracefully, in case it happened to pick up a request
   	 * while we were counting
   	 */
  @@ -2587,7 +2565,6 @@
       head_listener = ap_listeners;
   
       while (!restart_pending && !shutdown_pending) {
  -      sleep(10); /* ZZZZ how long? 10000 intervals */
           pid = wait_or_timeout(&status);
           
           if (pid >= 0) {
  @@ -2674,7 +2651,7 @@
   
       /* If we're doing a graceful_restart then we're going to see a lot
        * of children exiting immediately when we get into the main loop
  -     * below (because we just sent them SIGUSR1).  This happens pretty
  +     * below (because we just sent them SIGWINCH).  This happens pretty
        * rapidly... and for each one that exits we'll start a new one until
        * we reach at least daemons_min_free.  But we may be permitted to
        * start more than that, so we'll just keep track of how many we're
  @@ -2754,10 +2731,10 @@
   	int i, j;
   
   	ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, server_conf,
  -		    "SIGUSR1 received.  Doing graceful restart");
  +		    "SIGWINCH received.  Doing graceful restart");
   
   	/* kill off the idle ones */
  -	if (ap_killpg(pgrp, SIGHUP) < 0) {
  +	if (ap_killpg(pgrp, SIGWINCH) < 0) {
   	    ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "killpg SIGHUP");
   	}
   
  
  
  

Mime
View raw message