diff --git a/src/DebugLogger.cc b/src/DebugLogger.cc index 4ff950c377..a7b2a41dfe 100644 --- a/src/DebugLogger.cc +++ b/src/DebugLogger.cc @@ -56,7 +56,7 @@ void DebugLogger::OpenDebugLog(const char* filename) } } - setvbuf(file, NULL, _IOLBF, 0); + util::detail::setvbuf(file, NULL, _IOLBF, 0); } else file = stderr; diff --git a/src/File.cc b/src/File.cc index 44c78ccd91..864a0cc37f 100644 --- a/src/File.cc +++ b/src/File.cc @@ -202,16 +202,8 @@ void File::SetBuf(bool arg_buffered) if ( ! f ) return; -#ifndef _MSC_VER - if ( setvbuf(f, NULL, arg_buffered ? _IOFBF : _IOLBF, 0) != 0 ) + if ( util::detail::setvbuf(f, NULL, arg_buffered ? _IOFBF : _IOLBF, 0) != 0 ) reporter->Error("setvbuf failed"); -#else - // TODO: this turns off buffering altogether because Windows wants us to pass a valid - // buffer and length if we're going to pass one of the other modes. We need to - // investigate the performance ramifications of this. - if ( setvbuf(f, NULL, _IONBF, 0) != 0 ) - reporter->Error("setvbuf failed"); -#endif buffered = arg_buffered; } diff --git a/src/file_analysis/analyzer/extract/Extract.cc b/src/file_analysis/analyzer/extract/Extract.cc index 77a696daf3..e6805b867a 100644 --- a/src/file_analysis/analyzer/extract/Extract.cc +++ b/src/file_analysis/analyzer/extract/Extract.cc @@ -23,7 +23,7 @@ Extract::Extract(RecordValPtr args, file_analysis::File* file, const std::string if ( file_stream ) { // Try to ensure full buffering. - if ( setvbuf(file_stream, nullptr, _IOFBF, BUFSIZ) ) + if ( util::detail::setvbuf(file_stream, nullptr, _IOFBF, BUFSIZ) ) { util::zeek_strerror_r(errno, buf, sizeof(buf)); reporter->Warning("cannot set buffering mode for %s: %s", filename.data(), buf);