bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

assertion in lock-acquire.c fixed


From: Marcus Brinkmann
Subject: assertion in lock-acquire.c fixed
Date: Wed, 26 Jun 2002 18:15:11 +0200
User-agent: Mutt/1.4i

Hi,

I got the following assertion failure:

ext2fs.static, libfshelp/lock-acquire.c, line 47, assertion *user == box->type
failed.

at boot time when I had several entries in /etc/ttys.

After some debugging, I found out that several threads raced for locks on
/var/run/utmp, and that the problem was that more than one acquired
exclusive locks at the same time.  Some more debugging revealed that this
occured when A had a shared lock, B was waiting to get an exclusive lock,
and when A released its locks, C got the exclusive lock before B.  But B
only waited for "box->type == LOCK_SH", so it would take the lock once
box-type was LOCK_EX (instead the LOCK_UN it expected).

I changed this to "box->type != LOCK_UN", which should fix this, but someone
might look over this routine to see if it really does the right thing in all
cases.  The below diff and changelog entry was committed.

Thanks,
Marcus

2002-06-26  Marcus Brinkmann  <marcus@gnu.org>

        * lock-acquire.c (fshelp_acquire_lock): Also wait for exclusive
        locks which might have been acquired while we were waiting for
        shared locks to finish.

Index: lock-acquire.c
===================================================================
RCS file: /cvsroot/hurd/hurd/libfshelp/lock-acquire.c,v
retrieving revision 1.5
diff -u -p -r1.5 lock-acquire.c
--- lock-acquire.c      14 Oct 1996 01:56:34 -0000      1.5
+++ lock-acquire.c      26 Jun 2002 16:09:11 -0000
@@ -111,8 +111,8 @@ fshelp_acquire_lock (struct lock_box *bo
        }
       else if (flags & LOCK_EX)
        {
-         /* Wait for any shared locks to finish. */
-         while (box->type == LOCK_SH)
+         /* Wait for any shared (and exclusive) locks to finish. */
+         while (box->type != LOCK_UN)
            {
              if (flags & LOCK_NB)
                return EWOULDBLOCK;


-- 
`Rhubarb is no Egyptian god.' Debian http://www.debian.org brinkmd@debian.org
Marcus Brinkmann              GNU    http://www.gnu.org    marcus@gnu.org
Marcus.Brinkmann@ruhr-uni-bochum.de
http://www.marcus-brinkmann.de



reply via email to

[Prev in Thread] Current Thread [Next in Thread]