Skip to content

Commit

Permalink
Lock before assigning the server.listener to prevent data race
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafa committed Oct 24, 2023
1 parent 98354ae commit a776985
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions network/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,9 @@ func (s *Server) Run() *gerr.GatewayDError {
s.logger.Error().Err(origErr).Msg("Server failed to start listening")
return gerr.ErrServerListenFailed.Wrap(origErr)
}
s.mu.Lock()
s.engine.listener = listener
s.mu.Unlock()
defer s.engine.listener.Close()

if s.engine.listener == nil {
Expand Down

0 comments on commit a776985

Please sign in to comment.