Skip to content

Always call HttpUtility::SendJsonBody() with a boost::asio::yield_context - #10764

Closed
Al2Klimov wants to merge 2 commits into
masterfrom
SendJsonBody-yield_context
Closed

Always call HttpUtility::SendJsonBody() with a boost::asio::yield_context#10764
Al2Klimov wants to merge 2 commits into
masterfrom
SendJsonBody-yield_context

Conversation

@Al2Klimov

@Al2Klimov Al2Klimov commented Mar 19, 2026

Copy link
Copy Markdown
Member

to respect l_FlushThreshold in all messages.

Especially l_FlushThreshold may now be lowered in the future without re-evaluating all possible responses.

Side effect: all HTTP responses use chunked encoding now.

By the way...

@Al2Klimov
Al2Klimov requested a review from yhabteab March 19, 2026 14:18
@cla-bot cla-bot Bot added the cla/signed label Mar 19, 2026
@Al2Klimov
Al2Klimov force-pushed the SendJsonBody-yield_context branch from 36ed2d0 to c56cbaa Compare March 26, 2026 14:45
@Al2Klimov
Al2Klimov force-pushed the SendJsonBody-yield_context branch 3 times, most recently from 1d14ee6 to 0f9e718 Compare July 1, 2026 12:59
Al2Klimov added 2 commits July 1, 2026 15:01
…context`

to respect `l_FlushThreshold` in all messages.

Especially `l_FlushThreshold` may now be lowered in the future
without re-evaluating all possible responses.

Side effect: all HTTP responses use chunked encoding now.
@Al2Klimov
Al2Klimov force-pushed the SendJsonBody-yield_context branch from 0f9e718 to 7843c64 Compare July 1, 2026 13:01
@julianbrost

Copy link
Copy Markdown
Member

As you seem to be putting more effort into this one recently:

to respect l_FlushThreshold in all messages.

Especially l_FlushThreshold may now be lowered in the future without re-evaluating all possible responses.

I'm not immediately convinced if this is a good idea. In particular, all the handlers that make use of chunked encoding so far where checked for patterns that would cause problems with yielding coroutines. In particular:

// This is safe.
ObjectLock olock(something);
HttpUtility::SendJsonBody(response, params, result);

// Now it becomes unsafe as `yc` may yield and resume on a different thread,
// but C++ std mutexes must be released on the same thread.
ObjectLock olock(something);
HttpUtility::SendJsonBody(response, params, result, yc);

So this change means the same burden for every single handler.

Also, chunked encoding also isn't something that we must use just for the sake of it, it's sufficient if handlers that are expected to generate large responses use it.

@Al2Klimov

Copy link
Copy Markdown
Member Author

Damn.

@Al2Klimov Al2Klimov closed this Jul 1, 2026
@Al2Klimov
Al2Klimov deleted the SendJsonBody-yield_context branch July 1, 2026 13:42
@yhabteab
yhabteab removed their request for review July 1, 2026 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants