Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

send_all without mutex? #43

Answered by Theldus
iyer-arvind asked this question in Q&A
Discussion options

Maybe very trivial: Going through the code, it is not obvious to me how without locking a (client specific?) mutex in send_all is it ensured that two large frames sent from different threads avoid queuing up their send without exclusion.

If this happens, there is no guarantee of order of send, and the message will get mixed up.

Am I missing something?

You must be logged in to vote

Hi @iyer-arvind,
It is a good question. I've never thought about it. You mean two or more messages from two or more threads to the same client, right?

I think you are right. If send (within send_all) cannot send the entire frame at once, there may be a race condition between multiple sends fighting over a single fd/client.

Please let me know if I understand your question correctly so I can push a fix as soon as possible ;-).

Replies: 1 comment 3 replies

Comment options

Hi @iyer-arvind,
It is a good question. I've never thought about it. You mean two or more messages from two or more threads to the same client, right?

I think you are right. If send (within send_all) cannot send the entire frame at once, there may be a race condition between multiple sends fighting over a single fd/client.

Please let me know if I understand your question correctly so I can push a fix as soon as possible ;-).

You must be logged in to vote
3 replies
Comment options

This is absolutely what I meant.

Thanks for reverting back so soon!

Comment options

Commit 6531521 serializes all sends from the same fd and the race condition should no longer exist ;-).

Thanks for noticing and reporting this issue =).

Comment options

Reviewed. Should work. Thanks a lot!

Answer selected by iyer-arvind
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /