tcp_forwarder: fix error handling in data causing a crash #1218
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Sometimes when starting
pymobiledevice3 usbmux forward 9100 9100
the process exits with an exit code = 1 when trying to connect to the socket with curl.This happens because the socket is already closed when trying to send data back.
In my case I have a WDA WebDriverAgent running on an iOS device with an mjpeg server on port 9100
And when i try to curl it, curl closes the connection without reading the response.
The device responses, passing the data to the socket. And when it's time to pass the data to the local socket - it's already closed from the curl end, so an exception is thrown which is not suppressed (I don't know why it doesn't wright anything to stderr).
The try catch block on lines 117-127 catches the exception when writing to a closed socket.
https://github.com/doronz88/pymobiledevice3/pull/1218/files#diff-60b67652b62396a6f7dc122e1ed622712e07bd537e4b507e29edfdb873a0cd17R117-R127