You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
IpmiClient timeout: cleanup runs alongside the still-running worker, and Close Session is never confirmed #132
Where:src/main/java/org/metricshub/ipmi/client/IpmiClient.java (try-with-resources around Utils.execute), src/main/java/org/metricshub/ipmi/client/Utils.java (execute), src/main/java/org/metricshub/ipmi/client/runner/AbstractIpmiRunner.java (close).
Context: Codex raised this on #124: Utils.execute() only bounds the runner's call(); the try-with-resources in each IpmiClient method then calls AbstractIpmiRunner.close() on the calling thread, after the deadline, so the cleanup is not covered by IpmiClientConfiguration.timeout.
close() then runs on the calling thread while the worker is still using the connector: closeSession() sends Close Session without waiting for its reply (the SessionValid state switches to Authcap and sends the request), and tearDown() closes the UDP socket and the timers under the running worker, which then fails and logs errors.
In the current code nothing in close() waits for a reply, so the caller's TimeoutException is not delayed in practice. But this is not guaranteed by design or by any test, and:
Close Session is never confirmed: if it is lost, the BMC session stays allocated until it expires;
confirm Close Session with a short timeout taken from the remaining budget (best effort, never beyond the deadline);
make close() null-safe and idempotent;
add a test against a fake BMC (a local UDP socket that answers the handshake and then drops replies) asserting that every IpmiClient method returns within timeout plus a small margin, and that no library thread survives.
No documentation change is needed until this is fixed.
Where:
src/main/java/org/metricshub/ipmi/client/IpmiClient.java(try-with-resources aroundUtils.execute),src/main/java/org/metricshub/ipmi/client/Utils.java(execute),src/main/java/org/metricshub/ipmi/client/runner/AbstractIpmiRunner.java(close).Context: Codex raised this on #124:
Utils.execute()only bounds the runner'scall(); the try-with-resources in eachIpmiClientmethod then callsAbstractIpmiRunner.close()on the calling thread, after the deadline, so the cleanup is not covered byIpmiClientConfiguration.timeout.What the code does today:
Utils.execute()cancels the future (cancel(true)) and callsshutdownNow()without waiting for the worker. BecauseConnection.waitForResponse()swallowsInterruptedException(Timeouts and cancellation: waitForResponse counts sleeps instead of wall-clock, swallows InterruptedException, and non-daemon threads keep the JVM alive #79), the worker usually keeps running.close()then runs on the calling thread while the worker is still using the connector:closeSession()sends Close Session without waiting for its reply (theSessionValidstate switches toAuthcapand sends the request), andtearDown()closes the UDP socket and the timers under the running worker, which then fails and logs errors.close()waits for a reply, so the caller'sTimeoutExceptionis not delayed in practice. But this is not guaranteed by design or by any test, and:close()throwsNullPointerExceptionwhenstartSession()failed before the connector was created (Timeouts and cancellation: waitForResponse counts sleeps instead of wall-clock, swallows InterruptedException, and non-daemon threads keep the JVM alive #79).Suggested fix:
close()null-safe and idempotent;IpmiClientmethod returns withintimeoutplus a small margin, and that no library thread survives.No documentation change is needed until this is fixed.
Related: #77 (per-message timeout), #78 (sync retry), #79 (cancellation, non-daemon threads).