diff options
Diffstat (limited to 'app/web_hub.go')
-rw-r--r-- | app/web_hub.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/app/web_hub.go b/app/web_hub.go index 0a70cb6d1..1525dfbba 100644 --- a/app/web_hub.go +++ b/app/web_hub.go @@ -36,6 +36,7 @@ type Hub struct { unregister chan *WebConn broadcast chan *model.WebSocketEvent stop chan string + didStop chan struct{} invalidateUser chan string ExplicitStop bool goroutineId int @@ -44,11 +45,12 @@ type Hub struct { func (a *App) NewWebHub() *Hub { return &Hub{ app: a, - register: make(chan *WebConn), - unregister: make(chan *WebConn), + register: make(chan *WebConn, 1), + unregister: make(chan *WebConn, 1), connections: make([]*WebConn, 0, model.SESSION_CACHE_SIZE), broadcast: make(chan *model.WebSocketEvent, BROADCAST_QUEUE_SIZE), stop: make(chan string), + didStop: make(chan struct{}, 1), invalidateUser: make(chan string), ExplicitStop: false, } @@ -348,6 +350,7 @@ func getGoroutineId() int { func (h *Hub) Stop() { h.stop <- "all" + <-h.didStop } func (h *Hub) Start() { @@ -428,9 +431,10 @@ func (h *Hub) Start() { case <-h.stop: for _, webCon := range h.connections { - webCon.WebSocket.Close() + webCon.Close() } h.ExplicitStop = true + h.didStop <- struct{}{} return } |