aboutsummaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--pkg/rpctype/rpc.go12
-rw-r--r--syz-fuzzer/fuzzer.go2
-rw-r--r--syz-manager/hub.go4
-rw-r--r--syz-runner/runner.go2
-rw-r--r--tools/syz-hubtool/hubtool.go2
5 files changed, 13 insertions, 9 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)
}
diff --git a/syz-fuzzer/fuzzer.go b/syz-fuzzer/fuzzer.go
index 8ede85f6d..6e45bc229 100644
--- a/syz-fuzzer/fuzzer.go
+++ b/syz-fuzzer/fuzzer.go
@@ -180,7 +180,7 @@ func main() {
machineInfo, modules := collectMachineInfos(target)
log.Logf(0, "dialing manager at %v", *flagManager)
- manager, err := rpctype.NewRPCClient(*flagManager, timeouts.Scale, *flagNetCompression)
+ manager, err := rpctype.NewRPCClient(*flagManager, timeouts.Scale, false, *flagNetCompression)
if err != nil {
log.SyzFatalf("failed to create an RPC client: %v ", err)
}
diff --git a/syz-manager/hub.go b/syz-manager/hub.go
index c4483a12a..8de9f1f4d 100644
--- a/syz-manager/hub.go
+++ b/syz-manager/hub.go
@@ -129,7 +129,7 @@ func (hc *HubConnector) connect(corpus [][]byte) (*rpctype.RPCClient, error) {
if err != nil {
return nil, err
}
- hub, err := rpctype.NewRPCClient(hc.cfg.HubAddr, 1, true)
+ hub, err := rpctype.NewRPCClient(hc.cfg.HubAddr, 1, true, true)
if err != nil {
return nil, err
}
@@ -162,7 +162,7 @@ func (hc *HubConnector) connect(corpus [][]byte) (*rpctype.RPCClient, error) {
if err != nil {
return nil, err
}
- hub, err = rpctype.NewRPCClient(hc.cfg.HubAddr, 1, true)
+ hub, err = rpctype.NewRPCClient(hc.cfg.HubAddr, 1, true, true)
if err != nil {
return nil, err
}
diff --git a/syz-runner/runner.go b/syz-runner/runner.go
index 9f97ebfd9..7bea3e1a5 100644
--- a/syz-runner/runner.go
+++ b/syz-runner/runner.go
@@ -46,7 +46,7 @@ func main() {
}
timeouts := config.Timeouts
- vrf, err := rpctype.NewRPCClient(*flagAddr, timeouts.Scale, true)
+ vrf, err := rpctype.NewRPCClient(*flagAddr, timeouts.Scale, true, true)
if err != nil {
log.Fatalf("failed to connect to verifier : %v", err)
}
diff --git a/tools/syz-hubtool/hubtool.go b/tools/syz-hubtool/hubtool.go
index 08d55cd95..a3317801e 100644
--- a/tools/syz-hubtool/hubtool.go
+++ b/tools/syz-hubtool/hubtool.go
@@ -57,7 +57,7 @@ func main() {
return
}
log.Printf("connecting to hub at %v...", *flagHubAddress)
- conn, err := rpctype.NewRPCClient(*flagHubAddress, 1, true)
+ conn, err := rpctype.NewRPCClient(*flagHubAddress, 1, true, true)
if err != nil {
log.Fatalf("failed to connect to hub: %v", err)
}