mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 00:03:02 +01:00
Fix for turning forced writes off
This commit is contained in:
parent
6c92c1f3b2
commit
e98988ae33
@ -303,26 +303,27 @@ void PIO_force_write(FIL file, USHORT flag)
|
|||||||
* Set (or clear) force write, if possible, for the database.
|
* 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))
|
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);
|
||||||
/* TMN: Close the existing handle since we're now opening */
|
|
||||||
/* the files for exclusive access */
|
MaybeCloseFile(&hOld);
|
||||||
MaybeCloseFile(&file->fil_desc);
|
hNew = CreateFile(file->fil_string,
|
||||||
desc = CreateFile(file->fil_string,
|
|
||||||
GENERIC_READ | GENERIC_WRITE,
|
GENERIC_READ | GENERIC_WRITE,
|
||||||
g_dwShareFlags,
|
g_dwShareFlags,
|
||||||
NULL,
|
NULL,
|
||||||
OPEN_EXISTING,
|
OPEN_EXISTING,
|
||||||
FILE_ATTRIBUTE_NORMAL |
|
FILE_ATTRIBUTE_NORMAL |
|
||||||
FILE_FLAG_WRITE_THROUGH |
|
g_dwExtraFlags |
|
||||||
g_dwExtraFlags,
|
(flag ? FILE_FLAG_WRITE_THROUGH : 0),
|
||||||
0);
|
0);
|
||||||
|
|
||||||
if (desc == INVALID_HANDLE_VALUE)
|
if (hNew == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
ERR_post(isc_io_error,
|
ERR_post(isc_io_error,
|
||||||
gds_arg_string,
|
gds_arg_string,
|
||||||
@ -336,16 +337,13 @@ void PIO_force_write(FIL file, USHORT flag)
|
|||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TMN: Take note! Assumes sizeof(long) == sizeof(void*) ! */
|
if (flag) {
|
||||||
file->fil_force_write_desc = reinterpret_cast<SLONG>(desc);
|
|
||||||
}
|
|
||||||
file->fil_flags |= (FIL_force_write | FIL_force_write_init);
|
file->fil_flags |= (FIL_force_write | FIL_force_write_init);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
file->fil_flags &= ~FIL_force_write;
|
file->fil_flags &= ~FIL_force_write;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PIO_header(DBB dbb, SCHAR * address, int length)
|
void PIO_header(DBB dbb, SCHAR * address, int length)
|
||||||
|
Loading…
Reference in New Issue
Block a user