From 1af1366ff3b26598c1f2adef97be028cfcb0d2e7 Mon Sep 17 00:00:00 2001 From: deusstultus Date: Fri, 5 Dec 2014 09:00:07 -0600 Subject: [PATCH 1/2] Revert 25a07f10 -- makefile.unix STATIC=1 not cleanly implemented --- src/makefile.unix | 1 - 1 file changed, 1 deletion(-) diff --git a/src/makefile.unix b/src/makefile.unix index 913b1472d7889..48fcd31176922 100644 --- a/src/makefile.unix +++ b/src/makefile.unix @@ -23,7 +23,6 @@ ifdef UNIT_TEST DEFS+=-DUNIT_TEST=1 endif -STATIC = 1 LMODE = dynamic LMODE2 = dynamic ifdef STATIC From 6eb44b0bb28b9aba05ebee7c2fbd79b8483a5eb8 Mon Sep 17 00:00:00 2001 From: crowning- Date: Fri, 5 Dec 2014 22:24:40 +0100 Subject: [PATCH 2/2] Temporary file when writing peers.dat obsolete On client shutdown write directly into "peers.dat" and not into a temporary file which gets renamed to "peers.dat" later. --- src/db.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/db.cpp b/src/db.cpp index 15c02d082ee39..d7f528ebd9ab0 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -495,11 +495,6 @@ bool CAddrDB::Write(const CAddrMan& addr) { unsigned char pchMessageStart[4] = { 0xfb, 0xc0, 0xb6, 0xdb }; - // Generate random temporary filename - unsigned short randv = 0; - RAND_bytes((unsigned char *)&randv, sizeof(randv)); - std::string tmpfn = strprintf("peers.dat.%04x", randv); - // serialize addresses, checksum data up to that point, then append csum CDataStream ssPeers(SER_DISK, CLIENT_VERSION); ssPeers << FLATDATA(pchMessageStart); @@ -507,9 +502,9 @@ bool CAddrDB::Write(const CAddrMan& addr) uint256 hash = Hash(ssPeers.begin(), ssPeers.end()); ssPeers << hash; - // open temp output file, and associate with CAutoFile - boost::filesystem::path pathTmp = GetDataDir() / tmpfn; - FILE *file = fopen(pathTmp.string().c_str(), "wb"); + // open output file, and associate with CAutoFile + boost::filesystem::path pathAddr = GetDataDir() / "peers.dat"; + FILE *file = fopen(pathAddr.string().c_str(), "wb"); CAutoFile fileout = CAutoFile(file, SER_DISK, CLIENT_VERSION); if (!fileout) return error("CAddrman::Write() : open failed"); @@ -524,10 +519,6 @@ bool CAddrDB::Write(const CAddrMan& addr) FileCommit(fileout); fileout.fclose(); - // replace existing peers.dat, if any, with new peers.dat.XXXX - if (!RenameOver(pathTmp, pathAddr)) - return error("CAddrman::Write() : Rename-into-place failed"); - return true; }