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

ClientConn.Close() doesn't always make Recv() end #1293

Closed
yacovm opened this issue Jun 10, 2017 · 1 comment · Fixed by #1275
Closed

ClientConn.Close() doesn't always make Recv() end #1293

yacovm opened this issue Jun 10, 2017 · 1 comment · Fixed by #1275
Assignees

Comments

@yacovm
Copy link

yacovm commented Jun 10, 2017

Hi.

I'm having trouble with implementing the following logic with gRPC streams:
I have a client that sometimes calls Recv() on a gRPC stream and this invocation of Recv() should block until a message is received from the server.
However, sometimes I want the client to abort the Recv() invocation.
In order to do so, I have implemented another call that runs from a different goroutine, and simply calls Close() on the connection that the client stream was created with.
I've noticed that sometimes (although rarely) - the Recv() method gets stuck even though Close() was called after.

I had success with reproducing this issue in the attached link.

Could it be that closing the connection isn't supposed to make the Recv() method return, and the "right" way to do it is with context.WithCancel ?

What version of gRPC are you using?

Not sure, the commit hash is:
commit 4acc910

What version of Go are you using (go version)?

go version go1.7.1 linux/amd64

What operating system (Linux, Windows, …) and version?

Description: Ubuntu 14.04.5 LTS

What did you do?

Provided a test that from 1 goroutine calls Recv() and then after 500ms calls Close() on the underlying connection.
Sometimes, the Recv() method doesn't return after the Close() is called.
https://gist.github.com/yacovm/a39409305056fa36abb9ed849b6b9770

What did you expect to see?

I expect Recv() to always return when Close() is called

What did you see instead?

Sometimes Recv() is stuck.

@MakMukhi
Copy link
Contributor

This should be fixed by #1275.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 26, 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

Successfully merging a pull request may close this issue.

3 participants