Fixed topic gc bug
This commit is contained in:
		@@ -69,7 +69,7 @@ class TopicManager
 | 
			
		||||
            $this->topics,
 | 
			
		||||
            function (Topic $topic) {
 | 
			
		||||
                $topic->garbageCollect();
 | 
			
		||||
                return ($topic->getHistorySize() > 0 && $topic->getSubscriberCount() > 0) || ($topic->getAge() < 60);
 | 
			
		||||
                return ($topic->getHistorySize() > 0 || $topic->getSubscriberCount() > 0) || ($topic->getAge() < 60);
 | 
			
		||||
            }
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -55,6 +55,7 @@ class ResponseMiddleware
 | 
			
		||||
                if ($t instanceof SecurityException) {
 | 
			
		||||
                    return Response::plaintext("Access Denied")->withStatus(Response::STATUS_UNAUTHORIZED);
 | 
			
		||||
                }
 | 
			
		||||
                $this->logger->warning(get_class($t).": ".$t->getMessage(), [ 'file'=>$t->getFile(), 'line'=>$t->getLine() ]);
 | 
			
		||||
                return Response::plaintext("500: Internal Server Error (".$t->getMessage().")\n")->withStatus(500);
 | 
			
		||||
            }
 | 
			
		||||
        )->then(
 | 
			
		||||
 
 | 
			
		||||
@@ -54,6 +54,9 @@ class Server
 | 
			
		||||
        $this->logger = $this->createLogger();
 | 
			
		||||
 | 
			
		||||
        $this->topicManager = new TopicManager();
 | 
			
		||||
        $this->loop->addPeriodicTimer(30, function () {
 | 
			
		||||
            $this->topicManager->garbageCollect();
 | 
			
		||||
        });
 | 
			
		||||
        
 | 
			
		||||
        $this->webSocketClients = new SplObjectStorage();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user