Skip to content

Commit

Permalink
misc(proxy-wasm) rename call to dispatch_call
Browse files Browse the repository at this point in the history
Making struct member names explict to distinguish them from the upcoming
Proxy-Wasm foreign call support.
  • Loading branch information
casimiro committed Nov 26, 2024
1 parent 7c421e8 commit 31e1e86
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 48 deletions.
20 changes: 10 additions & 10 deletions src/common/proxy_wasm/ngx_proxy_wasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand All @@ -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,
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
32 changes: 16 additions & 16 deletions src/common/proxy_wasm/ngx_proxy_wasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down Expand Up @@ -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 */
Expand All @@ -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;
};

Expand Down
2 changes: 1 addition & 1 deletion src/common/proxy_wasm/ngx_proxy_wasm_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
35 changes: 19 additions & 16 deletions src/common/proxy_wasm/ngx_proxy_wasm_maps.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 */
Expand All @@ -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;
}


Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/http/proxy_wasm/ngx_http_proxy_wasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/http/proxy_wasm/ngx_http_proxy_wasm_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}


Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 31e1e86

Please sign in to comment.