From: Roman Arutyunyan Date: Tue, 31 Jan 2017 17:22:01 +0000 (+0300) Subject: Support of undefined return from stream body filter. X-Git-Tag: 0.1.9~2 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=d5cd834282a4672507199d57b67090794311d772;p=njs.git Support of undefined return from stream body filter. --- diff --git a/nginx/ngx_stream_js_module.c b/nginx/ngx_stream_js_module.c index 13597b18..e28888c3 100644 --- a/nginx/ngx_stream_js_module.c +++ b/nginx/ngx_stream_js_module.c @@ -503,28 +503,30 @@ ngx_stream_js_body_filter(ngx_stream_session_t *s, ngx_chain_t *in, return NGX_ERROR; } - if (njs_vm_retval(ctx->vm, &value) != NJS_OK) { - return NGX_ERROR; - } + if (ctx->vm->retval.type != NJS_VOID) { + if (njs_vm_retval(ctx->vm, &value) != NJS_OK) { + return NGX_ERROR; + } - ngx_log_debug2(NGX_LOG_DEBUG_STREAM, c->log, 0, - "js return value: \"%*s\"", - value.length, value.start); + ngx_log_debug2(NGX_LOG_DEBUG_STREAM, c->log, 0, + "js return value: \"%*s\"", + value.length, value.start); - if (value.length) { - rc = ngx_atoi(value.start, value.length); + if (value.length) { + rc = ngx_atoi(value.start, value.length); - if (rc != NGX_OK && rc != -NGX_ERROR) { - ngx_log_error(NGX_LOG_ERR, c->log, 0, - "unexpected js return code: \"%*s\"", - value.length, value.start); - return NGX_ERROR; - } + if (rc != NGX_OK && rc != -NGX_ERROR) { + ngx_log_error(NGX_LOG_ERR, c->log, 0, + "unexpected js return code: \"%*s\"", + value.length, value.start); + return NGX_ERROR; + } - rc = -rc; + rc = -rc; - if (rc == NGX_ERROR) { - return NGX_ERROR; + if (rc == NGX_ERROR) { + return NGX_ERROR; + } } }