Skip to content

Commit

Permalink
fixes #270 race reading sock.wdeadline
Browse files Browse the repository at this point in the history
  • Loading branch information
gdamore committed Jan 30, 2017
1 parent 400df24 commit 2e75342
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions core.go
Expand Up @@ -235,15 +235,17 @@ func (sock *socket) SendMsg(msg *Message) error {
}
sock.Lock()
useBestEffort := sock.bestEffort
if sock.wdeadline != 0 {
msg.expire = time.Now().Add(sock.wdeadline)
wdeadline := sock.wdeadline
sock.Unlock()

if wdeadline != 0 {
msg.expire = time.Now().Add(wdeadline)
} else {
msg.expire = time.Time{}
}
sock.Unlock()

if !useBestEffort {
timeout := mkTimer(sock.wdeadline)
timeout := mkTimer(wdeadline)
select {
case <-timeout:
return ErrSendTimeout
Expand Down

0 comments on commit 2e75342

Please sign in to comment.