Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions client/rpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ type RPCClient struct {

shutdown bool
shutdownCh chan struct{}
shutdownLock sync.Mutex
shutdownLock sync.RWMutex
}

// send is used to send an object using the MsgPack encoding. send
Expand All @@ -89,7 +89,7 @@ func (c *RPCClient) send(header *requestHeader, obj interface{}) error {
c.writeLock.Lock()
defer c.writeLock.Unlock()

if c.shutdown {
if c.IsClosed() {
return clientClosed
}

Expand Down Expand Up @@ -184,6 +184,8 @@ func ClientFromConfig(c *Config) (*RPCClient, error) {
type StreamHandle uint64

func (c *RPCClient) IsClosed() bool {
c.shutdownLock.RLock()
defer c.shutdownLock.RUnlock()
return c.shutdown
}

Expand Down Expand Up @@ -848,7 +850,7 @@ func (c *RPCClient) listen() {
var respHeader responseHeader
for {
if err := c.dec.Decode(&respHeader); err != nil {
if !c.shutdown {
if !c.IsClosed() {
log.Printf("[ERR] agent.client: Failed to decode response header: %v", err)
}
break
Expand Down
Loading