Skip to content

Commit

Permalink
protocols/client: close yamux session when closing the stream
Browse files Browse the repository at this point in the history
For yamux builtin client, we should close the yamux session when closing
the stream otherwise the session keeps open and can confuse the server.

Fixes: kata-containers#300

Signed-off-by: Peng Tao <bergwolf@gmail.com>
  • Loading branch information
bergwolf committed Jul 18, 2018
1 parent 17b44df commit 8abefd1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion protocols/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ type AgentClient struct {
conn *grpc.ClientConn
}

type yamuxSessionStream struct {
net.Conn
session *yamux.Session
}

func (y *yamuxSessionStream) Close() error {
return y.session.Close()
}

type dialer func(string, time.Duration) (net.Conn, error)

// NewAgentClient creates a new agent gRPC client and handles both unix and vsock addresses.
Expand Down Expand Up @@ -161,7 +170,12 @@ func agentDialer(addr *url.URL, enableYamux bool) dialer {
return nil, err
}

return stream, nil
y := &yamuxSessionStream{
Conn: stream.(net.Conn),
session: session,
}

return y, nil
}
}

Expand Down

0 comments on commit 8abefd1

Please sign in to comment.