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

jsonrpc.ServeConn doesn't detect network client hangup #1828

Closed
gopherbot opened this issue May 15, 2011 · 3 comments
Closed

jsonrpc.ServeConn doesn't detect network client hangup #1828

gopherbot opened this issue May 15, 2011 · 3 comments

Comments

@gopherbot
Copy link

by viscous:

What steps will reproduce the problem?
1. run attached breakjsonrpc.go
2. run attached gorpc.py

What is the expected output?
A single "connection reset" log message:
2011/05/14 16:36:34 rpc: rpc: server cannot decode request: read tcp [::1]:52123:
connection reset by peer

What do you see instead?
The above log message is repeated ad infinitum.

Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?
Ubuntu 11.04

Which revision are you using?  (hg identify)
5d2ce135523+ (release-branch.r57) release/release.r57.1
I did check top of tree, though.


Please provide any additional information below.
The underlying problem is that rpc.*Server·ServeCodec serves until it gets an os.EOF or
io.ErrUnexpectedEOF, but json.*Decoder·readValue gets a net.OpError, so it just loops
forever, trying and failing to read from the same connection.

Two possible fixes:
- rpc.*Server·ServeCodec stops serving for all error types instead of just os.EOF and
io.ErrUnexpectedEOF
- jsonrpc.*serverCodec·ReadRequestHeader, which calls into the json decoder, masks all
non-eof errors as io.ErrUnexpectedEOF

I'm not sure of the ramifications for the first, so I tried the second, and it appears
to work. Here's a patch that does it:
--- a/src/pkg/rpc/jsonrpc/server.go     Wed May 04 00:17:17 2011 -0400
+++ b/src/pkg/rpc/jsonrpc/server.go     Sat May 14 17:34:33 2011 -0700
@@ -67,6 +67,9 @@
 func (c *serverCodec) ReadRequestHeader(r *rpc.Request) os.Error {
        c.req.reset()
        if err := c.dec.Decode(&c.req); err != nil {
+               if err != os.EOF {
+                       return io.ErrUnexpectedEOF
+               }
                return err
        }
        r.ServiceMethod = c.req.Method

Attachments:

  1. breakjsonrpc.go (782 bytes)
  2. gorpc.py (371 bytes)
@adg
Copy link
Contributor

adg commented May 18, 2011

Comment 1:

Owner changed to @adg.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Nov 1, 2011

Comment 2:

This issue was closed by revision 2e79e8e.

Status changed to Fixed.

@bytbox
Copy link
Contributor

bytbox commented Nov 7, 2011

Comment 3:

Not fixed - re-filed as issue #2427.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc unassigned adg Jun 22, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants