diff options
Diffstat (limited to '')
-rw-r--r-- | server/mpm/winnt/child.c | 27 | ||||
-rw-r--r-- | server/mpm/winnt/mpm_winnt.c | 23 | ||||
-rw-r--r-- | server/mpm/winnt/nt_eventlog.c | 1 | ||||
-rw-r--r-- | server/mpm/winnt/service.c | 8 |
4 files changed, 37 insertions, 22 deletions
diff --git a/server/mpm/winnt/child.c b/server/mpm/winnt/child.c index 21755f3..05151a8 100644 --- a/server/mpm/winnt/child.c +++ b/server/mpm/winnt/child.c @@ -352,7 +352,7 @@ static unsigned int __stdcall winnt_accept(void *lr_) ap_listen_rec *lr = (ap_listen_rec *)lr_; apr_os_sock_info_t sockinfo; winnt_conn_ctx_t *context = NULL; - DWORD BytesRead; + DWORD BytesRead = 0; SOCKET nlsd; LPFN_ACCEPTEX lpfnAcceptEx = NULL; LPFN_GETACCEPTEXSOCKADDRS lpfnGetAcceptExSockaddrs = NULL; @@ -784,8 +784,8 @@ static winnt_conn_ctx_t *winnt_get_connection(winnt_conn_ctx_t *context) */ static DWORD __stdcall worker_main(void *thread_num_val) { - apr_thread_t *thd; - apr_os_thread_t osthd; + apr_thread_t *thd = NULL; + apr_os_thread_t osthd = NULL; static int requests_this_child = 0; winnt_conn_ctx_t *context = NULL; int thread_num = (int)thread_num_val; @@ -793,7 +793,16 @@ static DWORD __stdcall worker_main(void *thread_num_val) conn_rec *c; apr_int32_t disconnected; +#if AP_HAS_THREAD_LOCAL + if (ap_thread_current_create(&thd, NULL, pchild) != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_WARNING, 0, ap_server_conf, APLOGNO(10376) + "Couldn't initialize worker thread, thread locals won't " + "be available"); + osthd = apr_os_thread_current(); + } +#else osthd = apr_os_thread_current(); +#endif while (1) { @@ -826,8 +835,10 @@ static DWORD __stdcall worker_main(void *thread_num_val) continue; } - thd = NULL; - apr_os_thread_put(&thd, &osthd, context->ptrans); + if (osthd) { + thd = NULL; + apr_os_thread_put(&thd, &osthd, context->ptrans); + } c->current_thread = thd; ap_process_connection(c, context->sock); @@ -842,6 +853,12 @@ static DWORD __stdcall worker_main(void *thread_num_val) ap_update_child_status_from_indexes(0, thread_num, SERVER_DEAD, NULL); +#if AP_HAS_THREAD_LOCAL + if (!osthd) { + apr_pool_destroy(apr_thread_pool_get(thd)); + } +#endif + return 0; } diff --git a/server/mpm/winnt/mpm_winnt.c b/server/mpm/winnt/mpm_winnt.c index 3d71f80..1b8962e 100644 --- a/server/mpm/winnt/mpm_winnt.c +++ b/server/mpm/winnt/mpm_winnt.c @@ -437,7 +437,7 @@ static int send_handles_to_child(apr_pool_t *p, * get_listeners_from_parent() * The listen sockets are opened in the parent. This function, which runs * exclusively in the child process, receives them from the parent and - * makes them availeble in the child. + * makes them available in the child. */ static void get_listeners_from_parent(server_rec *s) { @@ -559,6 +559,7 @@ static int create_process(apr_pool_t *p, HANDLE *child_proc, HANDLE *child_exit_ int envc; apr_pool_create_ex(&ptemp, p, NULL, NULL); + apr_pool_tag(ptemp, "create_process"); /* Build the command line. Should look something like this: * C:/apache/bin/httpd.exe -f ap_server_confname @@ -586,10 +587,10 @@ static int create_process(apr_pool_t *p, HANDLE *child_proc, HANDLE *child_exit_ return -1; } - args = malloc((ap_server_conf->process->argc + 1) * sizeof (char*)); + args = ap_malloc((ap_server_conf->process->argc + 1) * sizeof (char*)); memcpy(args + 1, ap_server_conf->process->argv + 1, (ap_server_conf->process->argc - 1) * sizeof (char*)); - args[0] = malloc(strlen(cmd) + 1); + args[0] = ap_malloc(strlen(cmd) + 1); strcpy(args[0], cmd); args[ap_server_conf->process->argc] = NULL; } @@ -743,7 +744,7 @@ static int create_process(apr_pool_t *p, HANDLE *child_proc, HANDLE *child_exit_ * of this event means that the child process has exited prematurely * due to a seg fault or other irrecoverable error. For server * robustness, master_main will restart the child process under this - * condtion. + * condition. * * master_main uses the child_exit_event to signal the child process * to exit. @@ -1130,7 +1131,7 @@ static void winnt_rewrite_args(process_rec *process) "Failed to get the full path of %s", process->argv[0]); exit(APEXIT_INIT); } - /* WARNING: There is an implict assumption here that the + /* WARNING: There is an implicit assumption here that the * executable resides in ServerRoot or ServerRoot\bin */ def_server_root = (char *) apr_filepath_name_get(binpath); @@ -1377,7 +1378,7 @@ static int winnt_pre_config(apr_pool_t *pconf_, apr_pool_t *plog, apr_pool_t *pt ap_exists_config_define("DEBUG")) one_process = -1; - /* XXX: presume proper privilages; one nice thing would be + /* XXX: presume proper privileges; one nice thing would be * a loud emit if running as "LocalSystem"/"SYSTEM" to indicate * they should change to a user with write access to logs/ alone. */ @@ -1574,7 +1575,6 @@ static int winnt_post_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *pt /* This code should be run once in the parent and not run * across a restart */ - PSECURITY_ATTRIBUTES sa = GetNullACL(); /* returns NULL if invalid (Win95?) */ setup_signal_names(apr_psprintf(pconf, "ap%lu", parent_pid)); ap_log_pid(pconf, ap_pid_fname); @@ -1582,29 +1582,26 @@ static int winnt_post_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *pt /* Create shutdown event, apPID_shutdown, where PID is the parent * Apache process ID. Shutdown is signaled by 'apache -k shutdown'. */ - shutdown_event = CreateEvent(sa, FALSE, FALSE, signal_shutdown_name); + shutdown_event = CreateEvent(NULL, FALSE, FALSE, signal_shutdown_name); if (!shutdown_event) { ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_os_error(), ap_server_conf, APLOGNO(00448) "Parent: Cannot create shutdown event %s", signal_shutdown_name); - CleanNullACL((void *)sa); return HTTP_INTERNAL_SERVER_ERROR; } /* Create restart event, apPID_restart, where PID is the parent * Apache process ID. Restart is signaled by 'apache -k restart'. */ - restart_event = CreateEvent(sa, FALSE, FALSE, signal_restart_name); + restart_event = CreateEvent(NULL, FALSE, FALSE, signal_restart_name); if (!restart_event) { CloseHandle(shutdown_event); ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_os_error(), ap_server_conf, APLOGNO(00449) "Parent: Cannot create restart event %s", signal_restart_name); - CleanNullACL((void *)sa); return HTTP_INTERNAL_SERVER_ERROR; } - CleanNullACL((void *)sa); /* Create the start mutex, as an unnamed object for security. - * Ths start mutex is used during a restart to prevent more than + * The start mutex is used during a restart to prevent more than * one child process from entering the accept loop at once. */ rv = apr_proc_mutex_create(&start_mutex, NULL, diff --git a/server/mpm/winnt/nt_eventlog.c b/server/mpm/winnt/nt_eventlog.c index e7e80d0..cd49ee6 100644 --- a/server/mpm/winnt/nt_eventlog.c +++ b/server/mpm/winnt/nt_eventlog.c @@ -39,6 +39,7 @@ static DWORD WINAPI service_stderr_thread(LPVOID hPipe) apr_pool_t *p; apr_pool_create_ex(&p, NULL, NULL, NULL); + apr_pool_tag(p, "service_stderr_thread"); errarg[0] = "The Apache service named"; errarg[1] = display_name; diff --git a/server/mpm/winnt/service.c b/server/mpm/winnt/service.c index 121aca1..2e473cf 100644 --- a/server/mpm/winnt/service.c +++ b/server/mpm/winnt/service.c @@ -801,7 +801,7 @@ apr_status_t mpm_service_install(apr_pool_t *ptemp, int argc, rv = apr_get_os_error(); ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL, APLOGNO(00369) "Failed to open the Windows service " - "manager, perhaps you forgot to log in as Adminstrator?"); + "manager, perhaps you forgot to log in as Administrator?"); return (rv); } @@ -957,7 +957,7 @@ apr_status_t mpm_service_uninstall(void) rv = apr_get_os_error(); ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL, APLOGNO(10009) "Failed to open the Windows service " - "manager, perhaps you forgot to log in as Adminstrator?"); + "manager, perhaps you forgot to log in as Administrator?"); return (rv); } @@ -1047,7 +1047,7 @@ apr_status_t mpm_service_start(apr_pool_t *ptemp, int argc, rv = apr_get_os_error(); ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL, APLOGNO(10011) "Failed to open the Windows service " - "manager, perhaps you forgot to log in as Adminstrator?"); + "manager, perhaps you forgot to log in as Administrator?"); return (rv); } @@ -1157,7 +1157,7 @@ void mpm_signal_service(apr_pool_t *ptemp, int signal) ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, apr_get_os_error(), NULL, APLOGNO(10013) "Failed to open the Windows service " - "manager, perhaps you forgot to log in as Adminstrator?"); + "manager, perhaps you forgot to log in as Administrator?"); return; } |