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

Purge requests if they're still in the map after 65k requests in between

This commit is contained in:
Niklas Keller 2017-06-23 15:34:12 +02:00
parent 957e3eaf3d
commit f536ddfd8a

View File

@ -71,7 +71,7 @@ abstract class Server {
}
$deferred = $this->questions[$id];
unset($this->questions[$id]);
$deferred->resolve($message);
};
}
@ -86,12 +86,16 @@ abstract class Server {
$this->nextId %= 0xffff;
}
$message = $this->createMessage($question, $id);
if (isset($this->questions[$id])) {
$deferred = $this->questions[$id];
unset($this->questions[$id]);
$deferred->fail(new ResolutionException("Request hasn't been answered with 65k requests in between"));
}
$message = $this->createMessage($question, $id);
$this->questions[$id] = $deferred = new Deferred;
yield $this->send($message);
$this->receive()->onResolve($this->onResolve);
return yield $deferred->promise();