Skip to content

Commit 34acc54

Browse files
urrskurfeex
andauthored
Apply suggestions from code review
Co-authored-by: Felix Exner <feex@universal-robots.com>
1 parent 83fa37d commit 34acc54

2 files changed

Lines changed: 3 additions & 10 deletions

File tree

include/ur_client_library/comm/stream.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ class URStream : public TCPSocket
105105
*/
106106
bool stopRequested()
107107
{
108-
const SocketState s = getState();
109-
return s == SocketState::Disconnecting || s == SocketState::Disconnected;
108+
return TCPSocket::isStopRequested();
110109
}
111110

112111
/*!

src/primary/primary_client.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,7 @@ PrimaryClient::PrimaryClient(const std::string& robot_ip, [[maybe_unused]] comm:
6767
PrimaryClient::~PrimaryClient()
6868
{
6969
URCL_LOG_INFO("Stopping primary client pipeline");
70-
// Disconnect the stream BEFORE stopping (joining) the pipeline. The pipeline's producer thread
71-
// may be sleeping inside its reconnect backoff or blocked in TCPSocket::setup(); disconnect()
72-
// moves the socket into the deliberate-stop state and closes it so both paths abort within one
73-
// poll slice and pipeline_->stop()'s join returns promptly instead of blocking until the
74-
// (potentially unbounded) reconnect timeout expires.
75-
stream_.disconnect();
76-
pipeline_->stop();
70+
stop();
7771
}
7872

7973
void PrimaryClient::start(const size_t max_num_tries, const std::chrono::milliseconds reconnection_time)
@@ -86,7 +80,7 @@ void PrimaryClient::start(const size_t max_num_tries, const std::chrono::millise
8680
void PrimaryClient::stop()
8781
{
8882
// Disconnect the stream before joining the pipeline so a producer thread stuck in its reconnect
89-
// path is aborted and the join returns promptly (see ~PrimaryClient). A subsequent start()
83+
// path is aborted and the join returns promptly. A subsequent start()
9084
// reconnects via URProducer::setupProducer(), whose connect() clears the deliberate-stop state.
9185
stream_.disconnect();
9286
pipeline_->stop();

0 commit comments

Comments
 (0)