From 1f0546f0da3e93ddf818cc83eda4d1f9c7388c94 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 30 Jan 2017 15:15:37 +0100 Subject: 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. --- syz-hub/hub.go | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'syz-hub') 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 { -- cgit mrf-deployment