1/* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements.  See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License.  You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/**
18 * @file  mpm_winnt.h
19 * @brief WinNT MPM specific
20 *
21 * @addtogroup APACHE_MPM_WINNT
22 * @{
23 */
24
25#ifndef APACHE_MPM_WINNT_H
26#define APACHE_MPM_WINNT_H
27
28#include "ap_listen.h"
29
30/* From service.c: */
31
32#define SERVICE_APACHE_RESTART 128
33
34#ifndef AP_DEFAULT_SERVICE_NAME
35#define AP_DEFAULT_SERVICE_NAME "Apache2.2"
36#endif
37
38#define SERVICECONFIG9X "Software\\Microsoft\\Windows\\CurrentVersion\\RunServices"
39#define SERVICECONFIG "System\\CurrentControlSet\\Services\\%s"
40#define SERVICEPARAMS "System\\CurrentControlSet\\Services\\%s\\Parameters"
41
42apr_status_t mpm_service_set_name(apr_pool_t *p, const char **display_name,
43                                                 const char *set_name);
44apr_status_t mpm_merge_service_args(apr_pool_t *p, apr_array_header_t *args,
45                                   int fixed_args);
46
47apr_status_t mpm_service_to_start(const char **display_name, apr_pool_t *p);
48apr_status_t mpm_service_started(void);
49apr_status_t mpm_service_install(apr_pool_t *ptemp, int argc,
50                                char const* const* argv, int reconfig);
51apr_status_t mpm_service_uninstall(void);
52
53apr_status_t mpm_service_start(apr_pool_t *ptemp, int argc,
54                              char const* const* argv);
55
56void mpm_signal_service(apr_pool_t *ptemp, int signal);
57
58void mpm_service_stopping(void);
59
60void mpm_start_console_handler(void);
61void mpm_start_child_console_handler(void);
62
63/* From nt_eventlog.c: */
64
65void mpm_nt_eventlog_stderr_open(const char *display_name, apr_pool_t *p);
66void mpm_nt_eventlog_stderr_flush(void);
67
68/* From winnt.c: */
69
70extern int use_acceptex;
71extern int winnt_mpm_state;
72extern OSVERSIONINFO osver;
73extern void clean_child_exit(int);
74
75void setup_signal_names(char *prefix);
76
77typedef enum {
78    SIGNAL_PARENT_SHUTDOWN,
79    SIGNAL_PARENT_RESTART,
80    SIGNAL_PARENT_RESTART_GRACEFUL
81} ap_signal_parent_e;
82AP_DECLARE(void) ap_signal_parent(ap_signal_parent_e type);
83
84/*
85 * The Windoes MPM uses a queue of completion contexts that it passes
86 * between the accept threads and the worker threads. Declare the
87 * functions to access the queue and the structures passed on the
88 * queue in the header file to enable modules to access them
89 * if necessary. The queue resides in the MPM.
90 */
91#ifdef CONTAINING_RECORD
92#undef CONTAINING_RECORD
93#endif
94#define CONTAINING_RECORD(address, type, field) ((type *)( \
95                                                  (PCHAR)(address) - \
96                                                  (PCHAR)(&((type *)0)->field)))
97#if APR_HAVE_IPV6
98#define PADDED_ADDR_SIZE (sizeof(SOCKADDR_IN6)+16)
99#else
100#define PADDED_ADDR_SIZE (sizeof(SOCKADDR_IN)+16)
101#endif
102
103typedef struct CompContext {
104    struct CompContext *next;
105    OVERLAPPED Overlapped;
106    apr_socket_t *sock;
107    SOCKET accept_socket;
108    char buff[2*PADDED_ADDR_SIZE];
109    struct sockaddr *sa_server;
110    int sa_server_len;
111    struct sockaddr *sa_client;
112    int sa_client_len;
113    apr_pool_t *ptrans;
114    apr_bucket_alloc_t *ba;
115    short socket_family;
116} COMP_CONTEXT, *PCOMP_CONTEXT;
117
118typedef enum {
119    IOCP_CONNECTION_ACCEPTED = 1,
120    IOCP_WAIT_FOR_RECEIVE = 2,
121    IOCP_WAIT_FOR_TRANSMITFILE = 3,
122    IOCP_SHUTDOWN = 4
123} io_state_e;
124
125PCOMP_CONTEXT mpm_get_completion_context(void);
126void          mpm_recycle_completion_context(PCOMP_CONTEXT pCompContext);
127apr_status_t  mpm_post_completion_context(PCOMP_CONTEXT pCompContext, io_state_e state);
128void hold_console_open_on_error(void);
129
130/* From child.c: */
131void child_main(apr_pool_t *pconf);
132
133#endif /* APACHE_MPM_WINNT_H */
134/** @} */
135