Skip to content

Commit 6e7f969

Browse files
refactor: minor improvement
1 parent d8a8227 commit 6e7f969

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

server.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ func (s *Server) acceptLoop() error {
155155
// handles the message through the session in different goroutines,
156156
// and waits until the session's closed, then close the conn.
157157
func (s *Server) handleConn(conn net.Conn) {
158+
defer conn.Close() // nolint
159+
158160
sess := newSession(conn, &sessionOption{
159161
Packer: s.Packer,
160162
Codec: s.Codec,
@@ -175,9 +177,6 @@ func (s *Server) handleConn(conn net.Conn) {
175177
if s.OnSessionClose != nil {
176178
go s.OnSessionClose(sess)
177179
}
178-
if err := conn.Close(); err != nil {
179-
Log.Errorf("connection close err: %s", err)
180-
}
181180
}
182181

183182
// Stop stops server. Closing Listener and all connections.

0 commit comments

Comments
 (0)