Moved event subscription out of go func to avoid race condition where in the event broadcast was completed even before the subscription was done in go func, resulting in permissions service not starting for the node. (#866)

This commit is contained in:
Sai V 2019-11-05 02:54:39 +08:00 committed by Samer Falah
parent 66d91d0210
commit 118ccc6e8f
1 changed files with 5 additions and 3 deletions

View File

@ -117,10 +117,12 @@ func NewQuorumPermissionCtrl(stack *node.Node, pconfig *types.PermissionConfig)
startWaitGroup: wg,
errorChan: make(chan error),
}
stopChan, stopSubscription := p.subscribeStopEvent()
inProcRPCServerSub := stack.EventMux().Subscribe(rpc.InProcServerReadyEvent{})
log.Debug("permission service: waiting for InProcRPC Server")
go func(_wg *sync.WaitGroup) {
log.Debug("permission service: waiting for InProcRPC Server")
stopChan, stopSubscription := p.subscribeStopEvent()
inProcRPCServerSub := stack.EventMux().Subscribe(rpc.InProcServerReadyEvent{})
defer func(start time.Time) {
log.Debug("permission service: InProcRPC server is ready", "took", time.Since(start))
stopSubscription.Unsubscribe()