Closed filinvadim closed 4 years ago
Just:
p.timeMutex.Lock()
p.lastReceivedTime = time.Now()
p.timeMutex.Unlock()
Same for WebSocketV2ClientBase
@filinvadim thanks for the feedback, usually this won’t happen, however it has possibility in theory as lastReceivedTime is written in two routines. I don’t want to introduce mutex, so just move the lastReceivedTime initialization to earlier places. You can check the latest master branch.
@eynzhang so data race is still in place. You need a mutex, sorry.
@filinvadim could you share how you reproduce this issue?
Sorry no, @eynzhang . It's in your code. Just go run --race ...
You have access to the variable lastReceivedTime
from 2 threads - tickerLoop and readLoop. That's data race. Reopen please to warn other developers.