diff --git a/composer.json b/composer.json index 1d88eae..de0d909 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "ezimuel/ringphp", + "name": "sy-records/ringphp", "description": "Fork of guzzle/RingPHP (abandoned) to be used with elasticsearch-php", "license": "MIT", "authors": [ @@ -9,6 +9,10 @@ "homepage": "https://github.com/mtdowling" } ], + "support": { + "issues": "https://github.com/lufei/ringphp/issues", + "source": "https://github.com/lufei/ringphp" + }, "require": { "php": ">=5.4.0", "ezimuel/guzzlestreams": "^3.0.1", @@ -31,6 +35,10 @@ "GuzzleHttp\\Tests\\Ring\\": "tests/" } }, + "replace": { + "guzzlehttp/ringphp": "self.version", + "ezimuel/ringphp": "self.version" + }, "scripts": { "test": "make test", "test-ci": "make coverage" diff --git a/src/Client/CurlHandler.php b/src/Client/CurlHandler.php index e00aa4e..1c463c9 100644 --- a/src/Client/CurlHandler.php +++ b/src/Client/CurlHandler.php @@ -106,7 +106,7 @@ private function checkoutEasyHandle() // Add a new handle $handle = curl_init(); - $id = (int) $handle; + $id = Core::handle2Id($handle); $this->handles[$id] = $handle; $this->ownedHandles[$id] = true; @@ -115,7 +115,7 @@ private function checkoutEasyHandle() private function releaseEasyHandle($handle) { - $id = (int) $handle; + $id = Core::handle2Id($handle); if (count($this->ownedHandles) > $this->maxHandles) { curl_close($this->handles[$id]); unset($this->handles[$id], $this->ownedHandles[$id]); diff --git a/src/Core.php b/src/Core.php index dd7d1a0..85f4312 100644 --- a/src/Core.php +++ b/src/Core.php @@ -361,4 +361,18 @@ public static function getDebugResource($value = null) return fopen('php://output', 'w'); } } + + public static function handle2Id($handle) + { + if (is_resource($handle)) { + $id = (int) $handle; + } else { + if (PHP_VERSION_ID < 70200) { + $id = spl_object_hash($handle); + } else { + $id = spl_object_id($handle); + } + } + return $id; + } }