rbb 99/02/15 12:39:02
Modified: pthreads/src/include http_conf_globals.h httpd.h scoreboard.h pthreads/src/main http_main.c scoreboard.c Log: Scoreboard updates. We now store the number of workers and acceptors in the scoreboard file. I also added two new states for acceptor threads, ACCEPTING and QUEUEing. Lastly, we are now using reasonable defaults for HARD_SERVER_LIMIT and HARD_THREAD_LIMIT. Revision Changes Path 1.6 +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.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- http_conf_globals.h 1999/02/11 16:33:00 1.5 +++ http_conf_globals.h 1999/02/15 20:38:54 1.6 @@ -74,6 +74,7 @@ extern gid_t group_id_list[NGROUPS_MAX]; #endif extern int ap_threads_per_child; +extern int ap_acceptors_per_child; extern int ap_idle_thread_threshold; extern int ap_busy_thread_threshold; extern int ap_max_requests_per_child; 1.7 +4 -2 apache-apr/pthreads/src/include/httpd.h Index: httpd.h =================================================================== RCS file: /home/cvs/apache-apr/pthreads/src/include/httpd.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- httpd.h 1999/02/11 16:33:00 1.6 +++ httpd.h 1999/02/15 20:38:57 1.7 @@ -307,7 +307,7 @@ * the overhead. */ #ifndef HARD_SERVER_LIMIT -#define HARD_SERVER_LIMIT 256 +#define HARD_SERVER_LIMIT 8 #endif /* Limit on the threads per process. Clients will be locked out if more than @@ -318,7 +318,7 @@ * the overhead. */ #ifndef HARD_THREAD_LIMIT -#define HARD_THREAD_LIMIT 500 +#define HARD_THREAD_LIMIT 64 #endif /* @@ -1039,6 +1039,8 @@ API_EXPORT(int) ap_is_directory(const char *name); API_EXPORT(int) ap_can_exec(const struct stat *); API_EXPORT(void) ap_chdir_file(const char *file); +API_EXPORT(int) ap_get_max_daemons(void); +server_rec * get_server_conf(void); #ifndef HAVE_CANONICAL_FILENAME /* 1.6 +5 -3 apache-apr/pthreads/src/include/scoreboard.h Index: scoreboard.h =================================================================== RCS file: /home/cvs/apache-apr/pthreads/src/include/scoreboard.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- scoreboard.h 1999/02/15 15:45:16 1.5 +++ scoreboard.h 1999/02/15 20:38:57 1.6 @@ -89,7 +89,9 @@ #define SERVER_BUSY_LOG 6 /* Logging the request */ #define SERVER_BUSY_DNS 7 /* Looking up a hostname */ #define SERVER_GRACEFUL 8 /* server is gracefully finishing request */ -#define SERVER_NUM_STATUS 9 /* number of status settings */ +#define SERVER_ACCEPTING 9 /* thread is accepting connections */ +#define SERVER_QUEUEING 10 /* thread is putting connection on the queue */ +#define SERVER_NUM_STATUS 11 /* number of status settings */ /* A "virtual time" is simply a counter that indicates that a child is * making progress. The parent checks up on each child, and when they have @@ -171,8 +173,8 @@ typedef struct { pid_t pid; ap_generation_t generation; /* generation of this child */ - int threads; - int inactive_threads; + int worker_threads; + int acceptor_threads; #ifdef OPTIMIZE_TIMEOUTS time_t last_rtime; /* time(0) of the last change */ vtime_t last_vtime; /* the last vtime the parent has seen */ 1.25 +11 -24 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.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- http_main.c 1999/02/15 18:42:49 1.24 +++ http_main.c 1999/02/15 20:39:01 1.25 @@ -157,6 +157,7 @@ gid_t group_id_list[NGROUPS_MAX]; #endif int ap_threads_per_child; +int ap_acceptors_per_child; int ap_max_requests_per_child; int ap_idle_thread_threshold; int ap_busy_thread_threshold; @@ -186,15 +187,6 @@ static int max_daemons_limit = -1; /* - * The maximum number of threads in each child process. This is ap_threads_ - * per child + # of acceptor threads. Used to optimize routines that must - * scan the entire scoreboard. This is garaunteed not to change, unless the - * server is restarted, at which point, it must be updated to incorporate - * any changes in the threadsperchild or listen directives. - */ -int max_threads_limit; - -/* * During config time, listeners is treated as a NULL-terminated list. * child_main previously would start at the beginning of the list each time * through the loop, so a socket early on in the list could easily starve out @@ -423,13 +415,7 @@ 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++) + for (i = 0; i < ap_threads_per_child + ap_acceptors_per_child; i++) ap_update_child_status(child_num, i, SERVER_DEAD, (request_rec *) NULL); if (pchild) { @@ -1777,11 +1763,13 @@ sock_disable_nagle(sd); */ - (void) ap_update_child_status(my_pid, my_tid, SERVER_READY, - (request_rec *) NULL); while (0 < requests_this_child) { + (void) ap_update_child_status(my_pid, my_tid, SERVER_ACCEPTING, + (request_rec *) NULL); csd = accept(sd, &sa_client, &len); + (void) ap_update_child_status(my_pid, my_tid, SERVER_QUEUEING, + (request_rec *) NULL); if (csd >= 0) { if (queue_push(&csd_queue, csd, &sa_client) != 0) { /* ap_log_error*/ @@ -2072,12 +2060,10 @@ int pid; listen_rec *lr; - max_threads_limit = 0; - for (lr = ap_listeners, max_threads_limit = 0; lr; - lr=lr->next, max_threads_limit++); + for (lr = ap_listeners, ap_acceptors_per_child = 0; lr; + lr=lr->next, ap_acceptors_per_child++); - max_threads_limit += ap_threads_per_child; - if (max_threads_limit > HARD_THREAD_LIMIT) { + if (ap_acceptors_per_child + ap_threads_per_child > HARD_THREAD_LIMIT) { ap_log_error(APLOG_MARK, APLOG_ERR, s, "Worker threads plus acceptor threads is greater than HARD_THREAD_LIMIT, please correct"); exit(-1); @@ -2476,7 +2462,8 @@ */ for (i = 0; i < ap_daemons_limit; ++i) { - for (j = 0; j < max_threads_limit; j++) { + for (j = 0; j < ap_threads_per_child + ap_acceptors_per_child; + j++) { if (ap_scoreboard_image->servers[i][j].status != SERVER_DEAD) { ap_scoreboard_image->servers[i][j].status = SERVER_GRACEFUL; } 1.4 +6 -10 apache-apr/pthreads/src/main/scoreboard.c Index: scoreboard.c =================================================================== RCS file: /home/cvs/apache-apr/pthreads/src/main/scoreboard.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- scoreboard.c 1999/02/15 18:42:50 1.3 +++ scoreboard.c 1999/02/15 20:39:01 1.4 @@ -562,10 +562,6 @@ return -1; } - - - - int ap_update_child_status(int child_num, int thread_num, int status, request_rec *r) { int old_status; @@ -581,12 +577,12 @@ ps = &ap_scoreboard_image->parent[child_num]; - if (status == SERVER_READY && old_status != SERVER_READY) - ps->inactive_threads++; - else if (old_status == SERVER_READY) - ps->inactive_threads--; - else if (old_status == SERVER_STARTING) + if ((status == SERVER_READY || status == SERVER_ACCEPTING) + && old_status == SERVER_STARTING) { ss->tid = pthread_self(); + ps->worker_threads = ap_threads_per_child; + ps->acceptor_threads = ap_acceptors_per_child; + } if (ap_extended_status) { if (status == SERVER_READY || status == SERVER_DEAD) { @@ -618,7 +614,7 @@ ss->vhostrec = r->server; } } - + return old_status; }