Skip to content

multi_timeout improvements - #22584

Closed
icing wants to merge 8 commits into
curl:masterfrom
icing:splay-on-timediffs
Closed

icing wants to merge 8 commits into
curl:masterfrom
icing:splay-on-timediffs

Conversation

@icing

@icing icing commented Aug 14, 2026

Copy link
Copy Markdown
Contributor
  • Move expire timeout code from multi into splay.c
  • keep a "time_base" timestamp to calculate timediff_t for actual timeout values. Unfortunately this means our timeouts will go wrong after ~500,000 years of continuous operations...
  • use timediff_t as key in splay instead of curltime
  • use timediff_t in transfers expire times instead of curltime
  • re-comment splay.c for better understanding how it works
  • replace splay nodes double-linked "same" list with a single link, we almost never have duplicate keys
  • keep transfer mid in splay nodes instead of the transfer pointer
  • keep registered bit in splay node for tracking instead of separate bit in transfer
  • adapt unit1309.c to changes in timediff_t and mid

- Move expire timeout code from multi into splay.c
- keep a "time_base" timestamp to calculate timediff_t for
  actual timeout values. Unfortunately this means our
  timeouts will go wrong after ~500,000 years of continuous
  operations...
- use timediff_t as key in splay instead of curltime
- use timediff_t in transfers expire times instead of curltime
- re-comment splay.c for better understanding how it works
- replace splay nodes double-linked "same" list with a single link,
  we almost never have duplicate keys
- keep transfer `mid` in splay nodes instead of the transfer pointer
- keep registered bit in splay node for tracking instead of separate
  bit in transfer
- adapt unit1309.c to changes in timediff_t and mid
@github-actions github-actions Bot added the tests label Aug 14, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors multi-handle timeout management around base-relative microsecond offsets and simplifies splay-tree nodes.

Changes:

  • Moves timeout-tree operations into splay.c.
  • Replaces timestamp keys and easy pointers with offsets and transfer IDs.
  • Updates timeout callers, tracing, tests, and size limits.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/unit/unit3214.c Updates multi-handle size limit.
tests/unit/unit1309.c Adapts splay tests to the new API.
tests/data/test1309 Updates expected test output.
lib/vdns/asyn-thrdd.c Uses renamed timer-clearing API.
lib/urldata.h Stores relative timeout offsets.
lib/url.c Clears all timers during cleanup.
lib/splay.h Defines timeout and revised splay APIs.
lib/splay.c Implements timeout management and simplified splay nodes.
lib/multiif.h Revises expiration APIs.
lib/multihandle.h Embeds timeout state in multi handles.
lib/multi.c Integrates relative timeout handling.
lib/http.c Uses renamed timer-clearing API.
lib/curlx/timeval.h Declares microsecond conversion helper.
lib/curlx/timeval.c Implements conversion helper.
lib/curl_trc.c Traces relative expiration offsets.
lib/cshutdn.c Uses consolidated expiration API.
lib/connect.c Uses consolidated expiration API.
lib/cf-ip-happy.c Uses renamed timer-clearing API.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/curlx/timeval.c Outdated
Comment thread lib/splay.c
Comment thread lib/splay.h
Comment thread lib/splay.c Outdated
- fix us_to_ms ceil to handle negative values
- update SPLAY documentation
- fix comment
- add test cases
@icing
icing requested a review from bagder August 14, 2026 15:08
@bagder bagder closed this in 3d6d93a Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

3 participants