Repository navigation
Conversation
|
I added a test because i noticed there wasn't one for async stdin, only for normal stdin upload. the failing test seems to be unrelated |
7a477fb to
481e91f
Compare
d68d1b2 to
971b83e
Compare
|
both tests are still failing in the torture test because of the socket fd which the main thread passes to the background thread. I don't see a solution other than making valgrind ignore it somehow because the socket needs to be alive throughout the whole program lifecycle. |
Is there perhaps a way to wait for that thread before exit, |
b4f3e7e to
f89318e
Compare
waiting for the thread is not really an option because it is inside a blocking read call most of the time and the fd needs to be open until exit. |
I had only tested it by typing into stdin directly tbh. After testing like you did, it always sent the data for me but not the concluding However, I wasn't able to reproduce the case where it doesn't send the data at all. Could you test it again with the new commits and tell me if it still happens pls? |
|
Ill have some time this week to do some testing as well. There's a more detailed use-case in https://github.com/denandz/httpstream2tcp |
I can no longer reproduce either problem with your updated branch. The no content problem involved a debug break which was interactive, as I showed earlier. My guess is it was a timing dependent problem and had nothing to do with the debugger. |
I don't really have a debugger setup on windows, so I tried to test it with But I guess it is fixed now if you can't reproduce it either. |
|
Viktor before this is landed I'd like more time to hear from @denandz to make sure everything is ok with his setup which may be more complicated than our tests. |
Sounds good to me. Short of his blessing, I'd be happy to land this on the next cycle, if no one else is reporting issues. Do we know specifics about @denandz setup? |
Yes:
|
|
Thank you for your patience, team. Busy week on my end. I've successfully tested these changes with httpstream2tcp and OpenSSH. No issues on my end, LGTM and blessings given! 🙏 |
|
sry for the noise. I had committed a faulty change, which I now reverted by resetting to the previous commit, so nothing has changed in total. However, there is a flaky netbsd test which is failing now. I don't have anything more to add to this pr, its done from my side. |
It is a dangerous function. Remove usage by only starting the thread after setup completed successfully. Ref: https://learn.microsoft.com/windows/win32/api/processthreadsapi/nf-processthreadsapi-terminatethread Ref: curl#21467 (comment) Ref: curl#18996 (comment) Ref: curl#18451 Follow-up to 9a26633 curl#17572 Closes curl#22383
|
I've squashed your commits and rebased on upstream/master to prepare for landing this. I've force-pushed the proposed final commit to your branch. Since there was dual author information I used the one with your real name (also the name on your github profile). Please amend the commit meta if necessary. After it passes CI I will take a final look. for example While reviewing this PR I found two issues related to this stdin upload area but separate from this PR so I will address them separately. The first is how curl can ignore truncated data on stdin (this is how I saw 0 content being uploaded in the debugger), filed as #22682. The second is CPU usage issue like if stdin is used like to type to peer and back and forth and it's waiting a lot, filed as #22640. |
It is a dangerous function. Remove usage by only starting the thread after setup completed successfully. Ref: https://learn.microsoft.com/windows/win32/api/processthreadsapi/nf-processthreadsapi-terminatethread Ref: curl#21467 (comment) Ref: curl#18996 (comment) Ref: curl#18451 Follow-up to 9a26633 curl#17572 Closes curl#22383
done. Thank you for your work |
|
Thanks |
- Don't do premature write shutdown (SHUT_WR) on the socket used to read the stdin data (aka socket_r). - Remove broken setsockopt call for SO_DONTLINGER on socket_r. - Treat ReadFile receiving 0 bytes as valid (it seems this is allowed). Prior to this change a partial shutdown of the write side of the read socket that the main thread reads stdin data from (socket_r) happened before reading the data from the socket. The partial shutdown caused a FIN to be sent which lingered for ~2 minutes (typical OS configured time), and after that time the connection was terminated. Theory of operation to read stdin on windows is a connection is established to relay stdin from a dedicated thread (write to socket_w) to the main thread (read from socket_r) so reading stdin is non-blocking. Data truncation would occur if this process was not completed by the linger time. Ref: curl#22383 (comment) Closes #xxxx
- Don't do premature write shutdown (SHUT_WR) on the socket used to read the stdin data (aka socket_r). - Don't do premature read shutdown (SHUT_RD) on the socket used to write the stdin data (aka socket_w). - Remove broken setsockopt call for SO_DONTLINGER on socket_r. - Wait until all data sent from socket_w is acknowledged by socket_r. Prior to this change a partial shutdown of the write side of the read socket that the main thread reads stdin data from (socket_r) happened before reading the data from the socket. The partial shutdown caused a FIN to be sent which lingered for ~2 minutes (typical OS configured time), and after that time the connection was terminated. Theory of operation to read stdin on windows is a connection is established to relay stdin from a dedicated thread (write to socket_w) to the main thread (read from socket_r) so reading stdin is non-blocking. Data truncation would occur if this process was not completed by the OS FIN reply wait time. Note this FIN wait time is not the same as SO_LINGER wait time, the latter only used by closesocket. Ref: #22383 (comment) Closes #22682
It is a dangerous function. Remove usage by only starting the thread after setup completed successfully.
Ref: https://learn.microsoft.com/windows/win32/api/processthreadsapi/nf-processthreadsapi-terminatethread
Ref: #21467 (comment)
Ref: #18996 (comment)
Ref: #18451
Follow-up to 9a26633 #17572