Skip to content
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

examples/websocket/server.go: concurrent write to socket #77

Closed
JordanP opened this issue Nov 30, 2017 · 2 comments
Closed

examples/websocket/server.go: concurrent write to socket #77

JordanP opened this issue Nov 30, 2017 · 2 comments

Comments

@JordanP
Copy link

JordanP commented Nov 30, 2017

In the handleWSConn function, the goroutine calls c.WriteMessage and the other for loop also calls c.WriteMessage. But according to Gorilla WS doc, WriteMessage is not goroutine safe. We need to use a mutex to protect concurrent writes.

I saw a couple of goroutine panics because of this while doing some light stress tests.

@nicksardo
Copy link
Contributor

nicksardo commented Dec 7, 2017

Nice find. Could you send a PR?

@nicksardo
Copy link
Contributor

nicksardo commented Dec 7, 2017

Correction, I'll do it. Need to add a copyright to it.

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

No branches or pull requests

2 participants