Project

General

Profile

Feature #967 » request-queue-limit.patch

-- Tom Fernandes <anyaddress - Anonymous, 2008-03-19 21:32

View differences:

pkg/src/mod_fastcgi.c (working copy)
256 256
			       applications prefer SIGUSR1 while the
257 257
			       rest of the world would use SIGTERM
258 258
			       *sigh* */
259

  
260
	/*
261
         * If this limit is >= 0, and the queue of requests waiting for
262
         * a FastCGI backend to become free would become larger than
263
         * this, send a 503 response instead of queueing the request.
264
	 */
265
	signed short request_queue_limit;
259 266
} fcgi_extension_host;
260 267

  
261 268
/*
......
1193 1193
					{ "allow-x-send-file",  NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION },      /* 15 */
1194 1194
					{ "strip-request-uri",  NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION },      /* 16 */
1195 1195
					{ "kill-signal",        NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },      /* 17 */
1196
						{ "request-queue-limit", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },      /* 18 */
1196 1197
						{ NULL,                NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
1197 1198
					};
......
1220 1220
				host->break_scriptfilename_for_php = 0;
1221 1221
				host->allow_xsendfile = 0; /* handle X-LIGHTTPD-send-file */
1222 1222
				host->kill_signal = SIGTERM;
1223
					host->request_queue_limit = -1;
1223 1224

  
1224 1225
					fcv[0].destination = host->host;
1225 1226
					fcv[1].destination = host->docroot;
......
1241 1241
					fcv[15].destination = &(host->allow_xsendfile);
1242 1242
					fcv[16].destination = host->strip_request_uri;
1243 1243
				fcv[17].destination = &(host->kill_signal);
1244
					fcv[18].destination = &(host->request_queue_limit);
1244 1245

  
1245 1246
					if (0 != config_insert_values_internal(srv, da_host->value, fcv)) {
1246 1247
						return HANDLER_ERROR;
......
3124 3124
	host = hctx->host;
3125 3125
}
3126 3126

  
3127
	/* overload check */
3128
	if (host->request_queue_limit >= 0 && host->load > host->request_queue_limit) {
3129
		if (p->conf.debug > 0) {
3130
			log_error_write(srv, __FILE__, __LINE__, "sbsd",
3131
					"request for ", con->uri.path,
3132
					"rejected; current load is ", host->load);
3133
		}
3134
		fcgi_connection_close(srv, hctx);
3135
		con->http_status = 503;
3136
		con->mode = DIRECT;
3137
		return HANDLER_FINISHED;
3138
	}
3139

  
3127 3140
	/* ok, create the request */
3128 3141
	switch(fcgi_write_request(srv, hctx)) {
3129 3142
	case HANDLER_ERROR:
3130
-- pkg.orig/doc/fastcgi.txt	(revision 4423)
3143
++ pkg/doc/fastcgi.txt	(working copy)
......
111 111
	  "broken-scriptfilename" => <boolean>, # OPTIONAL
112 112
          "disable-time" => <integer>, # optional
113 113
          "allow-x-send-file" => <boolean> # optional
114
	  "request-queue-limit" => <integer>, # OPTIONAL
114 115
	),
115 116
        ( "host" => ...
116 117
        )
......
146 147
                again
147 148
  :"allow-x-send-file": controls if X-LIGHTTPD-send-file headers
148 149
                are allowed
150
  :"request-queue-limit": is optional, and defaults to -1. 
151
                If this limit is >= 0, and the queue of requests waiting
152
                for a FastCGI process to become available to serve them
153
                would become larger than this, send a 503 response
154
                instead of queueing the request.
149 155

  
150 156
  If bin-path is set:
151 157

  
(2-2/3)