-
Notifications
You must be signed in to change notification settings - Fork 84
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
Fix POSIX transport profiles #321
base: develop
Are you sure you want to change the base?
Conversation
The proposed implementation restarts blocking operations like This could be prevented by setting the timeout to 0 after |
We need |
Ok. I've pushed a commit that sets the timeout to 0 after the first occurrence of an EINTR interrupt. |
Could you explain the purpose of this last commit? |
You can also recalculate the timeout as we do here: Micro-XRCE-DDS-Client/src/c/core/session/session.c Lines 335 to 344 in 160fc85
|
Let's say the timeout is 1 second. And after half a second a signal is received and If you prefer, I can add calls to |
Yes please, make it block the required time. |
41b292f
to
18b285a
Compare
I've pushed a fix to compute the remaining time. |
18b285a
to
705369b
Compare
I've included |
@Acuadros95 can we test this in integration tests? |
Integration tests running on eProsima/Micro-XRCE-DDS#144 Tests are OK! |
I just pushed another commit to fix the non-polling versions of the UDP and TCP transport profiles. To behave identically to the polling versions, receive timeouts should not be treated as errors. |
This commit fixes the socket type used with getaddrinfo(). It was SOCK_DGRAM, but it should be SOCK_STREAM for TCP. Additionally, it adds a signal handler for SIGPIPE on Linux, similar to the polling implementation. Signed-off-by: J. S. Seldenthuis <[email protected]>
Blocking I/O functions, like connect(), poll(), send() and recv(), will return -1 with errno == EINTR if the process/thread is interrupted by a signal. This is not an I/O error, but generally means the operations should be restarted. This commit implements the auto-restart behavior, which allows the transport profiles to be used in environments that generate a lot of signals, like the FreeRTOS simulator for Linux. Signed-off-by: J. S. Seldenthuis <[email protected]>
This commit recomputes the timeout in uxr_read_*_data_platform() after each occurrence of an EINTR interrupt. This ensures that the function will never block longer than the specified timeout. Signed-off-by: J. S. Seldenthuis <[email protected]>
c66ca5b
to
eb8fa97
Compare
How can I see the error here? I can't find why the build is failing. |
Click the tag and go to the In this case uncrustify is failing on the following files:
You can use this uncrustify.cfg to fix the style: https://raw.githubusercontent.com/eProsima/cpp-style/master/uncrustify.cfg |
The non-polling versions of the POSIX transport profiles shoud behave the same as the polling versions. That means that a receive timeout, because no data was available, is not an error. Signed-off-by: J. S. Seldenthuis <[email protected]>
eb8fa97
to
73340ab
Compare
@Acuadros95, thanks. I've fixed the issues. |
This pull requests adds proper handling of EINTR to the UDP and TCP transport profiles on POSIX platforms.
Some platforms, like the FreeRTOS simulator for Linux, generate a lot signals. This causes blocking I/O functions (like
connect()
,poll()
,send()
andrecv()
) to fail witherrno == EINTR
. Currently, Micro-XRCE-DDS-Client assumes this means the connection has been lost. Instead, it should restart the I/O operation and try again. This pull request implements the auto-restart behavior.Additionally, #318 contains a bug in
getaddrinfo()
(the socket type for TCP should beSOCK_STREAM
instead ofSOCK_DGRAM
). Also, it didn't register a signal handler forSIGPIPE
, like the polling TCP transport does. This pull request fixes both of those issues.I've tested these changes with the FreeRTOS simulator for POSIX and they fix the communication issues we had there.