diff --git a/go/host/events/logs.go b/go/host/events/logs.go index ac57b69fdf..97a2914be3 100644 --- a/go/host/events/logs.go +++ b/go/host/events/logs.go @@ -68,7 +68,7 @@ func (l *LogEventManager) Unsubscribe(id rpc.ID) { } l.subscriptionMutex.RLock() logSubscription, found := l.subscriptions[id] - close(logSubscription.ch) + ch := logSubscription.ch l.subscriptionMutex.RUnlock() if found { @@ -78,6 +78,7 @@ func (l *LogEventManager) Unsubscribe(id rpc.ID) { if enclaveUnsubErr != nil { l.logger.Error("The subscription management between the host and the enclave is out of sync", log.SubIDKey, id, log.ErrKey, enclaveUnsubErr) } + close(ch) } }