1
0
mirror of https://github.com/danog/dns.git synced 2024-11-30 04:29:06 +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->questionFactory = new QuestionFactory;
$this->gcWatcher = Loop::repeat(5000, function () { $sockets = &$this->sockets;
if (empty($this->sockets)) { $this->gcWatcher = Loop::repeat(5000, static function () use (&$sockets) {
if (!$sockets) {
return; return;
} }
$now = \time(); $now = \time();
foreach ($this->sockets as $key => $server) { foreach ($sockets as $key => $server) {
if ($server->getLastActivity() < $now - 60) { if ($server->getLastActivity() < $now - 60) {
$server->close(); $server->close();
unset($this->sockets[$key]); unset($sockets[$key]);
} }
} }
}); });