Skip to content

Commit

Permalink
agent: shutdown connection on node stop
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen J Day <[email protected]>
  • Loading branch information
stevvooe committed Aug 1, 2016
1 parent 058bc22 commit 9720c3a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion agent/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ func (n *Node) Stop(ctx context.Context) error {
return ctx.Err()
default:
close(n.stopped)
n.setControlSocket(nil)
// recurse and wait for closure
return n.Stop(ctx)
}
Expand Down Expand Up @@ -377,6 +378,7 @@ func (n *Node) runAgent(ctx context.Context, db *bolt.DB, creds credentials.Tran
if err != nil {
return err
}
defer conn.Close()

agent, err := New(&Config{
Hostname: n.config.Hostname,
Expand Down Expand Up @@ -430,7 +432,9 @@ func (n *Node) CertificateRequested() <-chan struct{} {
func (n *Node) setControlSocket(conn *grpc.ClientConn) {
n.Lock()
if n.conn != nil {
n.conn.Close()
if err := n.conn.Close(); err != nil {
log.L.WithError(err).Error("closing grpc connection failed")
}
}
n.conn = conn
n.connCond.Broadcast()
Expand Down

0 comments on commit 9720c3a

Please sign in to comment.