From d5cd834282a4672507199d57b67090794311d772 Mon Sep 17 00:00:00 2001 From: Roman Arutyunyan Date: Tue, 31 Jan 2017 20:22:01 +0300 Subject: [PATCH] Support of undefined return from stream body filter. --- nginx/ngx_stream_js_module.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) 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; + } } } -- 2.47.3