* mmap.cc (handler_disk_file::msync): Retry up to 99 times if FlushViewOFile

fails with ERROR_LOCK_VIOLATION.
This commit is contained in:
Christopher Faylor 2013-01-18 00:28:21 +00:00
parent 5988aa6e3f
commit c5eb7a4971
2 changed files with 21 additions and 7 deletions

View File

@ -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> 2013-01-16 Christopher Faylor <me.cygwin2013@cgf.cx>
* sigproc.cc (no_signals_available): Finally remove this macro * sigproc.cc (no_signals_available): Finally remove this macro

View File

@ -1,7 +1,7 @@
/* mmap.cc /* mmap.cc
Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 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. This file is part of Cygwin.
@ -1657,12 +1657,21 @@ fhandler_disk_file::munmap (HANDLE h, caddr_t addr, size_t len)
int int
fhandler_disk_file::msync (HANDLE h, caddr_t addr, size_t len, int flags) fhandler_disk_file::msync (HANDLE h, caddr_t addr, size_t len, int flags)
{ {
if (FlushViewOfFile (addr, len) == 0) const int retry = 100;
{ /* The wisdom of google tells us that FlushViewOfFile may fail with
__seterrno (); ERROR_LOCK_VIOLATION if "if the memory system is writing dirty
return -1; pages to disk". And, we've seen reports of this happening in the
} cygwin list. So retry 99 times and hope we get lucky. */
return 0; 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 bool