cvs commit: apache-2.0/mpm/src/modules/mpm/winnt winnt.c
stoddard99/08/20 21:43:18 Modified:mpm/src/main listen.c mpm/src/modules/mpm/winnt winnt.c Log: Forgot listen.c in the earlier AcceptEx patch to winnt.c. Enable winnt mpm to detech OS at runtime. Revision ChangesPath 1.5 +9 -0 apache-2.0/mpm/src/main/listen.c Index: listen.c === RCS file: /home/cvs/apache-2.0/mpm/src/main/listen.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- listen.c 1999/07/26 07:03:09 1.4 +++ listen.c 1999/08/21 04:43:08 1.5 @@ -78,11 +78,20 @@ else ap_snprintf(addr, sizeof(addr), "port %d", ntohs(server->sin_port)); +#ifdef WIN32 +s = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, WSA_FLAG_OVERLAPPED); +if (s == INVALID_SOCKET) { + ap_log_error(APLOG_MARK, APLOG_CRIT, NULL, + "make_sock: failed to get a socket for %s", addr); + return -1; +} +#else if ((s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) { ap_log_error(APLOG_MARK, APLOG_CRIT, NULL, "make_sock: failed to get a socket for %s", addr); return -1; } +#endif #ifdef SO_REUSEADDR if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof(int)) < 0) { 1.10 +23 -13apache-2.0/mpm/src/modules/mpm/winnt/winnt.c Index: winnt.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/winnt/winnt.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- winnt.c 1999/08/20 20:20:33 1.9 +++ winnt.c 1999/08/21 04:43:15 1.10 @@ -94,6 +94,8 @@ static server_rec *server_conf; static int one_process = 0; + +static OSVERSIONINFO osver; /* VER_PLATFORM_WIN32_NT */ event *exit_event; mutex *start_mutex; int my_pid; @@ -767,12 +769,12 @@ ap_clear_pool(lpCompContext->ptrans); lpCompContext->conn_io = ap_bcreate(lpCompContext->ptrans, B_RDWR); +/* Grab a connection off the network */ +if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT) +lpCompContext = winnt_get_connection(lpCompContext); +else +lpCompContext = win9x_get_connection(lpCompContext); -#ifdef QUEUED_ACCEPT -lpCompContext = win9x_get_connection(lpCompContext); -#else -lpCompContext = winnt_get_connection(lpCompContext); -#endif if (!lpCompContext) break; @@ -954,10 +956,9 @@ child_handles[i] = create_thread((void (*)(void *)) child_main, (void *) i); } -#ifdef QUEUED_ACCEPT -/* spawn off accept thread */ -create_thread((void (*)(void *)) accept_and_queue_connections, (void *) NULL); -#endif +/* spawn off accept thread (WIN9x only) */ +if (osver.dwPlatformId != VER_PLATFORM_WIN32_NT) +create_thread((void (*)(void *)) accept_and_queue_connections, (void *) NULL); rv = WaitForSingleObject(exit_event, INFINITE); printf("exit event signalled \n"); @@ -965,11 +966,17 @@ /* Get ready to shutdown and exit */ ap_release_mutex(start_mutex); -#ifdef QUEUED_ACCEPT -for (i = 0; i < nthreads; i++) { - add_job(-1); + +if (osver.dwPlatformId != VER_PLATFORM_WIN32_NT) { +/* This is only needed for platforms that use the accept queue code + * (WIN9x only). It should work on NT but not as efficiently as the + * code written specifically for Windows NT. + */ +for (i = 0; i < nthreads; i++) { +add_job(-1); +} } -#endif + /* Wait for all your children */ end_time = time(NULL) + 180; while (nthreads) { @@ -1359,6 +1366,9 @@ { char *pid; one_process=1;//!!getenv("ONE_PROCESS"); + +osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); +GetVersionEx(&osver); /* AP_PARENT_PID is only valid in the child */ pid = getenv("AP_PARENT_PID");
cvs commit: apache-2.0/mpm/src/modules/mpm/winnt winnt.c
manoj 99/08/17 15:05:23 Modified:mpm/src/main http_main.c mpm/src/modules/mpm/dexter dexter.c mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c mpm/src/modules/mpm/winnt winnt.c Log: Move the code to force Expat linking into common code. Revision ChangesPath 1.10 +10 -0 apache-2.0/mpm/src/main/http_main.c Index: http_main.c === RCS file: /home/cvs/apache-2.0/mpm/src/main/http_main.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -u -r1.9 -r1.10 --- http_main.c 1999/08/17 20:58:54 1.9 +++ http_main.c 1999/08/17 22:04:46 1.10 @@ -352,6 +352,16 @@ exit(0); } +/* force Expat to be linked into the server executable */ +#if defined(USE_EXPAT) && !defined(SHARED_CORE_BOOTSTRAP) +#include "xmlparse.h" +const XML_LChar *suck_in_expat(void); +const XML_LChar *suck_in_expat(void) +{ +return XML_ErrorString(XML_ERROR_NONE); +} +#endif /* USE_EXPAT */ + #ifndef SHARED_CORE_BOOTSTRAP /* * Force ap_validate_password() into the image so that modules like 1.27 +0 -9 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.26 retrieving revision 1.27 diff -u -d -u -r1.26 -r1.27 --- dexter.c 1999/08/15 11:02:43 1.26 +++ dexter.c 1999/08/17 22:04:54 1.27 @@ -1630,12 +1630,3 @@ dexter_hooks /* register_hooks */ }; -/* force Expat to be linked into the server executable */ -#if defined(USE_EXPAT) && !defined(SHARED_CORE_BOOTSTRAP) -#include "xmlparse.h" -const XML_LChar *suck_in_expat(void); -const XML_LChar *suck_in_expat(void) -{ -return XML_ErrorString(XML_ERROR_NONE); -} -#endif /* USE_EXPAT */ 1.29 +0 -9 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.28 retrieving revision 1.29 diff -u -d -u -r1.28 -r1.29 --- mpmt_pthread.c1999/08/15 11:02:44 1.28 +++ mpmt_pthread.c1999/08/17 22:05:09 1.29 @@ -1698,12 +1698,3 @@ mpmt_pthread_hooks /* register_hooks */ }; -/* force Expat to be linked into the server executable */ -#if defined(USE_EXPAT) && !defined(SHARED_CORE_BOOTSTRAP) -#include "xmlparse.h" -const XML_LChar *suck_in_expat(void); -const XML_LChar *suck_in_expat(void) -{ -return XML_ErrorString(XML_ERROR_NONE); -} -#endif /* USE_EXPAT */ 1.8 +0 -10 apache-2.0/mpm/src/modules/mpm/winnt/winnt.c Index: winnt.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/winnt/winnt.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -u -r1.7 -r1.8 --- winnt.c 1999/08/17 19:51:43 1.7 +++ winnt.c 1999/08/17 22:05:17 1.8 @@ -1589,13 +1589,3 @@ NULL,/* handlers */ winnt_hooks /* register_hooks */ }; - -/* force Expat to be linked into the server executable */ -#if defined(USE_EXPAT) && !defined(SHARED_CORE_BOOTSTRAP) -#include "xmlparse.h" -const XML_LChar *suck_in_expat(void); -const XML_LChar *suck_in_expat(void) -{ -return XML_ErrorString(XML_ERROR_NONE); -} -#endif /* USE_EXPAT */
cvs commit: apache-2.0/mpm/src/modules/mpm/winnt winnt.c
stoddard99/08/17 12:51:44 Modified:mpm/src/modules/mpm/winnt winnt.c Log: More cleanup... Revision ChangesPath 1.7 +188 -354 apache-2.0/mpm/src/modules/mpm/winnt/winnt.c Index: winnt.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/winnt/winnt.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- winnt.c 1999/08/16 22:36:25 1.6 +++ winnt.c 1999/08/17 19:51:43 1.7 @@ -70,8 +70,9 @@ #include "../os/win32/getopt.h" #include "mpm_default.h" #include "../os/win32/iol_socket.h" + /* - * Actual definitions of WINNT MPM specific config globals + * Definitions of WINNT MPM specific config globals */ int ap_max_requests_per_child=0; int ap_daemons_to_start=0; @@ -80,117 +81,26 @@ static int workers_may_exit = 0; static int max_requests_per_child = 0; static int requests_this_child; -static int num_listenfds = 0; + static struct pollfd *listenfds; +static int num_listenfds = 0; +int listenmaxfd = -1; + static pool *pconf; /* Pool for config stuff */ static char ap_coredump_dir[MAX_STRING_LEN]; static server_rec *server_conf; -/*static int sd; ZZZ why is the global...? Only seems to be needed on Win32*/ -/* one_process --- debugging mode variable; can be set from the command line - * with the -X flag. If set, this gets you the child_main loop running - * in the process which originally started up (no detach, no make_child), - * which is a pretty nice debugging environment. (You'll get a SIGHUP - * early in standalone_main; just continue through. This is the server - * trying to kill off any child processes which it might have lying - * around --- Apache doesn't keep track of their pids, it just sends - * SIGHUP to the process group, ignoring it in the root process. - * Continue through and you'll be fine.). - */ - static int one_process = 0; - -#ifdef DEBUG_SIGSTOP -int raise_sigstop_flags; -#endif - - -/* *Non*-shared winnt.c globals... */ event *exit_event; mutex *start_mutex; int my_pid; int parent_pid; -int listenmaxfd = -1; -/* a clean exit from a child with proper cleanup - static void clean_child_exit(int code) __attribute__ ((noreturn)); -void clean_child_exit(int code) -{ -if (pchild) { - ap_destroy_pool(pchild); -} -exit(code); -} -*/ -/* - * Connection structures and accounting... - */ - -/* volatile just in case */ -static int volatile shutdown_pending; -static int volatile restart_pending; -static int volatile is_graceful; /* - * ap_start_shutdown() and ap_start_restart(), below, are a first stab at - * functions to initiate shutdown or restart without relying on signals. - * Previously this was initiated in sig_term() and restart() signal handlers, - * but we want to be able to start a shutdown/restart from other sources -- - * e.g. on Win32, from the service manager. Now the service manager can - * call ap_start_shutdown() or ap_start_restart() as appropiate. Note that - * these functions can also be called by the child processes, since global - * variables are no longer used to pass on the required action to the parent. - * - * These should only be called from the parent process itself, since the - * parent process will use the shutdown_pending and restart_pending variables - * to determine whether to shutdown or restart. The child process should - * call signal_parent() directly to tell the parent to die -- this will - * cause neither of those variable to be set, which the parent will - * assume means something serious is wrong (which it will be, for the - * child to force an exit) and so do an exit anyway. - */ - -void ap_start_shutdown(void) -{ -if (shutdown_pending == 1) { - /* Um, is this _probably_ not an error, if the user has - * tried to do a shutdown twice quickly, so we won't - * worry about reporting it. - */ - return; -} -shutdown_pending = 1; -} - -/* do a graceful restart if graceful == 1 */ -void ap_start_restart(int graceful) -{ - -if (restart_pending == 1) { - /* Probably not an error - don't bother reporting it */ - return; -} -restart_pending = 1; -is_graceful = graceful; -} - -static void sig_term(int sig) -{ -ap_start_shutdown(); -} - -static void restart(int sig) -{ -ap_start_restart(1); -} - - - - -/* * Signalling Apache on NT. * * Under Unix, Apache can be told to shutdown or restart by sending various @@ -232,7 +142,6 @@ * to die, or for a signal on the "spache-signal" event. So set the * "apache-signal" event here. */ - if
cvs commit: apache-2.0/mpm/src/modules/mpm/winnt winnt.c
stoddard99/08/16 15:36:26 Modified:mpm/src/modules/mpm/winnt winnt.c Log: Server will build and serve static pages (page size < bufsize) with the appropriate makefile hacks (remove mod_cgi, mod_include, etc.). Revision ChangesPath 1.6 +33 -41apache-2.0/mpm/src/modules/mpm/winnt/winnt.c Index: winnt.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/winnt/winnt.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- winnt.c 1999/08/13 19:45:26 1.5 +++ winnt.c 1999/08/16 22:36:25 1.6 @@ -113,7 +113,7 @@ mutex *start_mutex; int my_pid; int parent_pid; -int listenmaxfd; +int listenmaxfd = -1; /* a clean exit from a child with proper cleanup static void clean_child_exit(int code) __attribute__ ((noreturn)); @@ -362,11 +362,20 @@ ap_listen_rec *lr; int num_listeners = 0; +/* Setup the listeners */ +listenmaxfd = -1; +FD_ZERO(&listenfds); + if (ap_listen_open(pconf, s->port)) { return 0; } for (lr = ap_listeners; lr; lr = lr->next) { num_listeners++; +if (lr->fd >= 0) { +FD_SET(lr->fd, &listenfds); +if (lr->fd > listenmaxfd) +listenmaxfd = lr->fd; +} } head_listener = ap_listeners; @@ -671,7 +680,7 @@ int csd = -1; ap_iol *iol; int srv = 0; - +int conn_id = 1; /* Note: current_conn used to be a defined at file scope as follows... Since the signal code is not being used in WIN32, make the variable local */ //static APACHE_TLS conn_rec *volatile current_conn; @@ -776,7 +785,8 @@ current_conn = ap_new_connection(ptrans, server_conf, conn_io, (struct sockaddr_in *) &sa_client, - (struct sockaddr_in *) &sa_server); + (struct sockaddr_in *) &sa_server, + conn_id); ap_process_connection(current_conn); } @@ -896,12 +906,8 @@ pchild = ap_make_sub_pool(pconf); -//ap_standalone = 1; -//sd = -1; ?? this variable is global in 1.3.x! nthreads = ap_threads_per_child; -my_pid = getpid(); - //ap_restart_time = time(NULL); //reinit_scoreboard(pconf); @@ -1077,7 +1083,6 @@ destroy_semaphore(allowed_globals.jobsemaphore); ap_destroy_mutex(allowed_globals.jobmutex); -//ap_child_exit_modules(pconf, server_conf); ap_destroy_pool(pchild); //cleanup_scoreboard(); @@ -1139,7 +1144,6 @@ int rv; char buf[1024]; char *pCommand; - char *pEnvBlock; STARTUPINFO si; /* Filled in prior to call to CreateProcess */ PROCESS_INFORMATION pi; /* filled in on call to CreateProces */ @@ -1179,7 +1183,6 @@ return -1; } -// pEnvBlock = ap_psprintf(p, "AP_PARENT_PID=%d\0",parent_pid); SetEnvironmentVariable("AP_PARENT_PID",ap_psprintf(p,"%d",parent_pid)); /* Give the read in of the pipe (hPipeRead) to the child as stdin. The @@ -1194,8 +1197,8 @@ if (!CreateProcess(NULL, pCommand, NULL, NULL, TRUE, /* Inherit handles */ -CREATE_SUSPENDED, /* Creation flags */ // checkout DETACHED_PROCESS here and in the CGI -NULL, /* Environment block */ +CREATE_SUSPENDED, /* Creation flags */ +NULL, /* Environment block */ NULL, &si, &pi)) { ap_log_error(APLOG_MARK, APLOG_WIN32ERROR | APLOG_CRIT, server_conf, @@ -1220,7 +1223,7 @@ /* Create the exit_event, apCHILD_PID */ kill_event = CreateEvent(NULL, TRUE, FALSE, - ap_psprintf(pconf,"ap%d", pi.dwProcessId)); + ap_psprintf(pconf,"apC%d", pi.dwProcessId)); // exit_event_name... if (!kill_event) { ap_log_error(APLOG_MARK, APLOG_WIN32ERROR | APLOG_CRIT, server_conf, "Parent: Could not create exit event for child process"); @@ -1450,7 +1453,7 @@ static void winnt_pre_config(pool *pconf, pool *plog, pool *ptemp) { char *pid; -one_process = !!getenv("ONE_PROCESS"); +one_process=1;//!!getenv("ONE_PROCESS"); /* Track parent/child pids... */ pid = getenv("AP_PARENT_PID"); @@ -1474,7 +1477,6 @@ ap_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir)); -AMCSocketInitialize(); } /*
cvs commit: apache-2.0/mpm/src/modules/mpm/winnt winnt.c
stoddard99/08/13 12:45:27 Modified:mpm/src/modules/mpm/winnt winnt.c Log: Update listener code. Workaround stupid WIN32 bug(?) in WSASocket (fails with 10091 if the process environment block is not fully inherited from the parent). Start working on I/O layering support. It's time to make this thing serve a page. Waiting to check-in iol_file and iol_socket... Revision ChangesPath 1.5 +283 -244 apache-2.0/mpm/src/modules/mpm/winnt/winnt.c Index: winnt.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/winnt/winnt.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- winnt.c 1999/08/13 06:58:08 1.4 +++ winnt.c 1999/08/13 19:45:26 1.5 @@ -69,6 +69,7 @@ #include "multithread.h" #include "../os/win32/getopt.h" #include "mpm_default.h" +#include "../os/win32/iol_socket.h" /* * Actual definitions of WINNT MPM specific config globals */ @@ -76,7 +77,6 @@ int ap_daemons_to_start=0; static char *mpm_pid_fname=NULL; static int ap_threads_per_child = 0; -//static int ap_max_threads_per_child = 0; static int workers_may_exit = 0; static int max_requests_per_child = 0; static int requests_this_child; @@ -187,111 +187,9 @@ ap_start_restart(1); } -/* - * Find a listener which is ready for accept(). This advances the - * head_listener global. - */ -static ap_listen_rec *head_listener; -static ap_inline ap_listen_rec *find_ready_listener(fd_set * main_fds) -//static ap_listen_rec *find_ready_listener(fd_set * main_fds) -{ -ap_listen_rec *lr; - -lr = head_listener; -do { - if (FD_ISSET(lr->fd, main_fds)) { - head_listener = lr->next; - return (lr); - } - lr = lr->next; -} while (lr != head_listener); -return NULL; -} -static int setup_listeners(pool *pconf, server_rec *s) -{ -ap_listen_rec *lr; -int num_listeners = 0; - -if (ap_listen_open(pconf, s->port)) { - return 0; -} -for (lr = ap_listeners; lr; lr = lr->next) { -num_listeners++; -} - -/* Should we turn the list into a ring ?*/ -head_listener = ap_listeners; - -return num_listeners; -} - -static int setup_inherited_listeners(pool *p, server_rec *s) -{ -WSAPROTOCOL_INFO WSAProtocolInfo; -HANDLE pipe; -ap_listen_rec *lr; -DWORD BytesRead; -int num_listeners = 0; -int fd; -/* Setup the listeners */ -listenmaxfd = -1; -FD_ZERO(&listenfds); -/* Set up a default listener if necessary */ -if (ap_listeners == NULL) { -struct sockaddr_in local_addr; -ap_listen_rec *new; -local_addr.sin_family = AF_INET; -local_addr.sin_addr.s_addr = htonl(INADDR_ANY); - local_addr.sin_port = htons(s->port ? s->port : DEFAULT_HTTP_PORT); -new = malloc(sizeof(ap_listen_rec)); -new->local_addr = local_addr; -new->fd = -1; -new->next = ap_listeners; -ap_listeners = new; -} -/* Open the pipe to the parent process to receive the inherited socket - * data. The sockets have been set to listening in the parent process. - */ -pipe = GetStdHandle(STD_INPUT_HANDLE); -for (lr = ap_listeners; lr; lr = lr->next) { -if (!ReadFile(pipe, &WSAProtocolInfo, sizeof(WSAPROTOCOL_INFO), - &BytesRead, (LPOVERLAPPED) NULL)) { -ap_log_error(APLOG_MARK, APLOG_WIN32ERROR|APLOG_CRIT, server_conf, - "setup_inherited_listeners: Unable to read socket data from parent"); -exit(1); -} -fd = WSASocket(FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, - &WSAProtocolInfo, 0, 0); -if (fd == INVALID_SOCKET) { -ap_log_error(APLOG_MARK, APLOG_WIN32ERROR|APLOG_CRIT, server_conf, - "setup_inherited_listeners: WSASocket failed to get inherit the socket."); -exit(1); -} -if (fd >= 0) { -FD_SET(fd, &listenfds); -if (fd > listenmaxfd) -listenmaxfd = fd; -} -ap_note_cleanups_for_socket(p, fd); -} -CloseHandle(pipe); - - -for (lr = ap_listeners; lr; lr = lr->next) { -num_listeners++; -} - -/* turn the list into a ring ?*/ -//lr->next = ap_listeners; -head_listener = ap_listeners; - -return num_listeners; -} - - /* * Signalling Apache on NT. * @@ -397,7 +295,156 @@ return is_graceful; } +static int s_iInitCount = 0; +static int AMCSocketInitialize(void) +{ +int iVersionRequested; +WSADATA wsaData; +int err; + +if (s_iInitC
cvs commit: apache-2.0/mpm/src/modules/mpm/winnt winnt.c
manoj 99/08/12 23:58:14 Modified:mpm/src/include http_connection.h httpd.h mpm/src/main http_connection.c mpm/src/modules/mpm/dexter dexter.c mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c mpm/src/modules/mpm/prefork prefork.c mpm/src/modules/mpm/spmt_os2 spmt_os2.c mpm/src/modules/mpm/winnt winnt.c Log: Add a connection ID to conn_rec. It uniquely identifies a connection at any instant in time. It's not very well tested yet. Revision ChangesPath 1.7 +1 -1 apache-2.0/mpm/src/include/http_connection.h Index: http_connection.h === RCS file: /home/cvs/apache-2.0/mpm/src/include/http_connection.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -u -r1.6 -r1.7 --- http_connection.h 1999/08/05 19:56:04 1.6 +++ http_connection.h 1999/08/13 06:57:30 1.7 @@ -66,7 +66,7 @@ conn_rec *ap_new_connection(pool *p, server_rec *server, BUFF *inout, const struct sockaddr_in *remaddr, - const struct sockaddr_in *saddr); + const struct sockaddr_in *saddr, long id); CORE_EXPORT(void) ap_process_connection(conn_rec *); int ap_process_http_connection(conn_rec *); 1.12 +2 -0 apache-2.0/mpm/src/include/httpd.h Index: httpd.h === RCS file: /home/cvs/apache-2.0/mpm/src/include/httpd.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -u -r1.11 -r1.12 --- httpd.h 1999/08/06 00:54:19 1.11 +++ httpd.h 1999/08/13 06:57:33 1.12 @@ -816,6 +816,8 @@ char *local_host;/* used for ap_get_server_name when * UseCanonicalName is set to DNS * (ignores setting of HostnameLookups) */ +long id;/* ID of this connection; unique at any + * point in time */ void *conn_config; /* Notes on *this* connection */ }; 1.17 +3 -1 apache-2.0/mpm/src/main/http_connection.c Index: http_connection.c === RCS file: /home/cvs/apache-2.0/mpm/src/main/http_connection.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -u -r1.16 -r1.17 --- http_connection.c 1999/08/06 00:54:29 1.16 +++ http_connection.c 1999/08/13 06:57:40 1.17 @@ -258,7 +258,7 @@ conn_rec *ap_new_connection(pool *p, server_rec *server, BUFF *inout, const struct sockaddr_in *remaddr, - const struct sockaddr_in *saddr) + const struct sockaddr_in *saddr, long id) { conn_rec *conn = (conn_rec *) ap_pcalloc(p, sizeof(conn_rec)); @@ -278,6 +278,8 @@ conn->remote_addr = *remaddr; conn->remote_ip = ap_pstrdup(conn->pool, inet_ntoa(conn->remote_addr.sin_addr)); + +conn->id = id; return conn; } 1.22 +43 -33apache-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.21 retrieving revision 1.22 diff -u -d -u -r1.21 -r1.22 --- dexter.c 1999/08/12 02:02:27 1.21 +++ dexter.c 1999/08/13 06:57:46 1.22 @@ -145,18 +145,17 @@ static pool *pconf; /* Pool for config stuff */ static pool *pchild; /* Pool for httpd child stuff */ - -typedef struct { -pool *pool; -pthread_mutex_t mutex; -pthread_attr_t attr; -} worker_thread_info; +static pool *thread_pool_parent; /* Parent of per-thread pools */ +static pthread_mutex_t thread_pool_create_mutex; +static int child_num; static int my_pid; /* Linux getpid() doesn't work except in main thread. Use this instead */ /* Keep track of the number of worker threads currently active */ static int worker_thread_count; static pthread_mutex_t worker_thread_count_mutex; +static int worker_thread_free_ids[HARD_THREAD_LIMIT]; +static pthread_attr_t worker_thread_attr; /* Keep track of the number of idle worker threads */ static int idle_thread_count; @@ -849,7 +848,8 @@ * Child process main loop. */ -static void process_socket(pool *p, struct sockaddr *sa_client, int csd) +static void process_socket(pool *p, struct sockaddr *sa_client, int csd, + int conn_id) { struct sockaddr sa_server; /* */ size_t len = sizeof(struct sockaddr); @@ -886,7 +886,8 @@ current_conn = ap_new_
cvs commit: apache-2.0/mpm/src/modules/mpm/winnt winnt.c
stoddard99/08/11 09:03:56 Modified:mpm/src/modules/mpm/winnt winnt.c Log: Still a complete hacked up mess, but getting better! Revision ChangesPath 1.3 +201 -139 apache-2.0/mpm/src/modules/mpm/winnt/winnt.c Index: winnt.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/winnt/winnt.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- winnt.c 1999/08/05 22:05:47 1.2 +++ winnt.c 1999/08/11 16:03:55 1.3 @@ -187,8 +187,26 @@ ap_start_restart(1); } -static ap_listen_rec *old_listeners; +/* + * Find a listener which is ready for accept(). This advances the + * head_listener global. + */ static ap_listen_rec *head_listener; +static ap_inline ap_listen_rec *find_ready_listener(fd_set * main_fds) +//static ap_listen_rec *find_ready_listener(fd_set * main_fds) +{ +ap_listen_rec *lr; + +lr = head_listener; +do { + if (FD_ISSET(lr->fd, main_fds)) { + head_listener = lr->next; + return (lr); + } + lr = lr->next; +} while (lr != head_listener); +return NULL; +} static int setup_listeners(pool *pconf, server_rec *s) { ap_listen_rec *lr; @@ -200,56 +218,80 @@ for (lr = ap_listeners; lr; lr = lr->next) { num_listeners++; } + +/* Should we turn the list into a ring ?*/ +head_listener = ap_listeners; + return num_listeners; } -static int find_listener(ap_listen_rec *lr) +static int setup_inherited_listeners(pool *p, server_rec *s) { -ap_listen_rec *or; +WSAPROTOCOL_INFO WSAProtocolInfo; +HANDLE pipe; +ap_listen_rec *lr; +DWORD BytesRead; +int num_listeners = 0; +int fd; -for (or = old_listeners; or; or = or->next) { - if (!memcmp(&or->local_addr, &lr->local_addr, sizeof(or->local_addr))) { -// or->used = 1; - return or->fd; - } +/* Setup the listeners */ +listenmaxfd = -1; +FD_ZERO(&listenfds); + +/* Set up a default listener if necessary */ +if (ap_listeners == NULL) { +struct sockaddr_in local_addr; +ap_listen_rec *new; +local_addr.sin_family = AF_INET; +local_addr.sin_addr.s_addr = htonl(INADDR_ANY); + local_addr.sin_port = htons(s->port ? s->port : DEFAULT_HTTP_PORT); +new = malloc(sizeof(ap_listen_rec)); +new->local_addr = local_addr; +new->fd = -1; +new->next = ap_listeners; +ap_listeners = new; } -return -1; -} +/* Open the pipe to the parent process to receive the inherited socket + * data. The sockets have been set to listening in the parent process. + */ +pipe = GetStdHandle(STD_INPUT_HANDLE); +for (lr = ap_listeners; lr; lr = lr->next) { +if (!ReadFile(pipe, &WSAProtocolInfo, sizeof(WSAPROTOCOL_INFO), + &BytesRead, (LPOVERLAPPED) NULL)) { +ap_log_error(APLOG_MARK, APLOG_WIN32ERROR|APLOG_CRIT, server_conf, + "setup_inherited_listeners: Unable to read socket data from parent"); +exit(1); +} +fd = WSASocket(FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, + &WSAProtocolInfo, 0, 0); +if (fd == INVALID_SOCKET) { +ap_log_error(APLOG_MARK, APLOG_WIN32ERROR|APLOG_CRIT, server_conf, + "setup_inherited_listeners: WSASocket failed to get inherit the socket."); +exit(1); +} +if (fd >= 0) { +FD_SET(fd, &listenfds); +if (fd > listenmaxfd) +listenmaxfd = fd; +} +ap_note_cleanups_for_socket(p, fd); +} +CloseHandle(pipe); -static void close_unused_listeners(void) -{ -ap_listen_rec *or, *next; -for (or = old_listeners; or; or = next) { - next = or->next; -// if (!or->used) - closesocket(or->fd); - free(or); +for (lr = ap_listeners; lr; lr = lr->next) { +num_listeners++; } -old_listeners = NULL; -} -/* - * Find a listener which is ready for accept(). This advances the - * head_listener global. - */ -static ap_inline ap_listen_rec *find_ready_listener(fd_set * main_fds) -//static ap_listen_rec *find_ready_listener(fd_set * main_fds) -{ -ap_listen_rec *lr; +/* turn the list into a ring ?*/ +//lr->next = ap_listeners; +head_listener = ap_listeners; -lr = head_listener; -do { - if (FD_ISSET(lr->fd, main_fds)) { - head_listener = lr->next; - return (lr); - } - lr = lr->next; -} while (lr != head_listener); -return NULL; +return num_listeners; }
cvs commit: apache-2.0/mpm/src/modules/mpm/winnt winnt.c
stoddard99/08/05 15:05:49 Modified:mpm/src/modules/mpm/winnt winnt.c Log: A few more hacks before taking off for the weekend. Revision ChangesPath 1.2 +37 -46apache-2.0/mpm/src/modules/mpm/winnt/winnt.c Index: winnt.c === RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/winnt/winnt.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- winnt.c 1999/08/05 21:08:25 1.1 +++ winnt.c 1999/08/05 22:05:47 1.2 @@ -1274,19 +1274,16 @@ static int master_main(server_rec *s, HANDLE shutdown_event, HANDLE restart_event) { -int remaining_children_to_start; - -int child_num = 0; +int remaining_children_to_start = ap_daemons_to_start; +int i; int rv, cld; -HANDLE process_handles[MAX_PROCESSES]; -HANDLE process_kill_events[MAX_PROCESSES]; +int child_num = 0; +int restart_pending = 0; +int shutdown_pending = 0; int current_live_processes = 0; /* number of child process we know about */ -int processes_to_create = 0;/* number of child processes to create */ -pool *pparent = NULL; /* pool for the parent process. Cleaned on each restart */ -restart_pending = shutdown_pending = 0; - -remaining_children_to_start = ap_daemons_to_start; +HANDLE process_handles[MAX_PROCESSES]; +HANDLE process_kill_events[MAX_PROCESSES]; /* Create child process * Should only be one in this version of Apache for WIN32 @@ -1309,23 +1306,20 @@ process_handles[current_live_processes+1] = restart_event; rv = WaitForMultipleObjects(current_live_processes+2, (HANDLE *)process_handles, FALSE, INFINITE); +cld = rv - WAIT_OBJECT_0; if (rv == WAIT_FAILED) { /* Something serious is wrong */ ap_log_error(APLOG_MARK,APLOG_CRIT|APLOG_WIN32ERROR, server_conf, "master_main: : WaitForMultipeObjects on process handles and apache-signal -- doing shutdown"); shutdown_pending = 1; -break; } -if (rv == WAIT_TIMEOUT) { +else if (rv == WAIT_TIMEOUT) { /* Hey, this cannot happen */ ap_log_error(APLOG_MARK, APLOG_ERR, s, "master_main: WaitForMultipeObjects with INFINITE wait exited with WAIT_TIMEOUT"); shutdown_pending = 1; } - -cld = rv - WAIT_OBJECT_0; -//APD4("main process: wait finished, cld=%d handle %d (max=%d)", cld, process_handles[cld], current_live_processes); -if (cld == current_live_processes) { +else if (cld == current_live_processes) { /* shutdown_event signalled */ shutdown_pending = 1; ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, s, @@ -1341,8 +1335,8 @@ ap_log_error(APLOG_MARK,APLOG_ERR|APLOG_WIN32ERROR, server_conf, "master_main: SetEvent for child process in slot #%d failed", i); } -break; -} else if (cld == current_live_processes+1) { +} +else if (cld == current_live_processes+1) { /* restart_event signalled */ int children_to_kill = current_live_processes; restart_pending = 1; @@ -1352,40 +1346,41 @@ ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, s, "master_main: ResetEvent(restart_event) failed."); } -/* Signal each child process to die */ +/* Signal each child process to die + * We are making a big assumption here that the child process, once signaled, + * will REALLY go away. Since this is a restart, we do not want to hold the + * new child process up waiting for the old child to die. Remove the old + * child out of the process_handles table and hope for the best... + */ for (i = 0; i < children_to_kill; i++) { -//APD3("master_main: signalling child #%d handle %d to die", i, process_handles[i]); +/* APD3("master_main: signalling child #%d handle %d to die", i, process_handles[i]); */ if (SetEvent(process_kill_events[i]) == 0) ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, s, "master_main: SetEvent for child process in slot #%d failed", i); -/* Remove the process (and event) from the process table */ cleanup_process(process_handles, process_kill_events, i, ¤t_live_processes); } -processes_to_create = ap_daemons_to_start; -} else { +} +else { /* A child process must have exited because of MaxRequestPerChild being hit * or a fatal error condition (seg fault, etc.). Remove the dead process