[njs] Fetch: refactored out ngx_js_http_resolve_done().

noreply at nginx.com noreply at nginx.com
Fri Apr 11 15:29:02 UTC 2025


details:   https://github.com/nginx/njs/commit/befd1d603a9c898657702439644fd8f609610804
branches:  master
commit:    befd1d603a9c898657702439644fd8f609610804
user:      Zhidao HONG <z.hong at f5.com>
date:      Fri, 11 Apr 2025 21:59:16 +0800
description:
Fetch: refactored out ngx_js_http_resolve_done().


---
 nginx/ngx_js_fetch.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/nginx/ngx_js_fetch.c b/nginx/ngx_js_fetch.c
index 5abd43bd..d3f8b356 100644
--- a/nginx/ngx_js_fetch.c
+++ b/nginx/ngx_js_fetch.c
@@ -163,6 +163,7 @@ static njs_int_t ngx_js_headers_fill(njs_vm_t *vm, ngx_js_headers_t *headers,
     njs_value_t *init);
 static ngx_js_http_t *ngx_js_http_alloc(njs_vm_t *vm, ngx_pool_t *pool,
     ngx_log_t *log);
+static void ngx_js_http_resolve_done(ngx_js_http_t *http);
 static void ngx_js_http_destructor(ngx_js_event_t *event);
 static void ngx_js_resolve_handler(ngx_resolver_ctx_t *ctx);
 static njs_int_t ngx_js_fetch_promissified_result(njs_vm_t *vm,
@@ -1410,8 +1411,7 @@ ngx_js_resolve_handler(ngx_resolver_ctx_t *ctx)
         http->addrs[i].name.data = p;
     }
 
-    ngx_resolve_name_done(ctx);
-    http->ctx = NULL;
+    ngx_js_http_resolve_done(http);
 
     ngx_js_http_connect(http);
 
@@ -1446,6 +1446,16 @@ ngx_js_http_close_connection(ngx_connection_t *c)
 }
 
 
+static void
+ngx_js_http_resolve_done(ngx_js_http_t *http)
+{
+    if (http->ctx != NULL) {
+        ngx_resolve_name_done(http->ctx);
+        http->ctx = NULL;
+    }
+}
+
+
 static void
 ngx_js_http_destructor(ngx_js_event_t *event)
 {
@@ -1456,10 +1466,7 @@ ngx_js_http_destructor(ngx_js_event_t *event)
     ngx_log_debug1(NGX_LOG_DEBUG_EVENT, http->log, 0, "js fetch destructor:%p",
                    http);
 
-    if (http->ctx != NULL) {
-        ngx_resolve_name_done(http->ctx);
-        http->ctx = NULL;
-    }
+    ngx_js_http_resolve_done(http);
 
     if (http->peer.connection != NULL) {
         ngx_js_http_close_connection(http->peer.connection);


More information about the nginx-devel mailing list