From 64e6897739ccec96d311acc11a0f22ab232d041f Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 12 Dec 2013 00:36:49 -0800 Subject: [PATCH] packer/rpc: make sure curID in MuxConn is highest [GH-705] --- packer/rpc/muxconn.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packer/rpc/muxconn.go b/packer/rpc/muxconn.go index 174b3e36d..fe35ca4be 100644 --- a/packer/rpc/muxconn.go +++ b/packer/rpc/muxconn.go @@ -300,10 +300,14 @@ func (m *MuxConn) loop() { case streamStateFinWait2: stream.remoteClose() - // Remove this stream from being active so that it - // can be re-used m.mu.Lock() delete(m.streams, stream.id) + + // Make sure we attempt to use the next biggest stream ID + if stream.id >= m.curId { + m.curId = stream.id + 1 + } + m.mu.Unlock() default: log.Printf("[ERR] Fin received for stream %d in state: %d", id, stream.state)