Only posix_fadvise() on close if stream is nonnull, since fileno() segfaults (on Linux) if you try that.
This commit is contained in:
parent
778c397d48
commit
5ffab7f278
|
@ -1,4 +1,4 @@
|
||||||
//
|
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
|
@ -228,13 +228,13 @@ void cFile::Open( const TSTRING& sFileNameC, uint32 flags )
|
||||||
// Close -- Closes mpCurrStream and sets the pointer to NULL
|
// Close -- Closes mpCurrStream and sets the pointer to NULL
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
void cFile::Close() //throw(eFile)
|
void cFile::Close() //throw(eFile)
|
||||||
|
{
|
||||||
|
if(mpData->mpCurrStream != NULL)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_POSIX_FADVISE
|
#ifdef HAVE_POSIX_FADVISE
|
||||||
posix_fadvise(fileno(mpData->mpCurrStream),0,0, POSIX_FADV_DONTNEED);
|
posix_fadvise(fileno(mpData->mpCurrStream),0,0, POSIX_FADV_DONTNEED);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(mpData->mpCurrStream != NULL)
|
|
||||||
{
|
|
||||||
fclose( mpData->mpCurrStream );
|
fclose( mpData->mpCurrStream );
|
||||||
mpData->mpCurrStream = NULL;
|
mpData->mpCurrStream = NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue