embObjLib: in ethReceiver set receiving thread as non-blocking also on Windows #975
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.
In the
embObjLib
, theethReceiver
is the thread dedicated to receive the UDP messages sent by the ETH boards (such as EMS, MC4_PLUS).On Linux and macOS, this socket is set in non-blocking mode by the code:
in https://github.com/robotology/icub-main/blob/v2.6.2/src/libraries/icubmod/embObjLib/ethReceiver.cpp#L177-L180 .
However, there is no such flag on Windows, so in the Windows case the
recv
call in https://github.com/robotology/icub-main/blob/v2.6.2/src/libraries/icubmod/embObjLib/ethReceiver.cpp#L200 was actually blocking. I am not super-expert of this part of code, so I am not sure what was the effect of the code being non-blocking there on Windows, but for sure I experienced a related problem: when I was launching ayarprobotinterface
with aembObjMotionControl
device, during the close of the robotinterface, the close was hanging with message:Instead, by making the socket non-blocking also on Windows, the program exists correctly. In theory we may want to use the
recv_socket->enable(ACE_NONBLOCK);
also on Linux and macOS in place offlags |= MSG_DONTWAIT;
for uniformity and cleaning the code, but as I can't extensively test this part of the code and as it is of critical importance, for now I just made the modification on Windows, without any change for Linux and macOS.