]> git.kaiwu.me - njs.git/commitdiff
Support of undefined return from stream body filter.
authorRoman Arutyunyan <arut@nginx.com>
Tue, 31 Jan 2017 17:22:01 +0000 (20:22 +0300)
committerRoman Arutyunyan <arut@nginx.com>
Tue, 31 Jan 2017 17:22:01 +0000 (20:22 +0300)
nginx/ngx_stream_js_module.c

index 13597b18ced5bdcb045cb9eaa9527052898c9343..e28888c3be8cb7b5fe52797b57c80e5d546ee321 100644 (file)
@@ -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;
+                }
             }
         }