Skip to content

fix SetHostSocket when add stream failed#3386

Open
lo-tk wants to merge 1 commit into
apache:masterfrom
lo-tk:fix_SetHostSocket
Open

fix SetHostSocket when add stream failed#3386
lo-tk wants to merge 1 commit into
apache:masterfrom
lo-tk:fix_SetHostSocket

Conversation

@lo-tk

@lo-tk lo-tk commented Jul 14, 2026

Copy link
Copy Markdown

What problem does this PR solve?

Issue Number: introduced by PR #2938 .

Problem Summary:

Stream::SetHostSocket performs host-socket binding inside std::call_once, which makes the first execution result effectively global for all later callers. If AddStream(id()) fails during that first attempt, the lambda returns without setting _host_socket, but the once_flag is still consumed. After that, subsequent callers cannot retry the binding logic and may only observe the post-state through the function return value. This creates a broken state where the stream is not actually attached to any host socket, while later code paths still assume the binding has succeeded, eventually triggering _host_socket == NULL checks or null-dereference style crashes.

Changed:

return _host_socket != NULL ? 0 : -1;

Side effects:

  • Performance effects:

  • Breaking backward compatibility:


Check List:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants