aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2024-04-11 12:58:46 +0200
committerDmitry Vyukov <dvyukov@google.com>2024-04-11 14:27:17 +0000
commit3e33f94b2003d654f468173e3aa960921475fee1 (patch)
tree0d3b2befba02719266c9a741ead6c85893392784 /pkg
parent95ed9ece851c5ce0f8db8fbe8c852457b4c36a85 (diff)
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.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/rpctype/rpc.go12
1 files changed, 8 insertions, 4 deletions
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)
}