Skip to content

Commit 5c994c6

Browse files
committed
fix(gossip): prevent stateInfoCache.Stop() from blocking
Signed-off-by: remo-lab <remopanda7@gmail.com>
1 parent 68ca620 commit 5c994c6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

gossip/gossip/channel/channel.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,7 @@ type stateInfoCache struct {
10301030
*util.MembershipStore
10311031
msgstore.MessageStore
10321032
stopChan chan struct{}
1033+
stopOnce sync.Once
10331034
}
10341035

10351036
func (cache *stateInfoCache) validate(orgs []api.OrgIdentityType) {
@@ -1068,7 +1069,9 @@ func (cache *stateInfoCache) delete(msg *protoext.SignedGossipMessage) {
10681069
}
10691070

10701071
func (cache *stateInfoCache) Stop() {
1071-
cache.stopChan <- struct{}{}
1072+
cache.stopOnce.Do(func() {
1073+
close(cache.stopChan)
1074+
})
10721075
}
10731076

10741077
// GenerateMAC returns a byte slice that is derived from the peer's PKI-ID

0 commit comments

Comments
 (0)