aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2018-08-31 13:18:08 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2018-08-31 13:19:12 +0200
commitbb0277819a13bb09f2032381aebb023d47f42dc5 (patch)
treea7e7183b4a9c23c00d30f97bf14cb45adc682690 /src
parent104aad15677be0dbfb76221e3272d4426e0b562a (diff)
parent75ea00f391b742e435c650aae3e827aad913d552 (diff)
downloadbitcoin-bb0277819a13bb09f2032381aebb023d47f42dc5.tar.xz
Merge #13159: Don't close old debug log file handle prematurely when trying to re-open (on SIGHUP)
75ea00f391b742e435c650aae3e827aad913d552 Remove unused fsbridge::freopen (practicalswift) cceedbc4bf1056db17e0adf76d0db45b94777671 Don't close old debug log file handle prematurely when trying to re-open (on SIGHUP) (practicalswift) Pull request description: Don't close old debug log file handle prematurely when trying to re-open (on `SIGHUP`). Context: https://github.com/bitcoin/bitcoin/pull/13148#issuecomment-386288606 Thanks @ajtowns! Tree-SHA512: c436b4286f00fc428b60269b6d6321f435c72c7ccec3c15b2194aac71196529b30f32c2384b418ffe3ed67ba7ee8ec51f4c9c5748e65945697c0437eafcdacd1
Diffstat (limited to 'src')
-rw-r--r--src/fs.cpp5
-rw-r--r--src/fs.h1
-rw-r--r--src/logging.cpp10
3 files changed, 5 insertions, 11 deletions
diff --git a/src/fs.cpp b/src/fs.cpp
index e7d06e45ab..2dbc13643b 100644
--- a/src/fs.cpp
+++ b/src/fs.cpp
@@ -14,11 +14,6 @@ FILE *fopen(const fs::path& p, const char *mode)
return ::fopen(p.string().c_str(), mode);
}
-FILE *freopen(const fs::path& p, const char *mode, FILE *stream)
-{
- return ::freopen(p.string().c_str(), mode, stream);
-}
-
#ifndef WIN32
static std::string GetErrorReason() {
diff --git a/src/fs.h b/src/fs.h
index e3ff51604d..5a28d9a81c 100644
--- a/src/fs.h
+++ b/src/fs.h
@@ -18,7 +18,6 @@ namespace fs = boost::filesystem;
/** Bridge operations to C stdio */
namespace fsbridge {
FILE *fopen(const fs::path& p, const char *mode);
- FILE *freopen(const fs::path& p, const char *mode, FILE *stream);
class FileLock
{
diff --git a/src/logging.cpp b/src/logging.cpp
index 6557dddffb..0ae4f8121e 100644
--- a/src/logging.cpp
+++ b/src/logging.cpp
@@ -219,13 +219,13 @@ void BCLog::Logger::LogPrintStr(const std::string &str)
// reopen the log file, if requested
if (m_reopen_file) {
m_reopen_file = false;
- m_fileout = fsbridge::freopen(m_file_path, "a", m_fileout);
- if (!m_fileout) {
- return;
+ FILE* new_fileout = fsbridge::fopen(m_file_path, "a");
+ if (new_fileout) {
+ setbuf(new_fileout, nullptr); // unbuffered
+ fclose(m_fileout);
+ m_fileout = new_fileout;
}
- setbuf(m_fileout, nullptr); // unbuffered
}
-
FileWriteStr(strTimestamped, m_fileout);
}
}