From c269f18cc8d77a939b74a4abaf886d5d423ff329 Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Tue, 2 Mar 2021 03:27:19 +0300 Subject: Client: close() on destruct --- src/Client.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Client.php b/src/Client.php index ec3af88..7146f5a 100644 --- a/src/Client.php +++ b/src/Client.php @@ -38,6 +38,13 @@ class Client { $this->lastOutgoingRequestNo = mt_rand(1, self::REQUEST_NO_LIMIT); } + /** + * JobdClient destructor. + */ + public function __destruct() { + $this->close(); + } + /** * @return ResponseMessage * @throws \Exception @@ -331,7 +338,11 @@ class Client { * @return bool */ public function close() { - return fclose($this->sock); + if (!$this->sock) + return; + + fclose($this->sock); + $this->sock = null; } } \ No newline at end of file -- cgit v1.2.3