Skip to content

Commit

Permalink
Close listener after use
Browse files Browse the repository at this point in the history
Add new make target for finding race conditions in tests
  • Loading branch information
mostafa committed Oct 15, 2023
1 parent 91efb66 commit ac85264
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ clean:
test:
@go test -v ./...

test-race:
@go test -race -v ./...

benchmark:
@go test -bench=. -benchmem -run=^# ./...

Expand Down
1 change: 1 addition & 0 deletions network/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ func (s *Server) Run() *gerr.GatewayDError {
return gerr.ErrServerListenFailed.Wrap(origErr)
}
s.engine.listener = listener
defer s.engine.listener.Close()

if s.engine.listener == nil {
s.logger.Error().Msg("Server is not properly initialized")
Expand Down

0 comments on commit ac85264

Please sign in to comment.