1 /* 2 * $Id: mod_fastcgi.h,v 1.55 2009/09/29 00:31:55 robs Exp $ 3 */ 4 5 #ifndef MOD_FASTCGI_H 6 #define MOD_FASTCGI_H 7 8 #define MOD_FASTCGI_VERSION "mod_fastcgi-SNAP-0910052141" 9 10 #define FASTCGI_HANDLER_NAME "fastcgi-script" 11 12 /* 13 * # of idle seconds allowed to pass while connected to a FastCGI before aborting 14 */ 15 #define FCGI_DEFAULT_IDLE_TIMEOUT 30 16 17 /* 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. 22 */ 23 #define FCGI_NAMED_PIPE_CONNECT_TIMEOUT 90 24 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 none 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. 35 */ 36 #define WIN32_SHUTDOWN_GRACEFUL_WAIT 1000 37 38 /* 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. 41 */ 42 #define MAX_FAILED_STARTS 3 43 44 /* 45 * The number of seconds between attempts to start an application that 46 * has been declared broken (see MAX_FAILED_STARTS). 47 */ 48 #define FAILED_STARTS_DELAY 600 49 50 #define FCGI_DEFAULT_LISTEN_Q 100 /* listen queue (backlog) depth */ 51 #define FCGI_DEFAULT_RESTART_DELAY 5 /* delay between restarts */ 52 #define DEFAULT_INIT_START_DELAY 1 /* delay between starts */ 53 #define FCGI_DEFAULT_PRIORITY 0 /* process priority - not used */ 54 #define FCGI_MIN_EXEC_RETRY_DELAY 10 /* minimum number of seconds to 55 wait before restarting */ 56 #define MAX_INIT_ENV_VARS 64 /* max # of -initial-env options */ 57 58 /* max number of chars in a line of stderr we can handle from a FastCGI Server */ 59 #define FCGI_SERVER_MAX_STDERR_LINE_LEN 1023 60 61 /* size of the buffer the PM uses to read records from the request handlers */ 62 #define FCGI_MSGS_BUFSIZE 32 * 512 63 64 #define SERVER_BUFSIZE 8192 65 66 /* Dynamic FastCGI applications */ 67 #define FCGI_DEFAULT_MAX_PROCS 50 /* maximum number of processes that 68 * are allowed to run on system */ 69 #define FCGI_DEFAULT_MIN_PROCS 5 /* minimum number of processes that 70 * can be run without being killed 71 * off by the process manager */ 72 #define FCGI_DEFAULT_MAX_CLASS_PROCS 10 /* maximum number of processes that 73 * are allowed to run for a single 74 * application class */ 75 #define FCGI_DEFAULT_KILL_INTERVAL 300 /* number of seconds in which we 76 * should execute the kill policy 77 * by killing off extra instances */ 78 #define FCGI_DEFAULT_UPDATE_INTERVAL 300 /* number of seconds in which we 79 * should recalculate the value of 80 * totalConnTime variable */ 81 #define FCGI_DEFAULT_GAIN 0.5 /* value used as an exponent in the 82 * calculation of the exponentially 83 * decayed connection times; 84 * old values are scaled by 85 * (1-dynamicGain), so making it 86 * smaller weights them more heavily 87 * compared to the current value, 88 * which is scaled by dynamicGain */ 89 #define FCGI_DEFAULT_THRESHOLD_1 0 /* if load falls below this value 90 * and we have only one instance 91 * running, it is killed off */ 92 #define FCGI_DEFAULT_THRESHOLD_N 50 /* if load falls below this value 93 * and we have more than one 94 * instances, one is killed off */ 95 #define FCGI_DEFAULT_START_PROCESS_DELAY 3 /* specifies the maximum number of 96 * seconds a server should wait in 97 * attempt to connect to fcgi app 98 * before sending FCGI_REQUEST_TIMEOUT_JOB */ 99 #define FCGI_DEFAULT_MIN_SERVER_LIFE 30 /* the default minimum number of 100 * seconds a server must stay alive 101 * before it's considered broken. */ 102 /* 103 * # of sec to wait in a non-blocking connect() to the FastCGI application 104 * before aborting the request, or 0 to indicate that blocking connect()s 105 * should be used. Non-blocking connect()s are problematic on many platforms. 106 */ 107 #define FCGI_DEFAULT_APP_CONN_TIMEOUT 0 108 109 #define FCGI_DEFAULT_PROCESS_SLACK 5 /* if this number combined with the 110 * number of the currently running 111 * processes exceeds dynamicMaxProcs, then 112 * the KillDynamicProcs() is invoked */ 113 #define FCGI_DEFAULT_RESTART_DYNAMIC 0 /* Do not restart dynamic processes */ 114 #define FCGI_DEFAULT_AUTOUPDATE 0 /* do not automatically restart 115 * fcgi apps when the binary on the 116 * disk is changed. */ 117 118 /* 119 * Should data recieved from the FastCGI server be immediately flushed to 120 * the client? Default: FALSE 121 */ 122 #define FCGI_FLUSH FALSE 123 124 #ifdef WIN32 125 126 /* # of millisecs to wait on the mbox mutex */ 127 #define FCGI_MBOX_MUTEX_TIMEOUT 5000 128 129 #define DEFAULT_SOCK_DIR "\\\\.\\pipe\\FastCGI\\" 130 131 #elif defined(APACHE2) 132 133 /* Default dir for Unix/Domain sockets */ 134 #define DEFAULT_SOCK_DIR DEFAULT_REL_RUNTIMEDIR "/fastcgi" 135 136 #else /* !WIN32 && !APACHE2 */ 137 138 /* Default dir for Unix/Domain sockets */ 139 #define DEFAULT_SOCK_DIR "logs/fastcgi" 140 141 #endif 142 143 #define FCGI_MAGIC_TYPE "application/x-httpd-fcgi" 144 145 #if defined(PATH_MAX) 146 #define FCGI_MAXPATH PATH_MAX 147 #elif defined(MAXPATHLEN) 148 #define FCGI_MAXPATH MAXPATHLEN 149 #else 150 #define FCGI_MAXPATH 512 151 #endif 152 153 /* FCGI_REQUEST_COMPLETE_JOB is the longest: id, path, user, gid, qtime, start */ 154 #define FCGI_MSG_CRAP 1 + 2 + MAX_USER_NAME_LEN + 1 + MAX_GID_CHAR_LEN + (2 * 11) + 3 155 156 #if defined(PIPE_BUF) && PIPE_BUF < FCGI_MAXPATH + FCGI_MSG_CRAP 157 #define FCGI_MAX_MSG_LEN PIPE_BUF 158 #undef FCGI_MAXPATH 159 #define FCGI_MAXPATH PIPE_BUF - FCGI_MSG_CRAP 160 #else 161 #define FCGI_MAX_MSG_LEN FCGI_MAXPATH + FCGI_MSG_CRAP 162 #endif 163 164 /* There is no way to reliably determiine the highest descriptor that can be 165 * assigned (UNP Vol1 Ed2 p337, and APUE p43) so we pick a number. */ 166 #if (defined FD_SETSIZE) && (FD_SETSIZE > 1024) 167 #define FCGI_MAX_FD FD_SETSIZE 168 #else 169 #define FCGI_MAX_FD 1024 170 #endif 171 172 #ifndef SUN_LEN 173 #define SUN_LEN(sock) \ 174 (sizeof(*(sock)) - sizeof((sock)->sun_path) + strlen((sock)->sun_path)) 175 #endif 176 177 #if defined MAXLOGNAME && MAXLOGNAME > 15 178 #define MAX_USER_NAME_LEN MAXLOGNAME 179 #elif defined UT_NAMESIZE && UT_NAMESIZE > 15 180 #define MAX_USER_NAME_LEN UT_NAMESIZE 181 #else 182 #define MAX_USER_NAME_LEN 15 /* Max len of user name (suexec w/ ~user), */ 183 #endif /* must accomodate uid printed as %ld too */ 184 #define MAX_GID_CHAR_LEN 15 /* Max #chars in a gid printed as %ld */ 185 186 #ifndef TRUE 187 #define TRUE (1) 188 #endif 189 190 #ifndef FALSE 191 #define FALSE (0) 192 #endif 193 194 #ifndef min 195 #define min(a,b) ((a) < (b) ? (a) : (b)) 196 #endif 197 198 #ifndef max 199 #define max(a,b) ((a) > (b) ? (a) : (b)) 200 #endif 201 202 #ifdef APACHE2 203 204 #define get_signal_text(a) apr_signal_description_get(a) 205 206 #else /* !APACHE2 */ 207 208 /* This is (more or less) from http_main.c. It should be in an Apache header */ 209 #ifndef SYS_SIGLIST 210 #define SYS_SIGLIST ap_sys_siglist 211 extern const char *ap_sys_siglist[]; 212 #endif 213 214 #define get_signal_text(a) SYS_SIGLIST[WTERMSIG(a)] 215 216 #endif /* !APACHE2 */ 217 218 #endif /* MOD_FASTCGI_H */ 219 220