mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
rpc: increased log level in case RPC request could not be read
This commit is contained in:
parent
5f917715c5
commit
1746e2ddbd
3 changed files with 24 additions and 2 deletions
|
|
@ -18,6 +18,11 @@ package rpc
|
|||
|
||||
import "fmt"
|
||||
|
||||
var (
|
||||
// ErrConnectionClosed is thrown when the connection is closed
|
||||
ErrConnectionClosed = new(connectionClosedError)
|
||||
)
|
||||
|
||||
// request is for an unknown service
|
||||
type methodNotFoundError struct {
|
||||
service string
|
||||
|
|
@ -95,3 +100,15 @@ func (e *shutdownError) Code() int {
|
|||
func (e *shutdownError) Error() string {
|
||||
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
|
||||
if err := c.d.Decode(&incomingMsg); err != nil {
|
||||
if err == io.EOF {
|
||||
return nil, false, ErrConnectionClosed
|
||||
}
|
||||
return nil, false, &invalidRequestError{err.Error()}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -185,8 +185,10 @@ func (s *Server) serveRequest(codec ServerCodec, singleShot bool, options CodecO
|
|||
for atomic.LoadInt32(&s.run) == 1 {
|
||||
reqs, batch, err := s.readRequest(codec)
|
||||
if err != nil {
|
||||
glog.V(logger.Debug).Infof("%v\n", err)
|
||||
codec.Write(codec.CreateErrorResponse(nil, err))
|
||||
if err != ErrConnectionClosed {
|
||||
glog.V(logger.Error).Infof("%v\n", err)
|
||||
codec.Write(codec.CreateErrorResponse(nil, err))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue