1
0
mirror of https://github.com/danog/dns.git synced 2024-11-26 20:14:51 +01:00

Fix #68 - cyclic reference within BasicResolver->gcWatcher

This commit is contained in:
Bob Weinand 2017-11-07 16:18:49 +01:00 committed by GitHub
parent 36ef1a6959
commit cbaa517c8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -55,17 +55,18 @@ final class BasicResolver implements Resolver {
$this->questionFactory = new QuestionFactory;
$this->gcWatcher = Loop::repeat(5000, function () {
if (empty($this->sockets)) {
$sockets = &$this->sockets;
$this->gcWatcher = Loop::repeat(5000, static function () use (&$sockets) {
if (!$sockets) {
return;
}
$now = \time();
foreach ($this->sockets as $key => $server) {
foreach ($sockets as $key => $server) {
if ($server->getLastActivity() < $now - 60) {
$server->close();
unset($this->sockets[$key]);
unset($sockets[$key]);
}
}
});