r6335 - in glibc-package/trunk/debian: . patches/hurd-i386
Author: sthibault
Date: 2014-11-23 02:24:26 +0000 (Sun, 23 Nov 2014)
New Revision: 6335
Modified:
glibc-package/trunk/debian/changelog
glibc-package/trunk/debian/patches/hurd-i386/tg-WRLCK-upgrade.diff
Log:
hurd: Also fix atomicity of wr -> rd lock change
Modified: glibc-package/trunk/debian/changelog
===================================================================
--- glibc-package/trunk/debian/changelog 2014-11-23 00:27:17 UTC (rev 6334)
+++ glibc-package/trunk/debian/changelog 2014-11-23 02:24:26 UTC (rev 6335)
@@ -4,7 +4,7 @@
* patches/hurd-i386/libpthread_spin-lock.diff: New patch to fix spin-lock.h
inclusion order.
* patches/hurd-i386/tg-WRLCK-upgrade.diff: New patch to fix atomicity of
- upgrading rd locks into wr locks.
+ changing between rd locks and wr locks.
[ Adam Conrad ]
* debian/rules.d/tarball.mk: Fix update-from-upstream manual/* filter rule.
Modified: glibc-package/trunk/debian/patches/hurd-i386/tg-WRLCK-upgrade.diff
===================================================================
--- glibc-package/trunk/debian/patches/hurd-i386/tg-WRLCK-upgrade.diff 2014-11-23 00:27:17 UTC (rev 6334)
+++ glibc-package/trunk/debian/patches/hurd-i386/tg-WRLCK-upgrade.diff 2014-11-23 02:24:26 UTC (rev 6335)
@@ -1,28 +1,45 @@
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
-Subject: [PATCH] Make F_WRLCK potentially upgrade owned F_RDLCK
+Subject: [PATCH] Make F_RDLCK/F_WRLCK atomic
-lockf(LOCK_EX) would drop any existing shared lock before taking the exclusive
-lock. F_WRLCK needs an atomic upgrade, so use lockf(LOCK_SH|LOCK_EX) instead.
+lockf(LOCK_EX) would for instance drop any existing shared lock before taking
+the exclusive lock. F_RDLCK/F_WRLCK need atomic changes, so introduce and use
+__LOCK_ATOM
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
-* sysdeps/mach/hurd/fcntl.c (__libc_fcntl): For F_WRLCK, set cmd to
-LOCK_SH|LOCK_EX instead of LOCK_SH.
+* misc/sys/file.h (__LOCK_ATOMIC): New macro.
+* sysdeps/mach/hurd/fcntl.c (__libc_fcntl): Use __LOCK_ATOMIC along LOCK_SH and
+LOCK_EX.
---
- sysdeps/mach/hurd/fcntl.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
+ misc/sys/file.h | 1 +
+ sysdeps/mach/hurd/fcntl.c | 4 ++--
+ 2 files changed, 3 insertions(+), 2 deletions(-)
+diff --git a/misc/sys/file.h b/misc/sys/file.h
+index 64e8764..a5892db 100644
+--- a/misc/sys/file.h
++++ b/misc/sys/file.h
+@@ -40,6 +40,7 @@ __BEGIN_DECLS
+ #define LOCK_SH 1 /* Shared lock. */
+ #define LOCK_EX 2 /* Exclusive lock. */
+ #define LOCK_UN 8 /* Unlock. */
++#define __LOCK_ATOMIC 16 /* Atomic update. */
+
+ /* Can be OR'd in to one of the above. */
+ #define LOCK_NB 4 /* Don't block when locking. */
diff --git a/sysdeps/mach/hurd/fcntl.c b/sysdeps/mach/hurd/fcntl.c
-index 70180fa..b827fec 100644
+index 70180fa..8a8308f 100644
--- a/sysdeps/mach/hurd/fcntl.c
+++ b/sysdeps/mach/hurd/fcntl.c
-@@ -151,7 +151,7 @@ __libc_fcntl (int fd, int cmd, ...)
+@@ -150,8 +150,8 @@ __libc_fcntl (int fd, int cmd, ...)
+ }
switch (fl->l_type)
{
- case F_RDLCK: cmd |= LOCK_SH; break;
+- case F_RDLCK: cmd |= LOCK_SH; break;
- case F_WRLCK: cmd |= LOCK_EX; break;
-+ case F_WRLCK: cmd |= LOCK_SH | LOCK_EX; break;
++ case F_RDLCK: cmd |= LOCK_SH | __LOCK_ATOMIC; break;
++ case F_WRLCK: cmd |= LOCK_EX | __LOCK_ATOMIC; break;
case F_UNLCK: cmd |= LOCK_UN; break;
default:
errno = EINVAL;
Reply to: