Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2013-01-18 04:28:21 +0400
committerChristopher Faylor <me@cgf.cx>2013-01-18 04:28:21 +0400
commitc5eb7a4971c9f6d93cf9d03c7cbaf1d9144afdf0 (patch)
treee71a2a6a3d41483fb6accbfe93ee2b72310f59e8 /winsup
parent5988aa6e3ff8c53ec7c83cecf47c5438216b74f4 (diff)
* mmap.cc (handler_disk_file::msync): Retry up to 99 times if FlushViewOFile
fails with ERROR_LOCK_VIOLATION.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog5
-rw-r--r--winsup/cygwin/mmap.cc23
2 files changed, 21 insertions, 7 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 643c6f348..9920d98e4 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -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
diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc
index d8d78a51a..0ede7e6ab 100644
--- a/winsup/cygwin/mmap.cc
+++ b/winsup/cygwin/mmap.cc
@@ -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