From 34d14c4940430e2d301f7749e1798e22db89fe60 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 7 Feb 2022 14:36:41 +0200 Subject: [PATCH] all: substitute zeroTime with time.Time{}, since this generates more optimal binary code --- app/vmstorage/transport/server.go | 4 +--- lib/handshake/handshake.go | 6 ++---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/app/vmstorage/transport/server.go b/app/vmstorage/transport/server.go index a47f20cf3..48eef1a89 100644 --- a/app/vmstorage/transport/server.go +++ b/app/vmstorage/transport/server.go @@ -462,8 +462,6 @@ func (ctx *vmselectRequestCtx) writeUint64(n uint64) error { const maxRPCNameSize = 128 -var zeroTime time.Time - func (s *Server) processVMSelectRequest(ctx *vmselectRequestCtx) error { // Read rpcName // Do not set deadline on reading rpcName, since it may take a @@ -482,7 +480,7 @@ func (s *Server) processVMSelectRequest(ctx *vmselectRequestCtx) error { return fmt.Errorf("cannot set read deadline for reading request args: %w", err) } defer func() { - _ = ctx.bc.SetReadDeadline(zeroTime) + _ = ctx.bc.SetReadDeadline(time.Time{}) }() // Read the timeout for request execution. diff --git a/lib/handshake/handshake.go b/lib/handshake/handshake.go index 47841dd07..d4e40d32e 100644 --- a/lib/handshake/handshake.go +++ b/lib/handshake/handshake.go @@ -132,7 +132,7 @@ func writeMessage(c net.Conn, msg string) error { return fmt.Errorf("cannot flush %q to server: %w", msg, err) } } - if err := c.SetWriteDeadline(zeroTime); err != nil { + if err := c.SetWriteDeadline(time.Time{}); err != nil { return fmt.Errorf("cannot reset write deadline: %w", err) } return nil @@ -161,10 +161,8 @@ func readData(c net.Conn, dataLen int) ([]byte, error) { if n, err := io.ReadFull(c, data); err != nil { return nil, fmt.Errorf("cannot read message with size %d: %w; read only %d bytes", dataLen, err, n) } - if err := c.SetReadDeadline(zeroTime); err != nil { + if err := c.SetReadDeadline(time.Time{}); err != nil { return nil, fmt.Errorf("cannot reset read deadline: %w", err) } return data, nil } - -var zeroTime time.Time