You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rb...@hyperreal.org on 1999/02/10 22:06:55 UTC

cvs commit: apache-apr/pthreads/src/modules/standard mod_status.c

rbb         99/02/10 13:06:55

  Modified:    pthreads/src/include http_conf_globals.h
               pthreads/src/main http_config.c http_core.c http_main.c
               pthreads/src/modules/standard mod_status.c
  Log:
  Misc fixes.  Among these fixes are code to remove a warning from pthread_attr
  logic, logic to access the scoreboard correctly in increment_counts, better
  logic to count idle processes.  The idle process count still needs to be
  tweaked slightly, but this change keeps us from spawnign processes whenever we
  get requests.  I have also removed all the logic from mod_status.  Because of
  yesterday's scoreboard change, this module won't build, and it needs to be
  totally re-worked to work with the new scoreboard.
  
  Revision  Changes    Path
  1.4       +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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- http_conf_globals.h	1999/02/07 06:29:21	1.3
  +++ http_conf_globals.h	1999/02/10 21:06:51	1.4
  @@ -74,6 +74,7 @@
   extern gid_t group_id_list[NGROUPS_MAX];
   #endif
   extern int ap_threads_per_child;
  +extern int ap_min_idle_threads;
   extern int ap_max_requests_per_child;
   extern int ap_excess_requests_per_child;
   extern struct in_addr ap_bind_address;
  
  
  
  1.6       +1 -0      apache-apr/pthreads/src/main/http_config.c
  
  Index: http_config.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/pthreads/src/main/http_config.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- http_config.c	1999/02/07 06:29:30	1.5
  +++ http_config.c	1999/02/10 21:06:52	1.6
  @@ -1388,6 +1388,7 @@
       ap_lock_fname = DEFAULT_LOCKFILE;
       ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
       ap_threads_per_child = DEFAULT_THREADS_PER_CHILD;
  +    ap_min_idle_threads = (int)(ap_threads_per_child * 0.05);
       /* ZZZ  Initialize the Network Address here. */
       ap_bind_address.s_addr = htonl(INADDR_ANY);
       ap_listeners = NULL;
  
  
  
  1.5       +1 -0      apache-apr/pthreads/src/main/http_core.c
  
  Index: http_core.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/pthreads/src/main/http_core.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- http_core.c	1999/02/09 21:39:55	1.4
  +++ http_core.c	1999/02/10 21:06:52	1.5
  @@ -2203,6 +2203,7 @@
       }
   
       ap_threads_per_child = atoi(arg);
  +    ap_min_idle_threads = (int)(ap_threads_per_child * 0.05);
       if (ap_threads_per_child < 1) {
   	fprintf(stderr, "WARNING: Require ThreadsPerChild > 0, setting to 1\n");
   	ap_threads_per_child = 1;
  
  
  
  1.15      +12 -6     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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- http_main.c	1999/02/10 07:59:39	1.14
  +++ http_main.c	1999/02/10 21:06:53	1.15
  @@ -158,6 +158,7 @@
   #endif
   int ap_threads_per_child;
   int ap_max_requests_per_child;
  +int ap_min_idle_threads;
   int ap_excess_requests_per_child;
   char *ap_pid_fname;
   char *ap_scoreboard_fname;
  @@ -908,12 +909,12 @@
       }
   }
   
  -static void increment_counts(int child_num, request_rec *r)
  +static void increment_counts(int child_num, int thread_num, request_rec *r)
   {
       long int bs = 0;
       thread_score *ss;
   
  -    ss = &ap_scoreboard_image->servers[child_num];
  +    ss = &ap_scoreboard_image->servers[child_num][thread_num];
   
       if (r->sent_bodyct)
   	ap_bgetopt(r->connection->client, BO_BYTECT, &bs);
  @@ -1981,7 +1982,7 @@
   	    ap_process_request(r);
   	fprintf(stderr,"%d child_main: request done\n",my_child_num);
   	if (ap_extended_status)
  -	    increment_counts(my_child_num, r);
  +	    increment_counts(my_child_num, my_thread_num, r);
   	if (!current_conn->keepalive || ap_is_aborted(current_conn))
   	    break;
   	ap_destroy_pool(r->pool);
  @@ -2206,7 +2207,7 @@
       proc_info *my_info = NULL;
       sigset_t sig_mask;
       int ret;
  -    pthread_attr_t thread_attr = PTHREAD_COND_INITIALIZER;
  +    pthread_attr_t thread_attr;
   
       my_pid = getpid();
       requests_this_child = 0;
  @@ -2231,6 +2232,8 @@
   
       queue_init(&csd_queue, ap_threads_per_child);
   
  +    pthread_attr_init(&thread_attr);
  +
       /* We don't want to have to pthread_wait on these threads */
       pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED);
       /* Set signal masks for threads to basically nothing */
  @@ -2302,6 +2305,9 @@
       if ((ret = pthread_sigmask(SIG_SETMASK, &sig_mask, NULL)) != 0) {
           ap_log_error(APLOG_MARK, APLOG_ALERT, server_conf, "pthread_sigmask failed");
       }
  +
  +    pthread_attr_destroy(&thread_attr);
  +
       my_info = NULL;
       
       my_info = (proc_info *)malloc(sizeof(proc_info));
  @@ -2468,7 +2474,7 @@
   		}
   	    }
   	}
  -	if (idle_thread_count == max_threads_limit) {
  +	if (idle_thread_count <= ap_min_idle_threads) {
   	    idle_count++;
   	    to_kill = i;
   	}
  @@ -2481,7 +2487,7 @@
   	 * shut down gracefully, in case it happened to pick up a request
   	 * while we were counting
   	 */
  -        /*kill(ap_scoreboard_image->parent[to_kill].pid, SIGUSR1);*/
  +      /* kill(ap_scoreboard_image->parent[to_kill].pid, SIGUSR1); */
           idle_spawn_rate = 1;
       }
       else if (idle_count < ap_daemons_min_free) {
  
  
  
  1.3       +2 -1      apache-apr/pthreads/src/modules/standard/mod_status.c
  
  Index: mod_status.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/pthreads/src/modules/standard/mod_status.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- mod_status.c	1999/02/07 06:29:55	1.2
  +++ mod_status.c	1999/02/10 21:06:54	1.3
  @@ -227,6 +227,7 @@
   
   static int status_handler(request_rec *r)
   {
  +#if 0
       char *loc;
       time_t nowtime = time(NULL);
       time_t up_time;
  @@ -718,7 +719,7 @@
   	ap_rputs(ap_psignature("<HR>\n",r), r);
   	ap_rputs("</BODY></HTML>\n", r);
       }
  -
  +#endif
       return 0;
   }