Skip to content

Commit

Permalink
Check if listener is not nil before closing it
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafa committed Oct 15, 2023
1 parent 068f03c commit 6d1e6db
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions network/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ func (engine *Engine) Stop(ctx context.Context) error {
defer cancel()

engine.running.Store(false)
if err := engine.listener.Close(); err != nil {
engine.stopServer <- struct{}{}
close(engine.stopServer)
return gerr.ErrCloseListenerFailed.Wrap(err)
if engine.listener != nil {
if err := engine.listener.Close(); err != nil {
engine.stopServer <- struct{}{}
close(engine.stopServer)
return gerr.ErrCloseListenerFailed.Wrap(err)
}
}
engine.stopServer <- struct{}{}
close(engine.stopServer)
Expand Down

0 comments on commit 6d1e6db

Please sign in to comment.