Commit ab578e12 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys Committed by Rob Pike

net/rpc: log I/O and internal errors only if debugLog is set.

Fixes #6367.

R=rsc, r
CC=golang-dev
https://golang.org/cl/13395047
parent 765479cc
......@@ -161,7 +161,7 @@ func (client *Client) input() {
}
client.mutex.Unlock()
client.sending.Unlock()
if err != io.EOF && !closing {
if debugLog && err != io.EOF && !closing {
log.Println("rpc: client protocol error:", err)
}
}
......@@ -173,7 +173,9 @@ func (call *Call) done() {
default:
// We don't want to block here. It is the caller's responsibility to make
// sure the channel has enough buffer space. See comment in Go().
log.Println("rpc: discarding Call reply due to insufficient Done chan capacity")
if debugLog {
log.Println("rpc: discarding Call reply due to insufficient Done chan capacity")
}
}
}
......
......@@ -38,6 +38,9 @@ const debugText = `<html>
var debug = template.Must(template.New("RPC debug").Parse(debugText))
// If set, print log statements for internal and I/O errors.
var debugLog = false
type debugMethod struct {
Type *methodType
Name string
......
......@@ -266,6 +266,7 @@ func (server *Server) register(rcvr interface{}, name string, useName bool) erro
if len(s.method) == 0 {
str := ""
// To help the user, see if a pointer receiver would work.
method := suitableMethods(reflect.PtrTo(s.typ), false)
if len(method) != 0 {
......@@ -357,7 +358,7 @@ func (server *Server) sendResponse(sending *sync.Mutex, req *Request, reply inte
resp.Seq = req.Seq
sending.Lock()
err := codec.WriteResponse(resp, reply)
if err != nil {
if debugLog && err != nil {
log.Println("rpc: writing response:", err)
}
sending.Unlock()
......@@ -435,7 +436,7 @@ func (server *Server) ServeCodec(codec ServerCodec) {
for {
service, mtype, req, argv, replyv, keepReading, err := server.readRequest(codec)
if err != nil {
if err != io.EOF {
if debugLog && err != io.EOF {
log.Println("rpc:", err)
}
if !keepReading {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment