mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-21 00:07:36 +08:00
* mmap.cc (handler_disk_file::msync): Retry up to 99 times if FlushViewOFile
fails with ERROR_LOCK_VIOLATION.
This commit is contained in:
parent
5988aa6e3f
commit
c5eb7a4971
@ -1,3 +1,8 @@
|
||||
2013-01-17 Christopher Faylor <me.cygwin2013@cgf.cx>
|
||||
|
||||
* mmap.cc (handler_disk_file::msync): Retry up to 99 times if
|
||||
FlushViewOFile fails with ERROR_LOCK_VIOLATION.
|
||||
|
||||
2013-01-16 Christopher Faylor <me.cygwin2013@cgf.cx>
|
||||
|
||||
* sigproc.cc (no_signals_available): Finally remove this macro
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* mmap.cc
|
||||
|
||||
Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005,
|
||||
2006, 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
|
||||
2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Red Hat, Inc.
|
||||
|
||||
This file is part of Cygwin.
|
||||
|
||||
@ -1657,12 +1657,21 @@ fhandler_disk_file::munmap (HANDLE h, caddr_t addr, size_t len)
|
||||
int
|
||||
fhandler_disk_file::msync (HANDLE h, caddr_t addr, size_t len, int flags)
|
||||
{
|
||||
if (FlushViewOfFile (addr, len) == 0)
|
||||
{
|
||||
__seterrno ();
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
const int retry = 100;
|
||||
/* The wisdom of google tells us that FlushViewOfFile may fail with
|
||||
ERROR_LOCK_VIOLATION if "if the memory system is writing dirty
|
||||
pages to disk". And, we've seen reports of this happening in the
|
||||
cygwin list. So retry 99 times and hope we get lucky. */
|
||||
for (int i = 0; i < retry; i++)
|
||||
if (FlushViewOfFile (addr, len))
|
||||
return 0;
|
||||
else if (GetLastError () != ERROR_LOCK_VIOLATION)
|
||||
break;
|
||||
else if (i < (retry - 1))
|
||||
yield ();
|
||||
|
||||
__seterrno ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool
|
||||
|
Loading…
x
Reference in New Issue
Block a user