Skip to content

thread pool and queue - #20916

Closed
icing wants to merge 10 commits into
curl:masterfrom
icing:thrdpool+queue
Closed

icing wants to merge 10 commits into
curl:masterfrom
icing:thrdpool+queue

Conversation

@icing

@icing icing commented Mar 13, 2026 •

Copy link
Copy Markdown
Contributor
  • new source files for thread pool and queue
  • test cases 3300 and 3301 for them
  • internal documentation

@icing icing added the feature-window A merge of this requires an open feature window label Mar 13, 2026
@github-actions github-actions Bot added the tests label Mar 13, 2026
@icing
icing requested a review from bagder March 13, 2026 09:51
@icing

icing commented Mar 21, 2026

Copy link
Copy Markdown
Contributor Author

@bagder ready for merge, next in line. Will continue on Monday with the other ones.

@bagder
bagder requested a review from Copilot March 21, 2026 21:34
@bagder

bagder commented Mar 21, 2026

Copy link
Copy Markdown
Member

@aisle-analyzer

@aisle-research-bot

aisle-research-bot Bot commented Mar 21, 2026 •

Copy link
Copy Markdown

🔒 Aisle Security Analysis

We found 1 potential security issue(s) in this PR:

# Severity Title
1 🔵 Low Invalid timespec in Curl_cond_timedwait() can cause pthread_cond_timedwait EINVAL and busy-loop DoS

See details in the comment below.


Analyzed PR: #20916 at commit d8a11c0

Last updated on: 2026-03-21T22:01:31Z

@bagder bagder left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

💯

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

Adds new internal thread pool (Curl_thrdpool) and thread queue (Curl_thrdq) implementations to support asynchronous work item processing, along with unit tests and internal documentation.

Changes:

  • Introduce lib/thrdpool.* and lib/thrdqueue.* plus build integration.
  • Add unit tests unit3300/unit3301 and register them in the test harness.
  • Extend tracing/threads infrastructure (condvar wrappers + Curl_trc_feat_infof) and add internal documentation.

Reviewed changes

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

Show a summary per file
File Description
tests/unit/unit3301.c Adds unit tests for thread queue behavior (send/process/recv + event callback).
tests/unit/unit3300.c Adds unit tests for thread pool behavior (min/max threads, signaling, destroy modes).
tests/unit/Makefile.inc Registers new unit test sources in the unit test bundle.
tests/data/test3301 Adds test case metadata for unit3301.
tests/data/test3300 Adds test case metadata for unit3300.
tests/data/Makefile.am Registers new test case data files for distribution.
lib/thrdqueue.h Defines the thread queue API and callbacks.
lib/thrdqueue.c Implements the thread queue using llist + thread pool.
lib/thrdpool.h Defines the thread pool API and callbacks.
lib/thrdpool.c Implements the thread pool with worker slots, signaling, and idle waiting.
lib/curl_threads.h Adds cross-platform condition-variable types and APIs under USE_MUTEX.
lib/curl_threads.c Implements cross-platform condition-variable wrappers (signal/wait/timedwait).
lib/curl_trc.h Declares Curl_trc_feat_infof() for feature-based verbose logging.
lib/curl_trc.c Implements Curl_trc_feat_infof().
lib/memdebug.c Ensures memdebug cleanup unlocks after closing the logfile.
lib/Makefile.inc Adds new lib sources/headers to the build source lists.
docs/internals/THRDPOOL+QUEUE.md Documents thread pool/queue design, operation, and safety notes.
docs/Makefile.am Registers the new internal documentation page.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/thrdpool.c Resolved
Comment thread lib/thrdqueue.c Resolved
Comment thread lib/thrdqueue.c Resolved
Comment thread lib/thrdqueue.h Resolved
Comment thread lib/thrdqueue.h Resolved
Comment thread lib/thrdqueue.c Resolved
Comment thread lib/thrdqueue.c Resolved
Comment thread lib/thrdqueue.h Resolved
Comment thread tests/unit/unit3301.c Resolved
Comment thread lib/thrdpool.h Resolved
Comment thread lib/curl_threads.c Resolved
@icing
icing requested a review from bagder March 23, 2026 12:13
@bagder bagder closed this in 6f9f4b3 Mar 23, 2026
outcast36 pushed a commit to greearb/curl that referenced this pull request Jun 3, 2026
- new source files for thread pool and queue
- test cases 3217 and 3218 for them
- internal documentation

Closes curl#20916
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature-window A merge of this requires an open feature window tests

Development

Successfully merging this pull request may close these issues.

3 participants