-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
sockfilt: fix race-condition between threads and event-processing #5156
Conversation
f9b6799
to
e409acd
Compare
Once ready, I will squash the commits into logical chunks for rebase and merge. |
0d15f25
to
299b26d
Compare
299b26d
to
8d0ff97
Compare
@bagder I am seeing a random issue with test 715, but I do not think that sockfilt is causing the error here. Would you mind taking a look and giving me your insights about this proxy related test? |
I have been running test 715 in an endless loop for nearly 1 hour now and cannot reproduce the failure: Maybe the failure happens only on a slow CI machine? I will have to figure out how to make my machine "slower"... |
It seems to be a problem in sws when it runs as a CONNECT proxy. See the
It gets the "silly content" and passes that on and then it does nothing more until it times out. It doesn't seem to detect the end if that transfer. Compare that to a functioning test case (on my Linux host):
|
Thanks, can you tell me how that end of transfer should normally be signaled? Edit: I can see that it is checking for sread returning <= 0, so I guess the socket should be closed. But by whom? Is it a socket managed by sockfilt on the other end in this case? Is there some difference in the logs regarding that? |
This:
Ie it should get signaled to read and then read zero bytes. |
I mean on the other side of the connection. What is on the other side? sockfilt? And if yes, what makes sockfilt close the connection? |
1ff4da8
to
03b3e43
Compare
03b3e43
to
17389fb
Compare
I will create another PR to handle the remaining issues regarding waitpid on Windows. For now my focus is to get this PR ready for merge to avoid the race-condition in sockfilt. |
Fix race-condition of waiting threads finishing while events are already being processed which lead to invalid or skipped events. Use mutex to check for one event at a time or do post-processing. In addition to mutex-based locking use specific event as signal. Closes curl#5156
Replace the incomplete workaround regarding FD_CLOSE only signalling once by instead doing a pre-check with standard select and storing the result for later use. select keeps triggering on closed sockets on Windows while WSAEventSelect fires only once with data still available. By doing the pre-check we do not run in a deadlock due to waiting forever for another FD_CLOSE event.
And update other logmsg output in select_ws on Windows.
17389fb
to
c330831
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Maybe remove |
This is all Windows code. I'm not qualified to review it... |
Good idea. Forgot that after pressing the "Ready for review" button.
Maybe, but I still think you are the right person to review code style and C code in general. 😄 |
Fix race-condition of waiting threads finishing while events are
already being processed which lead to invalid or skipped events.