mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 08:02:41 +02:00
Silently handle socket errors in the UdpAdapter (closes #27), add testcase
Conflicts: tests/ClientTest.php
This commit is contained in:
committed by
Walter Dal Mut
parent
27c19c9e4b
commit
c6e7b744c3
@@ -15,9 +15,18 @@ final class UdpAdapter extends AdapterAbstract
|
||||
|
||||
public function write($message)
|
||||
{
|
||||
// Create a handler in order to handle the 'Host is down' message
|
||||
set_error_handler(function() {
|
||||
// Suppress the error, this is the UDP adapter and if we can't send
|
||||
// it then we shouldn't inturrupt their application.
|
||||
});
|
||||
|
||||
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
|
||||
socket_sendto($socket, $message, strlen($message), 0, $this->getOptions()->getHost(), $this->getOptions()->getPort());
|
||||
socket_close($socket);
|
||||
|
||||
// Remove our error handler.
|
||||
restore_error_handler();
|
||||
}
|
||||
|
||||
private function serialize(array $message)
|
||||
|
||||
Reference in New Issue
Block a user