Skip to content

Commit 5daa583

Browse files
author
CHENBING1
committed
Fix the issue where the 'Shutdown' method fails to properly exit.
1 parent 9d6b793 commit 5daa583

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

server/sse.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,20 +281,15 @@ func (s *SSEServer) Start(addr string) error {
281281
// Shutdown gracefully stops the SSE server, closing all active sessions
282282
// and shutting down the HTTP server.
283283
func (s *SSEServer) Shutdown(ctx context.Context) error {
284-
s.mu.RLock()
285-
srv := s.srv
286-
s.mu.RUnlock()
287-
288-
if srv != nil {
284+
if s.srv != nil {
289285
s.sessions.Range(func(key, value interface{}) bool {
290286
if session, ok := value.(*sseSession); ok {
291287
close(session.done)
292288
}
293289
s.sessions.Delete(key)
294290
return true
295291
})
296-
297-
return srv.Shutdown(ctx)
292+
return s.srv.Shutdown(ctx)
298293
}
299294
return nil
300295
}

0 commit comments

Comments
 (0)