From 31e1e8695b035226a8adf24047f2e3ee207cd60a Mon Sep 17 00:00:00 2001 From: Caio Ramos Casimiro Date: Mon, 25 Nov 2024 12:07:00 +0000 Subject: [PATCH] misc(proxy-wasm) rename `call` to `dispatch_call` Making struct member names explict to distinguish them from the upcoming Proxy-Wasm foreign call support. --- src/common/proxy_wasm/ngx_proxy_wasm.c | 20 +++++------ src/common/proxy_wasm/ngx_proxy_wasm.h | 32 ++++++++--------- src/common/proxy_wasm/ngx_proxy_wasm_host.c | 2 +- src/common/proxy_wasm/ngx_proxy_wasm_maps.c | 35 ++++++++++--------- src/http/proxy_wasm/ngx_http_proxy_wasm.c | 2 +- .../proxy_wasm/ngx_http_proxy_wasm_dispatch.c | 8 ++--- 6 files changed, 51 insertions(+), 48 deletions(-) diff --git a/src/common/proxy_wasm/ngx_proxy_wasm.c b/src/common/proxy_wasm/ngx_proxy_wasm.c index ce167ecba..f2eada95e 100644 --- a/src/common/proxy_wasm/ngx_proxy_wasm.c +++ b/src/common/proxy_wasm/ngx_proxy_wasm.c @@ -440,8 +440,8 @@ ngx_proxy_wasm_ctx_destroy(ngx_proxy_wasm_ctx_t *pwctx) ngx_pfree(pwctx->pool, pwctx->root_id.data); } - if (pwctx->call_status.data) { - ngx_pfree(pwctx->pool, pwctx->call_status.data); + if (pwctx->dispatch_call_status.data) { + ngx_pfree(pwctx->pool, pwctx->dispatch_call_status.data); } if (pwctx->response_status.data) { @@ -894,8 +894,8 @@ ngx_proxy_wasm_dispatch_calls_total(ngx_proxy_wasm_exec_t *pwexec) ngx_queue_t *q; ngx_uint_t n = 0; - for (q = ngx_queue_head(&pwexec->calls); - q != ngx_queue_sentinel(&pwexec->calls); + for (q = ngx_queue_head(&pwexec->dispatch_calls); + q != ngx_queue_sentinel(&pwexec->dispatch_calls); q = ngx_queue_next(q), n++) { /* void */ } dd("n: %ld", n); @@ -911,8 +911,8 @@ ngx_proxy_wasm_dispatch_calls_cancel(ngx_proxy_wasm_exec_t *pwexec) ngx_queue_t *q; ngx_http_proxy_wasm_dispatch_t *call; - while (!ngx_queue_empty(&pwexec->calls)) { - q = ngx_queue_head(&pwexec->calls); + while (!ngx_queue_empty(&pwexec->dispatch_calls)) { + q = ngx_queue_head(&pwexec->dispatch_calls); call = ngx_queue_data(q, ngx_http_proxy_wasm_dispatch_t, q); ngx_log_debug1(NGX_LOG_DEBUG_ALL, pwexec->log, 0, @@ -1145,7 +1145,7 @@ ngx_proxy_wasm_create_context(ngx_proxy_wasm_filter_t *filter, rexec->filter = filter; rexec->ictx = ictx; - ngx_queue_init(&rexec->calls); + ngx_queue_init(&rexec->dispatch_calls); log = filter->log; @@ -1262,7 +1262,7 @@ ngx_proxy_wasm_create_context(ngx_proxy_wasm_filter_t *filter, pwexec->ictx = ictx; pwexec->store = ictx->store; - ngx_queue_init(&pwexec->calls); + ngx_queue_init(&pwexec->dispatch_calls); } else { if (in->ictx != ictx) { @@ -1389,11 +1389,11 @@ ngx_proxy_wasm_on_done(ngx_proxy_wasm_exec_t *pwexec) #if 0 #ifdef NGX_WASM_HTTP - call = pwexec->call; + call = pwexec->dispatch_call; if (call) { ngx_http_proxy_wasm_dispatch_destroy(call); - pwexec->call = NULL; + pwexec->dispatch_call = NULL; } #endif #endif diff --git a/src/common/proxy_wasm/ngx_proxy_wasm.h b/src/common/proxy_wasm/ngx_proxy_wasm.h index 1d9c73981..6da1bc71f 100644 --- a/src/common/proxy_wasm/ngx_proxy_wasm.h +++ b/src/common/proxy_wasm/ngx_proxy_wasm.h @@ -188,9 +188,9 @@ struct ngx_proxy_wasm_exec_s { ngx_proxy_wasm_store_t *store; ngx_event_t *ev; #ifdef NGX_WASM_HTTP - ngx_http_proxy_wasm_dispatch_t *call; /* swap pointer for host functions */ + ngx_http_proxy_wasm_dispatch_t *dispatch_call; /* swap pointer for host functions */ #endif - ngx_queue_t calls; + ngx_queue_t dispatch_calls; /* flags */ @@ -231,19 +231,19 @@ struct ngx_proxy_wasm_ctx_s { size_t req_body_len; ngx_str_t authority; ngx_str_t scheme; - ngx_str_t path; /* r->uri + r->args */ - ngx_str_t start_time; /* r->start_sec + r->start_msec */ - ngx_str_t upstream_address; /* 1st part of ngx.upstream_addr */ - ngx_str_t upstream_port; /* 2nd part of ngx.upstsream_addr */ - ngx_str_t connection_id; /* r->connection->number */ - ngx_str_t mtls; /* ngx.https && ngx.ssl_client_verify */ - ngx_str_t root_id; /* pwexec->root_id */ - ngx_str_t call_status; /* dispatch response status */ - ngx_str_t response_status; /* response status */ + ngx_str_t path; /* r->uri + r->args */ + ngx_str_t start_time; /* r->start_sec + r->start_msec */ + ngx_str_t upstream_address; /* 1st part of ngx.upstream_addr */ + ngx_str_t upstream_port; /* 2nd part of ngx.upstsream_addr */ + ngx_str_t connection_id; /* r->connection->number */ + ngx_str_t mtls; /* ngx.https && ngx.ssl_client_verify */ + ngx_str_t root_id; /* pwexec->root_id */ + ngx_str_t dispatch_call_status; /* dispatch response status */ + ngx_str_t response_status; /* response status */ #if (NGX_DEBUG) - ngx_str_t worker_id; /* ngx_worker */ + ngx_str_t worker_id; /* ngx_worker */ #endif - ngx_uint_t call_code; + ngx_uint_t dispatch_call_code; ngx_uint_t response_code; /* host properties */ @@ -258,9 +258,9 @@ struct ngx_proxy_wasm_ctx_s { /* flags */ - unsigned main:1; /* r->main */ - unsigned init:1; /* can be utilized (has no filters) */ - unsigned ready:1; /* filters chain ready */ + unsigned main:1; /* r->main */ + unsigned init:1; /* can be utilized (has no filters) */ + unsigned ready:1; /* filters chain ready */ unsigned req_headers_in_access:1; }; diff --git a/src/common/proxy_wasm/ngx_proxy_wasm_host.c b/src/common/proxy_wasm/ngx_proxy_wasm_host.c index efde7b98f..3151312d7 100644 --- a/src/common/proxy_wasm/ngx_proxy_wasm_host.c +++ b/src/common/proxy_wasm/ngx_proxy_wasm_host.c @@ -127,7 +127,7 @@ ngx_proxy_wasm_get_buffer_helper(ngx_wavm_instance_t *instance, /* get */ - call = pwexec->call; + call = pwexec->dispatch_call; if (call == NULL) { return NULL; } diff --git a/src/common/proxy_wasm/ngx_proxy_wasm_maps.c b/src/common/proxy_wasm/ngx_proxy_wasm_maps.c index 1a81aa00a..856040da8 100644 --- a/src/common/proxy_wasm/ngx_proxy_wasm_maps.c +++ b/src/common/proxy_wasm/ngx_proxy_wasm_maps.c @@ -119,7 +119,7 @@ ngx_proxy_wasm_maps_get_map(ngx_wavm_instance_t *instance, case NGX_PROXY_WASM_MAP_HTTP_CALL_RESPONSE_HEADERS: pwexec = ngx_proxy_wasm_instance2pwexec(instance); - call = pwexec->call; + call = pwexec->dispatch_call; if (call == NULL) { return NULL; } @@ -782,7 +782,7 @@ ngx_proxy_wasm_maps_get_dispatch_response_status(ngx_wavm_instance_t *instance, pwexec = ngx_proxy_wasm_instance2pwexec(instance); pwctx = pwexec->parent; - call = pwexec->call; + call = pwexec->dispatch_call; reader = &call->http_reader; /* status */ @@ -799,31 +799,34 @@ ngx_proxy_wasm_maps_get_dispatch_response_status(ngx_wavm_instance_t *instance, /* update cached value */ - if (status != pwctx->call_code) { - pwctx->call_code = status; + if (status != pwctx->dispatch_call_code) { + pwctx->dispatch_call_code = status; - if (pwctx->call_status.len) { - ngx_pfree(pwctx->pool, pwctx->call_status.data); - pwctx->call_status.len = 0; + if (pwctx->dispatch_call_status.len) { + ngx_pfree(pwctx->pool, pwctx->dispatch_call_status.data); + pwctx->dispatch_call_status.len = 0; } } /* format */ - if (!pwctx->call_status.len) { - pwctx->call_status.data = ngx_pnalloc(pwctx->pool, NGX_INT_T_LEN); - if (pwctx->call_status.data == NULL) { + if (!pwctx->dispatch_call_status.len) { + pwctx->dispatch_call_status.data = ngx_pnalloc(pwctx->pool, + NGX_INT_T_LEN); + if (pwctx->dispatch_call_status.data == NULL) { return NULL; } - pwctx->call_status.len = ngx_sprintf(pwctx->call_status.data, "%03ui", - pwctx->call_code) - - pwctx->call_status.data; + pwctx->dispatch_call_status.len = ngx_sprintf( + pwctx->dispatch_call_status.data, + "%03ui", + pwctx->dispatch_call_code) + - pwctx->dispatch_call_status.data; } - ngx_wa_assert(pwctx->call_status.len); + ngx_wa_assert(pwctx->dispatch_call_status.len); - return &pwctx->call_status; + return &pwctx->dispatch_call_status; } @@ -838,7 +841,7 @@ ngx_proxy_wasm_maps_get_dispatch_status(ngx_wavm_instance_t *instance, ngx_wa_assert(map_type == NGX_PROXY_WASM_MAP_HTTP_CALL_RESPONSE_HEADERS); pwexec = ngx_proxy_wasm_instance2pwexec(instance); - call = pwexec->call; + call = pwexec->dispatch_call; sock = &call->sock; return ngx_wasm_socket_tcp_status_strerror(sock->status); diff --git a/src/http/proxy_wasm/ngx_http_proxy_wasm.c b/src/http/proxy_wasm/ngx_http_proxy_wasm.c index 463aea2b7..d44dafc4d 100644 --- a/src/http/proxy_wasm/ngx_http_proxy_wasm.c +++ b/src/http/proxy_wasm/ngx_http_proxy_wasm.c @@ -316,7 +316,7 @@ ngx_http_proxy_wasm_on_dispatch_response(ngx_proxy_wasm_exec_t *pwexec) ngx_uint_t n_headers, body_len; ngx_list_part_t *part; ngx_proxy_wasm_filter_t *filter = pwexec->filter; - ngx_http_proxy_wasm_dispatch_t *call = pwexec->call; + ngx_http_proxy_wasm_dispatch_t *call = pwexec->dispatch_call; ngx_http_wasm_req_ctx_t *rctx = call->rctx; n_headers = 0; diff --git a/src/http/proxy_wasm/ngx_http_proxy_wasm_dispatch.c b/src/http/proxy_wasm/ngx_http_proxy_wasm_dispatch.c index 220aaf1ee..3c8a6734e 100644 --- a/src/http/proxy_wasm/ngx_http_proxy_wasm_dispatch.c +++ b/src/http/proxy_wasm/ngx_http_proxy_wasm_dispatch.c @@ -63,7 +63,7 @@ invoke_on_http_dispatch_response(ngx_proxy_wasm_exec_t *pwexec, * Set current call for subsequent call detection after the step * (no yielding). */ - pwexec->call = call; + pwexec->dispatch_call = call; /** * Save step: ngx_proxy_wasm_run_step will set pwctx->step (for host @@ -92,7 +92,7 @@ invoke_on_http_dispatch_response(ngx_proxy_wasm_exec_t *pwexec, pwexec->parent->step = step; /* remove current call now that callback was invoked */ - pwexec->call = NULL; + pwexec->dispatch_call = NULL; return NGX_OK; } @@ -161,7 +161,7 @@ ngx_http_proxy_wasm_dispatch_err(ngx_http_proxy_wasm_dispatch_t *call, ngx_http_proxy_wasm_dispatch_destroy(call); - pwexec->call = NULL; + pwexec->dispatch_call = NULL; } @@ -430,7 +430,7 @@ ngx_http_proxy_wasm_dispatch(ngx_proxy_wasm_exec_t *pwexec, call->ev = ev; - ngx_queue_insert_head(&pwexec->calls, &call->q); + ngx_queue_insert_head(&pwexec->dispatch_calls, &call->q); ngx_proxy_wasm_ctx_set_next_action(pwctx, NGX_PROXY_WASM_ACTION_PAUSE);