Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix a corruption when connection writes interleaving messages #926

Merged
merged 3 commits into from
Mar 12, 2023

Conversation

romange
Copy link
Collaborator

@romange romange commented Mar 11, 2023

Fixes #924

The problem happens when a publisher sends a message and a new subscriber registers.
In that case it sends "subscribe" response and the publish messages and those
interleave sometimes.

Signed-off-by: Roman Gershman <[email protected]>
@romange romange force-pushed the FixPublishCorruption branch from 46bf90a to 36e561a Compare March 11, 2023 19:23
@romange romange requested a review from dranikpg March 11, 2023 20:10
romange added 2 commits March 11, 2023 22:37
The issue happens when SendMsgVecAsync is called with PubMessage that has
string_view objects referencing objects in stack. We replace string_view
with either string or shared_ptr<string>

Signed-off-by: Roman Gershman <[email protected]>
@romange romange force-pushed the FixPublishCorruption branch from c9a8f6c to 30bc01e Compare March 11, 2023 20:37
Comment on lines +58 to +59
std::shared_ptr<std::string> channel;
std::shared_ptr<std::string> message; // ensure that this message would out live passing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future we should probably just wrap this whole type into one shared ptr

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, it's not possible due to pattern field that is unique for each psubscriber.
we could only wrap (message,channel) together

@romange romange merged commit b88fc32 into main Mar 12, 2023
@romange romange deleted the FixPublishCorruption branch March 12, 2023 06:15
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.

Response Race On Subscription
2 participants