Skip to content

Commit 63f1173

Browse files
Never shrink configured read timeout during connect() setup
Address review feedback: connect() unconditionally set the setup-phase read timeout to 10 s, even when getConfiguredReceiveTimeout() already returned a larger value. That temporarily shrank the in-flight read timeout during the openapi.json GET. The worst case is the lazy-connect path inside commandPowerOn: power on calls setReceiveTimeout(timeout) (typically 300 s by default), then issues a PUT. If robot_api_version_ is still empty, put() lazy-calls connect(), which would previously drop the 300 s back to 10 s for the setup GET — exactly when the controller is booting and the GET most needs the larger budget. Treat the 10 s as a minimum-headroom for the setup GET, not a cap on the caller's preferences: start from the configured value and only bump up to 10 s if it is smaller. The save/restore around the GET still honors whatever the caller had configured before connect() was entered.
1 parent 241c1a2 commit 63f1173

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/ur/dashboard_client_implementation_x.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,19 @@ bool DashboardClientImplX::connect([[maybe_unused]] const size_t max_num_tries,
9696
// temporarily extend the read timeout for setup, then restore the configured value.
9797
// The restore must run on every exit, including exceptions from json::parse or
9898
// VersionInformation::fromString — hence the catch(...) rethrow guard.
99+
//
100+
// The 10 s here is a minimum-headroom for setup, not a cap on the caller's
101+
// preferences. If the caller (or an enclosing call like commandPowerOn) has already
102+
// configured a larger read timeout, never shrink it — a lazy connect() inside such a
103+
// call would otherwise reduce the in-flight deadline during the openapi.json GET.
99104
timeval configured_tv = getConfiguredReceiveTimeout();
100-
timeval setup_tv;
101-
setup_tv.tv_sec = 10;
102-
setup_tv.tv_usec = 0;
105+
constexpr time_t kSetupMinSeconds = 10;
106+
timeval setup_tv = configured_tv;
107+
if (setup_tv.tv_sec < kSetupMinSeconds)
108+
{
109+
setup_tv.tv_sec = kSetupMinSeconds;
110+
setup_tv.tv_usec = 0;
111+
}
103112
setReceiveTimeout(setup_tv);
104113

105114
bool result = false;

0 commit comments

Comments
 (0)