-
Notifications
You must be signed in to change notification settings - Fork 79
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
socket.c socket_receive_timeout() can hang on Windows #41
Comments
I think the real way to handle this is using WSAGetLastError(). In regards to |
Thank you for taking a look at this. I forgot to mention the way I was getting the libimobiledevice to hang was to start idevicebackup2 backup on a paired iPhone, then disconnect the USB cable about half way through the file sends. Maybe 5-10% of the time the idevicebackup2 would lockup with the CPU 100% busy reading nothing. |
I did a bit of testing this evening, adding a statement to socket_recieve_timeout() that prints WSAGetLastError(), errno, and the results from socket_check_fd() and recv(). When the disconnect occurs, socket_check_fd() returned 1, recv() returned -1 and WSAGetLastError is 10053 (connection aborted). Errno has one of the following values: 0, 2, 7, 17 with 17 being the most common. If only WSA were portable to the BSD socket standard, including errno. |
That helps. As mentioned I am in the process of integrating WSAGetLastError into the code to make sure we have proper errno set. You cannot trust errno in regards to any socket related error/status. |
Came up with this fc10c88. |
This should be resolved by now. If not feel free to re-open. |
Running into a hang with libimobiledevice on Windows tracked down to socket_receive_timeout() of socket.c, line 1296.
recv() is returning -1 on a socket with errno == 0 when the remote peer disconnected while there are still bytes to read (res > 0)
Line 1296 reads "return -errno;;"
Suggest replacing this with "return (errno == 0) ? -ECONNRESET : -errno;"
The text was updated successfully, but these errors were encountered: