Skip to content

Commit

Permalink
fix: Resolve crash introduced with cleanup code for force failed conn…
Browse files Browse the repository at this point in the history
…ections
  • Loading branch information
driskell committed Feb 26, 2024
1 parent 2f6d77d commit a17595b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lc-lib/transports/tcp/receivertcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,10 @@ func (t *receiverTCP) startConnection(socket *net.TCPConn) {
func (t *receiverTCP) connectionRoutine(socket net.Conn, conn *connection) {
defer t.connWait.Done()

didStart := false
if err := conn.run(func() {
conn.sendEvent(transports.NewConnectEvent(conn.ctx, socket.RemoteAddr().String(), conn.socket.Desc()))
didStart = true
}); err != nil {
if err == ErrHardCloseRequested {
log.Noticef("[R %s - %s] Client forcefully disconnected", socket.LocalAddr().String(), socket.RemoteAddr().String())
Expand All @@ -253,7 +255,9 @@ func (t *receiverTCP) connectionRoutine(socket net.Conn, conn *connection) {
log.Noticef("[R %s - %s] Client closed", socket.LocalAddr().String(), socket.RemoteAddr().String())
}

conn.sendEvent(transports.NewDisconnectEvent(conn.ctx, socket.RemoteAddr().String(), conn.socket.Desc()))
if didStart {
conn.sendEvent(transports.NewDisconnectEvent(conn.ctx, socket.RemoteAddr().String(), conn.socket.Desc()))
}

t.connMutex.Lock()
delete(t.connections, conn)
Expand Down

0 comments on commit a17595b

Please sign in to comment.