Skip to content

Commit

Permalink
Don't panic when callbacks aren't set
Browse files Browse the repository at this point in the history
  • Loading branch information
neilalexander committed Jul 27, 2021
1 parent 52626cd commit 54ae7b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -616,5 +616,7 @@ func (c *Conn) detach() {
s.lazyDestroy()
s.onMutex.RLock()
defer s.onMutex.RUnlock()
go s.onDetach(c.remoteSocketAddr)
if s.onDetach != nil {
go s.onDetach(c.remoteSocketAddr)
}
}
4 changes: 3 additions & 1 deletion socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,9 @@ func (s *Socket) registerConn(recvID uint16, remoteAddr resolvedAddrStr, c *Conn
s.conns[key] = c
s.onMutex.RLock()
defer s.onMutex.RUnlock()
go s.onAttach(c.remoteSocketAddr)
if s.onAttach != nil {
go s.onAttach(c.remoteSocketAddr)
}
return true
}

Expand Down

0 comments on commit 54ae7b1

Please sign in to comment.