nic-6443 commented on code in PR #13369:
URL: https://github.com/apache/apisix/pull/13369#discussion_r3233538814


##########
apisix/control/router.lua:
##########
@@ -190,10 +189,12 @@ function _M.match(uri)
         cached_version = plugin_mod.load_times
     end
 
-    core.table.clear(match_opts)
+    local match_opts = core.tablepool.fetch("control_router_match_opts", 0, 4)
     match_opts.method = get_method()
 
-    return router:dispatch(uri, match_opts)
+    local ok = router:dispatch(uri, match_opts)
+    core.tablepool.release("control_router_match_opts", match_opts)
+    return ok

Review Comment:
   Good catch — fixed in 491760b. Now captures `ok, err` and returns both.



##########
apisix/api_router.lua:
##########
@@ -105,10 +104,11 @@ function _M.match(api_ctx)
         return false
     end
 
-    core.table.clear(match_opts)
+    local match_opts = core.tablepool.fetch("api_router_match_opts", 0, 4)
     match_opts.method = api_ctx.var.request_method
 
     local ok = api_router:dispatch(api_ctx.var.uri, match_opts, api_ctx)
+    core.tablepool.release("api_router_match_opts", match_opts)
     return ok

Review Comment:
   The original code already only captured `ok` (`local ok = 
api_router:dispatch(...)`) — my change just added the tablepool release after 
it. No behavior change here.
   
   That said, `radixtree:dispatch()` returns either `true` on success or `nil, 
err` on failure. In `api_router.lua`, the caller only checks truthiness (`if ok 
then`), so the error value was already unused. No change needed here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to