Re: Win32 and fsync()

From: Gavin Sherry <swm(at)linuxworld(dot)com(dot)au>
To: Dann Corbit <DCorbit(at)connx(dot)com>
Cc: Merlin Moncure <merlin(dot)moncure(at)rcsonline(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Win32 and fsync()
Date: 2003-02-03 23:29:23
Message-ID: Pine.LNX.4.21.0302041028150.30161-100000@linuxworld.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 3 Feb 2003, Dann Corbit wrote:

> > -----Original Message-----
> > From: Merlin Moncure [mailto:merlin(dot)moncure(at)rcsonline(dot)com]
> > Sent: Monday, February 03, 2003 3:00 PM
> > To: Andrew Dunstan
> > Cc: pgsql-hackers(at)postgresql(dot)org
> > Subject: Re: [HACKERS] Win32 and fsync()
> >
> >
> > >I'm having difficulty digging up the reference, but I think I recall
> > seeing >something that said, roughly, on W32 there are 2 sets
> > of buffers
> > - those in >the user level library and those in the kernel
> > level driver, and >FlushFileBuffers drains the first, while
> > _commit drains both (it includes a >call to FlushFileBuffers).
> >
> > You were correct: here is the source.
> >
> >
> > int __cdecl _commit (
> > int filedes
> > )
> > {
> > int retval;
> >
> > /* if filedes out of range, complain */
> > if ( ((unsigned)filedes >= (unsigned)_nhandle) ||
> > !(_osfile(filedes) & FOPEN) )
> > {
> > errno = EBADF;
> > return (-1);
> > }
> >
> > _lock_fh(filedes);
> >
> > /* if filedes open, try to commit, else fall through to bad */
> > if (_osfile(filedes) & FOPEN) {
> >
> > if (
> > !FlushFileBuffers((HANDLE)_get_osfhandle(filedes))
> > ) {
> > retval = GetLastError();
> > } else {
> > retval = 0; /* return success */
> > }
> >
> > /* map the OS return code to C errno value
> > and return code */
> > if (retval == 0) {
> > goto good;
> > } else {
> > _doserrno = retval;
> > goto bad;
> > }
> >
> > }
> >
> > bad :
> > errno = EBADF;
> > retval = -1;
> > good :
> > _unlock_fh(filedes);
> > return (retval);
> > }
>
> Where is the "other" flush besides FlushFileBuffers()?

The only real code there is, it seems, an exclusive look on the file
descriptor. (Provided of course that that is what _lock_fh(filedes) does).

Gavin

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2003-02-03 23:31:23 Re: Win32 and fsync()
Previous Message Dann Corbit 2003-02-03 23:24:02 Re: Win32 and fsync()