1
0
mirror of https://github.com/danog/dns.git synced 2024-11-30 04:29:06 +01:00

Unload server when fwrite fails

Ignore errors from fwrite caused by disconnected sockets and immediately unload the server.
This commit is contained in:
Aaron Piotrowski 2017-03-02 16:38:11 -06:00
parent 5fc1cde2d2
commit 4e4d6e9f81

View File

@ -195,11 +195,11 @@ REGEX;
}
// Send request
$bytesWritten = \fwrite($server->socket, $requestPacket);
if ($bytesWritten === false || isset($packet[$bytesWritten])) {
throw new ResolutionException(
"Request send failed"
);
$bytesWritten = @\fwrite($server->socket, $requestPacket);
if ($bytesWritten === false || $bytesWritten === 0 && (!\is_resource($server->socket) || !\feof($server->socket))) {
$exception = new ResolutionException("Request send failed");
$this->unloadServer($server->id, $exception);
throw $exception;
}
$promisor = new Deferred;
@ -265,6 +265,7 @@ REGEX;
$uri = $this->parseCustomServerUri($options["server"]);
}
$promises = [];
foreach ($types as $type) {
$promises[] = $this->doRequest($uri, $name, $type);
}