diff options
author | Igor Sysoev <igor@sysoev.ru> | 2008-02-16 14:23:14 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2008-02-16 14:23:14 +0000 |
commit | 0a0c02f58b477257dd3e7e7f62274e5671b88e8e (patch) | |
tree | 6f51ea7b1224d4b344062a3b70eb2e51f83df66f /src | |
parent | 5fa1146dd5bfd68bc8212935a509edb6d2d0a4af (diff) | |
download | nginx-0a0c02f58b477257dd3e7e7f62274e5671b88e8e.tar.gz nginx-0a0c02f58b477257dd3e7e7f62274e5671b88e8e.zip |
optimize $r->sleep
Diffstat (limited to 'src')
-rw-r--r-- | src/http/modules/perl/nginx.xs | 12 | ||||
-rw-r--r-- | src/http/modules/perl/ngx_http_perl_module.c | 9 | ||||
-rw-r--r-- | src/http/modules/perl/ngx_http_perl_module.h | 4 |
3 files changed, 12 insertions, 13 deletions
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 diff --git a/src/http/modules/perl/ngx_http_perl_module.c b/src/http/modules/perl/ngx_http_perl_module.c index 07dad1c81..32d996a67 100644 --- a/src/http/modules/perl/ngx_http_perl_module.c +++ b/src/http/modules/perl/ngx_http_perl_module.c @@ -41,7 +41,6 @@ static ngx_int_t ngx_http_perl_ssi(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ssi_ctx, ngx_str_t **params); #endif -static void ngx_http_perl_sleep_handler(ngx_http_request_t *r); static char *ngx_http_perl_init_interpreter(ngx_conf_t *cf, ngx_http_perl_main_conf_t *pmcf); static PerlInterpreter *ngx_http_perl_create_interpreter(ngx_conf_t *cf, @@ -252,12 +251,6 @@ ngx_http_perl_handle_request(ngx_http_request_t *r) ctx->filename.data = NULL; ctx->redirect_uri.len = 0; - if (ctx->sleep) { - ngx_add_timer(r->connection->write, (ngx_msec_t) ctx->sleep); - r->write_event_handler = ngx_http_perl_sleep_handler; - ctx->sleep = 0; - } - if (ctx->done || ctx->next) { return; } @@ -276,7 +269,7 @@ ngx_http_perl_handle_request(ngx_http_request_t *r) } -static void +void ngx_http_perl_sleep_handler(ngx_http_request_t *r) { ngx_event_t *wev; diff --git a/src/http/modules/perl/ngx_http_perl_module.h b/src/http/modules/perl/ngx_http_perl_module.h index 6ae63e820..23969bcd4 100644 --- a/src/http/modules/perl/ngx_http_perl_module.h +++ b/src/http/modules/perl/ngx_http_perl_module.h @@ -25,9 +25,8 @@ typedef struct { ngx_str_t redirect_args; SV *next; - int sleep; - ngx_uint_t done; /* unsigned done:1; */ + ngx_uint_t done; /* unsigned done:1; */ ngx_array_t *variables; /* array of ngx_http_perl_var_t */ @@ -61,6 +60,7 @@ extern void boot_DynaLoader(pTHX_ CV* cv); void ngx_http_perl_handle_request(ngx_http_request_t *r); +void ngx_http_perl_sleep_handler(ngx_http_request_t *r); #endif /* _NGX_HTTP_PERL_MODULE_H_INCLUDED_ */ |