go-chat icon indicating copy to clipboard operation
go-chat copied to clipboard

Access to the clients map is not concurrency-safe

Open ghost opened this issue 9 years ago • 0 comments

A friend of mine is trying to learn Go and took this as an example. Unfortunately, it is a great example of a program that fails to be concurrency-safe.

The access to the clients map can be modified by any new connection in the goroutine spawned by http.Serve while being concurrently read-accessed in the handleMessages goroutine whenever an already established websocket writes data to the server.

ghost avatar Mar 24 '17 15:03 ghost