Fixed misleading error text on TCP connect timeout - #155
Open
julien-l wants to merge 1 commit into
Open
Conversation
When poll()/select() reports a timeout while waiting for a non-blocking connect() to complete, requestAssociationTCP() appended the last network error code to the condition text. No error code has been set in that case, so the text was that of error code 0, resulting in messages like TCP Initialization Error: Success (Timeout) on POSIX platforms, or "No error (Timeout)" on Windows, which reads as both a failure and a success at the same time. Report the timeout on its own instead. This complements the fix in the rc < 0 branch (GitHub PR DCMTK#129), which caches the error code before it is reset by close()/closesocket().
julien-l
force-pushed
the
fix-tcp-timeout-error-text
branch
from
July 30, 2026 19:28
2a42bf7 to
4278d4b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a connection attempt times out,
requestAssociationTCP()produces a condition text thatclaims both failure and success at the same time:
(macOS/Linux; on Windows the same path yields
No error (Timeout).)In
dcmnet/libsrc/dulfsm.cc, the non-blockingconnect()is awaited withpoll()/select().A return value of
0means timeout, not error — no error code has been set — but the timeoutbranch appended
OFStandard::getLastNetworkErrorCode().message()anyway, which renders errorcode 0 as
"Success"/"No error".This is the sibling of #129, which fixed the
rc < 0branch by caching the error code beforeclose()/closesocket()resets it. That fix is inmaster; therc == 0timeout branch stillreports error code 0.
Fix
Drop the error-code text from the timeout branch and report the timeout on its own:
One-line change plus a comment explaining why no error code is reported there.
Reproducing
Any SCU with a connect timeout set (
DcmSCU::setConnectionTimeout()) against an unreachablehost that silently drops SYN, e.g.:
A host that actively refuses gets
ECONNREFUSEDvia thegetsockopt(SO_ERROR)branch, so thebogus text only shows on a genuine timeout.
Observed with 3.6.9 and reproducible on current
master; the affected lines are unchangedin 3.7.0.