From: William A. Rowe Jr Date: Sun, 13 Feb 2005 22:10:02 +0000 (+0000) Subject: There -was- no race on Win32 in httpd-2.0, because the child thread X-Git-Tag: 2.0.54~66 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=56872f73cfed5ee8277a380eada795d680a395c0;p=thirdparty%2Fapache%2Fhttpd.git There -was- no race on Win32 in httpd-2.0, because the child thread start function arg was redefined to be racy on httpd-2.1 (now fixed.) However, things aren't always clear when one goes nuts with casts, in fact they mask the real behavior. So taking FirstBill's +1, clean up these ugly casts as we did in httpd-2.1 and make the code and it's behavior a little more self-evident. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.0.x@153678 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/STATUS b/STATUS index 8d78c77ffe9..f07425c8070 100644 --- a/STATUS +++ b/STATUS @@ -112,15 +112,6 @@ PATCHES TO BACKPORT FROM TRUNK: svn rev 124104 +1: minfrin - *) Win32: Eliminate a very ugly race - the parallel starting - threads were picking up thread identifiers other than their - own. Because the limit of threads is an int, stuffing the - int into the void* value is a safe argument convention. - - http://svn.apache.org/viewcvs.cgi?rev=123899&view=rev - - +1: stoddard - *) util_ldap: Add the directive LDAPConnectionTimeout to control the socket timeout value when binding to an LDAP server svn rev 126565 diff --git a/server/mpm/winnt/child.c b/server/mpm/winnt/child.c index a20d740743e..96150f5c5fb 100644 --- a/server/mpm/winnt/child.c +++ b/server/mpm/winnt/child.c @@ -321,7 +321,7 @@ static int remove_job(void) } -static void win9x_accept(void * dummy) +static unsigned int __stdcall win9x_accept(void * dummy) { struct timeval tv; fd_set main_fds; @@ -405,6 +405,7 @@ static void win9x_accept(void * dummy) } } SetEvent(exit_event); + return 0; } @@ -476,7 +477,7 @@ static PCOMP_CONTEXT win9x_get_connection(PCOMP_CONTEXT context) * connections to service. */ #define MAX_ACCEPTEX_ERR_COUNT 250 -static void winnt_accept(void *lr_) +static unsigned int __stdcall winnt_accept(void *lr_) { ap_listen_rec *lr = (ap_listen_rec *)lr_; apr_os_sock_info_t sockinfo; @@ -634,6 +635,7 @@ static void winnt_accept(void *lr_) } ap_log_error(APLOG_MARK, APLOG_INFO, APR_SUCCESS, ap_server_conf, "Child %d: Accept thread exiting.", my_pid); + return 0; } @@ -685,10 +687,11 @@ static PCOMP_CONTEXT winnt_get_connection(PCOMP_CONTEXT context) * Main entry point for the worker threads. Worker threads block in * win*_get_connection() awaiting a connection to service. */ -static void worker_main(long thread_num) +static unsigned int __stdcall worker_main(void *thread_num_val) { static int requests_this_child = 0; PCOMP_CONTEXT context = NULL; + int thread_num = (int)thread_num_val; ap_sb_handle_t *sbh; ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, ap_server_conf, @@ -754,6 +757,7 @@ static void worker_main(long thread_num) ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, ap_server_conf, "Child %d: Worker thread %ld exiting.", my_pid, thread_num); + return 0; } @@ -780,7 +784,7 @@ static void create_listener_thread() int tid; int num_listeners = 0; if (!use_acceptex) { - _beginthreadex(NULL, 0, (LPTHREAD_START_ROUTINE) win9x_accept, + _beginthreadex(NULL, 0, win9x_accept, NULL, 0, &tid); } else { /* Start an accept thread per listener @@ -803,7 +807,7 @@ static void create_listener_thread() /* Now start a thread per listener */ for (lr = ap_listeners; lr; lr = lr->next) { if (lr->sd != NULL) { - _beginthreadex(NULL, 1000, (LPTHREAD_START_ROUTINE) winnt_accept, + _beginthreadex(NULL, 1000, winnt_accept, (void *) lr, 0, &tid); } } @@ -895,7 +899,7 @@ void child_main(apr_pool_t *pconf) continue; } ap_update_child_status_from_indexes(0, i, SERVER_STARTING, NULL); - child_handles[i] = (HANDLE) _beginthreadex(NULL, 0, (LPTHREAD_START_ROUTINE) worker_main, + child_handles[i] = (HANDLE) _beginthreadex(NULL, 0, worker_main, (void *) i, 0, &tid); if (child_handles[i] == 0) { ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_os_error(), ap_server_conf,