mirror of
https://github.com/binwiederhier/ntfy.git
synced 2025-04-06 22:47:38 +03:00
Fix tests, lock topic as short as possible
This commit is contained in:
parent
85f2252a77
commit
c1f7bed8d1
3 changed files with 33 additions and 20 deletions
|
@ -1090,7 +1090,7 @@ func (s *Server) updateStatsAndPrune() {
|
|||
staleVisitors := 0
|
||||
for ip, v := range s.visitors {
|
||||
if v.Stale() {
|
||||
log.Debug("Deleting stale visitor %s", v.ip)
|
||||
log.Trace("Deleting stale visitor %s", v.ip)
|
||||
delete(s.visitors, ip)
|
||||
staleVisitors++
|
||||
}
|
||||
|
@ -1131,13 +1131,14 @@ func (s *Server) updateStatsAndPrune() {
|
|||
messages += count
|
||||
}
|
||||
|
||||
// Prune old topics, remove subscriptions without subscribers
|
||||
// Remove subscriptions without subscribers
|
||||
s.mu.Lock()
|
||||
var subscribers int
|
||||
for _, t := range s.topics {
|
||||
subs := t.Subscribers()
|
||||
subs := t.SubscribersCount()
|
||||
msgs, exists := messageCounts[t.ID]
|
||||
if subs == 0 && (!exists || msgs == 0) {
|
||||
log.Trace("Deleting empty topic %s", t.ID)
|
||||
delete(s.topics, t.ID)
|
||||
continue
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue