diff --git a/rep.go b/rep.go index 5d31423..8ca6f2a 100644 --- a/rep.go +++ b/rep.go @@ -114,10 +114,10 @@ func newRepReader(ctx context.Context, state *repState) *repReader { } func (r *repReader) addConn(c *Conn) { - go r.listen(r.ctx, c) r.mu.Lock() r.conns = append(r.conns, c) r.mu.Unlock() + go r.listen(r.ctx, c) } func (r *repReader) rmConn(conn *Conn) { diff --git a/socket.go b/socket.go index 021e3dc..6ea5719 100644 --- a/socket.go +++ b/socket.go @@ -280,12 +280,12 @@ func (sck *socket) addConn(c *Conn) { c.Peer.Meta[sysSockID] = uuid } sck.ids[uuid] = c - if sck.r != nil { - sck.r.addConn(c) - } if sck.w != nil { sck.w.addConn(c) } + if sck.r != nil { + sck.r.addConn(c) + } sck.mu.Unlock() }