You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if client close tcp connection directly when server write data with background context.
the goroutine do Write may block forever, and succeed Write may block too.
Solution
DO NOT call Write method with context.Background,
AND DO Read in goroutine once connection established.
analysis
in Conn.writeFrame if real write to tcp failed.
in defer func, it wait closed or context.Done.
if there is no read goroutine, no closed event
This shouldn't have affected anyone using the library correctly as you'd want to use c.CloseRead if you're not reading from the connection to have the ctx for write cancel when read fails. But will still fix as yes it's not intended.
Summary
if client close tcp connection directly when server write data with background context.
the goroutine do
Write
may block forever, and succeedWrite
may block too.Solution
DO NOT call
Write
method withcontext.Background
,AND DO
Read
in goroutine once connection established.analysis
in
Conn.writeFrame
if real write to tcp failed.in defer func, it wait
closed
orcontext.Done
.if there is no read goroutine, no
closed
eventfirst stucked write stack may like
succeed stack may like
reproduce code
The text was updated successfully, but these errors were encountered: