From c89e2320ee58922a6e8c1cdf206cfff6412241e5 Mon Sep 17 00:00:00 2001 From: Markus Staab <47448731+clxmstaab@users.noreply.github.com> Date: Tue, 2 Dec 2025 09:41:06 +0100 Subject: [PATCH 1/4] Share DNS and Connect between curl requests reduces overhead when doing multiple curl requests per php-request. other places which manually invoke `curl_init` can benefit in a similar way by adding such code. `curl_multi_*` will automatically share caches between requests, without the need for additional code. --- src/JiraClient.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/JiraClient.php b/src/JiraClient.php index 4f279da..243cf99 100644 --- a/src/JiraClient.php +++ b/src/JiraClient.php @@ -158,6 +158,18 @@ public function curlPrepare(\CurlHandle|bool $ch, array $curl_http_headers, ?str curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->getConfiguration()->getTimeout()); } + if (\function_exists('curl_share_init_persistent')) { + $share = curl_share_init_persistent([ + CURL_LOCK_DATA_DNS, + CURL_LOCK_DATA_CONNECT, + ]); + } else { + $share = curl_share_init(); + curl_share_setopt($share, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS); + curl_share_setopt($share, CURLSHOPT_SHARE, CURL_LOCK_DATA_CONNECT); + } + curl_setopt($ch, CURLOPT_SHARE, $share); + return $curl_http_headers; } From af7962190838ddd69a00cb10f5e4078ec6c22590 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Thu, 4 Dec 2025 07:20:27 +0100 Subject: [PATCH 2/4] fix --- src/JiraClient.php | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/JiraClient.php b/src/JiraClient.php index 243cf99..0d53d34 100644 --- a/src/JiraClient.php +++ b/src/JiraClient.php @@ -35,6 +35,8 @@ class JiraClient */ protected \CurlHandle $curl; + protected \CurlShareHandle $curlShare = null; + /** * Monolog instance. */ @@ -158,17 +160,19 @@ public function curlPrepare(\CurlHandle|bool $ch, array $curl_http_headers, ?str curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->getConfiguration()->getTimeout()); } - if (\function_exists('curl_share_init_persistent')) { - $share = curl_share_init_persistent([ - CURL_LOCK_DATA_DNS, - CURL_LOCK_DATA_CONNECT, - ]); - } else { - $share = curl_share_init(); - curl_share_setopt($share, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS); - curl_share_setopt($share, CURLSHOPT_SHARE, CURL_LOCK_DATA_CONNECT); + if ($this->curlShare === null) { + if (\function_exists('curl_share_init_persistent')) { + $this->curlShare = curl_share_init_persistent([ + CURL_LOCK_DATA_DNS, + CURL_LOCK_DATA_CONNECT, + ]); + } else { + $this->curlShare = curl_share_init(); + curl_share_setopt($share, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS); + curl_share_setopt($share, CURLSHOPT_SHARE, CURL_LOCK_DATA_CONNECT); + } } - curl_setopt($ch, CURLOPT_SHARE, $share); + curl_setopt($ch, CURLOPT_SHARE, $this->curlShare); return $curl_http_headers; } From 2b40a64eff3d53c09c5cb4efde30de18b87caf92 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Thu, 4 Dec 2025 07:33:04 +0100 Subject: [PATCH 3/4] cs --- src/JiraClient.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/JiraClient.php b/src/JiraClient.php index 0d53d34..3ba946d 100644 --- a/src/JiraClient.php +++ b/src/JiraClient.php @@ -35,6 +35,9 @@ class JiraClient */ protected \CurlHandle $curl; + /** + * CURL share instance. + */ protected \CurlShareHandle $curlShare = null; /** From b4c53aed83a26d9064c17591739025b2184cfc7b Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Thu, 4 Dec 2025 07:38:56 +0100 Subject: [PATCH 4/4] fix type --- src/JiraClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/JiraClient.php b/src/JiraClient.php index 3ba946d..ce59bf8 100644 --- a/src/JiraClient.php +++ b/src/JiraClient.php @@ -38,7 +38,7 @@ class JiraClient /** * CURL share instance. */ - protected \CurlShareHandle $curlShare = null; + protected \CurlShareHandle|\CurlSharePersistentHandle|null $curlShare = null; /** * Monolog instance.