Skip to content

fix: Reduce the chance of CurlEventPublisher exhausting file descriptors on high throughput PHP-FPM servers #216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/LaunchDarkly/Impl/Integrations/CurlEventPublisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class CurlEventPublisher implements EventPublisher
private bool $_ssl;
private string $_curl = '/usr/bin/env curl';
private int $_connectTimeout;
private int $_timeout;
private bool $_isWindows;

/** @var array<string, string> */
Expand Down Expand Up @@ -51,6 +52,7 @@ public function __construct(string $sdkKey, array $options = [])

$this->_eventHeaders = Util::eventHeaders($sdkKey, $options);
$this->_connectTimeout = $options['connect_timeout'];
$this->_timeout = $options['timeout'];
$this->_isWindows = PHP_OS_FAMILY == 'Windows';
}

Expand Down Expand Up @@ -81,6 +83,7 @@ private function createCurlArgs(string $payload): string
$scheme = $this->_ssl ? "https://" : "http://";
$args = " -X POST";
$args.= " --connect-timeout " . $this->_connectTimeout;
$args.= " --max-time " . $this->_timeout;

foreach ($this->_eventHeaders as $key => $value) {
if ($key == 'Authorization') {
Expand Down