Livestatus\Connection: check resource on disconnect

This commit is contained in:
Thomas Gelf 2014-11-16 18:01:07 +01:00
parent 2c7373f385
commit d368df8211
1 changed files with 11 additions and 1 deletions

View File

@ -407,11 +407,21 @@ if ($col > $size - 1) return $res;
return $this;
}
/**
* Disconnect in case we are connected to a Livestatus socket
*
* @return self
*/
public function disconnect()
{
if ($this->connection) {
if (is_resource($this->connection)
&& get_resource_type($this->connection) === 'Socket')
{
Benchmark::measure('Disconnecting livestatus...');
socket_close($this->connection);
Benchmark::measure('...socket closed');
}
return $this;
}
public function __destruct()