From 578e1a2e6c83aa4cfc8686b25f899db863f09f10 Mon Sep 17 00:00:00 2001 From: raylu Date: Mon, 8 Aug 2011 02:47:10 -0700 Subject: redo update code --- main.go | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 21af0a8..de39411 100644 --- a/main.go +++ b/main.go @@ -262,25 +262,21 @@ func poll(w http.ResponseWriter, r *http.Request) { http.Error(w, err.String(), http.StatusInternalServerError) return } - var update *Update - for i := 0; i < 30; i++ { - update = getUpdates(q.Get("pid"), timestamp) - if update != nil { - w.Write([]byte("[")) - for update != nil { - output, err := json.MarshalForHTML(update) - if err == nil { - w.Write(output) - } - update = update.Next - if update != nil { - w.Write([]byte(",")) - } + update := getUpdates(q.Get("pid"), timestamp) + if update != nil { + w.Write([]byte("[")) + for update != nil { + output, err := json.MarshalForHTML(update) + if err == nil { + w.Write(output) + } + update = update.Next + if update != nil { + w.Write([]byte(",")) } - w.Write([]byte("]")) - return } - time.Sleep(1e9) // 1 second + w.Write([]byte("]")) + return } w.Write([]byte("[]")) } -- cgit v1.2.3