From 0a0c02f58b477257dd3e7e7f62274e5671b88e8e Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Sat, 16 Feb 2008 14:23:14 +0000 Subject: optimize $r->sleep --- src/http/modules/perl/nginx.xs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/http/modules/perl/nginx.xs') diff --git a/src/http/modules/perl/nginx.xs b/src/http/modules/perl/nginx.xs index f3948e270..ea8c366df 100644 --- a/src/http/modules/perl/nginx.xs +++ b/src/http/modules/perl/nginx.xs @@ -934,17 +934,23 @@ sleep(r, sleep, next) CODE: ngx_http_request_t *r; + ngx_msec_t sleep; ngx_http_perl_ctx_t *ctx; ngx_http_perl_set_request(r); + sleep = SvIV(ST(1)); + + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "perl sleep: %M", sleep); + ctx = ngx_http_get_module_ctx(r, ngx_http_perl_module); - ctx->sleep = SvIV(ST(1)); ctx->next = SvRV(ST(2)); - ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, - "perl sleep: %d", ctx->sleep); + ngx_add_timer(r->connection->write, sleep); + + r->write_event_handler = ngx_http_perl_sleep_handler; void -- cgit