From 59090133c0ffae33a4f5a186567ba6a514d2c11b Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Sat, 17 Sep 2011 18:29:41 +0200 Subject: log low-level network messages only when fDebug is set --- src/main.cpp | 8 +++++--- src/net.h | 11 +++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 5b159fe415..6a3bacc78e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1744,9 +1744,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) { static map > mapReuseKey; RandAddSeedPerfmon(); - if (fDebug) + if (fDebug) { printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str()); - printf("received: %s (%d bytes)\n", strCommand.c_str(), vRecv.size()); + printf("received: %s (%d bytes)\n", strCommand.c_str(), vRecv.size()); + } if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0) { printf("dropmessagestest DROPPING RECV MESSAGE\n"); @@ -1934,7 +1935,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) pfrom->AddInventoryKnown(inv); bool fAlreadyHave = AlreadyHave(txdb, inv); - printf(" got inventory: %s %s\n", inv.ToString().c_str(), fAlreadyHave ? "have" : "new"); + if (fDebug) + printf(" got inventory: %s %s\n", inv.ToString().c_str(), fAlreadyHave ? "have" : "new"); if (!fAlreadyHave) pfrom->AskFor(inv); diff --git a/src/net.h b/src/net.h index efac1f452a..a8356eade1 100644 --- a/src/net.h +++ b/src/net.h @@ -282,9 +282,10 @@ public: nHeaderStart = vSend.size(); vSend << CMessageHeader(pszCommand, 0); nMessageStart = vSend.size(); - if (fDebug) + if (fDebug) { printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str()); - printf("sending: %s ", pszCommand); + printf("sending: %s ", pszCommand); + } } void AbortMessage() @@ -324,8 +325,10 @@ public: memcpy((char*)&vSend[nHeaderStart] + offsetof(CMessageHeader, nChecksum), &nChecksum, sizeof(nChecksum)); } - printf("(%d bytes) ", nSize); - printf("\n"); + if (fDebug) { + printf("(%d bytes) ", nSize); + printf("\n"); + } nHeaderStart = -1; nMessageStart = -1; -- cgit v1.2.3 From e674680ddd17382e0605472385e1bd5d0cf4e502 Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Sat, 17 Sep 2011 21:36:58 +0200 Subject: missed printf in AbortMessage(); merged printfs in EndMessage --- src/net.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/net.h b/src/net.h index a8356eade1..0026e402c2 100644 --- a/src/net.h +++ b/src/net.h @@ -296,7 +296,9 @@ public: nHeaderStart = -1; nMessageStart = -1; cs_vSend.Leave(); - printf("(aborted)\n"); + + if (fDebug) + printf("(aborted)\n"); } void EndMessage() @@ -326,8 +328,7 @@ public: } if (fDebug) { - printf("(%d bytes) ", nSize); - printf("\n"); + printf("(%d bytes)\n", nSize); } nHeaderStart = -1; -- cgit v1.2.3 From 88367a5fb85757aefea9bd0e9770d91c8c6e394d Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Mon, 19 Sep 2011 13:08:22 +0200 Subject: SocketHandler thread can be detached --- src/net.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/net.cpp b/src/net.cpp index 509d8905f9..2e257a6efc 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1713,7 +1713,7 @@ void StartNode(void* parg) printf("Error: CreateThread(ThreadIRCSeed) failed\n"); // Send and receive from sockets, accept connections - CreateThread(ThreadSocketHandler, NULL, true); + CreateThread(ThreadSocketHandler, NULL); // Initiate outbound connections if (!CreateThread(ThreadOpenConnections, NULL)) -- cgit v1.2.3