diff options
| author | Andrei Vagin <avagin@google.com> | 2024-05-08 14:45:11 -0700 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2024-05-09 07:49:18 +0000 |
| commit | 0507966124891755bd4be06ca0420c8b7e908032 (patch) | |
| tree | f2e20f4322153be8e35237e9c971a1083e9ca690 /pkg | |
| parent | 804e5bd862bec2c4d0d84ad8291ab8d5db7715c3 (diff) | |
pkg/rpctype: call setupKeepAlive only for tcp sockets
otherwise it panics:
panic: interface conversion: net.Conn is *net.UnixConn, not *net.TCPConn
Fixes: 610f2a54d02f ("pkg/rpctype: prepare for not using for target communication")
Signed-off-by: Andrei Vagin <avagin@google.com>
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/rpctype/rpc.go | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/pkg/rpctype/rpc.go b/pkg/rpctype/rpc.go index f6b8d1eff..cd57eb42d 100644 --- a/pkg/rpctype/rpc.go +++ b/pkg/rpctype/rpc.go @@ -64,13 +64,16 @@ func NewRPCClient(addr string) (*RPCClient, error) { // This is used by vm/gvisor which passes us a unix socket connection in stdin. // TODO: remove this once we switch to flatrpc for target communication. conn, err = net.FileConn(os.Stdin) + if err != nil { + return nil, err + } } else { conn, err = net.DialTimeout("tcp", addr, 3*time.Minute) + if err != nil { + return nil, err + } + setupKeepAlive(conn, time.Minute) } - if err != nil { - return nil, err - } - setupKeepAlive(conn, time.Minute) cli := &RPCClient{ conn: conn, c: rpc.NewClient(newFlateConn(conn)), |
