Main Page | Modules | Namespace List | Class List | Directories | File List | Class Members | File Members | Related Pages | Examples

mpm_common.h

Go to the documentation of this file.
00001 /* Licensed to the Apache Software Foundation (ASF) under one or more
00002  * contributor license agreements.  See the NOTICE file distributed with
00003  * this work for additional information regarding copyright ownership.
00004  * The ASF licenses this file to You under the Apache License, Version 2.0
00005  * (the "License"); you may not use this file except in compliance with
00006  * the License.  You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 /* The purpose of this file is to store the code that MOST mpm's will need
00018  * this does not mean a function only goes into this file if every MPM needs
00019  * it.  It means that if a function is needed by more than one MPM, and
00020  * future maintenance would be served by making the code common, then the
00021  * function belongs here.
00022  *
00023  * This is going in src/main because it is not platform specific, it is
00024  * specific to multi-process servers, but NOT to Unix.  Which is why it
00025  * does not belong in src/os/unix
00026  */
00027 
00037 #ifndef APACHE_MPM_COMMON_H
00038 #define APACHE_MPM_COMMON_H
00039 
00040 #include "ap_config.h"
00041 
00042 #if APR_HAVE_NETINET_TCP_H
00043 #include <netinet/tcp.h>    /* for TCP_NODELAY */
00044 #endif
00045 
00046 #include "mpm.h"
00047 
00048 #ifdef __cplusplus
00049 extern "C" {
00050 #endif
00051 
00052 /* The maximum length of the queue of pending connections, as defined
00053  * by listen(2).  Under some systems, it should be increased if you
00054  * are experiencing a heavy TCP SYN flood attack.
00055  *
00056  * It defaults to 511 instead of 512 because some systems store it 
00057  * as an 8-bit datatype; 512 truncated to 8-bits is 0, while 511 is 
00058  * 255 when truncated.
00059  */
00060 #ifndef DEFAULT_LISTENBACKLOG
00061 #define DEFAULT_LISTENBACKLOG 511
00062 #endif
00063         
00064 /* Signal used to gracefully restart */
00065 #define AP_SIG_GRACEFUL SIGUSR1
00066 
00067 /* Signal used to gracefully restart (without SIG prefix) */
00068 #define AP_SIG_GRACEFUL_SHORT USR1
00069 
00070 /* Signal used to gracefully restart (as a quoted string) */
00071 #define AP_SIG_GRACEFUL_STRING "SIGUSR1"
00072 
00073 /* Signal used to gracefully stop */
00074 #define AP_SIG_GRACEFUL_STOP SIGWINCH
00075 
00076 /* Signal used to gracefully stop (without SIG prefix) */
00077 #define AP_SIG_GRACEFUL_STOP_SHORT WINCH
00078 
00079 /* Signal used to gracefully stop (as a quoted string) */
00080 #define AP_SIG_GRACEFUL_STOP_STRING "SIGWINCH"
00081 
00098 #ifdef AP_MPM_WANT_RECLAIM_CHILD_PROCESSES
00099 void ap_reclaim_child_processes(int terminate);
00100 #endif
00101 
00115 #ifdef AP_MPM_WANT_RECLAIM_CHILD_PROCESSES
00116 void ap_relieve_child_processes(void);
00117 #endif
00118 
00130 #ifdef AP_MPM_WANT_RECLAIM_CHILD_PROCESSES
00131 void ap_register_extra_mpm_process(pid_t pid);
00132 #endif
00133 
00143 #ifdef AP_MPM_WANT_RECLAIM_CHILD_PROCESSES
00144 int ap_unregister_extra_mpm_process(pid_t pid);
00145 #endif
00146 
00156 #ifdef AP_MPM_WANT_RECLAIM_CHILD_PROCESSES
00157 apr_status_t ap_mpm_safe_kill(pid_t pid, int sig);
00158 #endif
00159 
00168 #ifdef AP_MPM_WANT_WAIT_OR_TIMEOUT
00169 void ap_wait_or_timeout(apr_exit_why_e *status, int *exitcode, apr_proc_t *ret, 
00170                         apr_pool_t *p);
00171 #endif
00172 
00180 #ifdef AP_MPM_WANT_PROCESS_CHILD_STATUS
00181 int ap_process_child_status(apr_proc_t *pid, apr_exit_why_e why, int status);
00182 #endif
00183 
00184 #if defined(TCP_NODELAY) && !defined(MPE) && !defined(TPF)
00185 
00192 void ap_sock_disable_nagle(apr_socket_t *s);
00193 #else
00194 #define ap_sock_disable_nagle(s)        /* NOOP */
00195 #endif
00196 
00197 #ifdef HAVE_GETPWNAM
00198 
00204 AP_DECLARE(uid_t) ap_uname2id(const char *name);
00205 #endif
00206 
00207 #ifdef HAVE_GETGRNAM
00214 AP_DECLARE(gid_t) ap_gname2id(const char *name);
00215 #endif
00216 
00217 #define AP_MPM_HARD_LIMITS_FILE APACHE_MPM_DIR "/mpm_default.h"
00218 
00219 #ifdef AP_MPM_USES_POD
00220 
00221 typedef struct ap_pod_t ap_pod_t;
00222 
00223 struct ap_pod_t {
00224     apr_file_t *pod_in;
00225     apr_file_t *pod_out;
00226     apr_pool_t *p;
00227 };
00228 
00234 AP_DECLARE(apr_status_t) ap_mpm_pod_open(apr_pool_t *p, ap_pod_t **pod);
00235 
00239 AP_DECLARE(apr_status_t) ap_mpm_pod_check(ap_pod_t *pod);
00240 
00244 AP_DECLARE(apr_status_t) ap_mpm_pod_close(ap_pod_t *pod);
00245 
00251 AP_DECLARE(apr_status_t) ap_mpm_pod_signal(ap_pod_t *pod);
00252 
00259 AP_DECLARE(void) ap_mpm_pod_killpg(ap_pod_t *pod, int num);
00260 #endif
00261 
00262 /*
00263  * These data members are common to all mpms. Each new mpm
00264  * should either use the appropriate ap_mpm_set_* function
00265  * in their command table or create their own for custom or
00266  * OS specific needs. These should work for most.
00267  */
00268 
00273 #ifdef AP_MPM_WANT_SET_MAX_REQUESTS
00274 extern int ap_max_requests_per_child;
00275 const char *ap_mpm_set_max_requests(cmd_parms *cmd, void *dummy,
00276                                     const char *arg);
00277 #endif
00278 
00282 #ifdef AP_MPM_WANT_SET_PIDFILE
00283 extern const char *ap_pid_fname;
00284 const char *ap_mpm_set_pidfile(cmd_parms *cmd, void *dummy,
00285                                const char *arg);
00286 #endif
00287 
00291 #ifdef AP_MPM_WANT_SET_LOCKFILE
00292 extern const char *ap_lock_fname;
00293 const char *ap_mpm_set_lockfile(cmd_parms *cmd, void *dummy,
00294                                 const char *arg);
00295 #endif
00296 
00300 #ifdef AP_MPM_WANT_SET_ACCEPT_LOCK_MECH
00301 extern apr_lockmech_e ap_accept_lock_mech;
00302 extern const char ap_valid_accept_mutex_string[];
00303 const char *ap_mpm_set_accept_lock_mech(cmd_parms *cmd, void *dummy,
00304                                         const char *arg);
00305 #endif
00306 
00307 /*
00308  * Set the scorboard file.
00309  */
00310 #ifdef AP_MPM_WANT_SET_SCOREBOARD
00311 const char *ap_mpm_set_scoreboard(cmd_parms *cmd, void *dummy,
00312                                   const char *arg);
00313 #endif
00314 
00315 /*
00316  * The directory that the server changes directory to dump core.
00317  */
00318 #ifdef AP_MPM_WANT_SET_COREDUMPDIR
00319 extern char ap_coredump_dir[MAX_STRING_LEN];
00320 extern int ap_coredumpdir_configured;
00321 const char *ap_mpm_set_coredumpdir(cmd_parms *cmd, void *dummy,
00322                                    const char *arg);
00323 #endif
00324 
00328 #ifdef AP_MPM_WANT_SET_GRACEFUL_SHUTDOWN
00329 extern int ap_graceful_shutdown_timeout;
00330 const char *ap_mpm_set_graceful_shutdown(cmd_parms *cmd, void *dummy,
00331                                          const char *arg);
00332 #define AP_GRACEFUL_SHUTDOWN_TIMEOUT_COMMAND \
00333 AP_INIT_TAKE1("GracefulShutdownTimeout", ap_mpm_set_graceful_shutdown, NULL, \
00334               RSRC_CONF, "Maximum time in seconds to wait for child "        \
00335               "processes to complete transactions during shutdown")
00336 #endif
00337 
00338 
00339 #ifdef AP_MPM_WANT_SIGNAL_SERVER
00340 int ap_signal_server(int *, apr_pool_t *);
00341 void ap_mpm_rewrite_args(process_rec *);
00342 #endif
00343 
00344 #ifdef AP_MPM_WANT_SET_MAX_MEM_FREE
00345 extern apr_uint32_t ap_max_mem_free;
00346 extern const char *ap_mpm_set_max_mem_free(cmd_parms *cmd, void *dummy,
00347                                            const char *arg);
00348 #endif
00349 
00350 #ifdef AP_MPM_WANT_SET_STACKSIZE
00351 extern apr_size_t ap_thread_stacksize;
00352 extern const char *ap_mpm_set_thread_stacksize(cmd_parms *cmd, void *dummy,
00353                                                const char *arg);
00354 #endif
00355 
00356 #ifdef AP_MPM_WANT_FATAL_SIGNAL_HANDLER
00357 extern apr_status_t ap_fatal_signal_setup(server_rec *s, apr_pool_t *pconf);
00358 extern apr_status_t ap_fatal_signal_child_setup(server_rec *s);
00359 #endif
00360 
00361 #if AP_ENABLE_EXCEPTION_HOOK
00362 extern const char *ap_mpm_set_exception_hook(cmd_parms *cmd, void *dummy,
00363                                              const char *arg);
00364 #endif
00365 
00366 AP_DECLARE_HOOK(int,monitor,(apr_pool_t *p))
00367 
00368 #ifdef __cplusplus
00369 }
00370 #endif
00371 
00372 #endif /* !APACHE_MPM_COMMON_H */

© sourcejam.com 2005-2008