Check if async connect() is success before read() or wirte() in TransportTCP#1202
Check if async connect() is success before read() or wirte() in TransportTCP#1202bxwllzz wants to merge 1 commit intoros:melodic-develfrom
Conversation
…CP::read() and TransportTCP::write()
|
This looks sane, and hasn't broken anything for us, but the usual caveats apply around ABI compatibility. |
|
Dropping this for now because it doesn't merge cleanly with #1217, which Clearpath needs to have in the |
|
@mikepurvis wrote:
'we'? |
|
Sorry— the |
|
Can you please consider merging this before "future-release"? |
|
Since the patch breaks ABI compatibility it is not straigh forward to merge this into already released distros. I created #1270 to find a consensus on the general question since I want to avoid this discussion on each PR. |
|
@mikepurvis To avoid breaking ABI compatibility, the But I think |
|
@dirk-thomas @mikepurvis: just curious: is this PR on the list to get merged into Melodic? Without this change, ROS1 on WSL is almost unusable. |
|
@bxwllzz Please consider to resolve the conflicts / rebase this to target the latest state of the target branch in order to be considered for the upcoming Noetic distro. |
|
@bxwllzz Closing due to no further reply. Please feel free to open a new PR against |
|
@dirk-thomas: is there any way to get this merged in Noetic after the initial release? This is still an issue with ROS in WSL which effectively makes it impossible to use ROS on WSL 1. |
|
Since it seems to break ABI it is very unlikely to get released into an already released distro (see my previous comment: #1202 (comment)). Anyone could try to rebase this patch and create a new PR targeting |
I found a bug in
transport_tcp.cppwhen I using ROS inWindows Subsystem for Linux (WSL).TransportTCP::read()did not check if aync socket is conneted. If socket is asynchronous, it may fails at recv() if its slow to connect (e.g. happens with wireless).TransportTCP::read()andTransportTCP::write()needs to check if its connected or not if it's asynchronous.Detailed debug log
Test Environment:
Fix
I add function
is_async_connected()toio.h. Given a socket which is still async connecting, this function will check if the connection is success, failed or still processing.And I add a private member
async_connected_to TransportTCP.Before every read() or write() on async socket, if async_connected_ is false, it will call
is_async_connected()to check it. If it's connected,async_connected_is set to true.Test
WSL and Ubuntu
I have tested this fix in my multi-machine project using the patched ros_comm (https://github.com/bxwllzz/ros_comm/tree/kinetic-fix-transport-tcp)
Only on Ubuntu
test_roscpp
I have also run unit_tests by running
catkin_make run_testsin ros_comm package for both WSL and Ubuntu.catkin_test_results build/test_results/test_roscpp/reports no failures.Maybe more tests about
is_async_connected()is needed for native Windows. Becauseselect()in WinSock is a little different from that in Unix. I have read documents about WinSock connect() select() and Unix connect() seriously to implementeis_async_connected().If other WSL users wants to try this fix for ROS Kinetic ahead, please clone my branch kinetic-fix-transport-tcp to your catkin workspace.