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

websocket-chat logical problem #8

Open
joyhope opened this issue Jul 15, 2016 · 0 comments
Open

websocket-chat logical problem #8

joyhope opened this issue Jul 15, 2016 · 0 comments

Comments

@joyhope
Copy link

joyhope commented Jul 15, 2016

Simple run the demo, it works, but the flow has problem.

func (c *Client) listenRead() the api is never exited, always blocked on the c.doneCh on the second time

        err := websocket.JSON.Receive(c.ws, &msg)
        if err == io.EOF {
            c.doneCh <- true   <<==

After first c.doneCh <-true is send, the select will immediate run default flow. The Receive will get io.EOF again, but at that time, the listenWrite is exit because of c.donCh. The c.doneCh is not buffered, so it will be blocked for ever.

The simple fix is add time.Sleep(xxx) after the c.doneCh <-true. (Any way it is not a good fix.)

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

1 participant