Skip to content

THRIFT-4171: Add setConnectTimeout to PHP TSocket#3531

Open
sveneld wants to merge 2 commits into
apache:masterfrom
sveneld:THRIFT-4171
Open

THRIFT-4171: Add setConnectTimeout to PHP TSocket#3531
sveneld wants to merge 2 commits into
apache:masterfrom
sveneld:THRIFT-4171

Conversation

@sveneld
Copy link
Copy Markdown
Contributor

@sveneld sveneld commented May 26, 2026

Resolves THRIFT-4171.

TSocket::setSendTimeout() was the only way to set the timeout passed to fsockopen()/pfsockopen(), so callers had to choose between a short connect timeout (good) and a short write timeout (often unwanted). Adds a separate setConnectTimeout(int $timeout) method; if it is not called, open() falls back to the send timeout, preserving today's behaviour.

Two unit tests cover both paths: the BC fallback and the override.

This addresses the same problem as the original PR #744, restructured around the typed properties introduced in recent PHP-library refactors.

  • Apache JIRA ticket: THRIFT-4171
  • Title follows THRIFT-NNNN: …
  • Squashed to a single commit
  • No breaking change — additive method; existing callers keep current behaviour
  • [skip ci] (n/a — code change)

Client: php

setSendTimeout() was used both as send timeout and as the timeout
argument to fsockopen(), so callers had no way to set a short connect
timeout without also shortening writes. Add setConnectTimeout(); if it
is not called, open() falls back to setSendTimeout() for backwards
compatibility.

Generated-by: Claude Opus 4.7
@mergeable mergeable Bot added the php label May 26, 2026
Fires only when the caller actually called setSendTimeout() — i.e., the
'I tuned send timeout expecting it to also bound connect' usage that
THRIFT-4171 is closing off. Default-constructed sockets (no
setSendTimeout, no setConnectTimeout) keep the existing fallback
silently so unrelated tests are not noisy.

Generated-by: Claude Opus 4.7
@sveneld
Copy link
Copy Markdown
Contributor Author

sveneld commented May 26, 2026

Pushed dfc68b3 adding an E_USER_DEPRECATED notice when open() falls back to the send timeout for the connect step. Gated on whether the caller actually invoked setSendTimeout(), so default-constructed sockets (or sockets where only the new setConnectTimeout() is used) stay silent. Notice wording follows the pre-1.0 convention — "will be removed in the next version".

@sveneld sveneld marked this pull request as ready for review May 27, 2026 20:21
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