From 1dd2b0a9ea1119139fdbd97d6ac810c7ddb5698f Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Thu, 14 Feb 2019 20:03:00 +0100 Subject: make subscribtions thread safe and more bullet proof --- cmd/dolmetschctl/dolmetschctl.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/dolmetschctl/dolmetschctl.go b/cmd/dolmetschctl/dolmetschctl.go index 9e878a8..86fde95 100644 --- a/cmd/dolmetschctl/dolmetschctl.go +++ b/cmd/dolmetschctl/dolmetschctl.go @@ -122,7 +122,8 @@ func handleWebSocketMessage(ctrl *controller.Controller, ws *websocket.Conn, msg func run(ctrl *controller.Controller, ws *websocket.Conn) error { ctrlCh := make(chan controller.Event, 100) - ctrl.Subscribe(ctrlCh) + unsub := ctrl.Subscribe(ctrlCh) + defer close(unsub) wsCh := make(chan types.WebSocketResponseFull) go wsReader(ws, wsCh) -- cgit v1.2.3