From 7d326336cfab895300aaf2a3ad74fa32ed050e35 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 26 Apr 2016 09:29:39 -0700 Subject: [PATCH] search: remove broken websocket status optimization. It was breaking the websocket integration test. We still need to compute the last status message even if nobody is currently connected, because when a websocket connection does arrive, we need to send the last commputed status message. Change-Id: Icea0fcc69941aa6249d32f0a4ef4ec03bdfb1e20 --- pkg/search/websocket.go | 3 --- pkg/test/integration/camlistore_test.go | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/pkg/search/websocket.go b/pkg/search/websocket.go index ada2c9a70..9f284be2b 100644 --- a/pkg/search/websocket.go +++ b/pkg/search/websocket.go @@ -72,9 +72,6 @@ func (h *wsHub) run() { for { select { case st := <-h.statusUpdate: - if len(h.conns) == 0 { - continue - } const prefix = `{"tag":"_status","status":` lastStatusMsg = make([]byte, 0, len(prefix)+len(st)+1) lastStatusMsg = append(lastStatusMsg, prefix...) diff --git a/pkg/test/integration/camlistore_test.go b/pkg/test/integration/camlistore_test.go index 12c095cde..146be88bf 100644 --- a/pkg/test/integration/camlistore_test.go +++ b/pkg/test/integration/camlistore_test.go @@ -72,6 +72,7 @@ func TestWebsocketQuery(t *testing.T) { if err != nil { t.Fatalf("Dial: %v", err) } + defer c.Close() wc, _, err := websocket.NewClient(c, &url.URL{Host: w.Addr(), Path: w.SearchHandlerPath() + "ws"}, nil, bufSize, bufSize) check(err)