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 ...@@ -3,6 +3,7 @@ package rpc
import ( import (
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
"io" "io"
"log"
"net/rpc" "net/rpc"
) )
...@@ -12,10 +13,17 @@ import ( ...@@ -12,10 +13,17 @@ import (
type Client struct { type Client struct {
mux *MuxConn mux *MuxConn
client *rpc.Client client *rpc.Client
closeMux bool
} }
func NewClient(rwc io.ReadWriteCloser) (*Client, error) { 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) { func NewClientWithMux(mux *MuxConn, streamId uint32) (*Client, error) {
...@@ -27,6 +35,7 @@ func NewClientWithMux(mux *MuxConn, streamId uint32) (*Client, error) { ...@@ -27,6 +35,7 @@ func NewClientWithMux(mux *MuxConn, streamId uint32) (*Client, error) {
return &Client{ return &Client{
mux: mux, mux: mux,
client: rpc.NewClient(clientConn), client: rpc.NewClient(clientConn),
closeMux: false,
}, nil }, nil
} }
...@@ -35,6 +44,11 @@ func (c *Client) Close() error { ...@@ -35,6 +44,11 @@ func (c *Client) Close() error {
return err return err
} }
if c.closeMux {
log.Printf("[WARN] Client is closing mux")
return c.mux.Close()
}
return nil 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