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...@locus.apache.org on 2000/07/11 21:00:25 UTC
cvs commit: apache-2.0/src/modules/mpm/mpmt mpm.h mpm_default.h mpmt.c
rbb 00/07/11 12:00:25
Modified: src/main mpm_common.c
src/modules/mpm config.m4
src/modules/mpm/mpmt mpm.h mpm_default.h mpmt.c
Log:
Remove all pthreads calls from the mpmt MPM prefork emulation. This makes
the mpmt MPM look almost exactly like the original prefork MPM. Basically,
all that's left is re-naming the defined directives so they work with 1.3
config files. That will come later.
Revision Changes Path
1.22 +1 -1 apache-2.0/src/main/mpm_common.c
Index: mpm_common.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/main/mpm_common.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- mpm_common.c 2000/07/10 22:08:07 1.21
+++ mpm_common.c 2000/07/11 19:00:14 1.22
@@ -81,7 +81,7 @@
#if defined(DEXTER) || defined(MPMT_BEOS_MPM) || defined(BEOS_MPM)
#define CHILD_TABLE 1
#define CHILD_INFO_TABLE ap_child_table
-#elif defined(MPMT_PTHREAD) || defined (NO_THREADS) || defined(PREFORK_MPM)
+#elif defined(MPMT_PTHREAD) || defined (PREFORK) || defined(PREFORK_MPM)
#define SCOREBOARD 1
#define CHILD_INFO_TABLE ap_scoreboard_image->parent
#endif
1.23 +4 -3 apache-2.0/src/modules/mpm/config.m4
Index: config.m4
===================================================================
RCS file: /home/cvs/apache-2.0/src/modules/mpm/config.m4,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- config.m4 2000/07/09 18:54:08 1.22
+++ config.m4 2000/07/11 19:00:16 1.23
@@ -43,8 +43,9 @@
if test "$mpm_explicit" = "no"; then
if test "$MPM_NAME" = "prefork" ; then
- MPM_NAME="mpmt_pthread"
- EXTRA_CFLAGS="$EXTRA_CFLAGS -DNO_THREADS"
+ MPM_NAME="prefork"
+ MPM_FAKE_NAME=prefork.c
+ EXTRA_CFLAGS="$EXTRA_CFLAGS -DPREFORK"
ac_cv_enable_threads="no"
AC_CACHE_SAVE
@@ -69,7 +70,7 @@
ln -s mpmt.c modules/mpm/mpmt/dexter.c
fi
- if test "$MPM_NAME" = "dexter" -o "$MPM_NAME" = "mpmt_pthread"; then
+ if test "$MPM_NAME" = "dexter" -o "$MPM_NAME" = "mpmt_pthread" -o "$MPM_NAME" = "prefork"; then
MPM_DIR=modules/mpm/mpmt;
MPM_LIB=$MPM_DIR/libmpmt.la
MPM_NAME="mpmt"
1.3 +1 -1 apache-2.0/src/modules/mpm/mpmt/mpm.h
Index: mpm.h
===================================================================
RCS file: /home/cvs/apache-2.0/src/modules/mpm/mpmt/mpm.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- mpm.h 2000/07/10 18:21:20 1.2
+++ mpm.h 2000/07/11 19:00:19 1.3
@@ -78,7 +78,7 @@
#ifdef DEXTER
/* variables only needed for dexter */
extern ap_ctable ap_child_table[HARD_SERVER_LIMIT];
-#elif defined(MPMT_PTHREAD)
+#else
/* variables only needed for mpmt_pthread */
extern int ap_threads_per_child;
extern int ap_max_requests_per_child;
1.2 +4 -4 apache-2.0/src/modules/mpm/mpmt/mpm_default.h
Index: mpm_default.h
===================================================================
RCS file: /home/cvs/apache-2.0/src/modules/mpm/mpmt/mpm_default.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- mpm_default.h 2000/07/07 17:35:43 1.1
+++ mpm_default.h 2000/07/11 19:00:20 1.2
@@ -74,7 +74,7 @@
#define DEFAULT_START_THREAD 5
#endif
-#elif defined(MPMT_PTHREAD)
+#else
#define DEFAULT_START_DAEMON 5
#endif /* defined MPMT_PTHREAD */
#endif /* ndef DEFAULT_START_DAEMON */
@@ -104,7 +104,7 @@
* enough that we can read the whole thing without worrying too much about
* the overhead.
*/
-#ifdef NO_THREADS
+#ifdef PREFORK
#define HARD_SERVER_LIMIT 256
#endif
#ifndef HARD_SERVER_LIMIT
@@ -118,14 +118,14 @@
* enough that we can read the whole thing without worrying too much about
* the overhead.
*/
-#ifdef NO_THREADS
+#ifdef PREFORK
#define HARD_THREAD_LIMIT 1
#endif
#ifndef HARD_THREAD_LIMIT
#define HARD_THREAD_LIMIT 64
#endif
-#ifdef NO_THREADS
+#ifdef PREFORK
#define DEFAULT_THREADS_PER_CHILD 1
#endif
#ifndef DEFAULT_THREADS_PER_CHILD
1.10 +37 -8 apache-2.0/src/modules/mpm/mpmt/mpmt.c
Index: mpmt.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/modules/mpm/mpmt/mpmt.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- mpmt.c 2000/07/10 22:08:08 1.9
+++ mpmt.c 2000/07/11 19:00:24 1.10
@@ -89,7 +89,9 @@
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
+#ifndef PREFORK
#include <pthread.h>
+#endif
#include <signal.h>
/*
@@ -137,7 +139,9 @@
static ap_file_t *pipe_of_death_in = NULL;
static ap_file_t *pipe_of_death_out = NULL;
+#ifndef PREFORK
static pthread_mutex_t pipe_of_death_mutex;
+#endif
/* *Non*-shared http_main globals... */
@@ -176,8 +180,10 @@
/* Keep track of the number of worker threads currently active */
/* These could probably all go away too with a little work. */
static int worker_thread_count;
+#ifndef PREFORK
static pthread_mutex_t worker_thread_count_mutex;
static pthread_attr_t worker_thread_attr;
+#endif
#ifdef DEXTER
static int worker_thread_free_ids[HARD_THREAD_LIMIT];
@@ -193,7 +199,9 @@
#else
#define SAFE_ACCEPT(stmt) (stmt)
#endif
+#ifndef PREFORK
static pthread_mutex_t thread_accept_mutex = PTHREAD_MUTEX_INITIALIZER;
+#endif
static ap_lock_t *process_accept_mutex;
static const char *lock_fname;
@@ -508,7 +516,7 @@
static int start_thread(void)
{
proc_info *my_info = NULL;
-#ifndef NO_THREADS
+#ifndef PREFORK
pthread_t thread;
#endif
@@ -528,7 +536,7 @@
/* We are creating threads right now */
(void) ap_update_child_status(child_num, worker_thread_count,
SERVER_STARTING, (request_rec *) NULL);
-#ifndef NO_THREADS
+#ifndef PREFORK
if (pthread_create(&thread, &worker_thread_attr, worker_thread, my_info)) {
ap_log_error(APLOG_MARK, APLOG_ALERT, errno, ap_server_conf,
"pthread_create: unable to create worker thread");
@@ -561,7 +569,9 @@
/* Sets workers_may_exit if we received a character on the pipe_of_death */
static void check_pipe_of_death(void)
{
+#ifndef PREFORK
pthread_mutex_lock(&pipe_of_death_mutex);
+#endif
if (!workers_may_exit) {
ap_status_t ret;
char pipe_read_char;
@@ -578,7 +588,9 @@
workers_may_exit = 1;
}
}
+#ifndef PREFORK
pthread_mutex_unlock(&pipe_of_death_mutex);
+#endif
}
#ifdef DEXTER
@@ -773,9 +785,13 @@
(void) ap_update_child_status(process_slot, thread_slot, SERVER_READY,
(request_rec *) NULL);
+#ifndef PREFORK
pthread_mutex_lock(&thread_accept_mutex);
+#endif
if (workers_may_exit) {
+#ifndef PREFORK
pthread_mutex_unlock(&thread_accept_mutex);
+#endif
break;
}
if ((rv = SAFE_ACCEPT(ap_lock(process_accept_mutex)))
@@ -848,7 +864,9 @@
"process gracefully.");
workers_may_exit = 1;
}
+#ifndef PREFORK
pthread_mutex_unlock(&thread_accept_mutex);
+#endif
process_socket(ptrans, csd, process_slot * HARD_THREAD_LIMIT + thread_slot);
requests_this_child--;
}
@@ -860,7 +878,9 @@
"process gracefully.");
workers_may_exit = 1;
}
+#ifndef PREFORK
pthread_mutex_unlock(&thread_accept_mutex);
+#endif
break;
}
ap_clear_pool(ptrans);
@@ -869,14 +889,18 @@
ap_destroy_pool(tpool);
ap_update_child_status(process_slot, thread_slot, SERVER_DEAD,
(request_rec *) NULL);
+#ifndef PREFORK
pthread_mutex_lock(&worker_thread_count_mutex);
+#endif
worker_thread_count--;
if (worker_thread_count == 0) {
/* All the threads have exited, now finish the shutdown process
* by signalling the sigwait thread */
kill(ap_my_pid, SIGTERM);
}
+#ifndef PREFORK
pthread_mutex_unlock(&worker_thread_count_mutex);
+#endif
return NULL;
}
@@ -885,11 +909,12 @@
static void child_main(int child_num_arg)
{
sigset_t sig_mask;
- int signal_received;
int i;
ap_listen_rec *lr;
ap_status_t rv;
-
+#ifndef PREFORK
+ int signal_received;
+#endif
ap_my_pid = getpid();
child_num = child_num_arg;
@@ -918,15 +943,15 @@
/* All threads should mask signals out, accoring to sigwait(2) man page */
sigfillset(&sig_mask);
-#if defined(SIGPROCMASK_SETS_THREAD_MASK) || defined (NO_THREADS)
-#ifdef NO_THREADS
+#if defined(SIGPROCMASK_SETS_THREAD_MASK) || defined (PREFORK)
+#ifdef PREFORK
sigdelset(&sig_mask, SIGHUP);
sigdelset(&sig_mask, SIGTERM);
#endif
if (sigprocmask(SIG_SETMASK, &sig_mask, NULL) != 0) {
ap_log_error(APLOG_MARK, APLOG_ALERT, errno, ap_server_conf, "sigprocmask");
}
-#ifdef NO_THREADS
+#ifdef PREFORK
ap_signal(SIGHUP, just_die);
ap_signal(SIGTERM, just_die);
#endif
@@ -963,6 +988,7 @@
pthread_mutex_init(&idle_thread_count_mutex, NULL);
#endif
worker_thread_count = 0;
+#ifndef PREFORK
pthread_mutex_init(&worker_thread_count_mutex, NULL);
pthread_mutex_init(&pipe_of_death_mutex, NULL);
pthread_attr_init(&worker_thread_attr);
@@ -975,15 +1001,17 @@
#else
pthread_attr_setdetachstate(&worker_thread_attr, PTHREAD_CREATE_DETACHED);
#endif
+#endif
for (i=0; i < ap_threads_per_child; i++) {
/* start_thread shouldn't fail here */
if (!start_thread()) {
break;
}
}
-#ifndef DEXTER
+#ifdef MPMT_PTHREAD
pthread_attr_destroy(&worker_thread_attr);
#endif
+#ifndef PREFORK
/* This thread will be the one responsible for handling signals */
sigemptyset(&sig_mask);
sigaddset(&sig_mask, SIGTERM);
@@ -999,6 +1027,7 @@
"received impossible signal: %d", signal_received);
just_die(SIGTERM);
}
+#endif
}
static int make_child(server_rec *s, int slot, time_t now)