[Openais] [PATCH]: corosync/trunk: Add hdb_handle_refcount_get call

Ryan O'Hara rohara at redhat.com
Tue Jun 23 14:06:46 PDT 2009


Here is a patch that adds a call to hdb.h that will give the refcount
for a specific handle in a given handle database. This is very useful
for debugging code that make use of the hdb interface (ie. openais
services).

Ryan

-------------- next part --------------
Index: include/corosync/hdb.h
===================================================================
--- include/corosync/hdb.h	(revision 2285)
+++ include/corosync/hdb.h	(working copy)
@@ -324,6 +324,35 @@
 	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)
 {


More information about the Openais mailing list