cvs commit: apache-apr/pthreads/src/main fdqueue.c http_main.c

1999-03-03 Thread rbb
rbb 99/03/03 08:02:46

  Modified:pthreads/src/main fdqueue.c http_main.c
  Log:
  Performance improvement, so we don't overfill our fdqueue array.  I am just 
moving
  where we update how much blanks space we have in the array, so we don't get 
the
  blank space back until the worker thread has finished serving the request.
  
  Revision  ChangesPath
  1.12  +9 -1  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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- fdqueue.c 1999/02/23 19:11:21 1.11
  +++ fdqueue.c 1999/03/03 16:02:45 1.12
  @@ -60,7 +60,6 @@
   queue-data[queue-head].fd = -1;
   if (fd != -1) {
   queue-head = (queue-head + 1) % queue-bounds;
  -queue-blanks++;
   }
   if (pthread_mutex_unlock(queue-one_big_mutex) != 0) {
   return FD_QUEUE_FAILURE;
  @@ -86,3 +85,12 @@
   }
   }
   
  +int increase_blanks(FDQueue *queue) {
  +if (pthread_mutex_lock(queue-one_big_mutex) != 0) {
  +return FD_QUEUE_FAILURE;
  +}
  +queue-blanks++;
  +if (pthread_mutex_unlock(queue-one_big_mutex) != 0) {
  +return FD_QUEUE_FAILURE;
  +}
  +}
  
  
  
  1.56  +1 -1  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.55
  retrieving revision 1.56
  diff -u -r1.55 -r1.56
  --- http_main.c   1999/02/24 20:30:17 1.55
  +++ http_main.c   1999/03/03 16:02:45 1.56
  @@ -2401,7 +2401,7 @@
   csd = queue_pop(csd_queue, sa_client);
if (csd = 0) {
process_socket(ptrans, sa_client, csd, my_pid, my_tid);
  - /*increase_blanks(csd_queue);*/
  + increase_blanks(csd_queue);
   } 
ap_clear_pool(ptrans);
   }
  
  
  


cvs commit: apache-apr/pthreads/src/main fdqueue.c http_core.c http_main.c

1999-02-23 Thread rbb
rbb 99/02/23 11:11:23

  Modified:pthreads/src/include fdqueue.h http_conf_globals.h
   pthreads/src/main fdqueue.c http_core.c http_main.c
  Log:
  A hopefully final commit for the fdqueue logic.  This removes the bug
  where our queue head and tail where getting out of joint because of
  threads coming out of wait state without being signaled.  This is allowed
  by the pthreads spec, but we have to code so our program doesn't do bad
  things when it happens.
  
  As a part of this patch, we are allowing users to determine how much
  overflow their fdqueue will handle.  Basically, our queue size is
  # of worker threads + user defined overcommit.  If the overcommit is
  less than or equal to # of accept threads, we bump it up to accept threads.
  This is to make sure we always have enough space for any acceptors that
  may get a connection after our queue is supposed to be full.
  
  Revision  ChangesPath
  1.6   +3 -1  apache-apr/pthreads/src/include/fdqueue.h
  
  Index: fdqueue.h
  ===
  RCS file: /home/cvs/apache-apr/pthreads/src/include/fdqueue.h,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- fdqueue.h 1999/02/22 20:05:45 1.5
  +++ fdqueue.h 1999/02/23 19:11:18 1.6
  @@ -29,11 +29,13 @@
   pthread_cond_t not_full;
   } FDQueue;
   
  -int queue_init(FDQueue *queue, size_t bounds, pool *a);
  +int queue_init(FDQueue *queue, int regular, int overflow, pool *a);
   void *queue_destroy(FDQueue *queue);
   int queue_push(FDQueue *queue, int fd, struct sockaddr *addr);
   int queue_pop(FDQueue *queue, struct sockaddr *addr);
   int queue_size(FDQueue *queue);
   int increase_blanks(FDQueue *queue);
  +int queue_full(FDQueue *queue);
  +int block_on_queue(FDQueue *queue);
   
   #endif /* FDQUEUE_H */
  
  
  
  1.7   +1 -0  apache-apr/pthreads/src/include/http_conf_globals.h
  
  Index: http_conf_globals.h
  ===
  RCS file: /home/cvs/apache-apr/pthreads/src/include/http_conf_globals.h,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- http_conf_globals.h   1999/02/15 20:38:54 1.6
  +++ http_conf_globals.h   1999/02/23 19:11:19 1.7
  @@ -75,6 +75,7 @@
   #endif
   extern int ap_threads_per_child;
   extern int ap_acceptors_per_child;
  +extern int ap_overflow;
   extern int ap_idle_thread_threshold;
   extern int ap_busy_thread_threshold;
   extern int ap_max_requests_per_child;
  
  
  
  1.11  +23 -16apache-apr/pthreads/src/main/fdqueue.c
  
  Index: fdqueue.c
  ===
  RCS file: /home/cvs/apache-apr/pthreads/src/main/fdqueue.c,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- fdqueue.c 1999/02/22 20:05:46 1.10
  +++ fdqueue.c 1999/02/23 19:11:21 1.11
  @@ -3,15 +3,16 @@
   /* Assumption: queue itself is allocated by the user */
   /* Assumption: increment and decrement are atomic on int */
   
  -int queue_init(FDQueue *queue, size_t bounds, pool *a) {
  +int queue_init(FDQueue *queue, int regular, int overflow, pool *a) {
   int i;
  +int bounds = regular + overflow + 1;
   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;
  -queue-blanks = bounds - 1;
  +queue-blanks = regular;
   ap_register_cleanup(a, queue, (void (*)(void *))queue_destroy, 
ap_null_cleanup);
   for (i=0; i  bounds; ++i)
   queue-data[i].fd = -1;
  @@ -34,7 +35,7 @@
   queue-tail = (queue-tail + 1) % queue-bounds;
   queue-blanks--;
   pthread_cond_signal(queue-not_empty);
  -if (queue-blanks == 0) {
  +if (queue-head == (queue-tail + 1) % queue-bounds) {
   pthread_cond_wait(queue-not_full, queue-one_big_mutex);
   }
   if (pthread_mutex_unlock(queue-one_big_mutex) != 0) {
  @@ -47,35 +48,41 @@
   if (pthread_mutex_lock(queue-one_big_mutex) != 0) {
   return FD_QUEUE_FAILURE;
   }
  -if (queue-blanks = queue-bounds - 1) {
  +if (queue-blanks  0) {
  +pthread_cond_signal(queue-not_full);
  +}
  +if (queue-head == queue-tail) {
   pthread_cond_wait(queue-not_empty, queue-one_big_mutex);
   } 
   
   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 */
  -queue-head = (queue-head + 1) % queue-bounds;
  +if (fd != -1) {
  +queue-head = (queue-head + 1) % queue-bounds;
  +queue-blanks++;
  +

cvs commit: apache-apr/pthreads/src/main fdqueue.c

1999-02-21 Thread rbb
rbb 99/02/20 19:20:05

  Modified:pthreads/src/main fdqueue.c
  Log:
  We actually want to signal a thread everytime we add something to the
  fdqueue, not just when the queue was empty before we added it.  This
  was resulting in a bug where only one thread was ever actually working on a
  request, and when that request was done, it would get the next request and
  serve it.  Not the most efficient algorithm.  This should fix it.  I tested
  it as best as possible, but Monday I'll test it better.
  
  Revision  ChangesPath
  1.8   +1 -5  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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- fdqueue.c 1999/02/19 20:33:22 1.7
  +++ fdqueue.c 1999/02/21 03:20:05 1.8
  @@ -31,13 +31,9 @@
   }
   queue-data[queue-tail].fd = fd;
   queue-data[queue-tail].addr = *addr;
  -/* If the queue was empty, signal that it no longer is.  We use
  -   bounds-1 because of annoying allocation logic. */
  -if (queue-blanks = queue-bounds - 1) {
  -pthread_cond_signal(queue-not_empty);
  -}
   queue-tail = (queue-tail + 1) % queue-bounds;
   queue-blanks--;
  +pthread_cond_signal(queue-not_empty);
   if (queue-blanks == 0) {
   pthread_cond_wait(queue-not_full, queue-one_big_mutex);
   }
  
  
  


cvs commit: apache-apr/pthreads/src/main fdqueue.c http_main.c

1999-02-19 Thread rbb
rbb 99/02/19 12:33:25

  Modified:pthreads/src/include fdqueue.h
   pthreads/src/main fdqueue.c http_main.c
  Log:
  Fixes annoying fdqueue logic bug.  It used to be that if long lived 
connections
  used up all of your threads, any new connections to the same process would
  starve, because the worker threads were all busy.  Now, any process waits as
  soon as all of it's worker threads are not idle.  This keeps us from accepting
  quite as many connections, but now the ones we do accept will be served in a
  reasonable amount of time, no matter how long lived the previous requests 
were.
  
  Revision  ChangesPath
  1.3   +2 -0  apache-apr/pthreads/src/include/fdqueue.h
  
  Index: fdqueue.h
  ===
  RCS file: /home/cvs/apache-apr/pthreads/src/include/fdqueue.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- fdqueue.h 1999/02/12 18:30:19 1.2
  +++ fdqueue.h 1999/02/19 20:33:21 1.3
  @@ -23,6 +23,7 @@
   int tail;
   FDQueueElement *data;
   int bounds;
  +int blanks;
   pthread_mutex_t one_big_mutex;
   pthread_cond_t not_empty;
   pthread_cond_t not_full;
  @@ -33,5 +34,6 @@
   int queue_push(FDQueue *queue, int fd, struct sockaddr *addr);
   int queue_pop(FDQueue *queue, struct sockaddr *addr);
   int queue_size(FDQueue *queue);
  +int increase_blanks(FDQueue *queue);
   
   #endif /* FDQUEUE_H */
  
  
  
  1.7   +23 -10apache-apr/pthreads/src/main/fdqueue.c
  
  Index: fdqueue.c
  ===
  RCS file: /home/cvs/apache-apr/pthreads/src/main/fdqueue.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- fdqueue.c 1999/02/15 21:58:58 1.6
  +++ fdqueue.c 1999/02/19 20:33:22 1.7
  @@ -11,6 +11,7 @@
   queue-head = queue-tail = 0;
   queue-data = ap_palloc(a, (++bounds) * sizeof(FDQueueElement));
   queue-bounds = bounds;
  +queue-blanks = bounds - 1;
   ap_register_cleanup(a, queue, (void (*)(void *))queue_destroy, 
ap_null_cleanup);
   for (i=0; i  bounds; ++i)
   queue-data[i].fd = -1;
  @@ -28,20 +29,21 @@
   if (pthread_mutex_lock(queue-one_big_mutex) != 0) {
   return FD_QUEUE_FAILURE;
   }
  -while (queue-head == ((queue-tail + 1) % queue-bounds)) {
  -pthread_cond_wait(queue-not_full, queue-one_big_mutex);
  -}
   queue-data[queue-tail].fd = fd;
   queue-data[queue-tail].addr = *addr;
  -/* If the queue was empty, signal that it no longer is */
  -if (queue-head == queue-tail) {
  +/* If the queue was empty, signal that it no longer is.  We use
  +   bounds-1 because of annoying allocation logic. */
  +if (queue-blanks = queue-bounds - 1) {
   pthread_cond_signal(queue-not_empty);
   }
   queue-tail = (queue-tail + 1) % queue-bounds;
  +queue-blanks--;
  +if (queue-blanks == 0) {
  +pthread_cond_wait(queue-not_full, queue-one_big_mutex);
  +}
   if (pthread_mutex_unlock(queue-one_big_mutex) != 0) {
   return FD_QUEUE_FAILURE;
   }
  -return FD_QUEUE_SUCCESS;
   }
   
   int queue_pop(FDQueue *queue, struct sockaddr *addr) {
  @@ -49,7 +51,7 @@
   if (pthread_mutex_lock(queue-one_big_mutex) != 0) {
   return FD_QUEUE_FAILURE;
   }
  -if (queue-head == queue-tail) {
  +if (queue-blanks = queue-bounds - 1) {
   pthread_cond_wait(queue-not_empty, queue-one_big_mutex);
   } 
   
  @@ -57,14 +59,25 @@
   *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);
  -}
   queue-head = (queue-head + 1) % queue-bounds;
   if (pthread_mutex_unlock(queue-one_big_mutex) != 0) {
   return FD_QUEUE_FAILURE;
   }
   return fd;
  +}
  +
  +int increase_blanks(FDQueue *queue) {
  +if (pthread_mutex_lock(queue-one_big_mutex) != 0) {
  +return FD_QUEUE_FAILURE;
  +}
  +if (queue-blanks == 0) {
  +pthread_cond_signal(queue-not_full);
  +}
  +queue-blanks++;
  +if (pthread_mutex_unlock(queue-one_big_mutex) != 0) {
  +return FD_QUEUE_FAILURE;
  +}
  +return FD_QUEUE_SUCCESS;
   }
   
   int queue_size(FDQueue *queue) {
  
  
  
  1.49  +2 -1  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.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- http_main.c   1999/02/18 18:40:54 1.48
  +++ http_main.c   1999/02/19 20:33:23 1.49
  @@ -2309,7 +2309,8 @@
   csd = queue_pop(csd_queue, 

cvs commit: apache-apr/pthreads/src/main fdqueue.c http_main.c

1999-02-12 Thread rbb
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  ChangesPath
  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 -34apache-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, 

cvs commit: apache-apr/pthreads/src/main fdqueue.c http_main.c

1999-02-11 Thread rbb
rbb 99/02/11 14:15:56

  Modified:pthreads/src/main fdqueue.c http_main.c
  Log:
  Another pass at logic for signal handling.  SIGTERM works properly.  SIGHUP
  causes a zombie, and makes the socket unusable.  Graceful restarts are not
  close to working, because of signals issues with user based pthreads.  They
  are on the plate for tomorrow.
  
  Manoj and I worked on this together, both design and implementation.
  
  Revision  ChangesPath
  1.3   +2 -3  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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- fdqueue.c 1999/02/09 22:04:14 1.2
  +++ fdqueue.c 1999/02/11 22:15:55 1.3
  @@ -49,9 +49,8 @@
   if (pthread_mutex_lock(queue-one_big_mutex) != 0) {
   return FD_QUEUE_FAILURE;
   }
  -while (queue-head == queue-tail) {
  -pthread_cond_wait(queue-not_empty, queue-one_big_mutex);
  -}
  +pthread_cond_wait(queue-not_empty, queue-one_big_mutex);
  +
   fd = queue-data[queue-head].fd;
   *addr = queue-data[queue-head].addr;
   /* If the queue was full, signal that it no longer is */
  
  
  
  1.17  +100 -61   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.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- http_main.c   1999/02/11 16:33:04 1.16
  +++ http_main.c   1999/02/11 22:15:55 1.17
  @@ -175,7 +175,9 @@
   int ap_listenbacklog;
   int ap_dump_settings = 0;
   API_VAR_EXPORT int ap_extended_status = 0;
  +pthread_once_t firstcall = PTHREAD_ONCE_INIT;
   
  +
   /*
* The max child slot ever assigned, preserved across restarts.  Necessary
* to deal with MaxClients changes across SIGUSR1 restarts.  We use this
  @@ -480,15 +482,58 @@
   }
   }
   
  +void graceful_killer(void)
  +{
  +listen_rec *lr;
  +int i;
  +
  +for (i = 0; i  ap_threads_per_child; i++) {
  +pthread_cond_signal((csd_queue.not_empty));
  +}
  +/* Setup acceptor threads */
  +
  +lr = ap_listeners;
  +while (lr-next != NULL) {
  +close(lr-fd);
  + lr= lr-next;
  +}
  +fprintf(stderr, gonna exit doit);
  +pthread_exit(NULL);
  +}
  +
  +static int find_child_by_pid(pid_t pid) /* ZZZ */
  +{
  +int i;
  +
  +for (i = 0; i  max_daemons_limit; ++i)
  + if (ap_scoreboard_image-parent[i].pid == pid)
  + return i;
  +
  +return -1;
  +}
  +
   /* a clean exit from a child with proper cleanup 
  static void clean_child_exit(int code) __attribute__ ((noreturn)); */
   static void clean_child_exit(int code)
   {
  +int child_num = find_child_by_pid(getpid());
  +int i;
  +listen_rec *lr;
  +
  +/*  lr = ap_listeners;
  +while (lr-next != NULL) {
  +close(lr-fd);
  + lr= lr-next;
  + }*/
  +
  +for (i = 0; i  max_threads_limit; i++)
  +ap_update_child_status(child_num, i, SERVER_DEAD, (request_rec *) 
NULL);
  +
   if (pchild) {
ap_child_exit_modules(pchild, server_conf);
ap_destroy_pool(pchild);
   }
  -/*longjump(tls()-thread_exit, 1); */
  +
   exit(code);
   }
   
  @@ -834,8 +879,6 @@
   if (child_num  0)
return -1;
   
  -fprintf(stderr, Updating status for %d %d to %d\n, child_num, 
thread_num, status);
  -
   ss = ap_scoreboard_image-servers[child_num][thread_num];
   old_status = ss-status;
   ss-status = status;
  @@ -932,17 +975,6 @@
   
   }
   
  -static int find_child_by_pid(pid_t pid) /* ZZZ */
  -{
  -int i;
  -
  -for (i = 0; i  max_daemons_limit; ++i)
  - if (ap_scoreboard_image-parent[i].pid == pid)
  - return i;
  -
  -return -1;
  -}
  -
   static void reclaim_child_processes(int terminate)
   {
   int i, status;
  @@ -985,18 +1017,9 @@
case 2: /*  82ms */
break;
case 3: /* 344ms */
  - /* perhaps it missed the SIGHUP, lets try again */
  - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING,
  - server_conf,
  - child process %d did not exit, sending another SIGHUP,
  - pid);
  - kill(pid, SIGHUP);
  - waittime = 1024 * 16;
  - break;
case 4: /*  16ms */
case 5: /*  82ms */
case 6: /* 344ms */
  - break;
case 7: /* 1.4sec */
/* ok, now it's being annoying */
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING,
  @@ -1266,15 +1289,12 @@
   static int volatile usr1_just_die = 1;
   static int volatile 

cvs commit: apache-apr/pthreads/src/main fdqueue.c

1999-02-09 Thread manoj
manoj   99/02/09 14:04:16

  Modified:pthreads/src/main fdqueue.c
  Log:
  Optimization: don't pthread_cond_signal every time something is added to
  the queue, but only when there is a state change (empty - not empty, full
  - not full).
  
  Revision  ChangesPath
  1.2   +8 -3  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.1
  retrieving revision 1.2
  diff -u -u -r1.1 -r1.2
  --- fdqueue.c 1999/02/03 17:50:09 1.1
  +++ fdqueue.c 1999/02/09 22:04:14 1.2
  @@ -33,12 +33,14 @@
   }
   queue-data[queue-tail].fd = fd;
   queue-data[queue-tail].addr = *addr;
  +/* If the queue was empty, signal that it no longer is */
  +if (queue-head == queue-tail) {
  +pthread_cond_signal(queue-not_empty);
  +}
   queue-tail = (queue-tail + 1) % queue-bounds;
   if (pthread_mutex_unlock(queue-one_big_mutex) != 0) {
   return FD_QUEUE_FAILURE;
   }
  -if (pthread_cond_signal(queue-not_empty) != 0)
  -perror(signal didn't work :();
   return FD_QUEUE_SUCCESS;
   }
   
  @@ -52,11 +54,14 @@
   }
   fd = queue-data[queue-head].fd;
   *addr = queue-data[queue-head].addr;
  +/* 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);
  +}
   queue-head = (queue-head + 1) % queue-bounds;
   if (pthread_mutex_unlock(queue-one_big_mutex) != 0) {
   return FD_QUEUE_FAILURE;
   }
  -pthread_cond_signal(queue-not_full);
   return fd;
   }