Skip to content

Commit 7a0c96c

Browse files
initiate Ping() timeout after collecting the stats
We have a hardcoded timeout of one second to send the daemon stats to the GUI. In some cases it's not unusual to hit the deadline. So in order to just measure the network call, we now initiate the timeout after collecting the daemon statistics. See: #1453
1 parent 8d31289 commit 7a0c96c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

daemon/ui/client.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,14 +326,16 @@ func (c *Client) ping(ts time.Time) (err error) {
326326
c.Lock()
327327
defer c.Unlock()
328328

329-
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
330-
defer cancel()
331329
reqID := uint64(ts.UnixNano())
332330

333331
pReq := &protocol.PingRequest{
334332
Id: reqID,
335333
Stats: c.stats.Serialize(),
336334
}
335+
336+
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
337+
defer cancel()
338+
337339
c.stats.RLock()
338340
pong, err := c.client.Ping(ctx, pReq)
339341
c.stats.RUnlock()

0 commit comments

Comments
 (0)