1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-23 01:26:11 +02:00

Make sure handlers can be closed multiple times

This commit is contained in:
Jordi Boggiano
2015-08-09 17:29:31 +01:00
parent d93492fb60
commit 3dccef613e
4 changed files with 40 additions and 2 deletions

View File

@@ -29,11 +29,17 @@ class UdpSocket
public function close()
{
socket_close($this->socket);
if (is_resource($this->socket)) {
socket_close($this->socket);
$this->socket = null;
}
}
protected function send($chunk)
{
if (!is_resource($this->socket)) {
throw new \LogicException('The UdpSocket to '.$this->ip.':'.$this->port.' has been closed and can not be written to anymore');
}
socket_sendto($this->socket, $chunk, strlen($chunk), $flags = 0, $this->ip, $this->port);
}