Repository navigation
core(http): route dispatch in four chains (MSVC nesting limit) - #2362
Merged
Merged
Conversation
HttpSession::process_request matched its REST routes with one else-if chain: 88 branches, 87 else-if, nesting 111. MSVC stops at 128 (C1061, "blocks nested too deeply"). - The chain is now four consecutive else-if chains of 27, 27, 25 and 9 branches, joined by a route_matched flag (the main_dash.cpp pattern). - The first three chains end in `else route_matched = false;`. Each later chain runs only while route_matched is false. - The routes are tried in the same order. The last chain keeps the old final else: admin, explorer, static files, getinfo. - The code after the chain is unchanged. - Token diff against master, comments excluded: only the route_matched tokens are added. Chains 2-4 are indented 4 more spaces. - Longest else-if chain in process_request: 26 (was 87). Deepest nesting: 37 (was 111).
| try { | ||
| decoded.push_back(static_cast<char>( | ||
| std::stoi(hex, nullptr, 16))); | ||
| i += 2; |
|
|
||
| std::string ep = target.substr(16); // after "/api/admin/pool/" | ||
| // strip query string | ||
| auto qpos = ep.find('?'); |
| {"code", "BAD_PARAMS"}, | ||
| {"method", ep}}; | ||
| std::string ep = target.substr(16); // after "/api/admin/coin/" | ||
| auto qpos = ep.find('?'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One commit, src/core/http_session.cpp only. Responses are unchanged.
HttpSession::process_requestmatched its REST routes with one else-if chain of 87 branches (nesting 111). MSVC stops at about 128 nested blocks (C1061, as in ltc: command-line parsing under the MSVC nesting limit (Windows build) #2361), so about 17 more routes would have broken the Windows build.route_matchedflag, the patternmain_dash.cppuses.rest_result/response_bodyand fall through to the shared response code after the chain, so the split keeps that code path as it was.route_matchedtokens and three braces.process_request37.Checks (Release)
timestamp,computed_at,ts,started). They are identical once those fields are masked, and two runs of the old binary differ in exactly the same 22.