You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TASK-053 step 2: cut dispatch over to lookup_v2 behind flag
Adds resolve_resource_for_request_v2 alongside the v1 resolver and
routes finalize_answer through it by default (use_lookup_v2_ flag,
true by default; transitional — removed in step 3).
The new resolver:
* Preserves the parent->single_resource fast path verbatim (it reads
registered_resources, which v1 also did — that data store is
orthogonal to the route-table tier choice).
* Otherwise delegates to lookup_v2 (cache -> exact -> radix -> regex),
extracts the shared_ptr<http_resource> arm of route_entry::handler,
replays captured_params into mr->dhr via set_arg, and populates
matched_path_template / matched_is_prefix for the hook ctx (gated
on need_path_template like the v1 resolver).
Two correctness fixes wired in alongside the cutover:
1. lookup_v2 was moving result.entry into the cache_value before
returning result to the caller. Pre-TASK-053 no caller read
result.entry.handler (lookup_pipeline_test only checks
.found / .tier), so the bug was latent. Once the resolver started
calling std::get_if<shared_ptr<...>> on the returned entry, every
dispatch saw a moved-from variant and 404'd. Copy on insert
instead — one shared_ptr ref-count bump and one captures-vector
copy on the cache-miss path, no effect on cache hits.
2. route_cache::find_by_view crashed on a fresh cache (bucket_count()
== 0 on libc++; cbegin(0)/cend(0) dereferences a null bucket-list
pointer). Pre-TASK-053 this path was test-only, so the UB was
dormant; the dispatch cutover puts find_by_view on the request
hot path, so the first request against a fresh server reliably
reproduced the crash. Early-out when bucket_count() == 0.
All v2_dispatch_contract, routing_regression, lookup_pipeline,
route_table_concurrency, hooks_route_resolved_miss_and_hit,
webserver_register_path_prefix, webserver_on_methods, webserver_route
suites pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments