From d364e375238272222b6cf88eea2ff688f53f0e01 Mon Sep 17 00:00:00 2001 From: Cody Roseborough Date: Mon, 27 Feb 2017 10:15:20 -0800 Subject: [PATCH] Fixes #1521: Snaptel hang on task watch Removes the timeout from the rest client when using task watch. Because the timeout isn't reset on each transfer of data having a timeout causes the watch to eventually hang when set. --- mgmt/rest/client/task.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mgmt/rest/client/task.go b/mgmt/rest/client/task.go index 9bcd529b9..a1d3703e0 100644 --- a/mgmt/rest/client/task.go +++ b/mgmt/rest/client/task.go @@ -93,6 +93,11 @@ func (c *Client) CreateTask(s *Schedule, wf *wmap.WorkflowMap, name string, dead // interactive with Event and Done channels. An HTTP GET request retrieves tasks. // StreamedTaskEvent returns if it succeeds. Otherwise, an error is returned. func (c *Client) WatchTask(id string) *WatchTasksResult { + // during watch we don't want to have a timeout + // Store the old timeout so we can restore when we are through + oldTimeout := c.http.Timeout + c.http.Timeout = time.Duration(0) + r := &WatchTasksResult{ EventChan: make(chan *rbody.StreamedTaskEvent), DoneChan: make(chan struct{}), @@ -131,6 +136,7 @@ func (c *Client) WatchTask(id string) *WatchTasksResult { // Start watching go func() { reader := bufio.NewReader(resp.Body) + defer func() { c.http.Timeout = oldTimeout }() for { select { case <-r.DoneChan: