]> git.proxmox.com Git - mirror_corosync.git/commitdiff
Add hdb_handle_refcount_get call.
authorRyan O'Hara <rohara@redhat.com>
Tue, 23 Jun 2009 22:28:31 +0000 (22:28 +0000)
committerRyan O'Hara <rohara@redhat.com>
Tue, 23 Jun 2009 22:28:31 +0000 (22:28 +0000)
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2287 fd59a12c-fef9-0310-b244-a6a79926bd2f

include/corosync/hdb.h

index 82c207f847510b27eaab18ceeb3c7d3bf3f53501..ff14535ac50f92bf04822c04b144daf984a07874 100644 (file)
@@ -324,6 +324,35 @@ static inline int hdb_handle_destroy (
        return (res);
 }
 
+static inline int hdb_handle_refcount_get (
+       struct hdb_handle_database *handle_database,
+       hdb_handle_t handle_in)
+{
+       unsigned int check = ((unsigned int)(((unsigned long long)handle_in) >> 32));
+       unsigned int handle = handle_in & 0xffffffff;
+
+       int refcount = 0;
+
+       if (handle >= handle_database->handle_count) {
+               hdb_database_unlock (&handle_database->lock);
+               errno = EBADF;
+               return (-1);
+       }
+
+       if (check != 0xffffffff &&
+               check != handle_database->handles[handle].check) {
+               hdb_database_unlock (&handle_database->lock);
+               errno = EBADF;
+               return (-1);
+       }
+
+       refcount = handle_database->handles[handle].ref_count;
+
+       hdb_database_unlock (&handle_database->lock);
+
+       return (refcount);
+}
+
 static inline void hdb_iterator_reset (
        struct hdb_handle_database *handle_database)
 {