Skip to content

Commit

Permalink
zmq4: fix REP socket races on client connection
Browse files Browse the repository at this point in the history
Fixes #119.

Co-authored-by: Sergey Egorov <[email protected]>
  • Loading branch information
egorse and Sergey Egorov authored Jan 29, 2022
1 parent a8dffa5 commit b7c2c56
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion rep.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down

0 comments on commit b7c2c56

Please sign in to comment.