From e3c0fba34b73814d93ac57d1903387b1eb5136e4 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Tue, 27 Oct 2015 10:27:18 +0100 Subject: [PATCH] Must not call hex.Dump in non-debug mode... --- lib/protocol/debug.go | 4 ++++ lib/protocol/protocol.go | 10 ++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/protocol/debug.go b/lib/protocol/debug.go index fcc4b3b23..717445f70 100644 --- a/lib/protocol/debug.go +++ b/lib/protocol/debug.go @@ -16,3 +16,7 @@ var ( func init() { l.SetDebug("protocol", strings.Contains(os.Getenv("STTRACE"), "protocol") || os.Getenv("STTRACE") == "all") } + +func shouldDebug() bool { + return l.ShouldDebug("protocol") +} diff --git a/lib/protocol/protocol.go b/lib/protocol/protocol.go index 2420bf386..1b89ee097 100644 --- a/lib/protocol/protocol.go +++ b/lib/protocol/protocol.go @@ -411,10 +411,12 @@ func (c *rawConnection) readMessage() (hdr header, msg encodable, err error) { l.Debugf("decompressed to %d bytes", len(msgBuf)) } - if len(msgBuf) > 1024 { - l.Debugf("message data:\n%s", hex.Dump(msgBuf[:1024])) - } else { - l.Debugf("message data:\n%s", hex.Dump(msgBuf)) + if shouldDebug() { + if len(msgBuf) > 1024 { + l.Debugf("message data:\n%s", hex.Dump(msgBuf[:1024])) + } else { + l.Debugf("message data:\n%s", hex.Dump(msgBuf)) + } } // We check each returned error for the XDRError.IsEOF() method.