From 21917695a7079ded5401b9050f5357afaa907ed6 Mon Sep 17 00:00:00 2001 From: Lucian Petrut Date: Tue, 6 Dec 2022 10:35:36 +0200 Subject: [PATCH] log: fix stderr handling on Windows A recent commit configured stderr to use non-blocking IO in order to avoid partial writes with container runtimes. This broke the Windows build: ceph/src/log/Log.cc:85:36: error: 'F_GETFL' was not declared in this scope 85 | int flags = fcntl(m_fd_stderr, F_GETFL); | ^~~~~~~ ceph/src/log/Log.cc:85:17: error: 'fcntl' was not declared in this scope 85 | int flags = fcntl(m_fd_stderr, F_GETFL); | ^~~~~ ceph/src/log/Log.cc:90:19: error: 'O_NONBLOCK' was not declared in this scope 90 | if (!(flags & O_NONBLOCK)) { | ^~~~~~~~~~ ceph/src/log/Log.cc:92:34: error: 'F_SETFL' was not declared in this scope 92 | flags = fcntl(m_fd_stderr, F_SETFL, flags); We're going to skip this since we don't actually need to use non-blocking IO with stderr on Windows. Fixes: 2551130bcc12c55ddaa879b4f5b77c81890b51b2 Signed-off-by: Lucian Petrut (cherry picked from commit b7a7debb87a3da3af2f67dae02f56f3de26d11a9) --- src/log/Log.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/log/Log.cc b/src/log/Log.cc index b6ce72beb830f..0a16d6fa69fc1 100644 --- a/src/log/Log.cc +++ b/src/log/Log.cc @@ -70,6 +70,7 @@ Log::~Log() void Log::_configure_stderr() { +#ifndef _WIN32 struct stat info; if (int rc = fstat(m_fd_stderr, &info); rc == -1) { std::cerr << "failed to stat stderr: " << cpp_strerror(errno) << std::endl; @@ -80,6 +81,8 @@ void Log::_configure_stderr() /* Set O_NONBLOCK on FIFO stderr file. We want to ensure atomic debug log * writes so they do not get partially read by e.g. buggy container * runtimes. See also IEEE Std 1003.1-2017 and Log::_log_stderr below. + * + * This isn't required on Windows. */ int flags = fcntl(m_fd_stderr, F_GETFL); if (flags == -1) { @@ -96,6 +99,7 @@ void Log::_configure_stderr() } do_stderr_poll = true; } +#endif // !_WIN32 } -- 2.39.5