-
Notifications
You must be signed in to change notification settings - Fork 81
Description
Summary
This issue details two distinct concerns related to the rmf_websocket::BroadcastServer - unsafe shutdown error and a request for improved logging.
Problem: Shutdown error (Bad file descriptor)
BroadcastServer shutdown causes the following errors,
[info] Error getting remote endpoint: system:9 (Bad file descriptor)
[info] asio async_shutdown error: system:9 (Bad file descriptor)
[info] handle_accept error: Operation canceled
[info] Stopping acceptance of new connections because the underlying transport is no longer listening.
This seems to indicate a race condition or improper cleanup of the ASIO resources. It always occurs immediately after _data->echo_server.stop_listening() is called within the stop() method
rmf_ros2/rmf_websocket/src/rmf_websocket/BroadcastServer.cpp
Lines 88 to 99 in a4a984a
| /// Stop Server | |
| void stop() | |
| { | |
| std::cout << "Stop BroadcastServer" << std::endl; | |
| if (_server_thread.joinable()) | |
| { | |
| _data->echo_server.stop_listening(); | |
| _data->echo_server.stop(); | |
| // TODO: properly close all connections | |
| _server_thread.join(); | |
| } | |
| } |
Proposed fix
Ensure all server-level shutdown commands are posted to and executed on the io_service's thread (addressed in #457).
Feature Request: Replace stdout logging
Currently BroadcastServer uses std::cout for logging output which streams directly to standard output. I would like to propose replacing direct std::cout calls with ROS 2 logging. This would involve passing a node by modifying the BroadcastServer's constructor.
API/ABI compatibility concerns
This would likely constitute an API break for rmf_websocket as constructor for BroadcastServer would change. It might also have ABI implications that I am not aware of. An initial search of the all Open-RMF repos indicates that this class is only ever used in the following tests
using WebsocketServer = rmf_websocket::BroadcastServer; using WebsocketServer = rmf_websocket::BroadcastServer;
So the question to maintainers, is this break acceptable so that we can stream logs to ROS 2 logging instead of stdout?