Re: Win32 and fsync() - Mailing list pgsql-hackers

From Merlin Moncure
Subject Re: Win32 and fsync()
Date
Msg-id 303E00EBDD07B943924382E153890E5433F7C0@cuthbert.rcsinc.local
Whole thread Raw
In response to Win32 and fsync()  ("Dann Corbit" <DCorbit@connx.com>)
List pgsql-hackers
>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;     /*
returnsuccess */               } 
               /* 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);
}


pgsql-hackers by date:

Previous
From: "Dave Page"
Date:
Subject: Re: Win32 and fsync()
Next
From: Gavin Sherry
Date:
Subject: Re: Win32 and fsync()