Only posix_fadvise() on close if stream is nonnull, since fileno() segfaults (on Linux) if you try that.

This commit is contained in:
Brian Cox 2016-05-09 10:34:53 -07:00
parent 778c397d48
commit 5ffab7f278
1 changed files with 5 additions and 5 deletions

View File

@ -1,4 +1,4 @@
//
// The developer of the original code and/or files is Tripwire, Inc.
// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire,
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
@ -229,12 +229,12 @@ void cFile::Open( const TSTRING& sFileNameC, uint32 flags )
///////////////////////////////////////////////////////////////////////////
void cFile::Close() //throw(eFile)
{
if(mpData->mpCurrStream != NULL)
{
#ifdef HAVE_POSIX_FADVISE
posix_fadvise(fileno(mpData->mpCurrStream),0,0, POSIX_FADV_DONTNEED);
#endif
if(mpData->mpCurrStream != NULL)
{
fclose( mpData->mpCurrStream );
mpData->mpCurrStream = NULL;
}