]> sourceware.org Git - newlib-cygwin.git/commitdiff
Avoid deadlock in flock(2)
authorCorinna Vinschen <corinna@vinschen.de>
Thu, 5 Nov 2015 17:31:36 +0000 (18:31 +0100)
committerCorinna Vinschen <corinna@vinschen.de>
Thu, 5 Nov 2015 17:31:36 +0000 (18:31 +0100)
* fcntl.cc (fcntl64): Don't lock fd table when performing locking.
* flock.cc (flock): Ditto.
(lockf): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
winsup/cygwin/ChangeLog
winsup/cygwin/fcntl.cc
winsup/cygwin/flock.cc
winsup/cygwin/release/2.3.0

index 456bcd16c2b32fbe604e4d933c669083053aea8c..73b8237ffcd6e7a78cafc518db47fea01e1bc35c 100644 (file)
@@ -1,3 +1,9 @@
+2015-11-05  Corinna Vinschen  <corinna@vinschen.de>
+
+       * fcntl.cc (fcntl64): Don't lock fd table when performing locking.
+       * flock.cc (flock): Ditto.
+       (lockf): Ditto.
+
 2015-11-05  Corinna Vinschen  <corinna@vinschen.de>
 
        * sigproc.cc (pending_signals::clear): Yet another fix to fix the fix.
index babb064243887664bb938fd6bdc332232f85a978..cb97f682c6bc6bbf361ce0ced9a7fd1bb92d72de 100644 (file)
@@ -1,7 +1,7 @@
 /* fcntl.cc: fcntl syscall
 
    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2008, 2009,
-   2010, 2011, 2012, 2013, 2014 Red Hat, Inc.
+   2010, 2011, 2012, 2013, 2014, 2015 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -32,7 +32,9 @@ fcntl64 (int fd, int cmd, ...)
     {
 
       debug_printf ("fcntl(%d, %d, ...)", fd, cmd);
-      cygheap_fdget cfd (fd, true);
+
+      /* Don't lock the fd table when performing locking calls. */
+      cygheap_fdget cfd (fd, cmd < F_GETLK || cmd > F_SETLKW);
       if (cfd < 0)
        __leave;
 
index f26a76a741c157b5596191b7ee8606850bb49967..0ac55485bb2516a21031a4dcbcef5337ba76e50e 100644 (file)
@@ -1,6 +1,6 @@
 /* flock.cc.  NT specific implementation of advisory file locking.
 
-   Copyright 2003, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Red Hat, Inc.
+   Copyright 2003, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Red Hat, Inc.
 
    This file is part of Cygwin.
 
@@ -1773,7 +1773,7 @@ flock (int fd, int operation)
 
   __try
     {
-      cygheap_fdget cfd (fd, true);
+      cygheap_fdget cfd (fd);
       if (cfd < 0)
        __leave;
 
@@ -1817,7 +1817,7 @@ lockf (int filedes, int function, off_t size)
 
   __try
     {
-      cygheap_fdget cfd (filedes, true);
+      cygheap_fdget cfd (filedes);
       if (cfd < 0)
        __leave;
 
index 0ec7d8862171837dfe93b318a83c1b8b199d1758..737555510e5b04d6b8a09d16e6cfa4c7debdf173 100644 (file)
@@ -65,3 +65,6 @@ Bug Fixes
 
 - Workaround a bug in Windows 10 NLS handling.
   Addresses: https://cygwin.com/ml/cygwin/2015-10/msg00547.html
+
+- Avoid unnecessry locking and thus a potential deadlock in flock(2).
+  Addresses: https://cygwin.com/ml/cygwin/2015-11/msg00095.html
This page took 0.040711 seconds and 5 git commands to generate.