static ngx_js_ctx_t *ngx_http_js_ctx(njs_vm_t *vm, ngx_http_request_t *r);
static void ngx_http_js_periodic_handler(ngx_event_t *ev);
-static void ngx_http_js_periodic_write_event_handler(ngx_http_request_t *r);
static void ngx_http_js_periodic_shutdown_handler(ngx_event_t *ev);
+static void ngx_http_js_periodic_write_handler(ngx_event_t *ev);
static void ngx_http_js_periodic_finalize(ngx_http_request_t *r, ngx_int_t rc);
static void ngx_http_js_periodic_destroy(ngx_http_request_t *r,
ngx_js_periodic_t *periodic);
c->data = r;
c->destroyed = 0;
c->pool = r->pool;
+ c->read->log = &periodic->log;
c->read->handler = ngx_http_js_periodic_shutdown_handler;
+ c->write->log = &periodic->log;
+ c->write->handler = ngx_http_js_periodic_write_handler;
periodic->connection = c;
periodic->log_ctx.request = r;
r->valid_unparsed_uri = 1;
r->health_check = 1;
- r->write_event_handler = ngx_http_js_periodic_write_event_handler;
rc = ngx_http_js_init_vm(r, ngx_http_js_periodic_session_proto_id);
static void
-ngx_http_js_periodic_write_event_handler(ngx_http_request_t *r)
+ngx_http_js_periodic_write_handler(ngx_event_t *ev)
{
- ngx_http_js_ctx_t *ctx;
+ ngx_connection_t *c;
+ ngx_http_js_ctx_t *ctx;
+ ngx_http_request_t *r;
- ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
- "http js periodic write event handler");
+ c = ev->data;
+ r = c->data;
+
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,
+ "http js periodic write handler");
ctx = ngx_http_get_module_ctx(r, ngx_http_js_module);
c->fd = (ngx_socket_t) -1;
c->pool = NULL;
c->destroyed = 1;
+
+ if (c->write->posted) {
+ ngx_delete_posted_event(c->write);
+ }
}
}
if (rc == NGX_OK) {
- ngx_http_post_request(r, NULL);
+ ngx_post_event(r->connection->write, &ngx_posted_events);
}
-
- ngx_http_run_posted_requests(r->connection);
}
js_content test.sr_in_sr_callback;
}
+ location /sr_error_in_callback {
+ js_content test.sr_error_in_callback;
+ }
+
location /sr_uri_except {
js_content test.sr_uri_except;
}
.then(body_fwd_cb);
}
+ function sr_error_in_callback(r) {
+ r.subrequest("/sub1", () => {});
+ r.subrequest("/sub1", () => { throw "Oops!"; });
+ r.return(200);
+ }
+
function sr_in_sr_callback(r) {
r.subrequest('/return', function (reply) {
try {
sr_js_in_subrequest, sr_js_in_subrequest_pr, js_sub,
sr_in_sr_callback, sr_out_of_order, sr_except_not_a_func,
sr_uri_except, sr_except_failed_to_convert_options_arg,
- sr_unsafe};
+ sr_unsafe, sr_error_in_callback};
EOF
}
+TODO: {
+local $TODO = 'not yet' unless has_version('0.8.5');
+
+http_get('/sr_error_in_callback');
+
+}
+
$t->stop();
ok(index($t->read_file('error.log'), 'callback is not a function') > 0,