Skip to content

Commit f911ede

Browse files
committed
qmp/socket: Only wait for mon.stream to be closed in Disconnect if initialised
This allows Disconnect() to be called as a way to cancel a Connect() call. Without Disconnect() blocking forever reading from a nil channel. Fixes #200 Signed-off-by: Thomas Parrott <[email protected]>
1 parent 580ce45 commit f911ede

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

qmp/socket.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ func (mon *SocketMonitor) Disconnect() error {
104104
atomic.StoreInt32(mon.listeners, 0)
105105
err := mon.c.Close()
106106

107-
for range mon.stream {
107+
if mon.stream != nil {
108+
for range mon.stream {
109+
}
108110
}
109111

110112
return err

0 commit comments

Comments
 (0)