diff options
| author | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2022-11-21 09:10:24 -0800 |
|---|---|---|
| committer | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2022-11-21 09:10:24 -0800 |
| commit | 75e4191b32b72ab4ac8e267c274f37769f95c995 (patch) | |
| tree | 8755568b3441b42369e04bd9e1b6da409401b322 /hotline/server.go | |
| parent | 72cb1789ee01779d7c4e3e3294b79037a0d462a9 (diff) | |
Minor improvements to sendTransaction
1. Remove use of defer for the unlock because it make hold the mutex longer than necessary
2. Remove shadowed err var on L166
Diffstat (limited to 'hotline/server.go')
| -rw-r--r-- | hotline/server.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/hotline/server.go b/hotline/server.go index e28ff9a..1aa9b1a 100644 --- a/hotline/server.go +++ b/hotline/server.go @@ -152,8 +152,8 @@ func (s *Server) sendTransaction(t Transaction) error { } s.mux.Lock() - defer s.mux.Unlock() client := s.Clients[uint16(clientID)] + s.mux.Unlock() if client == nil { return fmt.Errorf("invalid client id %v", *t.clientID) } @@ -163,7 +163,8 @@ func (s *Server) sendTransaction(t Transaction) error { return err } - if _, err := client.Connection.Write(b); err != nil { + _, err = client.Connection.Write(b) + if err != nil { return err } |