From 9f2783349e8ff11f737f86f1f7df2850e4c5c514 Mon Sep 17 00:00:00 2001 From: Kleissner Date: Sat, 11 Dec 2021 21:43:06 +0100 Subject: [PATCH] Fix race condition in UDT, check if socket is nil before closing it --- udt/multiplexer.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/udt/multiplexer.go b/udt/multiplexer.go index 3299f85..ec634e1 100644 --- a/udt/multiplexer.go +++ b/udt/multiplexer.go @@ -49,7 +49,9 @@ func (m *multiplexer) goRead() { select { case buf = <-m.incomingData: case <-m.terminationSignal: - m.socket.Close() // Pass the external termination signal down to the socket. This makes sure any pending reader on the socket (especially if blocking) returns with EOF. + if m.socket != nil { + m.socket.Close() // Pass the external termination signal down to the socket. This makes sure any pending reader on the socket (especially if blocking) returns with EOF. + } return }