Commit a6299fc4 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

packer/rpc: log when client closes mux

parent fed689bb
......@@ -3,6 +3,7 @@ package rpc
import (
"github.com/mitchellh/packer/packer"
"io"
"log"
"net/rpc"
)
......@@ -10,12 +11,19 @@ import (
// Establishing a connection is up to the user, the Client can just
// communicate over any ReadWriteCloser.
type Client struct {
mux *MuxConn
client *rpc.Client
mux *MuxConn
client *rpc.Client
closeMux bool
}
func NewClient(rwc io.ReadWriteCloser) (*Client, error) {
return NewClientWithMux(NewMuxConn(rwc), 0)
result, err := NewClientWithMux(NewMuxConn(rwc), 0)
if err != nil {
return nil, err
}
result.closeMux = true
return result, err
}
func NewClientWithMux(mux *MuxConn, streamId uint32) (*Client, error) {
......@@ -25,8 +33,9 @@ func NewClientWithMux(mux *MuxConn, streamId uint32) (*Client, error) {
}
return &Client{
mux: mux,
client: rpc.NewClient(clientConn),
mux: mux,
client: rpc.NewClient(clientConn),
closeMux: false,
}, nil
}
......@@ -35,6 +44,11 @@ func (c *Client) Close() error {
return err
}
if c.closeMux {
log.Printf("[WARN] Client is closing mux")
return c.mux.Close()
}
return nil
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment