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

SetReadDeadline and Concurrency #338

Closed
rodicus opened this issue Jan 30, 2018 · 8 comments
Closed

SetReadDeadline and Concurrency #338

rodicus opened this issue Jan 30, 2018 · 8 comments

Comments

@rodicus
Copy link

rodicus commented Jan 30, 2018

Hi,

The Concurrency section of the documentation lists the read-related methods that should only be called by one routine. I am just wondering why SetReadDeadline is listed in there as it only seems to call the respective net.Conn method, which is supposedly safe for multi-routine use.

Thanks in advance,

Rod

@garyburd
Copy link
Contributor

garyburd commented Jan 31, 2018

The SetReadDeadline method can be called concurrently in the current implementation.

Do you need to call it concurrently, and if so, why?

@rodicus
Copy link
Author

rodicus commented Jan 31, 2018

I want to extend the read deadline on both, incoming application messages and pongs, and they happen to be handled on separate routines.

@garyburd
Copy link
Contributor

Is there a reason why you cannot extend the deadline from the reading goroutine?

@rodicus
Copy link
Author

rodicus commented Jan 31, 2018

I meant to say from the pong and reading routines. IIUC the websocket connection state can become permanently corrupted if a read op times out, so I am just trying to minimize that. However, I do want the connection to tell me something is wrong if I haven't heard from the client for a while either from pongs or regular messages.

@garyburd
Copy link
Contributor

The pong handler is called from the reading goroutine and can set the deadline.

@rodicus
Copy link
Author

rodicus commented Jan 31, 2018

I didn't realize the pong handler is called from advanceFrame which is itself called from reading methods. I assumed pongs and other control messages were received on a separate routine. Thanks for pointing that out.

@garyburd
Copy link
Contributor

The overview documentation says:

The control message handler functions are called from the NextReader, ReadMessage and message reader Read methods.

I'll repeat this in the SetPing/Pong/CloseHandler documentation.

@rodicus
Copy link
Author

rodicus commented Jan 31, 2018

I overlooked that (my bad). Adding the extra comment sounds great. Thanks Gary!

garyburd added a commit that referenced this issue Feb 1, 2018
@gorilla gorilla locked and limited conversation to collaborators Aug 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants