mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
Merge 1746e2ddbd into e27af97a3c
This commit is contained in:
commit
ba9bb93433
3 changed files with 24 additions and 2 deletions
|
|
@ -18,6 +18,11 @@ package rpc
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
|
var (
|
||||||
|
// ErrConnectionClosed is thrown when the connection is closed
|
||||||
|
ErrConnectionClosed = new(connectionClosedError)
|
||||||
|
)
|
||||||
|
|
||||||
// request is for an unknown service
|
// request is for an unknown service
|
||||||
type methodNotFoundError struct {
|
type methodNotFoundError struct {
|
||||||
service string
|
service string
|
||||||
|
|
@ -95,3 +100,15 @@ func (e *shutdownError) Code() int {
|
||||||
func (e *shutdownError) Error() string {
|
func (e *shutdownError) Error() string {
|
||||||
return "server is shutting down"
|
return "server is shutting down"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// connectionClosedError is thrown when the connection is closed
|
||||||
|
type connectionClosedError struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *connectionClosedError) Code() int {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *connectionClosedError) Error() string {
|
||||||
|
return "connection closed"
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,9 @@ func (c *jsonCodec) ReadRequestHeaders() ([]rpcRequest, bool, RPCError) {
|
||||||
|
|
||||||
var incomingMsg json.RawMessage
|
var incomingMsg json.RawMessage
|
||||||
if err := c.d.Decode(&incomingMsg); err != nil {
|
if err := c.d.Decode(&incomingMsg); err != nil {
|
||||||
|
if err == io.EOF {
|
||||||
|
return nil, false, ErrConnectionClosed
|
||||||
|
}
|
||||||
return nil, false, &invalidRequestError{err.Error()}
|
return nil, false, &invalidRequestError{err.Error()}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -183,8 +183,10 @@ func (s *Server) serveRequest(codec ServerCodec, singleShot bool, options CodecO
|
||||||
for atomic.LoadInt32(&s.run) == 1 {
|
for atomic.LoadInt32(&s.run) == 1 {
|
||||||
reqs, batch, err := s.readRequest(codec)
|
reqs, batch, err := s.readRequest(codec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.V(logger.Debug).Infof("%v\n", err)
|
if err != ErrConnectionClosed {
|
||||||
codec.Write(codec.CreateErrorResponse(nil, err))
|
glog.V(logger.Error).Infof("%v\n", err)
|
||||||
|
codec.Write(codec.CreateErrorResponse(nil, err))
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue