Skip to content

Commit cdd9988

Browse files
Use plain timeval members instead of unique_ptr for X timeouts
The std::unique_ptr<timeval> indirection was carried over from DashboardClientImplG5, where it composes with TCPSocket's existing unique_ptr<timeval> member. In DashboardClientImplX it bought nothing: no nullable semantics are needed because the constructor now installs a 10 s default that every getter falls back to anyway. Replace recv_timeout_ and send_timeout_ with value-typed timeval members defaulted to {10, 0}. setReceiveTimeout / setSendTimeout assign directly; the getters return the member. Behavior is preserved (verified end-to-end against a stalling-server test that times connect() at the configured value).
1 parent cae7489 commit cdd9988

2 files changed

Lines changed: 6 additions & 29 deletions

File tree

include/ur_client_library/ur/dashboard_client_implementation_x.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,8 @@ class DashboardClientImplX : public DashboardClientImpl
186186

187187
std::unique_ptr<httplib::Client> cli_;
188188
VersionInformation robot_api_version_;
189-
// Caller-configured timeouts. Null until the corresponding setter is called explicitly;
190-
// the getters fall back to the constructor default (10 s) in that case. Mirrors the
191-
// recv_timeout_ pattern used by DashboardClientImplG5.
192-
std::unique_ptr<timeval> recv_timeout_;
193-
std::unique_ptr<timeval> send_timeout_;
189+
timeval recv_timeout_ = {10, 0};
190+
timeval send_timeout_ = {10, 0};
194191
};
195192

196193
} // namespace urcl

src/ur/dashboard_client_implementation_x.cpp

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ DashboardClientImplX::DashboardClientImplX(const std::string& host) : DashboardC
6767

6868
void DashboardClientImplX::setReceiveTimeout(const timeval& timeout)
6969
{
70-
recv_timeout_ = std::make_unique<timeval>(timeout);
70+
recv_timeout_ = timeout;
7171
if (cli_)
7272
{
7373
cli_->set_read_timeout(std::chrono::seconds(timeout.tv_sec) + std::chrono::microseconds(timeout.tv_usec));
@@ -76,7 +76,7 @@ void DashboardClientImplX::setReceiveTimeout(const timeval& timeout)
7676

7777
void DashboardClientImplX::setSendTimeout(const timeval& timeout)
7878
{
79-
send_timeout_ = std::make_unique<timeval>(timeout);
79+
send_timeout_ = timeout;
8080
if (cli_)
8181
{
8282
cli_->set_write_timeout(std::chrono::seconds(timeout.tv_sec) + std::chrono::microseconds(timeout.tv_usec));
@@ -160,33 +160,13 @@ timeval DashboardClientImplX::getConfiguredReceiveTimeout() const
160160
// return that. Otherwise fall back to the constructor default. See the constructor
161161
// comment for the rationale on the 10 s default (covers brake_release / program
162162
// load/upload/download without per-method timeouts).
163-
timeval tv;
164-
if (recv_timeout_ != nullptr)
165-
{
166-
tv = *recv_timeout_;
167-
}
168-
else
169-
{
170-
tv.tv_sec = 10;
171-
tv.tv_usec = 0;
172-
}
173-
return tv;
163+
return recv_timeout_;
174164
}
175165

176166
timeval DashboardClientImplX::getConfiguredSendTimeout() const
177167
{
178168
// Mirrors getConfiguredReceiveTimeout. Default of 10 s matches the constructor.
179-
timeval tv;
180-
if (send_timeout_ != nullptr)
181-
{
182-
tv = *send_timeout_;
183-
}
184-
else
185-
{
186-
tv.tv_sec = 10;
187-
tv.tv_usec = 0;
188-
}
189-
return tv;
169+
return send_timeout_;
190170
}
191171

192172
VersionInformation DashboardClientImplX::queryPolyScopeVersion()

0 commit comments

Comments
 (0)