mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Use workaround for setvbuf on Windows in DebugLogger/Extract file analyzer
This commit is contained in:
parent
f2a3e23dfa
commit
29b0380815
3 changed files with 3 additions and 11 deletions
|
@ -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;
|
||||
|
|
10
src/File.cc
10
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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue