Skip to content

Commit b7c2c56

Browse files
egorseSergey Egorov
and
Sergey Egorov
authored
zmq4: fix REP socket races on client connection
Fixes #119. Co-authored-by: Sergey Egorov <sergey.egorov@teleste.com>
1 parent a8dffa5 commit b7c2c56

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

rep.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ func newRepReader(ctx context.Context, state *repState) *repReader {
114114
}
115115

116116
func (r *repReader) addConn(c *Conn) {
117-
go r.listen(r.ctx, c)
118117
r.mu.Lock()
119118
r.conns = append(r.conns, c)
120119
r.mu.Unlock()
120+
go r.listen(r.ctx, c)
121121
}
122122

123123
func (r *repReader) rmConn(conn *Conn) {

socket.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -280,12 +280,12 @@ func (sck *socket) addConn(c *Conn) {
280280
c.Peer.Meta[sysSockID] = uuid
281281
}
282282
sck.ids[uuid] = c
283-
if sck.r != nil {
284-
sck.r.addConn(c)
285-
}
286283
if sck.w != nil {
287284
sck.w.addConn(c)
288285
}
286+
if sck.r != nil {
287+
sck.r.addConn(c)
288+
}
289289
sck.mu.Unlock()
290290
}
291291

0 commit comments

Comments
 (0)