[Windows][melodic-devel] workaround WSAPoll doesn't report failed connections. #1816
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.
This fixes ms-iot/ROSOnWindows#151
The original problem manifests as
ros::master::check()
never return back when themaster
is not running. It turns out that it is waiting forWSAPoll
to be returned, which is at this below line:ros_comm/utilities/xmlrpcpp/src/XmlRpcDispatch.cpp
Line 125 in d487d58
However, for a non-blocking socket which has a failed connection,
WSAPoll
exhibits a behavior which is not to signal this error for the caller, and with the infinite timeout, it just waits forever. There are many discussions about this behavior.To workaround this issue, I am proposing for Windows platform adding a connection readiness pre-checks for writable sockets, which can be done by calling
select
and it will come back with a result immediately whether it is anconnection-error
socket orwritable-ready
socket. After we have the result, we can decide to error out or go ahead with the originalWSAPoll
to finish its job.