fix(GODT-2949): Fix close of close channel in event service
This issue is triggered due to the `Service.Close()` call after the go-routine for the event service exists. It is possible that during this period a recently added subscriber with `pendingOpAdd` gets cancelled and closed. However, the subscriber later also enqueues a `pendingOpRemove` which gets processed again with a call in `user.eventService.Close()` leading to the double close panic. This patch simply removes the `s.Close()` from the service, and leaves the cleanup to called externally from user.Close() or user.Logout().
This commit is contained in:
parent
e422b28bc3
commit
cf3abaa96f
|
@ -192,7 +192,6 @@ func (s *Service) run(ctx context.Context, lastEventID string) {
|
|||
defer s.cpc.Close()
|
||||
defer s.timer.Stop()
|
||||
defer s.log.Info("Exiting service")
|
||||
defer s.Close()
|
||||
|
||||
client := network.NewClientRetryWrapper(s.eventSource, &network.ExpCoolDown{})
|
||||
|
||||
|
@ -303,14 +302,15 @@ func (s *Service) Close() {
|
|||
|
||||
// Cleanup pending removes.
|
||||
for _, s := range s.pendingSubscriptions {
|
||||
if s.op == pendingOpRemove {
|
||||
if !processed.Contains(s.sub) {
|
||||
if !processed.Contains(s.sub) {
|
||||
processed.Add(s.sub)
|
||||
|
||||
if s.op == pendingOpRemove {
|
||||
s.sub.close()
|
||||
} else {
|
||||
s.sub.cancel()
|
||||
s.sub.close()
|
||||
}
|
||||
} else {
|
||||
s.sub.cancel()
|
||||
s.sub.close()
|
||||
processed.Add(s.sub)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue