From d7f1d200ab5d385c727261621c069dfbc6170e78 Mon Sep 17 00:00:00 2001 From: Giel van Schijndel Date: Fri, 24 Jun 2011 20:09:24 +0200 Subject: fix warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare] Don't check for a negative parameter count, because not only will it never happen, it doesn't make any sense either. Invalid sockets (as returned by socket(2)) are always exactly -1 (not just negative as negative file descriptors are technically not prohibited by POSIX) on POSIX systems. Since we store them in SOCKET (unsigned int), however, that really is ~0U (or MAX_UINT) which happens to be what INVALID_SOCKET is already defined to, so an additional check for being negative is not only unnecessary (unsigned integers aren't *ever* negative) its redundant as well (the INVALID_SOCKET comparison is enough). Signed-off-by: Giel van Schijndel --- src/net.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/net.cpp') diff --git a/src/net.cpp b/src/net.cpp index 0d3348da72..da13874495 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -831,7 +831,7 @@ void ThreadSocketHandler2(void* parg) { BOOST_FOREACH(CNode* pnode, vNodes) { - if (pnode->hSocket == INVALID_SOCKET || pnode->hSocket < 0) + if (pnode->hSocket == INVALID_SOCKET) continue; FD_SET(pnode->hSocket, &fdsetRecv); FD_SET(pnode->hSocket, &fdsetError); -- cgit v1.2.3 From 858cebed7dee2e9801e754a9969844b7969254ee Mon Sep 17 00:00:00 2001 From: Giel van Schijndel Date: Fri, 24 Jun 2011 22:00:59 +0200 Subject: fix warning: unused variable 'X' [-Wunused-variable] Remove several unused variables. Signed-off-by: Giel van Schijndel --- src/net.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/net.cpp') diff --git a/src/net.cpp b/src/net.cpp index da13874495..ac5a2834b0 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1700,7 +1700,7 @@ void StartNode(void* parg) printf("Error: CreateThread(ThreadIRCSeed) failed\n"); // Send and receive from sockets, accept connections - pthread_t hThreadSocketHandler = CreateThread(ThreadSocketHandler, NULL, true); + CreateThread(ThreadSocketHandler, NULL, true); // Initiate outbound connections if (!CreateThread(ThreadOpenConnections, NULL)) -- cgit v1.2.3 From 8c41469140584f3cbdd09fb62a1287da0216f431 Mon Sep 17 00:00:00 2001 From: Patrick Varilly Date: Thu, 14 Jul 2011 02:45:34 +0200 Subject: Single DB transaction for all addresses in a message Cuts disk activity at startup immensely --- src/net.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/net.cpp') diff --git a/src/net.cpp b/src/net.cpp index ac5a2834b0..dcfff934b6 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -440,7 +440,7 @@ void ThreadGetMyExternalIP(void* parg) -bool AddAddress(CAddress addr, int64 nTimePenalty) +bool AddAddress(CAddress addr, int64 nTimePenalty, CAddrDB *pAddrDB) { if (!addr.IsRoutable()) return false; @@ -455,7 +455,10 @@ bool AddAddress(CAddress addr, int64 nTimePenalty) // New address printf("AddAddress(%s)\n", addr.ToString().c_str()); mapAddresses.insert(make_pair(addr.GetKey(), addr)); - CAddrDB().WriteAddress(addr); + if (pAddrDB) + pAddrDB->WriteAddress(addr); + else + CAddrDB().WriteAddress(addr); return true; } else @@ -477,7 +480,12 @@ bool AddAddress(CAddress addr, int64 nTimePenalty) fUpdated = true; } if (fUpdated) - CAddrDB().WriteAddress(addrFound); + { + if (pAddrDB) + pAddrDB->WriteAddress(addrFound); + else + CAddrDB().WriteAddress(addrFound); + } } } return false; -- cgit v1.2.3 From d655a26c9dd157a9e4bf08bff14bfaa69791287a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Gimenez?= Date: Thu, 14 Jul 2011 02:57:39 +0200 Subject: Single DB transaction for addresses from DNS seeds --- src/net.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/net.cpp') diff --git a/src/net.cpp b/src/net.cpp index dcfff934b6..2a90f6d0cc 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1166,6 +1166,8 @@ void DNSAddressSeed() if (!fTestNet) { printf("Loading addresses from DNS seeds (could take a while)\n"); + CAddrDB addrDB; + addrDB.TxnBegin(); for (int seed_idx = 0; seed_idx < ARRAYLEN(strDNSSeed); seed_idx++) { vector vaddr; @@ -1176,12 +1178,14 @@ void DNSAddressSeed() if (addr.GetByte(3) != 127) { addr.nTime = 0; - AddAddress(addr); + AddAddress(addr, 0, &addrDB); found++; } } } } + + addrDB.TxnCommit(); // Save addresses (it's ok if this fails) } printf("%d addresses found from DNS seeds\n", found); -- cgit v1.2.3