From 3e33f94b2003d654f468173e3aa960921475fee1 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 11 Apr 2024 12:58:46 +0200 Subject: pkg/rpctype: allow to disable timeouts Fuzzer don't need timeouts for the RPC connection much, if it does not receive new programs, we will kill it due to "no output" anyway. But they are problematic when we do parallel calls (Exchange), e.g. one call can cancel timeout of an existing call. They also will be more problematic if we also send notifications about programs fuzzer started executing in parallel. And they also marginally slow down things. Disable timeouts in the fuzzer. --- pkg/rpctype/rpc.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'pkg') diff --git a/pkg/rpctype/rpc.go b/pkg/rpctype/rpc.go index b90e13f08..ef434ebef 100644 --- a/pkg/rpctype/rpc.go +++ b/pkg/rpctype/rpc.go @@ -69,6 +69,7 @@ type RPCClient struct { conn net.Conn c *rpc.Client timeScale time.Duration + useTimeouts bool useCompression bool } @@ -89,7 +90,7 @@ func Dial(addr string, timeScale time.Duration) (net.Conn, error) { return conn, nil } -func NewRPCClient(addr string, timeScale time.Duration, useCompression bool) (*RPCClient, error) { +func NewRPCClient(addr string, timeScale time.Duration, useTimeouts, useCompression bool) (*RPCClient, error) { conn, err := Dial(addr, timeScale) if err != nil { return nil, err @@ -98,15 +99,18 @@ func NewRPCClient(addr string, timeScale time.Duration, useCompression bool) (*R conn: conn, c: rpc.NewClient(maybeFlateConn(conn, useCompression)), timeScale: timeScale, + useTimeouts: useTimeouts, useCompression: useCompression, } return cli, nil } func (cli *RPCClient) Call(method string, args, reply interface{}) error { - // Note: SetDeadline is not implemented on fuchsia, so don't fail on error. - cli.conn.SetDeadline(time.Now().Add(3 * time.Minute * cli.timeScale)) - defer cli.conn.SetDeadline(time.Time{}) + if cli.useTimeouts { + // Note: SetDeadline is not implemented on fuchsia, so don't fail on error. + cli.conn.SetDeadline(time.Now().Add(3 * time.Minute * cli.timeScale)) + defer cli.conn.SetDeadline(time.Time{}) + } return cli.c.Call(method, args, reply) } -- cgit mrf-deployment