fix: clamp negative msecs to -1 for waitForReadyRead() - #220
Merged
itay-grudev merged 5 commits intoJun 16, 2026
Merged
Conversation
waitForReadyRead() treats any negative value as an error (returning false immediately), but Qt6 defines -1 as the "wait forever" sentinel. When msecs is computed from (timeout - elapsed), it can become negative due to elapsed overflow, causing sendMessage() to silently fail. Clamp negative values to -1 so the behavior matches user intent. Fixes itay-grudev#194
re2zero
marked this pull request as ready for review
June 3, 2026 05:11
itay-grudev
approved these changes
Jun 16, 2026
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.
Summary
waitForReadyRead()silently failing when msecs is negativeProblem
QAbstractSocket::waitForReadyRead(int msecs)treats any negative value asan error and returns
falseimmediately. However, Qt6 defines-1as the"wait forever" sentinel.
In
writeConfirmedFrame(),msecsis computed as(timeout - elapsed), which can become negative when elapsed exceeds theoriginal timeout. This causes
sendMessage()to silently fail.Fix
Clamp negative msecs to
-1, which is the correct Qt6 "wait forever" value.This preserves the original intent: when the timeout budget is exhausted,
block until data arrives rather than failing immediately.
Test Plan
Fixes #194