Commit 6ebfd502 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

packer/rpc: fix data race by acquiring wrong locks in MuxConn

parent 9b579a9d
......@@ -26,7 +26,6 @@ type MuxConn struct {
rwc io.ReadWriteCloser
streamsAccept map[uint32]*Stream
streamsDial map[uint32]*Stream
mu sync.RWMutex
muAccept sync.RWMutex
muDial sync.RWMutex
wlock sync.Mutex
......@@ -78,8 +77,10 @@ func NewMuxConn(rwc io.ReadWriteCloser) *MuxConn {
// Close closes the underlying io.ReadWriteCloser. This will also close
// all streams that are open.
func (m *MuxConn) Close() error {
m.mu.Lock()
defer m.mu.Unlock()
m.muAccept.Lock()
m.muDial.Lock()
defer m.muAccept.Unlock()
defer m.muDial.Unlock()
// Close all the streams
for _, w := range m.streamsAccept {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment