services: fix timer draining

Ref. #3736.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This commit is contained in:
Anna Shaleva 2024-12-09 12:10:15 +03:00
parent 35c2c5cc0e
commit 827acfca23

View file

@ -471,7 +471,10 @@ func (s *Server) Shutdown() {
session.iteratorsLock.Lock() session.iteratorsLock.Lock()
session.finalize() session.finalize()
if !session.timer.Stop() { if !session.timer.Stop() {
<-session.timer.C select {
case <-session.timer.C:
default:
}
} }
session.iteratorsLock.Unlock() session.iteratorsLock.Unlock()
} }
@ -2596,7 +2599,10 @@ func (s *Server) terminateSession(reqParams params.Params) (any, *neorpc.Error)
session.iteratorsLock.Lock() session.iteratorsLock.Lock()
session.finalize() session.finalize()
if !session.timer.Stop() { if !session.timer.Stop() {
<-session.timer.C select {
case <-session.timer.C:
default:
}
} }
delete(s.sessions, strSID) delete(s.sessions, strSID)
session.iteratorsLock.Unlock() session.iteratorsLock.Unlock()