summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Trawick <trawick@apache.org>2011-05-06 13:51:38 +0000
committerJeff Trawick <trawick@apache.org>2011-05-06 13:51:38 +0000
commitf4286c21a96d407a4c9d5d31f262808830f8f176 (patch)
tree40563940c9c16faf855cf031934f017929298299
parentfb980e3cce2a8f1fec66093daa9f5ee29cddbd1f (diff)
downloadhttpd-f4286c21a96d407a4c9d5d31f262808830f8f176.tar.gz
Grab these from trunk:
r1091079 fix const-ness mismatch in call to mpm_nt_eventlog_stderr_open() r1091076 match expected type of arg to StartService() r1089600 cleanups to function signatures, prototypes, visibility r1089605 yank some dead code and variables (only a small part of the patch to service.c was applicable) r1089614 Log the OS socket (int) instead of the apr_socket_t *. r1089624 can't format time_t with %d; cast this small interval time to int r1089639 HANDLE is PVOID which is reasonably formatted by %pp, but not by %d r1089659 format string fixes: DWORD is unsigned long and needs %lu instead of %d or %i r1089688 axe ap_registry_get_server_root(), which seems to have been unused after httpd 1.3 r1089689 get prototype for ap_os_create_privileged_process() r1089690 axe a couple of unused vars, mark a function as static r1089857-equivalent Fix format string for pid in "Child: <pid>" messages r1040220 subset (fuangk) Fixed some win32 types. mod_win32.c changes aren't needed "DWORD tid" is "unsigned tid" due to use of different thread create fn r1025492 subset (fuangk) get prototypes for time(), _beginthreadex() remove cast from apr_getopt_init() call to fix warning, fix const-ness of service_name r983412 (fuangk) ap_regkey.c: Added casts to silent compiler warnings. No direct trunk equiv since code was rewritten or removed: . util_script.c warnings for assignent+truth value . missing const from signature of set_disable_acceptex() Reviewed by: wrowe, covener git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@1100216 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--STATUS11
-rw-r--r--os/win32/ap_regkey.c14
-rw-r--r--os/win32/os.h2
-rw-r--r--os/win32/util_win32.c3
-rw-r--r--server/mpm/winnt/child.c54
-rw-r--r--server/mpm/winnt/mpm_winnt.c94
-rw-r--r--server/mpm/winnt/mpm_winnt.h6
-rw-r--r--server/mpm/winnt/nt_eventlog.c8
-rw-r--r--server/mpm/winnt/service.c47
-rw-r--r--server/util_script.c8
10 files changed, 94 insertions, 153 deletions
diff --git a/STATUS b/STATUS
index 648bb08ccf..9206368f7e 100644
--- a/STATUS
+++ b/STATUS
@@ -91,17 +91,6 @@ RELEASE SHOWSTOPPERS:
PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
[ start all new proposals below, under PATCHES PROPOSED. ]
- * Fixes for gcc -Wall warnings in Windows code
- Trunk patch: revisions/descriptions at
- http://people.apache.org/~trawick/mingw_patch_revisions.txt
- 2.2.x patch: http://people.apache.org/~trawick/mingw_fix_warnings.txt
- (It is worth pointing out that DWORD = unsigned long for 16-,
- 32-, and 64-bit builds.)
- 2.2.x warnings without patch:
- http://people.apache.org/~trawick/mingw_r1092398_warnings.txt
- 2.2.x warnings with patch:
- http://people.apache.org/~trawick/mingw_patch_warnings.txt
- +1: trawick, wrowe, covener
PATCHES PROPOSED TO BACKPORT FROM TRUNK:
[ New proposals should be added at the end of the list ]
diff --git a/os/win32/ap_regkey.c b/os/win32/ap_regkey.c
index ea5a56d379..e080ab4f1f 100644
--- a/os/win32/ap_regkey.c
+++ b/os/win32/ap_regkey.c
@@ -43,7 +43,7 @@ AP_DECLARE(const ap_regkey_t *) ap_regkey_const(int i)
}
-apr_status_t regkey_cleanup(void *key)
+static apr_status_t regkey_cleanup(void *key)
{
ap_regkey_t *regkey = key;
@@ -363,7 +363,7 @@ AP_DECLARE(apr_status_t) ap_regkey_value_raw_get(void **result,
else if (valuelen)
return APR_ENAMETOOLONG;
/* Read to NULL buffer to determine value size */
- rc = RegQueryValueExW(key->hkey, wvalname, 0, resulttype,
+ rc = RegQueryValueExW(key->hkey, wvalname, 0, (LPDWORD)resulttype,
NULL, (LPDWORD)resultsize);
if (rc != ERROR_SUCCESS) {
return APR_FROM_OS_ERROR(rc);
@@ -371,7 +371,7 @@ AP_DECLARE(apr_status_t) ap_regkey_value_raw_get(void **result,
/* Read value based on size query above */
*result = apr_palloc(pool, *resultsize);
- rc = RegQueryValueExW(key->hkey, wvalname, 0, resulttype,
+ rc = RegQueryValueExW(key->hkey, wvalname, 0, (LPDWORD)resulttype,
(LPBYTE)*result, (LPDWORD)resultsize);
}
#endif /* APR_HAS_UNICODE_FS */
@@ -379,14 +379,14 @@ AP_DECLARE(apr_status_t) ap_regkey_value_raw_get(void **result,
ELSE_WIN_OS_IS_ANSI
{
/* Read to NULL buffer to determine value size */
- rc = RegQueryValueEx(key->hkey, valuename, 0, resulttype,
+ rc = RegQueryValueEx(key->hkey, valuename, 0, (LPDWORD)resulttype,
NULL, (LPDWORD)resultsize);
if (rc != ERROR_SUCCESS)
return APR_FROM_OS_ERROR(rc);
/* Read value based on size query above */
*result = apr_palloc(pool, *resultsize);
- rc = RegQueryValueEx(key->hkey, valuename, 0, resulttype,
+ rc = RegQueryValueEx(key->hkey, valuename, 0, (LPDWORD)resulttype,
(LPBYTE)*result, (LPDWORD)resultsize);
if (rc != ERROR_SUCCESS)
return APR_FROM_OS_ERROR(rc);
@@ -452,7 +452,7 @@ AP_DECLARE(apr_status_t) ap_regkey_value_array_get(apr_array_header_t **result,
void *value;
char *buf;
char *tmp;
- DWORD type;
+ apr_int32_t type;
apr_size_t size = 0;
rv = ap_regkey_value_raw_get(&value, &size, &type, key, valuename, pool);
@@ -468,8 +468,6 @@ AP_DECLARE(apr_status_t) ap_regkey_value_array_get(apr_array_header_t **result,
{
apr_size_t alloclen;
apr_size_t valuelen = strlen(valuename) + 1;
- apr_size_t wvallen = 256;
- apr_wchar_t *wvalue = (apr_wchar_t *)value;
/* ###: deliberately overallocate plus two extra nulls.
* We could precalculate the exact buffer here instead, the question
diff --git a/os/win32/os.h b/os/win32/os.h
index 0583e42299..7d9d70cb57 100644
--- a/os/win32/os.h
+++ b/os/win32/os.h
@@ -85,7 +85,7 @@ typedef enum {
FARPROC ap_load_dll_func(ap_dlltoken_e fnLib, char* fnName, int ordinal);
-PSECURITY_ATTRIBUTES GetNullACL();
+PSECURITY_ATTRIBUTES GetNullACL(void);
void CleanNullACL(void *sa);
int set_listeners_noninheritable(apr_pool_t *p);
diff --git a/os/win32/util_win32.c b/os/win32/util_win32.c
index ab96ff1136..3a4038a5d0 100644
--- a/os/win32/util_win32.c
+++ b/os/win32/util_win32.c
@@ -20,6 +20,7 @@
#include "httpd.h"
#include "http_log.h"
+#include "ap_mpm.h"
#include <stdarg.h>
#include <time.h>
@@ -105,7 +106,7 @@ FARPROC ap_load_dll_func(ap_dlltoken_e fnLib, char* fnName, int ordinal)
/* To share the semaphores with other processes, we need a NULL ACL
* Code from MS KB Q106387
*/
-PSECURITY_ATTRIBUTES GetNullACL()
+PSECURITY_ATTRIBUTES GetNullACL(void)
{
PSECURITY_DESCRIPTOR pSD;
PSECURITY_ATTRIBUTES sa;
diff --git a/server/mpm/winnt/child.c b/server/mpm/winnt/child.c
index 5ad9e728a0..82cec95fb9 100644
--- a/server/mpm/winnt/child.c
+++ b/server/mpm/winnt/child.c
@@ -39,6 +39,8 @@
#include <malloc.h>
#include "apr_atomic.h"
+#include <process.h>
+
#ifdef __MINGW32__
#include <mswsock.h>
#endif
@@ -67,8 +69,8 @@ static apr_thread_mutex_t *child_lock;
static apr_thread_mutex_t *qlock;
static PCOMP_CONTEXT qhead = NULL;
static PCOMP_CONTEXT qtail = NULL;
-static int num_completion_contexts = 0;
-static int max_num_completion_contexts = 0;
+static apr_uint32_t num_completion_contexts = 0;
+static apr_uint32_t max_num_completion_contexts = 0;
static HANDLE ThreadDispatchIOCP = NULL;
static HANDLE qwait_event = NULL;
@@ -354,7 +356,7 @@ static unsigned int __stdcall win9x_accept(void * dummy)
apr_os_sock_get(&nsd, lr->sd);
FD_SET(nsd, &listenfds);
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
- "Child %d: Listening on port %d.", my_pid, lr->bind_addr->port);
+ "Child %lu: Listening on port %d.", my_pid, lr->bind_addr->port);
}
}
@@ -514,7 +516,7 @@ static unsigned int __stdcall winnt_accept(void *lr_)
#endif
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
- "Child %d: Starting thread to listen on port %d.", my_pid, lr->bind_addr->port);
+ "Child %lu: Starting thread to listen on port %d.", my_pid, lr->bind_addr->port);
while (!shutdown_in_progress) {
if (!context) {
context = mpm_get_completion_context();
@@ -582,7 +584,7 @@ static unsigned int __stdcall winnt_accept(void *lr_)
context->accept_socket = INVALID_SOCKET;
if (err_count > MAX_ACCEPTEX_ERR_COUNT) {
ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf,
- "Child %d: Encountered too many errors accepting client connections. "
+ "Child %lu: Encountered too many errors accepting client connections. "
"Possible causes: dynamic address renewal, or incompatible VPN or firewall software. "
"Try using the Win32DisableAcceptEx directive.", my_pid);
err_count = 0;
@@ -594,7 +596,7 @@ static unsigned int __stdcall winnt_accept(void *lr_)
++err_count;
if (err_count > MAX_ACCEPTEX_ERR_COUNT) {
ap_log_error(APLOG_MARK,APLOG_ERR, rv, ap_server_conf,
- "Child %d: Encountered too many errors accepting client connections. "
+ "Child %lu: Encountered too many errors accepting client connections. "
"Possible causes: Unknown. "
"Try using the Win32DisableAcceptEx directive.", my_pid);
err_count = 0;
@@ -680,7 +682,7 @@ static unsigned int __stdcall winnt_accept(void *lr_)
SetEvent(exit_event);
}
ap_log_error(APLOG_MARK, APLOG_INFO, APR_SUCCESS, ap_server_conf,
- "Child %d: Accept thread exiting.", my_pid);
+ "Child %lu: Accept thread exiting.", my_pid);
return 0;
}
@@ -709,7 +711,7 @@ static PCOMP_CONTEXT winnt_get_connection(PCOMP_CONTEXT context)
if (!rc) {
rc = apr_get_os_error();
ap_log_error(APLOG_MARK,APLOG_DEBUG, rc, ap_server_conf,
- "Child %d: GetQueuedComplationStatus returned %d", my_pid, rc);
+ "Child %lu: GetQueuedComplationStatus returned %d", my_pid, rc);
continue;
}
@@ -826,9 +828,9 @@ static void cleanup_thread(HANDLE *handles, int *thread_cnt, int thread_to_clean
* monitors the child process for maintenance and shutdown
* events.
*/
-static void create_listener_thread()
+static void create_listener_thread(void)
{
- int tid;
+ unsigned tid;
int num_listeners = 0;
if (!use_acceptex) {
_beginthreadex(NULL, 0, win9x_accept,
@@ -874,7 +876,7 @@ void child_main(apr_pool_t *pconf)
int watch_thread;
int time_remains;
int cld;
- int tid;
+ unsigned tid;
int rv;
int i;
@@ -888,7 +890,7 @@ void child_main(apr_pool_t *pconf)
max_requests_per_child_event = CreateEvent(NULL, TRUE, FALSE, NULL);
if (!max_requests_per_child_event) {
ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_os_error(), ap_server_conf,
- "Child %d: Failed to create a max_requests event.", my_pid);
+ "Child %lu: Failed to create a max_requests event.", my_pid);
exit(APEXIT_CHILDINIT);
}
child_events[0] = exit_event;
@@ -906,11 +908,11 @@ void child_main(apr_pool_t *pconf)
status = apr_proc_mutex_lock(start_mutex);
if (status != APR_SUCCESS) {
ap_log_error(APLOG_MARK,APLOG_ERR, status, ap_server_conf,
- "Child %d: Failed to acquire the start_mutex. Process will exit.", my_pid);
+ "Child %lu: Failed to acquire the start_mutex. Process will exit.", my_pid);
exit(APEXIT_CHILDINIT);
}
ap_log_error(APLOG_MARK,APLOG_NOTICE, APR_SUCCESS, ap_server_conf,
- "Child %d: Acquired the start mutex.", my_pid);
+ "Child %lu: Acquired the start mutex.", my_pid);
/*
* Create the worker thread dispatch IOCompletionPort
@@ -926,7 +928,7 @@ void child_main(apr_pool_t *pconf)
qwait_event = CreateEvent(NULL, TRUE, FALSE, NULL);
if (!qwait_event) {
ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_os_error(), ap_server_conf,
- "Child %d: Failed to create a qwait event.", my_pid);
+ "Child %lu: Failed to create a qwait event.", my_pid);
exit(APEXIT_CHILDINIT);
}
}
@@ -935,7 +937,7 @@ void child_main(apr_pool_t *pconf)
* Create the pool of worker threads
*/
ap_log_error(APLOG_MARK,APLOG_NOTICE, APR_SUCCESS, ap_server_conf,
- "Child %d: Starting %d worker threads.", my_pid, ap_threads_per_child);
+ "Child %lu: Starting %d worker threads.", my_pid, ap_threads_per_child);
child_handles = (HANDLE) apr_pcalloc(pchild, ap_threads_per_child * sizeof(HANDLE));
apr_thread_mutex_create(&child_lock, APR_THREAD_MUTEX_DEFAULT, pchild);
@@ -951,7 +953,7 @@ void child_main(apr_pool_t *pconf)
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,
- "Child %d: _beginthreadex failed. Unable to create all worker threads. "
+ "Child %lu: _beginthreadex failed. Unable to create all worker threads. "
"Created %d of the %d threads requested with the ThreadsPerChild configuration directive.",
my_pid, threads_created, ap_threads_per_child);
ap_signal_parent(SIGNAL_PARENT_SHUTDOWN);
@@ -1023,13 +1025,13 @@ void child_main(apr_pool_t *pconf)
if (rv == WAIT_FAILED) {
/* Something serious is wrong */
ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_os_error(), ap_server_conf,
- "Child %d: WAIT_FAILED -- shutting down server", my_pid);
+ "Child %lu: WAIT_FAILED -- shutting down server", my_pid);
break;
}
else if (cld == 0) {
/* Exit event was signaled */
ap_log_error(APLOG_MARK, APLOG_NOTICE, APR_SUCCESS, ap_server_conf,
- "Child %d: Exit event signaled. Child process is ending.", my_pid);
+ "Child %lu: Exit event signaled. Child process is ending.", my_pid);
break;
}
else {
@@ -1037,7 +1039,7 @@ void child_main(apr_pool_t *pconf)
* Signal the parent to restart
*/
ap_log_error(APLOG_MARK, APLOG_NOTICE, APR_SUCCESS, ap_server_conf,
- "Child %d: Process exiting because it reached "
+ "Child %lu: Process exiting because it reached "
"MaxRequestsPerChild. Signaling the parent to "
"restart a new child process.", my_pid);
ap_signal_parent(SIGNAL_PARENT_RESTART);
@@ -1082,11 +1084,11 @@ void child_main(apr_pool_t *pconf)
rv = apr_proc_mutex_unlock(start_mutex);
if (rv == APR_SUCCESS) {
ap_log_error(APLOG_MARK,APLOG_NOTICE, rv, ap_server_conf,
- "Child %d: Released the start mutex", my_pid);
+ "Child %lu: Released the start mutex", my_pid);
}
else {
ap_log_error(APLOG_MARK,APLOG_ERR, rv, ap_server_conf,
- "Child %d: Failure releasing the start mutex", my_pid);
+ "Child %lu: Failure releasing the start mutex", my_pid);
}
/* Shutdown the worker threads */
@@ -1099,7 +1101,7 @@ void child_main(apr_pool_t *pconf)
/* Post worker threads blocked on the ThreadDispatch IOCompletion port */
while (g_blocked_threads > 0) {
ap_log_error(APLOG_MARK,APLOG_INFO, APR_SUCCESS, ap_server_conf,
- "Child %d: %d threads blocked on the completion port", my_pid, g_blocked_threads);
+ "Child %lu: %d threads blocked on the completion port", my_pid, g_blocked_threads);
for (i=g_blocked_threads; i > 0; i--) {
PostQueuedCompletionStatus(ThreadDispatchIOCP, 0, IOCP_SHUTDOWN, NULL);
}
@@ -1139,7 +1141,7 @@ void child_main(apr_pool_t *pconf)
if ((time_remains % 30000) == 0) {
ap_log_error(APLOG_MARK, APLOG_NOTICE, APR_SUCCESS,
ap_server_conf,
- "Child %d: Waiting %d more seconds "
+ "Child %lu: Waiting %d more seconds "
"for %d worker threads to finish.",
my_pid, time_remains / 1000, threads_created);
}
@@ -1183,7 +1185,7 @@ void child_main(apr_pool_t *pconf)
/* Kill remaining threads off the hard way */
if (threads_created) {
ap_log_error(APLOG_MARK,APLOG_NOTICE, APR_SUCCESS, ap_server_conf,
- "Child %d: Terminating %d threads that failed to exit.",
+ "Child %lu: Terminating %d threads that failed to exit.",
my_pid, threads_created);
}
for (i = 0; i < threads_created; i++) {
@@ -1198,7 +1200,7 @@ void child_main(apr_pool_t *pconf)
}
}
ap_log_error(APLOG_MARK,APLOG_NOTICE, APR_SUCCESS, ap_server_conf,
- "Child %d: All worker threads have exited.", my_pid);
+ "Child %lu: All worker threads have exited.", my_pid);
CloseHandle(allowed_globals.jobsemaphore);
apr_thread_mutex_destroy(allowed_globals.jobmutex);
diff --git a/server/mpm/winnt/mpm_winnt.c b/server/mpm/winnt/mpm_winnt.c
index 797c023275..d95131751d 100644
--- a/server/mpm/winnt/mpm_winnt.c
+++ b/server/mpm/winnt/mpm_winnt.c
@@ -102,30 +102,11 @@ extern HANDLE exit_event;
*/
static HANDLE pipe;
-/* Stub functions until this MPM supports the connection status API */
-
-AP_DECLARE(void) ap_update_connection_status(long conn_id, const char *key, \
- const char *value)
-{
- /* NOP */
-}
-
-AP_DECLARE(void) ap_reset_connection_status(long conn_id)
-{
- /* NOP */
-}
-
-AP_DECLARE(apr_array_header_t *) ap_get_status_table(apr_pool_t *p)
-{
- /* NOP */
- return NULL;
-}
-
/*
* Command processors
*/
-static const char *set_threads_per_child (cmd_parms *cmd, void *dummy, char *arg)
+static const char *set_threads_per_child (cmd_parms *cmd, void *dummy, const char *arg)
{
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
if (err != NULL) {
@@ -191,7 +172,7 @@ static const char *set_thread_limit (cmd_parms *cmd, void *dummy, const char *ar
}
return NULL;
}
-static const char *set_disable_acceptex(cmd_parms *cmd, void *dummy, char *arg)
+static const char *set_disable_acceptex(cmd_parms *cmd, void *dummy)
{
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
if (err != NULL) {
@@ -340,9 +321,9 @@ AP_DECLARE(void) ap_signal_parent(ap_signal_parent_e type)
* start mutex [signal from the parent to begin accept()]
* scoreboard shm handle [to recreate the ap_scoreboard]
*/
-void get_handles_from_parent(server_rec *s, HANDLE *child_exit_event,
- apr_proc_mutex_t **child_start_mutex,
- apr_shm_t **scoreboard_shm)
+static void get_handles_from_parent(server_rec *s, HANDLE *child_exit_event,
+ apr_proc_mutex_t **child_start_mutex,
+ apr_shm_t **scoreboard_shm)
{
HANDLE hScore;
HANDLE ready_event;
@@ -358,7 +339,7 @@ void get_handles_from_parent(server_rec *s, HANDLE *child_exit_event,
&BytesRead, (LPOVERLAPPED) NULL)
|| (BytesRead != sizeof(HANDLE))) {
ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_os_error(), ap_server_conf,
- "Child %d: Unable to retrieve the ready event from the parent", my_pid);
+ "Child %lu: Unable to retrieve the ready event from the parent", my_pid);
exit(APEXIT_CHILDINIT);
}
@@ -369,7 +350,7 @@ void get_handles_from_parent(server_rec *s, HANDLE *child_exit_event,
&BytesRead, (LPOVERLAPPED) NULL)
|| (BytesRead != sizeof(HANDLE))) {
ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_os_error(), ap_server_conf,
- "Child %d: Unable to retrieve the exit event from the parent", my_pid);
+ "Child %lu: Unable to retrieve the exit event from the parent", my_pid);
exit(APEXIT_CHILDINIT);
}
@@ -377,14 +358,14 @@ void get_handles_from_parent(server_rec *s, HANDLE *child_exit_event,
&BytesRead, (LPOVERLAPPED) NULL)
|| (BytesRead != sizeof(os_start))) {
ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_os_error(), ap_server_conf,
- "Child %d: Unable to retrieve the start_mutex from the parent", my_pid);
+ "Child %lu: Unable to retrieve the start_mutex from the parent", my_pid);
exit(APEXIT_CHILDINIT);
}
*child_start_mutex = NULL;
if ((rv = apr_os_proc_mutex_put(child_start_mutex, &os_start, s->process->pool))
!= APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_CRIT, rv, ap_server_conf,
- "Child %d: Unable to access the start_mutex from the parent", my_pid);
+ "Child %lu: Unable to access the start_mutex from the parent", my_pid);
exit(APEXIT_CHILDINIT);
}
@@ -392,21 +373,21 @@ void get_handles_from_parent(server_rec *s, HANDLE *child_exit_event,
&BytesRead, (LPOVERLAPPED) NULL)
|| (BytesRead != sizeof(hScore))) {
ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_os_error(), ap_server_conf,
- "Child %d: Unable to retrieve the scoreboard from the parent", my_pid);
+ "Child %lu: Unable to retrieve the scoreboard from the parent", my_pid);
exit(APEXIT_CHILDINIT);
}
*scoreboard_shm = NULL;
if ((rv = apr_os_shm_put(scoreboard_shm, &hScore, s->process->pool))
!= APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_CRIT, rv, ap_server_conf,
- "Child %d: Unable to access the scoreboard from the parent", my_pid);
+ "Child %lu: Unable to access the scoreboard from the parent", my_pid);
exit(APEXIT_CHILDINIT);
}
rv = ap_reopen_scoreboard(s->process->pool, scoreboard_shm, 1);
if (rv || !(sb_shared = apr_shm_baseaddr_get(*scoreboard_shm))) {
ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
- "Child %d: Unable to reopen the scoreboard from the parent", my_pid);
+ "Child %lu: Unable to reopen the scoreboard from the parent", my_pid);
exit(APEXIT_CHILDINIT);
}
/* We must 'initialize' the scoreboard to relink all the
@@ -415,7 +396,7 @@ void get_handles_from_parent(server_rec *s, HANDLE *child_exit_event,
ap_init_scoreboard(sb_shared);
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf,
- "Child %d: Retrieved our scoreboard from the parent.", my_pid);
+ "Child %lu: Retrieved our scoreboard from the parent.", my_pid);
}
@@ -505,7 +486,7 @@ static int send_handles_to_child(apr_pool_t *p,
* exclusively in the child process, receives them from the parent and
* makes them availeble in the child.
*/
-void get_listeners_from_parent(server_rec *s)
+static void get_listeners_from_parent(server_rec *s)
{
WSAPROTOCOL_INFO WSAProtocolInfo;
ap_listen_rec *lr;
@@ -539,7 +520,7 @@ void get_listeners_from_parent(server_rec *s)
&WSAProtocolInfo, 0, 0);
if (nsd == INVALID_SOCKET) {
ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_netos_error(), ap_server_conf,
- "Child %d: setup_inherited_listeners(), WSASocket failed to open the inherited socket.", my_pid);
+ "Child %lu: setup_inherited_listeners(), WSASocket failed to open the inherited socket.", my_pid);
exit(APEXIT_CHILDINIT);
}
@@ -571,7 +552,7 @@ void get_listeners_from_parent(server_rec *s)
}
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf,
- "Child %d: retrieved %d listeners from parent", my_pid, lcnt);
+ "Child %lu: retrieved %d listeners from parent", my_pid, lcnt);
}
@@ -591,14 +572,14 @@ static int send_listeners_to_child(apr_pool_t *p, DWORD dwProcessId,
for (lr = ap_listeners; lr; lr = lr->next, ++lcnt) {
apr_os_sock_t nsd;
lpWSAProtocolInfo = apr_pcalloc(p, sizeof(WSAPROTOCOL_INFO));
- apr_os_sock_get(&nsd,lr->sd);
+ apr_os_sock_get(&nsd, lr->sd);
ap_log_error(APLOG_MARK, APLOG_INFO, APR_SUCCESS, ap_server_conf,
- "Parent: Duplicating socket %d and sending it to child process %d",
+ "Parent: Duplicating socket %d and sending it to child process %lu",
nsd, dwProcessId);
if (WSADuplicateSocket(nsd, dwProcessId,
lpWSAProtocolInfo) == SOCKET_ERROR) {
ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_netos_error(), ap_server_conf,
- "Parent: WSADuplicateSocket failed for socket %d. Check the FAQ.", lr->sd );
+ "Parent: WSADuplicateSocket failed for socket %d. Check the FAQ.", nsd);
return -1;
}
@@ -606,13 +587,13 @@ static int send_listeners_to_child(apr_pool_t *p, DWORD dwProcessId,
sizeof(WSAPROTOCOL_INFO), &BytesWritten))
!= APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_CRIT, rv, ap_server_conf,
- "Parent: Unable to write duplicated socket %d to the child.", lr->sd );
+ "Parent: Unable to write duplicated socket %d to the child.", nsd);
return -1;
}
}
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf,
- "Parent: Sent %d listeners to child %d", lcnt, dwProcessId);
+ "Parent: Sent %d listeners to child %lu", lcnt, dwProcessId);
return 0;
}
@@ -731,11 +712,12 @@ static int create_process(apr_pool_t *p, HANDLE *child_proc, HANDLE *child_exit_
}
env = apr_palloc(ptemp, (envc + 2) * sizeof (char*));
memcpy(env, _environ, envc * sizeof (char*));
- apr_snprintf(pidbuf, sizeof(pidbuf), "AP_PARENT_PID=%i", parent_pid);
+ apr_snprintf(pidbuf, sizeof(pidbuf), "AP_PARENT_PID=%lu", parent_pid);
env[envc] = pidbuf;
env[envc + 1] = NULL;
- rv = apr_proc_create(&new_child, cmd, args, env, attr, ptemp);
+ rv = apr_proc_create(&new_child, cmd, (const char * const *)args,
+ (const char * const *)env, attr, ptemp);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_CRIT, rv, ap_server_conf,
"Parent: Failed to create the child process.");
@@ -928,7 +910,7 @@ static int master_main(server_rec *s, HANDLE shutdown_event, HANDLE restart_even
}
if (SetEvent(child_exit_event) == 0) {
ap_log_error(APLOG_MARK, APLOG_ERR, apr_get_os_error(), s,
- "Parent: SetEvent for child process %d failed.",
+ "Parent: SetEvent for child process %pp failed.",
event_handles[CHILD_HANDLE]);
}
/* Don't wait to verify that the child process really exits,
@@ -948,14 +930,14 @@ static int master_main(server_rec *s, HANDLE shutdown_event, HANDLE restart_even
|| exitcode == APEXIT_CHILDINIT
|| exitcode == APEXIT_INIT) {
ap_log_error(APLOG_MARK, APLOG_CRIT, 0, ap_server_conf,
- "Parent: child process exited with status %u -- Aborting.", exitcode);
+ "Parent: child process exited with status %lu -- Aborting.", exitcode);
shutdown_pending = 1;
}
else {
int i;
restart_pending = 1;
ap_log_error(APLOG_MARK, APLOG_NOTICE, APR_SUCCESS, ap_server_conf,
- "Parent: child process exited with status %u -- Restarting.", exitcode);
+ "Parent: child process exited with status %lu -- Restarting.", exitcode);
for (i = 0; i < ap_threads_per_child; i++) {
ap_update_child_status_from_indexes(0, i, SERVER_DEAD, NULL);
}
@@ -987,7 +969,8 @@ die_now:
/* Signal the child processes to exit */
if (SetEvent(child_exit_event) == 0) {
ap_log_error(APLOG_MARK,APLOG_ERR, apr_get_os_error(), ap_server_conf,
- "Parent: SetEvent for child process %d failed", event_handles[CHILD_HANDLE]);
+ "Parent: SetEvent for child process %pp failed",
+ event_handles[CHILD_HANDLE]);
}
if (event_handles[CHILD_HANDLE]) {
rv = WaitForSingleObject(event_handles[CHILD_HANDLE], timeout);
@@ -999,7 +982,8 @@ die_now:
}
else {
ap_log_error(APLOG_MARK,APLOG_NOTICE, APR_SUCCESS, ap_server_conf,
- "Parent: Forcing termination of child process %d ", event_handles[CHILD_HANDLE]);
+ "Parent: Forcing termination of child process %pp",
+ event_handles[CHILD_HANDLE]);
TerminateProcess(event_handles[CHILD_HANDLE], 1);
CloseHandle(event_handles[CHILD_HANDLE]);
event_handles[CHILD_HANDLE] = NULL;
@@ -1074,9 +1058,9 @@ static apr_status_t service_set = SERVICE_UNSET;
static apr_status_t service_to_start_success;
static int inst_argc;
static const char * const *inst_argv;
-static char *service_name = NULL;
+static const char *service_name = NULL;
-void winnt_rewrite_args(process_rec *process)
+static void winnt_rewrite_args(process_rec *process)
{
/* Handle the following SCM aspects in this phase:
*
@@ -1216,7 +1200,7 @@ void winnt_rewrite_args(process_rec *process)
optbuf[0] = '-';
optbuf[2] = '\0';
- apr_getopt_init(&opt, process->pool, process->argc, (char**) process->argv);
+ apr_getopt_init(&opt, process->pool, process->argc, process->argv);
opt->errfn = NULL;
while ((rv = apr_getopt(opt, "wn:k:" AP_SERVER_BASEARGS,
optbuf + 1, &optarg)) == APR_SUCCESS) {
@@ -1540,7 +1524,7 @@ static int winnt_post_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *pt
* across a restart
*/
PSECURITY_ATTRIBUTES sa = GetNullACL(); /* returns NULL if invalid (Win95?) */
- setup_signal_names(apr_psprintf(pconf,"ap%d", parent_pid));
+ setup_signal_names(apr_psprintf(pconf,"ap%lu", parent_pid));
ap_log_pid(pconf, ap_pid_fname);
@@ -1652,7 +1636,7 @@ static void winnt_child_init(apr_pool_t *pchild, struct server_rec *s)
{
apr_status_t rv;
- setup_signal_names(apr_psprintf(pchild,"ap%d", parent_pid));
+ setup_signal_names(apr_psprintf(pchild,"ap%lu", parent_pid));
/* This is a child process, not in single process mode */
if (!one_process) {
@@ -1674,7 +1658,7 @@ static void winnt_child_init(apr_pool_t *pchild, struct server_rec *s)
APR_LOCK_DEFAULT, s->process->pool);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK,APLOG_ERR, rv, ap_server_conf,
- "%s child %d: Unable to init the start_mutex.",
+ "%s child %lu: Unable to init the start_mutex.",
service_name, my_pid);
exit(APEXIT_CHILDINIT);
}
@@ -1717,12 +1701,12 @@ AP_DECLARE(int) ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s )
/* The child process or in one_process (debug) mode
*/
ap_log_error(APLOG_MARK, APLOG_NOTICE, APR_SUCCESS, ap_server_conf,
- "Child %d: Child process is running", my_pid);
+ "Child %lu: Child process is running", my_pid);
child_main(pconf);
ap_log_error(APLOG_MARK, APLOG_NOTICE, APR_SUCCESS, ap_server_conf,
- "Child %d: Child process is exiting", my_pid);
+ "Child %lu: Child process is exiting", my_pid);
return 1;
}
else
diff --git a/server/mpm/winnt/mpm_winnt.h b/server/mpm/winnt/mpm_winnt.h
index dfe0e51872..e21a6f4329 100644
--- a/server/mpm/winnt/mpm_winnt.h
+++ b/server/mpm/winnt/mpm_winnt.h
@@ -62,7 +62,7 @@ void mpm_start_child_console_handler(void);
/* From nt_eventlog.c: */
-void mpm_nt_eventlog_stderr_open(char *display_name, apr_pool_t *p);
+void mpm_nt_eventlog_stderr_open(const char *display_name, apr_pool_t *p);
void mpm_nt_eventlog_stderr_flush(void);
/* From winnt.c: */
@@ -126,5 +126,9 @@ PCOMP_CONTEXT mpm_get_completion_context(void);
void mpm_recycle_completion_context(PCOMP_CONTEXT pCompContext);
apr_status_t mpm_post_completion_context(PCOMP_CONTEXT pCompContext, io_state_e state);
void hold_console_open_on_error(void);
+
+/* From child.c: */
+void child_main(apr_pool_t *pconf);
+
#endif /* APACHE_MPM_WINNT_H */
/** @} */
diff --git a/server/mpm/winnt/nt_eventlog.c b/server/mpm/winnt/nt_eventlog.c
index baa1a88bed..d8d758bb76 100644
--- a/server/mpm/winnt/nt_eventlog.c
+++ b/server/mpm/winnt/nt_eventlog.c
@@ -24,7 +24,7 @@
#include "apr_portable.h"
#include "ap_regkey.h"
-static char *display_name = NULL;
+static const char *display_name = NULL;
static HANDLE stderr_thread = NULL;
static HANDLE stderr_ready;
@@ -101,7 +101,7 @@ static DWORD WINAPI service_stderr_thread(LPVOID hPipe)
if ((errres = GetLastError()) != ERROR_BROKEN_PIPE) {
apr_snprintf(errbuf, sizeof(errbuf),
- "Win32 error %d reading stderr pipe stream\r\n",
+ "Win32 error %lu reading stderr pipe stream\r\n",
GetLastError());
ReportEvent(hEventSource, EVENTLOG_ERROR_TYPE, 0,
@@ -131,13 +131,11 @@ void mpm_nt_eventlog_stderr_flush(void)
}
-void mpm_nt_eventlog_stderr_open(char *argv0, apr_pool_t *p)
+void mpm_nt_eventlog_stderr_open(const char *argv0, apr_pool_t *p)
{
SECURITY_ATTRIBUTES sa;
- HANDLE hProc = GetCurrentProcess();
HANDLE hPipeRead = NULL;
HANDLE hPipeWrite = NULL;
- HANDLE hDup = NULL;
DWORD threadid;
apr_file_t *eventlog_file;
apr_file_t *stderr_file;
diff --git a/server/mpm/winnt/service.c b/server/mpm/winnt/service.c
index 6c5d87b48f..d8f40b4806 100644
--- a/server/mpm/winnt/service.c
+++ b/server/mpm/winnt/service.c
@@ -34,6 +34,7 @@
#endif
#undef _WINUSER_
#include <winuser.h>
+#include <time.h>
static char *mpm_service_name = NULL;
static char *mpm_display_name = NULL;
@@ -52,42 +53,6 @@ static struct
static int ReportStatusToSCMgr(int currentState, int exitCode, int waitHint);
-#define PRODREGKEY "SOFTWARE\\" AP_SERVER_BASEVENDOR "\\" \
- AP_SERVER_BASEPRODUCT "\\" AP_SERVER_BASEREVISION
-
-/*
- * Get the server root from the registry into 'dir' which is
- * size bytes long. Returns 0 if the server root was found
- * or if the serverroot key does not exist (in which case
- * dir will contain an empty string), or -1 if there was
- * an error getting the key.
- */
-apr_status_t ap_registry_get_server_root(apr_pool_t *p, char **buf)
-{
- apr_status_t rv;
- ap_regkey_t *key;
-
- if ((rv = ap_regkey_open(&key, AP_REGKEY_LOCAL_MACHINE, PRODREGKEY,
- APR_READ, p)) == APR_SUCCESS) {
- rv = ap_regkey_value_get(buf, key, "ServerRoot", p);
- ap_regkey_close(key);
- if (rv == APR_SUCCESS)
- return rv;
- }
-
- if ((rv = ap_regkey_open(&key, AP_REGKEY_CURRENT_USER, PRODREGKEY,
- APR_READ, p)) == APR_SUCCESS) {
- rv = ap_regkey_value_get(buf, key, "ServerRoot", p);
- ap_regkey_close(key);
- if (rv == APR_SUCCESS)
- return rv;
- }
-
- *buf = NULL;
- return rv;
-}
-
-
/* The service configuration's is stored under the following trees:
*
* HKLM\System\CurrentControlSet\Services\[service name]
@@ -157,7 +122,8 @@ void hold_console_open_on_error(void)
return;
}
remains = ((start + 30) - time(NULL));
- sprintf (count, "%d...", remains);
+ sprintf(count, "%d...",
+ (int)remains); /* 30 or less, so can't overflow int */
if (!SetConsoleCursorPosition(hConErr, coninfo.dwCursorPosition))
return;
if (!WriteConsole(hConErr, count, (DWORD)strlen(count), &result, NULL)
@@ -427,7 +393,6 @@ static void set_service_description(void)
{
const char *full_description;
SC_HANDLE schSCManager;
- BOOL ret = 0;
/* Nothing to do if we are a console
*/
@@ -565,7 +530,7 @@ static void __stdcall service_nt_main_fn(DWORD argc, LPTSTR *argv)
}
-DWORD WINAPI service_nt_dispatch_thread(LPVOID nada)
+static DWORD WINAPI service_nt_dispatch_thread(LPVOID nada)
{
apr_status_t rv = APR_SUCCESS;
@@ -675,7 +640,7 @@ apr_status_t mpm_merge_service_args(apr_pool_t *p,
}
-void service_stopped(void)
+static void service_stopped(void)
{
/* Still have a thread & window to clean up, so signal now */
if (globdat.service_thread)
@@ -1075,7 +1040,7 @@ apr_status_t mpm_service_start(apr_pool_t *ptemp, int argc,
if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT)
{
- char **start_argv;
+ const CHAR **start_argv;
SC_HANDLE schService;
SC_HANDLE schSCManager;
diff --git a/server/util_script.c b/server/util_script.c
index 6d6f3f4a63..1300951ba6 100644
--- a/server/util_script.c
+++ b/server/util_script.c
@@ -187,16 +187,16 @@ AP_DECLARE(void) ap_add_common_vars(request_rec *r)
apr_table_addn(e, "PATH", apr_pstrdup(r->pool, env_path));
#ifdef WIN32
- if (env_temp = getenv("SystemRoot")) {
+ if ((env_temp = getenv("SystemRoot")) != NULL) {
apr_table_addn(e, "SystemRoot", env_temp);
}
- if (env_temp = getenv("COMSPEC")) {
+ if ((env_temp = getenv("COMSPEC")) != NULL) {
apr_table_addn(e, "COMSPEC", env_temp);
}
- if (env_temp = getenv("PATHEXT")) {
+ if ((env_temp = getenv("PATHEXT")) != NULL) {
apr_table_addn(e, "PATHEXT", env_temp);
}
- if (env_temp = getenv("WINDIR")) {
+ if ((env_temp = getenv("WINDIR")) != NULL) {
apr_table_addn(e, "WINDIR", env_temp);
}
#endif