From 1108438273737a883cd0f7e1d77e66dbaf76b92e Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 12 Dec 2013 10:23:37 -0800 Subject: [PATCH] packer/rpc: cleaner way to keep the seq number in MuxConn high --- packer/rpc/muxconn.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packer/rpc/muxconn.go b/packer/rpc/muxconn.go index fe35ca4be..f0e0ace39 100644 --- a/packer/rpc/muxconn.go +++ b/packer/rpc/muxconn.go @@ -163,6 +163,11 @@ func (m *MuxConn) openStream(id uint32) (*Stream, error) { m.mu.Lock() defer m.mu.Unlock() + // Make sure we attempt to use the next biggest stream ID + if id >= m.curId { + m.curId = id + 1 + } + // We have to check this again because there is a time period // above where we couldn't lost this lock. if stream, ok := m.streams[id]; ok { @@ -302,12 +307,6 @@ func (m *MuxConn) loop() { 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)