Skip to content

Conversation

@k311093
Copy link
Collaborator

@k311093 k311093 commented Jul 17, 2024

At websocket_agent, wsWrapper.Close() is executed twice, at deferred function and inside go routine. Call wsWrapper.Close() only at go routine that writes data to the wsWrapper.

Also move tcpConn.Close() after io.Copy(...) to avoid confusion.

At websocket_agent, wsWrapper.Close() is executed twice, at deferred
function and inside go routine. Call wsWrapper.Close() only at go
routine that writes data to the wsWrapper.

Also move tcpConn.Close() after io.Copy(...) to avoid confusion.
wsWrapper.Close()
}()
io.Copy(tcpConn, wsWrapper)
tcpConn.Close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should stay as it was, with the defer in line 1275. It has the same effect of closing at the end of the function, but with the added benefit of closing the socket even with an early return in case of errors.

I wrongly suggested before that this one needed fixing because I had the order of parameters to io.Copy inverted. Sorry about that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants