Skip to content

Commit

Permalink
Ignore unknown socket error in __destruct, fixes #142
Browse files Browse the repository at this point in the history
  • Loading branch information
kelunik committed Oct 15, 2017
1 parent c04853c commit e171865
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/DefaultClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,12 @@ public function read(): Promise {

public function __destruct() {
if (!$this->successfulEnd && $this->requestCycle->socket) {
$this->socketPool->clear($this->requestCycle->socket);
try {
this->socketPool->clear($this->requestCycle->socket);
} catch (\Error $e) {
// This might happen due to the unpredictable __destruct call order
}

$socket = $this->requestCycle->socket;
$this->requestCycle->socket = null;
$socket->close();
Expand Down

0 comments on commit e171865

Please sign in to comment.