-
Notifications
You must be signed in to change notification settings - Fork 102
send_all without mutex? #43
-
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?
Beta Was this translation helpful? Give feedback.
All reactions
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
-
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 ;-).
Beta Was this translation helpful? Give feedback.
All reactions
-
This is absolutely what I meant.
Thanks for reverting back so soon!
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
Commit 6531521 serializes all sends from the same fd and the race condition should no longer exist ;-).
Thanks for noticing and reporting this issue =).
Beta Was this translation helpful? Give feedback.
All reactions
-
Reviewed. Should work. Thanks a lot!
Beta Was this translation helpful? Give feedback.
All reactions
-
🎉 1