Skip to content

Commit

Permalink
communicator/ssh: explicitly set c.conn = nil
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Oct 14, 2013
1 parent 4afe900 commit df3d751
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ BUG FIXES:
* builder/digitalocean: scrub API keys from config debug output [GH-516]
* builder/virtualbox: error if VirtualBox version cant be detected. [GH-488]
* builder/virtualbox: detect if vboxdrv isn't properly setup. [GH-488]
* communicator/ssh: Fix issue where a panic could arise from a nil
dereference. [GH-525]

## 0.3.9 (October 2, 2013)

Expand Down
8 changes: 8 additions & 0 deletions communicator/ssh/communicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,14 @@ func (c *comm) reconnect() (err error) {
log.Printf("reconnecting to TCP connection for SSH")
c.conn, err = c.config.Connection()
if err != nil {
// Explicitly set this to the REAL nil. Connection() can return
// a nil implementation of net.Conn which will make the
// "if c.conn == nil" check fail above. Read here for more information
// on this psychotic language feature:
//
// http://golang.org/doc/faq#nil_error
c.conn = nil

log.Printf("reconnection error: %s", err)
return
}
Expand Down

0 comments on commit df3d751

Please sign in to comment.