-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lingering Deadlock when Write and CloseRead called concurrently in 1.8.6 #248
Comments
I believe the if condition prevents it. It won't block on the two channels if a close is being written. I know the code flow is confusing, it'll be cleaned up soon with #239 To be clear, I'm referring to this line: https://github.com/nhooyr/websocket/blob/02861b474d9c29660eff53a3c424d589aaf46d1e/write.go#L259 |
Oh never mind, I see what you're saying, the lock would be held up by the goroutine writing so we would never even get to the if statement. 🤦 |
Right. The goroutine who calls |
Closes #248 Luckily, due to the 5s timeout on the close handshake, this would have had very minimal effects on anyone in production.
Closes #248 Luckily, due to the 5s timeout on the close handshake, this would have had very minimal effects on anyone in production.
* add SIMD wsmask from @wdvxdr1123 * prevent netconn timer leakage * fix for coder/websocket#248 * fix for coder/websocket#245 * use net.ErrClosed * improve unauthorized origin access message * golint * go mod tidy
Is there any plan for new release? |
In the fix for the deadlock introduced in 1.8.5, we have the following:
If there is a
(*Conn).Write
that passes theif
condition, then it waits for at least one of two channels to close, while still holding thewriteFrameMu
lock. Sincec.wroteClose
is set before(*Conn).CloseRead
gets to call(*Conn).writeFrame
(see(*Conn).writeClose
), it is possible that(*Conn).CloseRead
calls(*Conn).writeFrame
after(*Conn).Write
gets stuck, so(*Conn).CloseRead
will get stuck waiting to getwriteFrameMu
, and no progress can be made.One option would be to unlock
writeFrameMu
immediately after passing theif
condition.defer c.writeFrameMu.unlock()
would need to be removed since the mutex implementation doesn't allow for unlocking twice.The text was updated successfully, but these errors were encountered: