Эх сурвалжийг харах

rpc: don't exceed context deadline while waiting for send lock

Felix Lange 9 жил өмнө
parent
commit
464660651d
1 өөрчлөгдсөн 4 нэмэгдсэн , 0 устгасан
  1. 4 0
      rpc/client.go

+ 4 - 0
rpc/client.go

@@ -398,6 +398,10 @@ func (c *Client) send(ctx context.Context, op *requestOp, msg interface{}) error
 		err := c.write(ctx, msg)
 		c.sendDone <- err
 		return err
+	case <-ctx.Done():
+		// This can happen if the client is overloaded or unable to keep up with
+		// subscription notifications.
+		return ctx.Err()
 	case <-c.didQuit:
 		return ErrClientQuit
 	}