8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 20:43:02 +01:00

Fix for turning forced writes off

This commit is contained in:
tamlin 2001-12-28 05:16:58 +00:00
parent 6c92c1f3b2
commit e98988ae33

View File

@ -303,26 +303,27 @@ void PIO_force_write(FIL file, USHORT flag)
* Set (or clear) force write, if possible, for the database.
*
**************************************/
HANDLE desc;
if (flag)
const bool bOldForce = (file->fil_flags & FIL_force_write_init) != 0;
if ((flag && !bOldForce) ||
(!flag && bOldForce))
{
if (!(file->fil_flags & FIL_force_write_init))
{
/* TMN: Close the existing handle since we're now opening */
/* the files for exclusive access */
MaybeCloseFile(&file->fil_desc);
desc = CreateFile(file->fil_string,
SLONG& hOld = flag ? file->fil_desc : file->fil_force_write_desc;
HANDLE& hNew = reinterpret_cast<HANDLE&>(flag ? file->fil_force_write_desc : file->fil_desc);
MaybeCloseFile(&hOld);
hNew = CreateFile(file->fil_string,
GENERIC_READ | GENERIC_WRITE,
g_dwShareFlags,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL |
FILE_FLAG_WRITE_THROUGH |
g_dwExtraFlags,
g_dwExtraFlags |
(flag ? FILE_FLAG_WRITE_THROUGH : 0),
0);
if (desc == INVALID_HANDLE_VALUE)
if (hNew == INVALID_HANDLE_VALUE)
{
ERR_post(isc_io_error,
gds_arg_string,
@ -336,16 +337,13 @@ void PIO_force_write(FIL file, USHORT flag)
0);
}
/* TMN: Take note! Assumes sizeof(long) == sizeof(void*) ! */
file->fil_force_write_desc = reinterpret_cast<SLONG>(desc);
}
if (flag) {
file->fil_flags |= (FIL_force_write | FIL_force_write_init);
}
else
{
} else {
file->fil_flags &= ~FIL_force_write;
}
}
}
void PIO_header(DBB dbb, SCHAR * address, int length)