mirror of
https://github.com/nginx/nginx.git
synced 2024-12-05 06:19:01 +08:00
$r->sleep()
This commit is contained in:
parent
332efbc412
commit
e773324c30
@ -845,6 +845,27 @@ variable(r, name, value = NULL)
|
|||||||
ST(0) = TARG;
|
ST(0) = TARG;
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
sleep(r, sleep, next)
|
||||||
|
CODE:
|
||||||
|
|
||||||
|
dXSTARG;
|
||||||
|
ngx_http_request_t *r;
|
||||||
|
ngx_http_perl_ctx_t *ctx;
|
||||||
|
|
||||||
|
ngx_http_perl_set_request(r);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
XSRETURN_EMPTY;
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
log_error(r, err, msg)
|
log_error(r, err, msg)
|
||||||
CODE:
|
CODE:
|
||||||
|
@ -41,6 +41,7 @@ static ngx_int_t ngx_http_perl_ssi(ngx_http_request_t *r,
|
|||||||
ngx_http_ssi_ctx_t *ssi_ctx, ngx_str_t **params);
|
ngx_http_ssi_ctx_t *ssi_ctx, ngx_str_t **params);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void ngx_http_perl_sleep_handler(ngx_http_request_t *r);
|
||||||
static char *ngx_http_perl_init_interpreter(ngx_conf_t *cf,
|
static char *ngx_http_perl_init_interpreter(ngx_conf_t *cf,
|
||||||
ngx_http_perl_main_conf_t *pmcf);
|
ngx_http_perl_main_conf_t *pmcf);
|
||||||
static PerlInterpreter *
|
static PerlInterpreter *
|
||||||
@ -245,6 +246,12 @@ ngx_http_perl_handle_request(ngx_http_request_t *r)
|
|||||||
ctx->filename.data = NULL;
|
ctx->filename.data = NULL;
|
||||||
ctx->redirect_uri.len = 0;
|
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) {
|
if (ctx->done || ctx->next) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -263,6 +270,16 @@ ngx_http_perl_handle_request(ngx_http_request_t *r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
ngx_http_perl_sleep_handler(ngx_http_request_t *r)
|
||||||
|
{
|
||||||
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||||
|
"perl sleep handler");
|
||||||
|
|
||||||
|
ngx_http_perl_handle_request(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t
|
static ngx_int_t
|
||||||
ngx_http_perl_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,
|
ngx_http_perl_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,
|
||||||
uintptr_t data)
|
uintptr_t data)
|
||||||
|
@ -23,7 +23,9 @@ typedef struct {
|
|||||||
ngx_str_t filename;
|
ngx_str_t filename;
|
||||||
ngx_str_t redirect_uri;
|
ngx_str_t redirect_uri;
|
||||||
ngx_str_t redirect_args;
|
ngx_str_t redirect_args;
|
||||||
|
|
||||||
SV *next;
|
SV *next;
|
||||||
|
int sleep;
|
||||||
|
|
||||||
ngx_uint_t done; /* unsigned done:1; */
|
ngx_uint_t done; /* unsigned done:1; */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user