packer/plugin: set TCP keep-alive on connection

This commit is contained in:
Mitchell Hashimoto 2013-08-19 16:25:00 -07:00
parent 7647b12eab
commit de1e94eb90
2 changed files with 8 additions and 2 deletions

View File

@ -15,6 +15,7 @@ IMPROVEMENTS:
BUG FIXES:
* core: TCP connection between plugin processes will keep-alive. [GH-312]
* core: No more "unused key keep_input_artifact" for post processors [GH-310]
* post-processor/vagrant: `output_path` templates now work again.

View File

@ -10,6 +10,7 @@ import (
"io"
"io/ioutil"
"log"
"net"
"net/rpc"
"os"
"os/exec"
@ -328,10 +329,14 @@ func (c *Client) rpcClient() (*rpc.Client, error) {
return nil, err
}
client, err := rpc.Dial("tcp", address)
conn, err := net.Dial("tcp", address)
if err != nil {
return nil, err
}
return client, nil
// Make sure to set keep alive so that the connection doesn't die
tcpConn := conn.(*net.TCPConn)
tcpConn.SetKeepAlive(true)
return rpc.NewClient(tcpConn), nil
}