24
26
ngx_str_t *computed_arg;
25
27
ngx_str_t *computed_arg_elts;
26
float delay; /* in sec */
28
ngx_int_t delay; /* in msec */
27
29
ngx_http_cleanup_t *cln;
29
31
computed_arg_elts = computed_args->elts;
30
32
computed_arg = &computed_arg_elts[0];
32
delay = atof( (char*) computed_arg->data );
34
delay = ngx_atofp(computed_arg->data, computed_arg->len, 3);
34
if (delay < 0.001) { /* should be bigger than 1 msec */
36
if (delay == NGX_ERROR) {
35
37
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
36
38
"invalid sleep duration \"%V\"", &computed_arg_elts[0]);
38
40
return NGX_HTTP_BAD_REQUEST;
41
dd("adding timer with delay %.02lf sec, r:%.*s", delay,
43
dd("adding timer with delay %lu ms, r:%.*s", (unsigned long) delay,
44
(int) r->uri.len, r->uri.data);
45
ngx_add_timer(&ctx->sleep, (ngx_msec_t) (1000 * delay));
46
ngx_add_timer(&ctx->sleep, (ngx_msec_t) delay);
47
48
/* we don't check broken downstream connections
48
49
* ourselves so even if the client shuts down
159
160
ngx_str_t *computed_arg;
160
161
ngx_str_t *computed_arg_elts;
161
float delay; /* in sec */
162
ngx_int_t delay; /* in msec */
163
164
computed_arg_elts = computed_args->elts;
164
165
computed_arg = &computed_arg_elts[0];
166
delay = atof( (char*) computed_arg->data );
167
delay = ngx_atofp(computed_arg->data, computed_arg->len, 3);
168
if (delay < 0.001) { /* should be bigger than 1 msec */
169
if (delay == NGX_ERROR) {
169
170
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
170
171
"invalid sleep duration \"%V\"", &computed_arg_elts[0]);
171
172
return NGX_HTTP_BAD_REQUEST;
174
dd("blocking DELAY = %.02lf sec", delay);
175
dd("blocking delay: %lu ms", (unsigned long) delay);
176
ngx_msleep((ngx_msec_t) (1000 * delay));
177
ngx_msleep((ngx_msec_t) delay);