l4-hurd
[Top][All Lists]
Advanced

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

libhurd-cap-server/class-alloc.c


From: Neal H. Walfield
Subject: libhurd-cap-server/class-alloc.c
Date: Sun, 16 Jan 2005 12:46:10 -0500
User-agent: Wanderlust/2.10.1 (Watching The Wheels) SEMI/1.14.6 (Maruoka) FLIM/1.14.6 (Marutamachi) APEL/10.6 Emacs/21.3 (i386-pc-linux-gnu) MULE/5.0 (SAKAKI)

Hi,

hurd_cap_class_alloc manipulates the object slab
(i.e. CAP_CLASS->OBJ_SPACE) but does not lock the class.  Since the
locking interface is not exported, callers can't be expected to lock
the class.  Here is a patch to change hurd_cap_class_alloc to lock
CAP_CLASS.  Okay to check in?

Neal

libhurd-cap-server/

2005-01-16  Neal H. Walfield  <address@hidden>

        * class-alloc.c (hurd_cap_class_alloc): Lock CAP_CLASS.

Index: class-alloc.c
===================================================================
RCS file: /cvsroot/hurd/hurd-l4/libhurd-cap-server/class-alloc.c,v
retrieving revision 1.4
diff -u -r1.4 class-alloc.c
--- class-alloc.c       1 Nov 2004 20:54:00 -0000       1.4
+++ class-alloc.c       16 Jan 2005 17:37:04 -0000
@@ -1,5 +1,5 @@
 /* class-alloc.c - Allocate a capability object.
-   Copyright (C) 2004 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005 Free Software Foundation, Inc.
    Written by Marcus Brinkmann <address@hidden>
 
    This file is part of the GNU Hurd.
@@ -40,9 +40,11 @@
   void *new_obj;
   hurd_cap_obj_t obj;
 
+  pthread_mutex_lock (&cap_class->lock);
+
   err = hurd_slab_alloc (&cap_class->obj_space, &new_obj);
   if (err)
-    return err;
+    goto out;
   obj = new_obj;
 
   /* Let the user do their extra initialization.  */
@@ -52,7 +54,7 @@
       if (err)
        {
          hurd_slab_dealloc (&cap_class->obj_space, obj);
-         return err;
+         goto out;
        }
     }
 
@@ -60,5 +62,8 @@
   hurd_cap_obj_lock (obj);
 
   *r_obj = obj;
-  return 0;
+
+ out:
+  pthread_mutex_unlock (&cap_class->lock);
+  return err;
 }





reply via email to

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