From 3c53a62cd0848e94da8b95df00087bddc92ac6da Mon Sep 17 00:00:00 2001 From: Holger Woltersdorf Date: Mon, 29 Apr 2019 11:37:42 +0200 Subject: [PATCH 1/2] Remove failed sockets to prevent infinite re-use, closes #37 --- CHANGELOG.md | 9 +++++++++ src/Client.php | 14 +++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ef0fd6..8b982ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a CHANGELOG](http://keepachangelog.com). +## [2.7.1] - 2019-04-29 + +### Fixed + +* Remove failed sockets from internal collection that errored out during reading of response in order to prevent infinite + tries/re-use of those failed connections. - [#37] + ## [2.7.0] - 2019-04-28 ### Added @@ -186,6 +193,7 @@ Based on [Pierrick Charron](https://github.com/adoy)'s [PHP-FastCGI-Client](http * Getters/Setters for connect timeout, read/write timeout, keep alive, socket persistence from `Client` (now part of the socket connection) * Method `Client->getValues()` +[2.7.1]: https://github.com/hollodotme/fast-cgi-client/compare/v2.7.0...v2.7.1 [2.7.0]: https://github.com/hollodotme/fast-cgi-client/compare/v2.6.0...v2.7.0 [2.6.0]: https://github.com/hollodotme/fast-cgi-client/compare/v2.5.0...v2.6.0 [2.5.0]: https://github.com/hollodotme/fast-cgi-client/compare/v2.4.3...v2.5.0 @@ -212,3 +220,4 @@ Based on [Pierrick Charron](https://github.com/adoy)'s [PHP-FastCGI-Client](http [#26]: https://github.com/hollodotme/fast-cgi-client/issues/26 [#27]: https://github.com/hollodotme/fast-cgi-client/issues/27 [#33]: https://github.com/hollodotme/fast-cgi-client/pull/33 +[#37]: https://github.com/hollodotme/fast-cgi-client/issue/37 diff --git a/src/Client.php b/src/Client.php index 7a8f981..132e47e 100644 --- a/src/Client.php +++ b/src/Client.php @@ -125,7 +125,16 @@ public function sendAsyncRequest( ProvidesRequestData $request ) : int */ public function readResponse( int $requestId, ?int $timeoutMs = null ) : ProvidesResponseData { - return $this->sockets->getById( $requestId )->fetchResponse( $timeoutMs ); + try + { + return $this->sockets->getById( $requestId )->fetchResponse( $timeoutMs ); + } + catch ( Throwable $e ) + { + $this->sockets->remove( $requestId ); + + throw $e; + } } /** @@ -184,6 +193,8 @@ private function fetchResponseAndNotifyCallback( Socket $socket, ?int $timeoutMs } catch ( Throwable $e ) { + $this->sockets->remove( $socket->getId() ); + $socket->notifyFailureCallbacks( $e ); } } @@ -254,6 +265,7 @@ public function readResponses( ?int $timeoutMs = null, int ...$requestIds ) : Ge } catch ( Throwable $e ) { + $this->sockets->remove( $requestId ); } } } From 9ddf436a95f501d3bd4cb1a996aae3132f99e952 Mon Sep 17 00:00:00 2001 From: Holger Woltersdorf Date: Mon, 29 Apr 2019 11:39:01 +0200 Subject: [PATCH 2/2] Update documentation links --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 51f78b4..faea7b5 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ This is the documentation of the latest release. Please see the following links for earlier releases: * PHP >= 7.0 (EOL) [v1.0.0], [v1.0.1], [v1.1.0], [v1.2.0], [v1.3.0], [v1.4.0], [v1.4.1], [v1.4.2] -* PHP >= 7.1 [v2.0.0], [v2.0.1], [v2.1.0], [v2.2.0], [v2.3.0], [v2.4.0], [v2.4.1], [v2.4.2], [v2.4.3], [v2.5.0] +* PHP >= 7.1 [v2.0.0], [v2.0.1], [v2.1.0], [v2.2.0], [v2.3.0], [v2.4.0], [v2.4.1], [v2.4.2], [v2.4.3], [v2.5.0], [v2.6.0], [v2.7.0] Read more about the journey to and changes in `v2.6.0` in [this blog post](https://hollo.me/php/background-info-fast-cgi-client-v2.6.0.html). @@ -763,6 +763,8 @@ Run a call through a Unix Domain Socket This shows the response of the php-fpm status page. +[v2.7.0]: https://github.com/hollodotme/fast-cgi-client/blob/v2.7.0/README.md +[v2.6.0]: https://github.com/hollodotme/fast-cgi-client/blob/v2.6.0/README.md [v2.5.0]: https://github.com/hollodotme/fast-cgi-client/blob/v2.5.0/README.md [v2.4.3]: https://github.com/hollodotme/fast-cgi-client/blob/v2.4.3/README.md [v2.4.2]: https://github.com/hollodotme/fast-cgi-client/blob/v2.4.2/README.md