Client: close() on destruct

This commit is contained in:
Evgeny Zinoviev 2021-03-02 03:27:19 +03:00
parent 66cfd0aa35
commit c269f18cc8
2 changed files with 13 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "ch1p/jobd-client", "name": "ch1p/jobd-client",
"version": "1.1.1", "version": "1.1.2",
"repositories": [ "repositories": [
{ {
"type": "git", "type": "git",

View File

@ -38,6 +38,13 @@ class Client {
$this->lastOutgoingRequestNo = mt_rand(1, self::REQUEST_NO_LIMIT); $this->lastOutgoingRequestNo = mt_rand(1, self::REQUEST_NO_LIMIT);
} }
/**
* JobdClient destructor.
*/
public function __destruct() {
$this->close();
}
/** /**
* @return ResponseMessage * @return ResponseMessage
* @throws \Exception * @throws \Exception
@ -331,7 +338,11 @@ class Client {
* @return bool * @return bool
*/ */
public function close() { public function close() {
return fclose($this->sock); if (!$this->sock)
return;
fclose($this->sock);
$this->sock = null;
} }
} }