comparison src/http/modules/perl/ngx_http_perl_module.c @ 911:73c66ed9a9cd

$r->sleep()
author Igor Sysoev <igor@sysoev.ru>
date Tue, 12 Dec 2006 20:59:24 +0000
parents 82adc19b4b4d
children 90ce4d0e3241
comparison
equal deleted inserted replaced
910:918e19c51a65 911:73c66ed9a9cd
39 #if (NGX_HTTP_SSI) 39 #if (NGX_HTTP_SSI)
40 static ngx_int_t ngx_http_perl_ssi(ngx_http_request_t *r, 40 static ngx_int_t ngx_http_perl_ssi(ngx_http_request_t *r,
41 ngx_http_ssi_ctx_t *ssi_ctx, ngx_str_t **params); 41 ngx_http_ssi_ctx_t *ssi_ctx, ngx_str_t **params);
42 #endif 42 #endif
43 43
44 static void ngx_http_perl_sleep_handler(ngx_http_request_t *r);
44 static char *ngx_http_perl_init_interpreter(ngx_conf_t *cf, 45 static char *ngx_http_perl_init_interpreter(ngx_conf_t *cf,
45 ngx_http_perl_main_conf_t *pmcf); 46 ngx_http_perl_main_conf_t *pmcf);
46 static PerlInterpreter * 47 static PerlInterpreter *
47 ngx_http_perl_create_interpreter(ngx_http_perl_main_conf_t *pmcf, 48 ngx_http_perl_create_interpreter(ngx_http_perl_main_conf_t *pmcf,
48 ngx_log_t *log); 49 ngx_log_t *log);
243 } 244 }
244 245
245 ctx->filename.data = NULL; 246 ctx->filename.data = NULL;
246 ctx->redirect_uri.len = 0; 247 ctx->redirect_uri.len = 0;
247 248
249 if (ctx->sleep) {
250 ngx_add_timer(r->connection->write, (ngx_msec_t) ctx->sleep);
251 r->write_event_handler = ngx_http_perl_sleep_handler;
252 ctx->sleep = 0;
253 }
254
248 if (ctx->done || ctx->next) { 255 if (ctx->done || ctx->next) {
249 return; 256 return;
250 } 257 }
251 258
252 if (uri.len) { 259 if (uri.len) {
258 ngx_http_send_special(r, NGX_HTTP_LAST); 265 ngx_http_send_special(r, NGX_HTTP_LAST);
259 ctx->done = 1; 266 ctx->done = 1;
260 } 267 }
261 268
262 ngx_http_finalize_request(r, rc); 269 ngx_http_finalize_request(r, rc);
270 }
271
272
273 static void
274 ngx_http_perl_sleep_handler(ngx_http_request_t *r)
275 {
276 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
277 "perl sleep handler");
278
279 ngx_http_perl_handle_request(r);
263 } 280 }
264 281
265 282
266 static ngx_int_t 283 static ngx_int_t
267 ngx_http_perl_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v, 284 ngx_http_perl_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,