diff --git a/src/File.cc b/src/File.cc index b2a167740f..e9767deb29 100644 --- a/src/File.cc +++ b/src/File.cc @@ -202,10 +202,16 @@ void File::SetBuf(bool arg_buffered) if ( ! f ) return; +#ifndef _MSC_VER if ( 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 ) +#endif reporter->Error("setvbuf failed"); - buffered = arg_buffered; + buffered = arg_buffered; } bool File::Close() diff --git a/src/util.cc b/src/util.cc index 8f6f83538e..c3c8506bf7 100644 --- a/src/util.cc +++ b/src/util.cc @@ -2038,9 +2038,15 @@ RETSIGTYPE sig_handler(int signo); double current_time(bool real) { struct timeval tv; +#ifdef _MSC_VER + auto now = std::chrono::system_clock::now(); + auto ms = std::chrono::duration_cast(now.time_since_epoch()); + tv.tv_sec = ms.count() / 1000; + tv.tv_usec = (ms.count() % 1000) * 1000; +#else if ( gettimeofday(&tv, 0) < 0 ) reporter->InternalError("gettimeofday failed in current_time()"); - +#endif double t = double(tv.tv_sec) + double(tv.tv_usec) / 1e6; if ( ! run_state::pseudo_realtime || real || ! iosource_mgr || ! iosource_mgr->GetPktSrc() )