Re: Will FlushFileBuffers be automatically called on CloseHandle(hFile)?
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Mon, 20 Aug 2007 04:10:36 -0400
One of the principles of doing properly handled transacted databases is that you assume
that between any two instructions the machine will stop instantly. So the basic notion is
that you track what is and is not commited to the magnetic surface. do a lot of careful
flushes to commit a transaction. But now the disk drive takes over, and essentially lies
about the commitment of bits to the magnetic surface. So we can no longer tell if the
bits we submitted to the drive have been committed to the surface or nt. And that IS the
fault of the disk vendor! (I have three 1500VA battery backups on my system...)
Between 54% and 80% of all BSODs are caused by defective third-party device drivers.
joe
On Sun, 19 Aug 2007 16:53:58 -0700, "Nobody" <Nobody@xxxxxxxxx> wrote:
Joseph M. Newcomer [MVP]If there is a power failure, the data in the DRAM of the hard drive isThat is why they have such things as "Battery backup" and line conditioning in case of "brown outs"
lost, and you will never know if it made it out.
There is also these things called Surge protectors in case of power spikes.
I could hardly blame Microsoft or the Disk Vendor for such incidents.
The one thing that may or may not be MS fault is the BSOD.
That I would take issues with.
The old Visio, before microsoft took it over, did something odd that caused all the data to be lost.
I was an unfortunate member of that group.
Since Microsoft took it over, it appears to be better, but still
If there is a system crash it enevitably corrupts the Visio file.
http://www.corrupteddatarecovery.com/Repair/Microsoft-Visio-drawing-File-Repair-VSD-Data-Conversion.asp
The one thing that has irked me is disk monitoring.
My hard drive crashed at one time, I think it overheated.
Fortunately I was able to recover valuable information and most of the other data.
I don't know if Vista comes equipped with disk monitoring as far as temp and other monitoring features?
It should be part of the OS and not a 3rd party tool.
Thanks,
"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message news:h2jhc39krc7n35vq9ihidh2gcfk85m50qn@xxxxxxxxxx
It's actually worse than you can possibly imagine. For example, the act of "flushing"
butters to a modern hard drive means that the buffers are written to the onboard buffers
on the hard drive, but not committed to the magnetic surface until the hard drive gets
around to it. If there is a power failure, the data in the DRAM of the hard drive is
lost, and you will never know if it made it out. When I was at a recent trade show, I was
talking to a disk drive vendor, and when I asked how they cope with the inevitable data
lossage that would result, he said, as if it was a joke, "Oh, we just blame it on
Microsoft".
joe
On Tue, 14 Aug 2007 11:49:26 -0700, "David Ching" <dc@xxxxxxxxxxxxxxxxxxxxxx> wrote:
Joseph M. Newcomer [MVP]
"xmllmx" <xmllmx@xxxxxxxxx> wrote in message
news:1187115960.104492.215250@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
To begin with code:
HANDLE hFile = CreateFile(...);
WriteFile(hFile, ...);
ReadFile(hFile, ...);
CloseHandle(hFile);
My queston is: Can CloseHandle(hFile) make sure that all the cached
data of hFile will be flushed to the disk?
I googled it and found nothing. Hope someone can give me some tips.
Thanks in advance.
I don't think so. You should call FlushFileBuffers() yourself before
CloseHandle(). I believe we encountered some difficulty that the buffers
were not truly flushed even after calling FlushFileBuffers() when this code
is executed as the result of Windows shutting down or restarting. The file
became corrupted. The workaround was to save the file immediately and not
wait for the WM_ENDSESSION. But I'm vague on the details. You might want
to check if others have encountered problems with FlushFileBuffers().
-- David
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- References:
- Will FlushFileBuffers be automatically called on CloseHandle(hFile)?
- From: xmllmx
- Re: Will FlushFileBuffers be automatically called on CloseHandle(hFile)?
- From: David Ching
- Re: Will FlushFileBuffers be automatically called on CloseHandle(hFile)?
- From: Joseph M . Newcomer
- Re: Will FlushFileBuffers be automatically called on CloseHandle(hFile)?
- From: Nobody
- Will FlushFileBuffers be automatically called on CloseHandle(hFile)?
- Prev by Date: Re: help me !!!
- Next by Date: Re: Multiple views Single Document MDI
- Previous by thread: Re: Will FlushFileBuffers be automatically called on CloseHandle(hFile)?
- Next by thread: Re: Will FlushFileBuffers be automatically called on CloseHandle(hFile)?
- Index(es):
Relevant Pages
|