From be7861080b7061582639f8368f1c0a3f5ad3df00 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 27 Dec 2013 09:55:52 -0700 Subject: [PATCH] packer/rpc: make buffer real big for writes [GH-755] --- packer/rpc/muxconn.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packer/rpc/muxconn.go b/packer/rpc/muxconn.go index 434ebdea8..db8faabf6 100644 --- a/packer/rpc/muxconn.go +++ b/packer/rpc/muxconn.go @@ -402,10 +402,13 @@ func (m *MuxConn) loop() { case streamStateFinWait2: fallthrough case streamStateEstablished: - select { - case stream.writeCh <- data: - default: - panic(fmt.Sprintf("Failed to write data, buffer full for stream %d", id)) + if len(data) > 0 { + select { + case stream.writeCh <- data: + default: + panic(fmt.Sprintf( + "Failed to write data, buffer full for stream %d", id)) + } } default: log.Printf("[ERR] Data received for stream in state: %d", stream.state) @@ -469,7 +472,7 @@ const ( func newStream(from muxPacketFrom, id uint32, m *MuxConn) *Stream { // Create the stream object and channel where data will be sent to dataR, dataW := io.Pipe() - writeCh := make(chan []byte, 256) + writeCh := make(chan []byte, 4096) // Set the data channel so we can write to it. stream := &Stream{