add .deps, .project, .cdtproject, Debug, Release
[mod_fastcgi.git] / mod_fastcgi.h
blobb8b49050afb890e5281b7a7ea7573d99be4a04f5
1 /*
2 * $Id: mod_fastcgi.h,v 1.48 2003/11/25 00:02:19 robs Exp $
3 */
5 #ifndef MOD_FASTCGI_H
6 #define MOD_FASTCGI_H
8 #define MOD_FASTCGI_VERSION "2.4.2"
10 #define FASTCGI_HANDLER_NAME "fastcgi-script"
13 * # of idle seconds allowed to pass while connected to a FastCGI before aborting
15 #define FCGI_DEFAULT_IDLE_TIMEOUT 30
18 * (WIN32) # of sec to wait while trying to connect using a named pipe.
19 * This is overridden by -appConnTimeout, if set. This value is similiar
20 * to the OS specific (blocking) connect() timeout. According to XXX
21 * this is typically XXX sec.
23 #define FCGI_NAMED_PIPE_CONNECT_TIMEOUT 90
25 /*
26 * [WIN32] The number of millisecs to wait after having signaled the
27 * termination event to its applications before issuing a TerminateProcess().
28 * If all of the applications are based on a version of the FastCGI
29 * application library that properly handles the shutdown event
30 * (fcgi2 v2.2.4), this can be set to <= 0 to prevent the use of
31 * TerminateProcess() entirely. If non of the applications support the
32 * termination event, this value can be set to 1. It is highly reccomended
33 * that the termination event be supported, as TerminateProcess() is a
34 * brutal way of taking down an application.
36 #define WIN32_SHUTDOWN_GRACEFUL_WAIT 1000
39 * The number of failed starts that can occur before the application is
40 * considered broken and start attempts fall back to FAILED_STARTS_DELAY.
42 #define MAX_FAILED_STARTS 3
45 * The number of seconds an application has to have run without exiting
46 * for the application to be considered no longer broken.
48 #define RUNTIME_SUCCESS_INTERVAL 30
51 * The number of seconds between attempts to start an application that
52 * has been declared broken (see MAX_FAILED_STARTS).
54 #define FAILED_STARTS_DELAY 600
56 #define FCGI_DEFAULT_LISTEN_Q 100 /* listen queue (backlog) depth */
57 #define FCGI_DEFAULT_RESTART_DELAY 5 /* delay between restarts */
58 #define DEFAULT_INIT_START_DELAY 1 /* delay between starts */
59 #define FCGI_DEFAULT_PRIORITY 0 /* process priority - not used */
60 #define FCGI_MIN_EXEC_RETRY_DELAY 10 /* minimum number of seconds to
61 wait before restarting */
62 #define MAX_INIT_ENV_VARS 64 /* max # of -initial-env options */
64 /* max number of chars in a line of stderr we can handle from a FastCGI Server */
65 #define FCGI_SERVER_MAX_STDERR_LINE_LEN 1023
67 /* size of the buffer the PM uses to read records from the request handlers */
68 #define FCGI_MSGS_BUFSIZE 32 * 512
70 #define SERVER_BUFSIZE 8192
72 /* Dynamic FastCGI applications */
73 #define FCGI_DEFAULT_MAX_PROCS 50 /* maximum number of processes that
74 * are allowed to run on system */
75 #define FCGI_DEFAULT_MIN_PROCS 5 /* minimum number of processes that
76 * can be run without being killed
77 * off by the process manager */
78 #define FCGI_DEFAULT_MAX_CLASS_PROCS 10 /* maximum number of processes that
79 * are allowed to run for a single
80 * application class */
81 #define FCGI_DEFAULT_KILL_INTERVAL 300 /* number of seconds in which we
82 * should execute the kill policy
83 * by killing off extra instances */
84 #define FCGI_DEFAULT_UPDATE_INTERVAL 300 /* number of seconds in which we
85 * should recalculate the value of
86 * totalConnTime variable */
87 #define FCGI_DEFAULT_GAIN 0.5 /* value used as an exponent in the
88 * calculation of the exponentially
89 * decayed connection times;
90 * old values are scaled by
91 * (1-dynamicGain), so making it
92 * smaller weights them more heavily
93 * compared to the current value,
94 * which is scaled by dynamicGain */
95 #define FCGI_DEFAULT_THRESHOLD_1 0 /* if load falls below this value
96 * and we have only one instance
97 * running, it is killed off */
98 #define FCGI_DEFAULT_THRESHOLD_N 50 /* if load falls below this value
99 * and we have more than one
100 * instances, one is killed off */
101 #define FCGI_DEFAULT_START_PROCESS_DELAY 3 /* specifies the maximum number of
102 * seconds a server should wait in
103 * attempt to connect to fcgi app
104 * before sending FCGI_REQUEST_TIMEOUT_JOB */
107 * # of sec to wait in a non-blocking connect() to the FastCGI application
108 * before aborting the request, or 0 to indicate that blocking connect()s
109 * should be used. Non-blocking connect()s are problematic on many platforms.
111 #define FCGI_DEFAULT_APP_CONN_TIMEOUT 0
113 #define FCGI_DEFAULT_PROCESS_SLACK 5 /* if this number combined with the
114 * number of the currently running
115 * processes exceeds dynamicMaxProcs, then
116 * the KillDynamicProcs() is invoked */
117 #define FCGI_DEFAULT_RESTART_DYNAMIC 0 /* Do not restart dynamic processes */
118 #define FCGI_DEFAULT_AUTOUPDATE 0 /* do not automatically restart
119 * fcgi apps when the binary on the
120 * disk is changed. */
123 * Should data recieved from the FastCGI server be immediately flushed to
124 * the client? Default: FALSE
126 #define FCGI_FLUSH FALSE
128 #ifdef WIN32
130 /* # of millisecs to wait on the mbox mutex */
131 #define FCGI_MBOX_MUTEX_TIMEOUT 5000
133 #define DEFAULT_SOCK_DIR "\\\\.\\pipe\\FastCGI\\"
135 #elif defined(APACHE2)
137 /* Default dir for Unix/Domain sockets */
138 #define DEFAULT_SOCK_DIR DEFAULT_REL_RUNTIMEDIR "/fastcgi"
140 #else /* !WIN32 && !APACHE2 */
142 /* Default dir for Unix/Domain sockets */
143 #define DEFAULT_SOCK_DIR "logs/fastcgi"
145 #endif
147 #define FCGI_MAGIC_TYPE "application/x-httpd-fcgi"
149 #if defined(PATH_MAX)
150 #define FCGI_MAXPATH PATH_MAX
151 #elif defined(MAXPATHLEN)
152 #define FCGI_MAXPATH MAXPATHLEN
153 #else
154 #define FCGI_MAXPATH 512
155 #endif
157 /* FCGI_REQUEST_COMPLETE_JOB is the longest: id, path, user, gid, qtime, start */
158 #define FCGI_MSG_CRAP 1 + 2 + MAX_USER_NAME_LEN + 1 + MAX_GID_CHAR_LEN + (2 * 11) + 3
160 #if defined(PIPE_BUF) && PIPE_BUF < FCGI_MAXPATH + FCGI_MSG_CRAP
161 #define FCGI_MAX_MSG_LEN PIPE_BUF
162 #undef FCGI_MAXPATH
163 #define FCGI_MAXPATH PIPE_BUF - FCGI_MSG_CRAP
164 #else
165 #define FCGI_MAX_MSG_LEN FCGI_MAXPATH + FCGI_MSG_CRAP
166 #endif
168 /* There is no way to reliably determiine the highest descriptor that can be
169 * assigned (UNP Vol1 Ed2 p337, and APUE p43) so we pick a number. */
170 #if (defined FD_SETSIZE) && (FD_SETSIZE > 1024)
171 #define FCGI_MAX_FD FD_SETSIZE
172 #else
173 #define FCGI_MAX_FD 1024
174 #endif
176 #ifndef SUN_LEN
177 #define SUN_LEN(sock) \
178 (sizeof(*(sock)) - sizeof((sock)->sun_path) + strlen((sock)->sun_path))
179 #endif
181 #if defined MAXLOGNAME && MAXLOGNAME > 15
182 #define MAX_USER_NAME_LEN MAXLOGNAME
183 #elif defined UT_NAMESIZE && UT_NAMESIZE > 15
184 #define MAX_USER_NAME_LEN UT_NAMESIZE
185 #else
186 #define MAX_USER_NAME_LEN 15 /* Max len of user name (suexec w/ ~user), */
187 #endif /* must accomodate uid printed as %ld too */
188 #define MAX_GID_CHAR_LEN 15 /* Max #chars in a gid printed as %ld */
190 #ifndef TRUE
191 #define TRUE (1)
192 #endif
194 #ifndef FALSE
195 #define FALSE (0)
196 #endif
198 #ifndef min
199 #define min(a,b) ((a) < (b) ? (a) : (b))
200 #endif
202 #ifndef max
203 #define max(a,b) ((a) > (b) ? (a) : (b))
204 #endif
206 #ifdef APACHE2
208 #define get_signal_text(a) apr_signal_description_get(a)
210 #else /* !APACHE2 */
212 /* This is (more or less) from http_main.c. It should be in an Apache header */
213 #ifndef SYS_SIGLIST
214 #define SYS_SIGLIST ap_sys_siglist
215 extern const char *ap_sys_siglist[];
216 #endif
218 #define get_signal_text(a) SYS_SIGLIST[WTERMSIG(a)]
220 #endif /* !APACHE2 */
222 #endif /* MOD_FASTCGI_H */