Skip to content

THRIFT-6370: PHP: Give each TCurlClient its own curl handle - #3947

Draft
sveneld wants to merge 1 commit into
apache:masterfrom
sveneld:php-curl-instance-handle
Draft

sveneld wants to merge 1 commit into
apache:masterfrom
sveneld:php-curl-instance-handle

Conversation

@sveneld

@sveneld sveneld commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

TCurlClient instances currently share a static curl handle. If client A sets a 100 ms timeout, a new client B with no timeout inherits it: a response that arrives after 350 ms fails after about 100 ms. The connection timeout is shared in the same way.

Give each client its own reusable curl handle. Closing a client or handling a failed transfer releases only that client's handle. Remove the global shutdown callback so PHP can release the handle with its owning object.

JIRA: THRIFT-6370

Task: PHP: Give each TCurlClient its own curl handle

Acceptance criteria:

  • Timeout and connection-timeout settings do not carry over to another client.
  • Repeated requests reuse the owning client's handle.
  • Closing a client or failing its request leaves other clients' handles usable.
  • A subsequent request recreates a released handle.

Compatibility: closeCurlHandle() becomes an instance method. Replace TCurlClient::closeCurlHandle() with $client->closeCurlHandle(), or use $client->close() to release its handle and clear its buffers. The PHP README documents this change. Connections are reused within a client instance rather than shared across instances.

Validation on PHP 8.2.30 with PHPUnit 10.5.65:

  • The new timeout-isolation regression test failed before the implementation change, showing B using A's handle and both timeout settings.
  • All 35 TCurlClientTest cases and 4 TCurlClientRedirectTest cases pass after the change.
  • PHPCS passes for the changed PHP files; git diff --check is clean.
  • make style was attempted but is unavailable in the unconfigured worktree (No rule to make target 'style').

Implementation and regression tests were AI-assisted.

Generated-by: Codex (GPT-6)

Client: php

Keep curl options and handle cleanup local to each client. Add regression coverage for independent timeout settings, handle reuse and cleanup. Apache JIRA ticket pending; this change is prepared as a draft.

Generated-by: Codex (GPT-6)
@mergeable mergeable Bot added the php label Sep 23, 2026
@sveneld sveneld changed the title PHP: Give each TCurlClient its own curl handle (JIRA pending) THRIFT-6370: PHP: Give each TCurlClient its own curl handle Sep 26, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant