aboutsummaryrefslogtreecommitdiffstats
path: root/syz-hub
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-01-30 15:15:37 +0100
committerDmitry Vyukov <dvyukov@google.com>2017-01-30 15:15:37 +0100
commit1f0546f0da3e93ddf818cc83eda4d1f9c7388c94 (patch)
treecb615be555eda759987734071a2bed619be549a7 /syz-hub
parent8b2c1cb5bbde0ed2b055645d04ee3a2874569805 (diff)
manager, fuzzer, hub: move common rpc code into rpctype
If hub hangs, it causes all managers to hang as well as they call hub under the global mutex. So move common rpc code into rpctype and make it more careful about timeouts (tcp keepalives, call timeouts). Also don't call hub under the mutex, the call can be slow.
Diffstat (limited to 'syz-hub')
-rw-r--r--syz-hub/hub.go22
1 files changed, 4 insertions, 18 deletions
diff --git a/syz-hub/hub.go b/syz-hub/hub.go
index bb5128727..8b0be56d6 100644
--- a/syz-hub/hub.go
+++ b/syz-hub/hub.go
@@ -8,10 +8,7 @@ import (
"flag"
"fmt"
"io/ioutil"
- "net"
- "net/rpc"
"sync"
- "time"
. "github.com/google/syzkaller/log"
. "github.com/google/syzkaller/rpctype"
@@ -59,23 +56,12 @@ func main() {
hub.initHttp(cfg.Http)
- ln, err := net.Listen("tcp", cfg.Rpc)
+ s, err := NewRpcServer(cfg.Rpc, hub)
if err != nil {
- Fatalf("failed to listen on %v: %v", cfg.Rpc, err)
- }
- Logf(0, "serving rpc on tcp://%v", ln.Addr())
- s := rpc.NewServer()
- s.Register(hub)
- for {
- conn, err := ln.Accept()
- if err != nil {
- Logf(0, "failed to accept an rpc connection: %v", err)
- continue
- }
- conn.(*net.TCPConn).SetKeepAlive(true)
- conn.(*net.TCPConn).SetKeepAlivePeriod(time.Minute)
- go s.ServeConn(conn)
+ Fatalf("failed to create rpc server: %v", err)
}
+ Logf(0, "serving rpc on tcp://%v", s.Addr())
+ s.Serve()
}
func (hub *Hub) Connect(a *HubConnectArgs, r *int) error {