1 /* ====================================================================
2 * The Apache Software License, Version 1.1
4 * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
19 * 3. The end-user documentation included with the redistribution,
20 * if any, must include the following acknowledgment:
21 * "This product includes software developed by the
22 * Apache Software Foundation (http://www.apache.org/)."
23 * Alternately, this acknowledgment may appear in the software itself,
24 * if and wherever such third-party acknowledgments normally appear.
26 * 4. The names "Apache" and "Apache Software Foundation" must
27 * not be used to endorse or promote products derived from this
28 * software without prior written permission. For written
29 * permission, please contact apache@apache.org.
31 * 5. Products derived from this software may not be called "Apache",
32 * nor may "Apache" appear in their name, without prior written
33 * permission of the Apache Software Foundation.
35 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
36 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
37 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
42 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
45 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47 * ====================================================================
49 * This software consists of voluntary contributions made by many
50 * individuals on behalf of the Apache Software Foundation. For more
51 * information on the Apache Software Foundation, please see
52 * <http://www.apache.org/>.
54 * Portions of this software are based upon public domain software
55 * originally written at the National Center for Supercomputing Applications,
56 * University of Illinois, Urbana-Champaign.
59 #ifndef APACHE_MPM_WINNT_H
60 #define APACHE_MPM_WINNT_H
62 #include "ap_listen.h"
64 /* From registry.c: */
66 apr_status_t ap_registry_create_key(const char *key);
67 apr_status_t ap_registry_delete_key(const char *key);
69 apr_status_t ap_registry_store_value(const char *key, const char *name,
71 apr_status_t ap_registry_get_value(apr_pool_t *p, const char *key,
72 const char *name, char **ppValue);
73 apr_status_t ap_registry_store_array(apr_pool_t *p, const char *key,
74 const char *name, int nelts,
75 char const* const* elts);
76 apr_status_t ap_registry_get_array(apr_pool_t *p, const char *key,
78 apr_array_header_t **parray);
79 apr_status_t ap_registry_delete_value(const char *key, const char *name);
84 #define SERVICE_APACHE_RESTART 128
86 #ifndef AP_DEFAULT_SERVICE_NAME
87 #define AP_DEFAULT_SERVICE_NAME "Apache2"
90 #define SERVICECONFIG9X "Software\\Microsoft\\Windows\\CurrentVersion\\RunServices"
91 #define SERVICECONFIG "System\\CurrentControlSet\\Services\\%s"
92 #define SERVICEPARAMS "System\\CurrentControlSet\\Services\\%s\\Parameters"
94 apr_status_t mpm_service_set_name(apr_pool_t *p, const char **display_name,
95 const char *set_name);
96 apr_status_t mpm_merge_service_args(apr_pool_t *p, apr_array_header_t *args,
99 apr_status_t mpm_service_to_start(const char **display_name, apr_pool_t *p);
100 apr_status_t mpm_service_started(void);
101 apr_status_t mpm_service_install(apr_pool_t *ptemp, int argc,
102 char const* const* argv, int reconfig);
103 apr_status_t mpm_service_uninstall(void);
105 apr_status_t mpm_service_start(apr_pool_t *ptemp, int argc,
106 char const* const* argv);
108 void mpm_signal_service(apr_pool_t *ptemp, int signal);
110 void mpm_service_stopping(void);
112 void mpm_start_console_handler(void);
113 void mpm_start_child_console_handler(void);
115 /* From nt_eventlog.c: */
117 void mpm_nt_eventlog_stderr_open(char *display_name, apr_pool_t *p);
118 void mpm_nt_eventlog_stderr_flush(void);
122 extern OSVERSIONINFO osver;
123 extern void clean_child_exit(int);
125 void setup_signal_names(char *prefix);
128 SIGNAL_PARENT_SHUTDOWN,
129 SIGNAL_PARENT_RESTART,
130 SIGNAL_PARENT_RESTART_GRACEFUL
131 } ap_signal_parent_e;
132 AP_DECLARE(void) ap_signal_parent(ap_signal_parent_e type);
134 /* This code is stolen from the apr_private.h and misc/win32/misc.c
135 * Please see those sources for detailed documentation.
138 DLL_WINBASEAPI = 0, // kernel32 From WinBase.h
139 DLL_WINADVAPI = 1, // advapi32 From WinBase.h
140 DLL_WINSOCKAPI = 2, // mswsock From WinSock.h
141 DLL_WINSOCK2API = 3, // ws2_32 From WinSock2.h
142 DLL_defined = 4 // must define as last idx_ + 1
145 FARPROC ap_load_dll_func(ap_dlltoken_e fnLib, char *fnName, int ordinal);
147 #define AP_DECLARE_LATE_DLL_FUNC(lib, rettype, calltype, fn, ord, args, names) \
148 typedef rettype (calltype *ap_winapi_fpt_##fn) args; \
149 static ap_winapi_fpt_##fn ap_winapi_pfn_##fn = NULL; \
150 __inline rettype ap_winapi_##fn args \
151 { if (!ap_winapi_pfn_##fn) \
152 ap_winapi_pfn_##fn = (ap_winapi_fpt_##fn) ap_load_dll_func(lib, #fn, ord); \
153 return (*(ap_winapi_pfn_##fn)) names; }; \
155 /* Win2K kernel only */
156 AP_DECLARE_LATE_DLL_FUNC(DLL_WINADVAPI, BOOL, WINAPI, ChangeServiceConfig2A, 0, (
160 (hService, dwInfoLevel, lpInfo));
161 #undef ChangeServiceConfig2
162 #define ChangeServiceConfig2 ap_winapi_ChangeServiceConfig2A
164 /* WinNT kernel only */
165 AP_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, CancelIo, 0, (
168 #define CancelIo ap_winapi_CancelIo
170 /* Win9x kernel only */
171 AP_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, DWORD, WINAPI, RegisterServiceProcess, 0, (
174 (dwProcessId, dwType));
175 #define RegisterServiceProcess ap_winapi_RegisterServiceProcess
178 * The Windoes MPM uses a queue of completion contexts that it passes
179 * between the accept threads and the worker threads. Declare the
180 * functions to access the queue and the structures passed on the
181 * queue in the header file to enable modules to access them
182 * if necessary. The queue resides in the MPM.
184 #ifdef CONTAINING_RECORD
185 #undef CONTAINING_RECORD
187 #define CONTAINING_RECORD(address, type, field) ((type *)( \
189 (PCHAR)(&((type *)0)->field)))
190 #define PADDED_ADDR_SIZE sizeof(SOCKADDR_IN)+16
191 typedef struct CompContext {
192 struct CompContext *next;
193 OVERLAPPED Overlapped;
195 SOCKET accept_socket;
196 char buff[2*PADDED_ADDR_SIZE];
197 struct sockaddr *sa_server;
199 struct sockaddr *sa_client;
202 apr_bucket_alloc_t *ba;
203 } COMP_CONTEXT, *PCOMP_CONTEXT;
206 IOCP_CONNECTION_ACCEPTED = 1,
207 IOCP_WAIT_FOR_RECEIVE = 2,
208 IOCP_WAIT_FOR_TRANSMITFILE = 3,
212 AP_DECLARE(PCOMP_CONTEXT) mpm_get_completion_context(void);
213 AP_DECLARE(void) mpm_recycle_completion_context(PCOMP_CONTEXT pCompContext);
214 AP_DECLARE(apr_status_t) mpm_post_completion_context(PCOMP_CONTEXT pCompContext, io_state_e state);
215 #endif /* APACHE_MPM_WINNT_H */