cvs commit: apache-2.0/mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c
rse 99/08/15 04:02:45 Modified:mpm/src/modules/mpm/dexter dexter.c mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c Log: Unbreak dexter and pthread MPM after Ben's latest hook changes. Revision ChangesPath 1.26 +0 -3 apache-2.0/mpm/src/modules/mpm/dexter/dexter.c Index: dexter.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/dexter/dexter.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- dexter.c 1999/08/13 22:30:57 1.25 +++ dexter.c 1999/08/15 11:02:43 1.26 @@ -1621,15 +1621,12 @@ module MODULE_VAR_EXPORT mpm_dexter_module = { STANDARD20_MODULE_STUFF, -NULL,/* child_init */ NULL,/* create per-directory config structure */ NULL,/* merge per-directory config structures */ NULL,/* create per-server config structure */ NULL,/* merge per-server config structures */ dexter_cmds, /* command table */ NULL,/* handlers */ -NULL,/* check auth */ -NULL,/* check access */ dexter_hooks /* register_hooks */ }; 1.28 +0 -3 apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c Index: mpmt_pthread.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- mpmt_pthread.c1999/08/13 21:50:55 1.27 +++ mpmt_pthread.c1999/08/15 11:02:44 1.28 @@ -1689,15 +1689,12 @@ module MODULE_VAR_EXPORT mpm_mpmt_pthread_module = { STANDARD20_MODULE_STUFF, -NULL,/* child_init */ NULL,/* create per-directory config structure */ NULL,/* merge per-directory config structures */ NULL,/* create per-server config structure */ NULL,/* merge per-server config structures */ mpmt_pthread_cmds, /* command table */ NULL,/* handlers */ -NULL,/* check auth */ -NULL,/* check access */ mpmt_pthread_hooks /* register_hooks */ };
cvs commit: apache-2.0/mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c
manoj 99/08/11 16:55:44 Modified:mpm/src/modules/mpm/dexter dexter.c mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c Log: Move a little code around to shorten the worker_thread function a bit. Revision ChangesPath 1.20 +23 -20apache-2.0/mpm/src/modules/mpm/dexter/dexter.c Index: dexter.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/dexter/dexter.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -u -r1.19 -r1.20 --- dexter.c 1999/08/10 21:18:37 1.19 +++ dexter.c 1999/08/11 23:55:38 1.20 @@ -930,6 +930,27 @@ return 1; } +/* Sets workers_may_exit if we received a character on the pipe_of_death */ +static void check_pipe_of_death(void) +{ +pthread_mutex_lock(&pipe_of_death_mutex); +if (!workers_may_exit) { +int ret; +char pipe_read_char; + +ret = read(listenfds[0].fd, &pipe_read_char, 1); +if (ret == -1 && errno == EAGAIN) { +/* It lost the lottery. It must continue to suffer + * through a life of servitude. */ +} +else { +/* It won the lottery (or something else is very + * wrong). Embrace death with open arms. */ +workers_may_exit = 1; +} +} +pthread_mutex_unlock(&pipe_of_death_mutex); +} /* idle_thread_count should be incremented before starting a worker_thread */ @@ -941,8 +962,6 @@ pool *ptrans;/* Pool for per-transaction stuff */ int sd = -1; int srv; -int ret; -char pipe_read_char; int curr_pollfd, last_pollfd = 0; size_t len = sizeof(struct sockaddr); worker_thread_info *thread_info = arg; @@ -997,24 +1016,8 @@ if (listenfds[0].revents & POLLIN) { /* A process got a signal on the shutdown pipe. Check if we're * the lucky process to die. */ -pthread_mutex_lock(&pipe_of_death_mutex); -if (!workers_may_exit) { -ret = read(listenfds[0].fd, &pipe_read_char, 1); -if (ret == -1 && errno == EAGAIN) { -/* It lost the lottery. It must continue to suffer - * through a life of servitude. */ -pthread_mutex_unlock(&pipe_of_death_mutex); -continue; -} -else { -/* It won the lottery (or something else is very - * wrong). Embrace death with open arms. */ -workers_may_exit = 1; -pthread_mutex_unlock(&pipe_of_death_mutex); -break; -} -} -pthread_mutex_unlock(&pipe_of_death_mutex); +check_pipe_of_death(); +continue; } if (num_listenfds == 1) { 1.25 +23 -20 apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c Index: mpmt_pthread.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -u -r1.24 -r1.25 --- mpmt_pthread.c1999/08/10 21:18:43 1.24 +++ mpmt_pthread.c1999/08/11 23:55:42 1.25 @@ -900,6 +900,27 @@ ap_process_connection(current_conn); } +/* Sets workers_may_exit if we received a character on the pipe_of_death */ +static void check_pipe_of_death(void) +{ +pthread_mutex_lock(&pipe_of_death_mutex); +if (!workers_may_exit) { +int ret; +char pipe_read_char; + +ret = read(listenfds[0].fd, &pipe_read_char, 1); +if (ret == -1 && errno == EAGAIN) { +/* It lost the lottery. It must continue to suffer + * through a life of servitude. */ +} +else { +/* It won the lottery (or something else is very + * wrong). Embrace death with open arms. */ +workers_may_exit = 1; +} +} +pthread_mutex_unlock(&pipe_of_death_mutex); +} static void * worker_thread(void * dummy) { @@ -912,8 +933,6 @@ pool *ptrans;/* Pool for per-transaction stuff */ int sd = -1; int srv; -int ret; -char pipe_read_char; int curr_pollfd, last_pollfd = 0; size_t len = sizeof(struct sockaddr); @@ -958,24 +977,8 @@ if (listenfds[0].revents & POLLIN) { /* A process got a signal on the shutdown pipe. Check if we're * the lucky process to die. */ -pthread_mutex_
cvs commit: apache-2.0/mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c
manoj 99/08/10 14:18:46 Modified:mpm/src/modules/mpm/dexter dexter.c mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c Log: Put back the process_child_status code from 1.3. Handling of synchronous signals like SEGV and FPE is still a bit dodgy, though, so this won't accomplish much by itself. Revision ChangesPath 1.19 +53 -0 apache-2.0/mpm/src/modules/mpm/dexter/dexter.c Index: dexter.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/dexter/dexter.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -u -r1.18 -r1.19 --- dexter.c 1999/08/05 19:56:15 1.18 +++ dexter.c 1999/08/10 21:18:37 1.19 @@ -744,6 +744,57 @@ #endif } + +static void process_child_status(int pid, ap_wait_t status) +{ +/* Child died... if it died due to a fatal error, + * we should simply bail out. + */ +if ((WIFEXITED(status)) && + WEXITSTATUS(status) == APEXIT_CHILDFATAL) { + ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, server_conf, + "Child %d returned a Fatal error... \n" + "Apache is exiting!", + pid); + exit(APEXIT_CHILDFATAL); +} +if (WIFSIGNALED(status)) { + switch (WTERMSIG(status)) { + case SIGTERM: + case SIGHUP: + case SIGUSR1: + case SIGKILL: + break; + default: +#ifdef SYS_SIGLIST +#ifdef WCOREDUMP + if (WCOREDUMP(status)) { + ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, + server_conf, + "child pid %d exit signal %s (%d), " + "possible coredump in %s", + pid, (WTERMSIG(status) >= NumSIG) ? "" : + SYS_SIGLIST[WTERMSIG(status)], WTERMSIG(status), + ap_coredump_dir); + } + else { +#endif + ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, + server_conf, + "child pid %d exit signal %s (%d)", pid, + SYS_SIGLIST[WTERMSIG(status)], WTERMSIG(status)); +#ifdef WCOREDUMP + } +#endif +#else + ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, + server_conf, + "child pid %d exit signal %d", + pid, WTERMSIG(status)); +#endif + } +} +} static int setup_listeners(pool *pconf, server_rec *s) { @@ -1253,6 +1304,8 @@ pid = wait_or_timeout(&status); if (pid >= 0) { +process_child_status(pid, status); +/* non-fatal death... note that it's gone in the scoreboard. */ child_slot = find_child_by_pid(pid); if (child_slot >= 0) { ap_update_child_status(child_slot, SERVER_DEAD); 1.24 +54 -1 apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c Index: mpmt_pthread.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -u -r1.23 -r1.24 --- mpmt_pthread.c1999/08/05 19:56:19 1.23 +++ mpmt_pthread.c1999/08/10 21:18:43 1.24 @@ -568,7 +568,7 @@ { chdir(ap_coredump_dir); signal(sig, SIG_DFL); -kill(getpid(), sig); +kill(my_pid, sig); /* At this point we've got sig blocked, because we're still inside * the signal handler. When we leave the signal handler it will * be unblocked, and we'll take the signal... and coredump or whatever @@ -752,6 +752,57 @@ #endif } + +static void process_child_status(int pid, ap_wait_t status) +{ +/* Child died... if it died due to a fatal error, + * we should simply bail out. + */ +if ((WIFEXITED(status)) && + WEXITSTATUS(status) == APEXIT_CHILDFATAL) { + ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, server_conf, + "Child %d returned a Fatal error... \n" + "Apache is exiting!", + pid); + exit(APEXIT_CHILDFATAL); +} +if (WIFSIGNALED(status)) { + switch (WTERMSIG(status)) { + case SIGTERM: + case SIGHUP: + case SIGUSR1: + case SIGKILL: + break; + default: +#ifdef SYS_SIGLIST +#ifdef WCOREDUMP + if (WCOREDUMP(status)) { + ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, + server_conf, + "child pid %d exit signal %s (%d), " + "possible coredump in %s", +
cvs commit: apache-2.0/mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c
manoj 99/08/03 17:21:37 Modified:mpm/src/modules/mpm/dexter dexter.c mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c Log: Undo the stupid pipe of death changes I made earlier today. dean noted that we need an char_of_death array to do this safely, and it's just not worth the effort. The EINTR stuff is left behind, though. Hopefully this is now decent again. Revision ChangesPath 1.17 +5 -10 apache-2.0/mpm/src/modules/mpm/dexter/dexter.c Index: dexter.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/dexter/dexter.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -u -r1.16 -r1.17 --- dexter.c 1999/08/03 23:43:02 1.16 +++ dexter.c 1999/08/04 00:21:32 1.17 @@ -1404,7 +1404,7 @@ } if (is_graceful) { - int i, bytes_to_write; + int i; char char_of_death = '!'; ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, server_conf, @@ -1420,17 +1420,12 @@ } } /* give the children the signal to die */ -/* XXX - This while loop logic should be made into a utility function */ -bytes_to_write = num_daemons; -while (bytes_to_write > 0) { -i = write(pipe_of_death[1], &char_of_death, bytes_to_write); -if (i == -1) { +for (i = 0; i < num_daemons;) { +if (write(pipe_of_death[1], &char_of_death, 1) == -1) { if (errno == EINTR) continue; -ap_log_error(APLOG_MARK, APLOG_ERR, server_conf, - "write pipe_of_death"); -break; +ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "write pipe_of_death"); } -bytes_to_write -= i; +i++; } } else { 1.22 +6 -13 apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c Index: mpmt_pthread.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -u -r1.21 -r1.22 --- mpmt_pthread.c1999/08/03 23:36:43 1.21 +++ mpmt_pthread.c1999/08/04 00:21:35 1.22 @@ -1463,26 +1463,19 @@ update_scoreboard_global(); if (is_graceful) { - int i, j, bytes_to_write; + int i, j; char char_of_death = '!'; ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, server_conf, "SIGWINCH received. Doing graceful restart"); -/* give the children the signal to die. Sending more bytes than - * children is okay, because the pipe is recreated for every - * generation */ -/* XXX - This while loop logic should be made into a utility function */ -bytes_to_write = ap_daemons_limit; -while (bytes_to_write > 0) { -i = write(pipe_of_death[1], &char_of_death, bytes_to_write); -if (i == -1) { + /* give the children the signal to die */ +for (i = 0; i < ap_daemons_limit;) { +if (write(pipe_of_death[1], &char_of_death, 1) == -1) { if (errno == EINTR) continue; -ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, - "write pipe_of_death"); -break; +ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "write pipe_of_death"); } -bytes_to_write -= i; +i++; } /* This is mostly for debugging... so that we know what is still
cvs commit: apache-2.0/mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c
manoj 99/08/03 16:36:44 Modified:mpm/src/modules/mpm/dexter dexter.c mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c Log: Fix a couple of potential graceful restart bugs noted by Dean: EINTR was never dealt with in the code to write to the pipe of death, and in pathological cases where the number of processes is greater than PIPE_BUF, we could end up only killing some processes. Revision ChangesPath 1.15 +12 -3 apache-2.0/mpm/src/modules/mpm/dexter/dexter.c Index: dexter.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/dexter/dexter.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -u -r1.14 -r1.15 --- dexter.c 1999/08/03 20:41:36 1.14 +++ dexter.c 1999/08/03 23:36:41 1.15 @@ -1404,7 +1404,7 @@ } if (is_graceful) { - int i; + int i, bytes_to_write; char char_of_death = '!'; ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, server_conf, @@ -1420,8 +1420,17 @@ } } /* give the children the signal to die */ -if (write(pipe_of_death[1], &char_of_death, num_daemons) == -1) { -ap_log_error(APLOG_MARK, APLOG_ERR, server_conf, "write pipe_of_death"); +/* XXX - This while loop logic should be made into a utility function */ +bytes_to_write = num_daemons; +while (bytes_to_write > 0) { +i = write(pipe_of_death[1], &char_of_death, bytes_to_write); +if (i == -1) { +if (errno == EINTR) continue; +ap_log_error(APLOG_MARK, APLOG_ERR, server_conf, + "write pipe_of_death"); +break; +} +bytes_to_write -= i; } } else { 1.21 +12 -3 apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c Index: mpmt_pthread.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -u -r1.20 -r1.21 --- mpmt_pthread.c1999/08/03 20:41:37 1.20 +++ mpmt_pthread.c1999/08/03 23:36:43 1.21 @@ -1463,7 +1463,7 @@ update_scoreboard_global(); if (is_graceful) { - int i, j; + int i, j, bytes_to_write; char char_of_death = '!'; ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, server_conf, @@ -1472,8 +1472,17 @@ /* give the children the signal to die. Sending more bytes than * children is okay, because the pipe is recreated for every * generation */ -if (write(pipe_of_death[1], &char_of_death, ap_daemons_limit) == -1) { -ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "write pipe_of_death"); +/* XXX - This while loop logic should be made into a utility function */ +bytes_to_write = ap_daemons_limit; +while (bytes_to_write > 0) { +i = write(pipe_of_death[1], &char_of_death, bytes_to_write); +if (i == -1) { +if (errno == EINTR) continue; +ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, + "write pipe_of_death"); +break; +} +bytes_to_write -= i; } /* This is mostly for debugging... so that we know what is still
cvs commit: apache-2.0/mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c
manoj 99/08/03 13:41:38 Modified:mpm/src/modules/mpm/dexter dexter.c mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c Log: No reason to have a loop writing one byte at a time to the pipe of death when the write call will do it for us. Also fix the comments a bit. Revision ChangesPath 1.14 +3 -5 apache-2.0/mpm/src/modules/mpm/dexter/dexter.c Index: dexter.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/dexter/dexter.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -u -r1.13 -r1.14 --- dexter.c 1999/08/03 20:03:07 1.13 +++ dexter.c 1999/08/03 20:41:36 1.14 @@ -1419,11 +1419,9 @@ ap_scoreboard_image[i].status = SERVER_DYING; } } - /* kill off the idle ones */ -for (i = 0; i < num_daemons; ++i) { -if (write(pipe_of_death[1], &char_of_death, 1) == -1) { -ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "write pipe_of_death"); -} + /* give the children the signal to die */ +if (write(pipe_of_death[1], &char_of_death, num_daemons) == -1) { +ap_log_error(APLOG_MARK, APLOG_ERR, server_conf, "write pipe_of_death"); } } else { 1.20 +5 -5 apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c Index: mpmt_pthread.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -u -r1.19 -r1.20 --- mpmt_pthread.c1999/08/03 20:03:09 1.19 +++ mpmt_pthread.c1999/08/03 20:41:37 1.20 @@ -1469,11 +1469,11 @@ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, server_conf, "SIGWINCH received. Doing graceful restart"); - /* kill off the idle ones */ -for (i = 0; i < ap_daemons_limit; ++i) { -if (write(pipe_of_death[1], &char_of_death, 1) == -1) { -ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "write pipe_of_death"); -} +/* give the children the signal to die. Sending more bytes than + * children is okay, because the pipe is recreated for every + * generation */ +if (write(pipe_of_death[1], &char_of_death, ap_daemons_limit) == -1) { +ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "write pipe_of_death"); } /* This is mostly for debugging... so that we know what is still
cvs commit: apache-2.0/mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c
manoj 99/08/03 13:03:10 Modified:mpm/src/modules/mpm/dexter dexter.c mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c Log: get rid of the vestigial ap_open_logs call (and the ap_clear_pool that went along with it), to fix logging problems. Sometimes the bug would show up as a segfault, and sometimes as logging to an incorrect file. Revision ChangesPath 1.13 +0 -2 apache-2.0/mpm/src/modules/mpm/dexter/dexter.c Index: dexter.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/dexter/dexter.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -u -r1.12 -r1.13 --- dexter.c 1999/08/03 18:17:48 1.12 +++ dexter.c 1999/08/03 20:03:07 1.13 @@ -1333,8 +1333,6 @@ "no listening sockets available, shutting down"); return 1; } -ap_clear_pool(plog); -ap_open_logs(server_conf, plog); ap_log_pid(pconf, ap_pid_fname); SAFE_ACCEPT(accept_mutex_init(pconf, 1)); if (!is_graceful) { 1.19 +0 -2 apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c Index: mpmt_pthread.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -u -r1.18 -r1.19 --- mpmt_pthread.c1999/08/03 18:17:51 1.18 +++ mpmt_pthread.c1999/08/03 20:03:09 1.19 @@ -1377,8 +1377,6 @@ "no listening sockets available, shutting down"); return 1; } -ap_clear_pool(plog); -ap_open_logs(server_conf, plog); ap_log_pid(pconf, ap_pid_fname); SAFE_ACCEPT(accept_mutex_init(pconf, 1)); if (!is_graceful) {
cvs commit: apache-2.0/mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c
manoj 99/08/03 11:17:54 Modified:mpm/src/modules/mpm/dexter dexter.c mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c Log: Update with new hooks. Revision ChangesPath 1.12 +0 -2 apache-2.0/mpm/src/modules/mpm/dexter/dexter.c Index: dexter.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/dexter/dexter.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -u -r1.11 -r1.12 --- dexter.c 1999/07/29 20:06:19 1.11 +++ dexter.c 1999/08/03 18:17:48 1.12 @@ -1691,8 +1691,6 @@ module MODULE_VAR_EXPORT mpm_dexter_module = { STANDARD20_MODULE_STUFF, -NULL, /* post_config */ -NULL,/* open_logs */ NULL,/* child_init */ NULL,/* create per-directory config structure */ NULL,/* merge per-directory config structures */ 1.18 +0 -2 apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c Index: mpmt_pthread.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -u -r1.17 -r1.18 --- mpmt_pthread.c1999/07/29 20:43:28 1.17 +++ mpmt_pthread.c1999/08/03 18:17:51 1.18 @@ -1763,8 +1763,6 @@ module MODULE_VAR_EXPORT mpm_mpmt_pthread_module = { STANDARD20_MODULE_STUFF, -NULL, /* post_config */ -NULL,/* open_logs */ NULL,/* child_init */ NULL,/* create per-directory config structure */ NULL,/* merge per-directory config structures */
Re: cvs commit: apache-2.0/mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c
[EMAIL PROTECTED] wrote: > > manoj 99/07/29 13:06:20 > > Modified:mpm/src/modules/mpm/dexter dexter.c >mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c > Log: > Use Ben Hyde's warning fix on two other MPMs. Tch! Ben Laurie! Cheers, Ben. -- http://www.apache-ssl.org/ben.html "My grandfather once told me that there are two kinds of people: those who work and those who take the credit. He told me to try to be in the first group; there was less competition there." - Indira Gandhi
cvs commit: apache-2.0/mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c
manoj 99/07/29 13:06:20 Modified:mpm/src/modules/mpm/dexter dexter.c mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c Log: Use Ben Hyde's warning fix on two other MPMs. Revision ChangesPath 1.11 +1 -1 apache-2.0/mpm/src/modules/mpm/dexter/dexter.c Index: dexter.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/dexter/dexter.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -u -r1.10 -r1.11 --- dexter.c 1999/07/27 23:54:16 1.10 +++ dexter.c 1999/07/29 20:06:19 1.11 @@ -1447,7 +1447,7 @@ { static int restart_num = 0; -one_process = getenv("ONE_PROCESS"); +one_process = !!getenv("ONE_PROCESS"); /* sigh, want this only the second time around */ if (restart_num++ == 1) { 1.16 +1 -1 apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c Index: mpmt_pthread.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -u -r1.15 -r1.16 --- mpmt_pthread.c1999/07/28 22:35:42 1.15 +++ mpmt_pthread.c1999/07/29 20:06:20 1.16 @@ -1508,7 +1508,7 @@ { static int restart_num = 0; -one_process = getenv("ONE_PROCESS"); +one_process = !!getenv("ONE_PROCESS"); /* sigh, want this only the second time around */ if (restart_num++ == 1) {
cvs commit: apache-2.0/mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c
manoj 99/07/28 15:35:43 Modified:mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c Log: Replace Min/MaxSpareServers with Min/MaxSpareThreads. This allows the admin to specify with finer granularity how the server pool should be run. Revision ChangesPath 1.15 +24 -30 apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c Index: mpmt_pthread.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -u -r1.14 -r1.15 --- mpmt_pthread.c1999/07/27 23:54:24 1.14 +++ mpmt_pthread.c1999/07/28 22:35:42 1.15 @@ -83,8 +83,8 @@ static char *ap_pid_fname=NULL; static char *ap_scoreboard_fname=NULL; static int ap_daemons_to_start=0; -static int ap_daemons_min_free=0; -static int ap_daemons_max_free=0; +static int min_spare_threads=0; +static int max_spare_threads=0; static int ap_daemons_limit=0; static time_t ap_restart_time=0; API_VAR_EXPORT int ap_extended_status = 0; @@ -1169,7 +1169,7 @@ static void perform_idle_server_maintenance(void) { int i, j; -int idle_count_ceil, idle_count_floor, idle_thread_count; +int idle_thread_count; thread_score *ss; time_t now = 0; int free_length; @@ -1180,8 +1180,6 @@ /* initialize the free_list */ free_length = 0; -idle_count_ceil = 0; -idle_count_floor = 0; idle_thread_count = 0; last_non_dead = -1; total_non_dead = 0; @@ -1230,13 +1228,8 @@ } } max_daemons_limit = last_non_dead + 1; -idle_count_floor = idle_thread_count / ap_threads_per_child; -idle_count_ceil = idle_count_floor; -if (idle_thread_count % ap_threads_per_child) { -idle_count_ceil++; -} -if (idle_count_ceil > ap_daemons_max_free) { +if (idle_thread_count > max_spare_threads) { /* Kill off one child */ char char_of_death = '!'; if (write(pipe_of_death[1], &char_of_death, 1) == -1) { @@ -1244,7 +1237,7 @@ } idle_spawn_rate = 1; } -else if (idle_count_floor < ap_daemons_min_free) { +else if (idle_thread_count < min_spare_threads) { /* terminate the free list */ if (free_length == 0) { /* only report this condition once */ @@ -1264,10 +1257,11 @@ if (idle_spawn_rate >= 8) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, server_conf, "server seems busy, (you may need " - "to increase StartServers, or Min/MaxSpareServers), " - "spawning %d children, there are %d idle, and " - "%d total children", idle_spawn_rate, - idle_count_floor, total_non_dead); + "to increase StartServers, ThreadsPerChild " + "or Min/MaxSparetThreads), " + "spawning %d children, there are around %d idle " + "threads, and %d total children", idle_spawn_rate, + idle_thread_count, total_non_dead); } for (i = 0; i < free_length; ++i) { make_child(server_conf, free_slots[i], now); @@ -1388,10 +1382,10 @@ } set_signals(); -/* set up get_socket */ -if (ap_daemons_max_free < ap_daemons_min_free + 1) /* Don't thrash... */ - ap_daemons_max_free = ap_daemons_min_free + 1; +/* Don't thrash... */ +if (max_spare_threads < min_spare_threads + ap_threads_per_child) + max_spare_threads = min_spare_threads + ap_threads_per_child; /* 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 @@ -1530,8 +1524,8 @@ unixd_pre_config(); ap_listen_pre_config(); ap_daemons_to_start = DEFAULT_START_DAEMON; -ap_daemons_min_free = DEFAULT_MIN_FREE_DAEMON; -ap_daemons_max_free = DEFAULT_MAX_FREE_DAEMON; +min_spare_threads = DEFAULT_MIN_FREE_DAEMON * DEFAULT_THREADS_PER_CHILD; +max_spare_threads = DEFAULT_MAX_FREE_DAEMON * DEFAULT_THREADS_PER_CHILD; ap_daemons_limit = HARD_SERVER_LIMIT; ap_threads_per_child = DEFAULT_THREADS_PER_CHILD; ap_pid_fname = DEFAULT_PIDLOG; @@ -1598,32 +1592,32 @@ return NULL; } -static const char *set_min_free_servers(cmd_parms *cmd, void *dummy, char *arg) +static const char *set_min_spare_threads(cmd_parms *cmd, void *dummy, char *arg) { const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err != NULL) { return err; } -ap_daemons_min_free = atoi(arg); -if (ap_daemo
cvs commit: apache-2.0/mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c
manoj 99/07/27 16:54:26 Modified:mpm/src/modules/mpm/dexter dexter.c mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c Log: Update with latest hook additions. Revision ChangesPath 1.10 +6 -7 apache-2.0/mpm/src/modules/mpm/dexter/dexter.c Index: dexter.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/dexter/dexter.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -u -r1.9 -r1.10 --- dexter.c 1999/07/27 12:05:02 1.9 +++ dexter.c 1999/07/27 23:54:16 1.10 @@ -1443,12 +1443,6 @@ return 0; } -static void dexter_hooks(void) -{ -INIT_SIGLIST() -one_process = 0; -} - static void dexter_pre_config(pool *pconf, pool *plog, pool *ptemp) { static int restart_num = 0; @@ -1480,6 +1474,12 @@ ap_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir)); } +static void dexter_hooks(void) +{ +ap_hook_pre_config(dexter_pre_config, NULL, NULL, HOOK_MIDDLE); +INIT_SIGLIST() +one_process = 0; +} static const char *set_pidfile(cmd_parms *cmd, void *dummy, char *arg) { @@ -1691,7 +1691,6 @@ module MODULE_VAR_EXPORT mpm_dexter_module = { STANDARD20_MODULE_STUFF, -dexter_pre_config, /* pre_config */ NULL, /* post_config */ NULL,/* open_logs */ NULL,/* child_init */ 1.14 +7 -7 apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c Index: mpmt_pthread.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -u -r1.13 -r1.14 --- mpmt_pthread.c1999/07/27 12:05:03 1.13 +++ mpmt_pthread.c1999/07/27 23:54:24 1.14 @@ -1510,12 +1510,6 @@ return 0; } -static void mpmt_pthread_hooks(void) -{ -INIT_SIGLIST() -one_process = 0; -} - static void mpmt_pthread_pre_config(pool *pconf, pool *plog, pool *ptemp) { static int restart_num = 0; @@ -1549,6 +1543,13 @@ ap_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir)); } +static void mpmt_pthread_hooks(void) +{ +ap_hook_pre_config(mpmt_pthread_pre_config,NULL,NULL,HOOK_MIDDLE); +INIT_SIGLIST() +one_process = 0; +} + static const char *set_pidfile(cmd_parms *cmd, void *dummy, char *arg) { @@ -1764,7 +1765,6 @@ module MODULE_VAR_EXPORT mpm_mpmt_pthread_module = { STANDARD20_MODULE_STUFF, -mpmt_pthread_pre_config, /* pre_config */ NULL, /* post_config */ NULL,/* open_logs */ NULL,/* child_init */
cvs commit: apache-2.0/mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c
manoj 99/07/21 15:32:37 Modified:mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c Log: Fix silly bug. accept() has to be inside the accept mutexed block. doh. Revision ChangesPath 1.11 +10 -4 apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c Index: mpmt_pthread.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -u -r1.10 -r1.11 --- mpmt_pthread.c1999/07/18 21:37:31 1.10 +++ mpmt_pthread.c1999/07/21 22:32:36 1.11 @@ -950,10 +950,16 @@ } } got_fd: -SAFE_ACCEPT(accept_mutex_off(0)); -SAFE_ACCEPT(intra_mutex_off(0)); -if (workers_may_exit) break; -csd = ap_accept(sd, &sa_client, &len); +if (!workers_may_exit) { +csd = ap_accept(sd, &sa_client, &len); +SAFE_ACCEPT(accept_mutex_off(0)); +SAFE_ACCEPT(intra_mutex_off(0)); +} +else { +SAFE_ACCEPT(accept_mutex_off(0)); +SAFE_ACCEPT(intra_mutex_off(0)); +break; +} process_socket(ptrans, &sa_client, csd, process_slot, thread_slot); ap_clear_pool(ptrans); requests_this_child--;
cvs commit: apache-2.0/mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c
manoj 99/07/18 14:37:32 Modified:mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c Log: Sync module strucuture with the prefork MPM again. Revision ChangesPath 1.10 +0 -1 apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c Index: mpmt_pthread.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -u -r1.9 -r1.10 --- mpmt_pthread.c1999/07/16 10:27:03 1.9 +++ mpmt_pthread.c1999/07/18 21:37:31 1.10 @@ -1773,7 +1773,6 @@ NULL,/* check access */ NULL,/* type_checker */ NULL,/* pre-run fixups */ -NULL,/* logger */ NULL /* register hooks */ };
cvs commit: apache-2.0/mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c
rse 99/07/16 03:27:05 Modified:mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c Log: Be careful, accept_mutex_child_init() has to be done _before_ unixd_setup_child() switches the process UID, because else under platforms where the mutex is flock() based this fails... Revision ChangesPath 1.9 +3 -2 apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c Index: mpmt_pthread.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- mpmt_pthread.c1999/07/16 07:15:48 1.8 +++ mpmt_pthread.c1999/07/16 10:27:03 1.9 @@ -992,12 +992,13 @@ /*stuff to do before we switch id's, so we have permissions.*/ reopen_scoreboard(pchild); +SAFE_ACCEPT(intra_mutex_init(pchild, 1)); +SAFE_ACCEPT(accept_mutex_child_init(pchild)); + if (unixd_setup_child()) { clean_child_exit(APEXIT_CHILDFATAL); } -SAFE_ACCEPT(intra_mutex_init(pchild, 1)); -SAFE_ACCEPT(accept_mutex_child_init(pchild)); ap_child_init_hook(pchild, server_conf); /*done with init critical section */
cvs commit: apache-2.0/mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c
martin 99/07/16 00:15:49 Modified:mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c Log: Use new module structure Revision ChangesPath 1.8 +0 -2 apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c Index: mpmt_pthread.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- mpmt_pthread.c1999/07/16 00:24:04 1.7 +++ mpmt_pthread.c1999/07/16 07:15:48 1.8 @@ -1768,8 +1768,6 @@ NULL,/* merge per-server config structures */ mpmt_pthread_cmds, /* command table */ NULL,/* handlers */ -NULL,/* translate_handler */ -NULL,/* check_user_id */ NULL,/* check auth */ NULL,/* check access */ NULL,/* type_checker */
cvs commit: apache-2.0/mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c
manoj 99/07/15 17:24:07 Modified:mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c Log: poll+accept without accept serialziation is dangerous, so for the moment, keep serialization on all the time and get rid of the attempts to make its usage thread-safe. Revision ChangesPath 1.7 +9 -14 apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c Index: mpmt_pthread.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -u -r1.6 -r1.7 --- mpmt_pthread.c1999/07/09 20:40:22 1.6 +++ mpmt_pthread.c1999/07/16 00:24:04 1.7 @@ -91,8 +91,7 @@ static int workers_may_exit = 0; static int requests_this_child; static int num_listenfds = 0; -static struct pollfd *listenfds_child; /* The listenfds that each thread copies - for itself */ +static struct pollfd *listenfds; /* The structure used to pass unique initialization info to each thread */ typedef struct { @@ -102,7 +101,7 @@ pool *tpool; /* "pthread" would be confusing */ } proc_info; -#ifdef SINGLE_LISTEN_UNSERIALIZED_ACCEPT +#if 0 #define SAFE_ACCEPT(stmt) do {if (ap_listeners->next != NULL) {stmt;}} while (0) #else #define SAFE_ACCEPT(stmt) do {stmt;} while (0) @@ -867,7 +866,6 @@ char pipe_read_char; int curr_pollfd, last_pollfd = 0; size_t len = sizeof(struct sockaddr); -struct pollfd *listenfds; free(ti); @@ -879,9 +877,6 @@ /* TODO: Switch to a system where threads reuse the results from earlier poll calls - manoj */ -/* set up each thread's individual pollfd array */ -listenfds = ap_palloc(tpool, sizeof(struct pollfd) * (num_listenfds + 1)); -memcpy(listenfds, listenfds_child, sizeof(struct pollfd) * (num_listenfds + 1)); while (!workers_may_exit) { workers_may_exit |= (ap_max_requests_per_child != 0) && (requests_this_child <= 0); if (workers_may_exit) break; @@ -1017,14 +1012,14 @@ requests_this_child = ap_max_requests_per_child; /* Set up the pollfd array */ -listenfds_child = ap_palloc(pchild, sizeof(struct pollfd) * (num_listenfds + 1)); -listenfds_child[0].fd = pipe_of_death[0]; -listenfds_child[0].events = POLLIN; -listenfds_child[0].revents = 0; +listenfds = ap_palloc(pchild, sizeof(struct pollfd) * (num_listenfds + 1)); +listenfds[0].fd = pipe_of_death[0]; +listenfds[0].events = POLLIN; +listenfds[0].revents = 0; for (lr = ap_listeners, i = 1; i <= num_listenfds; lr = lr->next, ++i) { -listenfds_child[i].fd = lr->fd; -listenfds_child[i].events = POLLIN; /* should we add POLLPRI ?*/ -listenfds_child[i].revents = 0; +listenfds[i].fd = lr->fd; +listenfds[i].events = POLLIN; /* should we add POLLPRI ?*/ +listenfds[i].revents = 0; } /* Setup worker threads */
cvs commit: apache-2.0/mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c
martin 99/07/07 08:16:44 Modified:mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c Log: Update to new module layout (Hooks) Revision ChangesPath 1.4 +1 -2 apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c Index: mpmt_pthread.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- mpmt_pthread.c1999/07/02 18:22:26 1.3 +++ mpmt_pthread.c1999/07/07 15:16:43 1.4 @@ -1665,8 +1665,7 @@ NULL,/* type_checker */ NULL,/* pre-run fixups */ NULL,/* logger */ -NULL,/* header parser */ -NULL /* post_read_request */ +NULL /* register hooks */ }; /* force Expat to be linked into the server executable */