Просмотр исходного кода

Remove saHandleXXX and friends and use hdb instead.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2125 fd59a12c-fef9-0310-b244-a6a79926bd2f
Steven Dake 17 лет назад
Родитель
Сommit
1beb0c1fbd

+ 1 - 1
exec/coropoll.c

@@ -63,7 +63,7 @@ struct poll_instance {
 	int stop_requested;
 };
 
-DECLARE_HDB_DATABASE (poll_instance_database);
+DECLARE_HDB_DATABASE (poll_instance_database,NULL);
 
 hdb_handle_t poll_create (void)
 {

+ 2 - 2
exec/objdb.c

@@ -100,9 +100,9 @@ static pthread_rwlock_t reload_lock;
 static pthread_t lock_thread;
 static pthread_mutex_t meta_lock;
 
-DECLARE_HDB_DATABASE (object_instance_database);
+DECLARE_HDB_DATABASE (object_instance_database,NULL);
 
-DECLARE_HDB_DATABASE (object_find_instance_database);
+DECLARE_HDB_DATABASE (object_find_instance_database,NULL);
 
 static void objdb_wrlock(void)
 {

+ 1 - 1
exec/schedwrk.c

@@ -39,7 +39,7 @@
 static void (*serialize_lock) (void);
 static void (*serialize_unlock) (void);
 
-DECLARE_HDB_DATABASE (schedwrk_instance_database);
+DECLARE_HDB_DATABASE (schedwrk_instance_database,NULL);
 
 struct schedwrk_instance {
 	int (*schedwrk_fn) (const void *);

+ 1 - 1
exec/totemnet.c

@@ -206,7 +206,7 @@ static int totemnet_build_sockets (
 
 static struct totem_ip_address localhost;
 
-DECLARE_HDB_DATABASE (totemnet_instance_database);
+DECLARE_HDB_DATABASE (totemnet_instance_database,NULL);
 
 static void totemnet_instance_initialize (struct totemnet_instance *instance)
 {

+ 1 - 1
exec/totempg.c

@@ -226,7 +226,7 @@ struct totempg_group_instance {
 	int groups_cnt;
 };
 
-DECLARE_HDB_DATABASE (totempg_groups_instance_database);
+DECLARE_HDB_DATABASE (totempg_groups_instance_database,NULL);
 
 static unsigned char next_fragment = 1;
 

+ 1 - 1
exec/totemrrp.c

@@ -467,7 +467,7 @@ struct rrp_algo *rrp_algos[] = {
 /*
  * All instances in one database
  */
-DECLARE_HDB_DATABASE (totemrrp_instance_database);
+DECLARE_HDB_DATABASE (totemrrp_instance_database,NULL);
 
 #define log_printf(level, format, args...)				\
 do {									\

+ 1 - 1
exec/totemsrp.c

@@ -612,7 +612,7 @@ void main_iface_change_fn (
 /*
  * All instances in one database
  */
-DECLARE_HDB_DATABASE (totemsrp_instance_database);
+DECLARE_HDB_DATABASE (totemsrp_instance_database,NULL);
 
 struct message_handlers totemsrp_message_handlers = {
 	6,

+ 21 - 4
include/corosync/hdb.h

@@ -36,9 +36,10 @@
 #ifndef HDB_H_DEFINED
 #define HDB_H_DEFINED
 
+#include <errno.h>
+#include <assert.h>
 #include <stdlib.h>
 #include <string.h>
-#include <assert.h>
 #include <pthread.h>
 
 typedef unsigned long long hdb_handle_t;
@@ -60,6 +61,7 @@ struct hdb_handle_database {
 	unsigned int handle_count;
 	struct hdb_handle *handles;
 	unsigned int iterator;
+        void (*destructor) (void *);
 #if defined(HAVE_PTHREAD_SPIN_LOCK)
 	pthread_spinlock_t lock;
 #else
@@ -109,12 +111,17 @@ static inline void hdb_database_lock_destroy (pthread_mutex_t *mutex)
 }
 #endif
 
-#define DECLARE_HDB_DATABASE(database_name)				\
-static struct hdb_handle_database (database_name); 			\
+#define DECLARE_HDB_DATABASE(database_name,destructor_function)		\
+static struct hdb_handle_database (database_name) = {			\
+	.handle_count	= 0,						\
+	.handles 	= NULL,						\
+	.iterator	= 0,						\
+	.destructor	= destructor_function,				\
+	.first_run	= 0						\
+};									\
 static void database_name##_init(void)__attribute__((constructor));	\
 static void database_name##_init(void)					\
 {                                                                       \
-	memset (&(database_name), 0, sizeof (struct hdb_handle_database));\
 	hdb_database_lock_init (&(database_name).lock);		\
 }
 
@@ -176,6 +183,7 @@ static inline int hdb_handle_create (
 			sizeof (struct hdb_handle) * handle_database->handle_count);
 		if (new_handles == NULL) {
 			hdb_database_unlock (&handle_database->lock);
+			errno = ENOMEM;
 			return (-1);
 		}
 		handle_database->handles = new_handles;
@@ -183,6 +191,7 @@ static inline int hdb_handle_create (
 
 	instance = (void *)malloc (instance_size);
 	if (instance == 0) {
+		errno = ENOMEM;
 		return (-1);
 	}
 
@@ -230,17 +239,20 @@ static inline int hdb_handle_get (
 		check != handle_database->handles[handle].check) {
 
 		hdb_database_unlock (&handle_database->lock);
+		errno = EBADF;
 		return (-1);
 	}
 
 	*instance = NULL;
 	if (handle >= handle_database->handle_count) {
 		hdb_database_unlock (&handle_database->lock);
+		errno = EBADF;
 		return (-1);
 	}
 
 	if (handle_database->handles[handle].state != HDB_HANDLE_STATE_ACTIVE) {
 		hdb_database_unlock (&handle_database->lock);
+		errno = EBADF;
 		return (-1);
 	}
 
@@ -265,6 +277,7 @@ static inline int hdb_handle_put (
 		check != handle_database->handles[handle].check) {
 
 		hdb_database_unlock (&handle_database->lock);
+		errno = EBADF;
 		return (-1);
 	}
 
@@ -272,6 +285,9 @@ static inline int hdb_handle_put (
 	assert (handle_database->handles[handle].ref_count >= 0);
 
 	if (handle_database->handles[handle].ref_count == 0) {
+		if (handle_database->destructor) {
+			handle_database->destructor (handle_database->handles[handle].instance);
+		}
 		free (handle_database->handles[handle].instance);
 		memset (&handle_database->handles[handle], 0, sizeof (struct hdb_handle));
 	}
@@ -292,6 +308,7 @@ static inline int hdb_handle_destroy (
 	if (check != 0xffffffff &&
 		check != handle_database->handles[handle].check) {
 		hdb_database_unlock (&handle_database->lock);
+		errno = EBADF;
 		return (-1);
 	}
 

+ 44 - 41
lib/cfg.c

@@ -57,9 +57,12 @@
 #include <corosync/cfg.h>
 #include <corosync/mar_gen.h>
 #include <corosync/ipc_cfg.h>
+#include <corosync/hdb.h>
 
 #include <corosync/totem/totemip.h>
 
+#include "util.h"
+
 /*
  * Data structure for instance data
  */
@@ -78,7 +81,7 @@ static void cfg_handle_instance_destructor (void *);
 /*
  * All instances in one database
  */
-DECLARE_SAHDB_DATABASE (cfg_hdb,cfg_handle_instance_destructor);
+DECLARE_HDB_DATABASE (cfg_hdb,cfg_handle_instance_destructor);
 
 /*
  * Implementation
@@ -99,12 +102,12 @@ corosync_cfg_initialize (
 	struct cfg_instance *cfg_instance;
 	cs_error_t error = CS_OK;
 
-	error = saHandleCreate (&cfg_hdb, sizeof (struct cfg_instance), cfg_handle);
+	error = hdb_error_to_cs (hdb_handle_create (&cfg_hdb, sizeof (struct cfg_instance), cfg_handle));
 	if (error != CS_OK) {
 		goto error_no_destroy;
 	}
 
-	error = saHandleInstanceGet (&cfg_hdb, *cfg_handle, (void *)&cfg_instance);
+	error = hdb_error_to_cs (hdb_handle_get (&cfg_hdb, *cfg_handle, (void *)&cfg_instance));
 	if (error != CS_OK) {
 		goto error_destroy;
 	}
@@ -128,14 +131,14 @@ corosync_cfg_initialize (
 
 	pthread_mutex_init (&cfg_instance->dispatch_mutex, NULL);
 
-	(void)saHandleInstancePut (&cfg_hdb, *cfg_handle);
+	(void)hdb_handle_put (&cfg_hdb, *cfg_handle);
 
 	return (CS_OK);
 
 error_put_destroy:
-	(void)saHandleInstancePut (&cfg_hdb, *cfg_handle);
+	(void)hdb_handle_put (&cfg_hdb, *cfg_handle);
 error_destroy:
-	(void)saHandleDestroy (&cfg_hdb, *cfg_handle);
+	(void)hdb_handle_destroy (&cfg_hdb, *cfg_handle);
 error_no_destroy:
 	return (error);
 }
@@ -148,14 +151,14 @@ corosync_cfg_fd_get (
 	struct cfg_instance *cfg_instance;
 	cs_error_t error;
 
-	error = saHandleInstanceGet (&cfg_hdb, cfg_handle, (void *)&cfg_instance);
+	error = hdb_error_to_cs (hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_instance));
 	if (error != CS_OK) {
 		return (error);
 	}
 
 	*selection_fd = coroipcc_fd_get (cfg_instance->ipc_ctx);
 
-	(void)saHandleInstancePut (&cfg_hdb, cfg_handle);
+	(void)hdb_handle_put (&cfg_hdb, cfg_handle);
 	return (CS_OK);
 }
 
@@ -173,8 +176,8 @@ corosync_cfg_dispatch (
 	corosync_cfg_callbacks_t callbacks;
 	coroipc_response_header_t *dispatch_data;
 
-	error = saHandleInstanceGet (&cfg_hdb, cfg_handle,
-		(void *)&cfg_instance);
+	error = hdb_error_to_cs (hdb_handle_get (&cfg_hdb, cfg_handle,
+		(void *)&cfg_instance));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -253,7 +256,7 @@ corosync_cfg_dispatch (
 	} while (cont);
 
 error_put:
-	(void)saHandleInstancePut (&cfg_hdb, cfg_handle);
+	(void)hdb_handle_put (&cfg_hdb, cfg_handle);
 error_nounlock:
 	return (error);
 }
@@ -265,7 +268,7 @@ corosync_cfg_finalize (
 	struct cfg_instance *cfg_instance;
 	cs_error_t error;
 
-	error = saHandleInstanceGet (&cfg_hdb, cfg_handle, (void *)&cfg_instance);
+	error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_instance));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -280,7 +283,7 @@ corosync_cfg_finalize (
 	if (cfg_instance->finalize) {
 		pthread_mutex_unlock (&cfg_instance->response_mutex);
 		pthread_mutex_unlock (&cfg_instance->dispatch_mutex);
-		(void)saHandleInstancePut (&cfg_hdb, cfg_handle);
+		(void)hdb_handle_put (&cfg_hdb, cfg_handle);
 		return (CS_ERR_BAD_HANDLE);
 	}
 
@@ -296,9 +299,9 @@ corosync_cfg_finalize (
 
 	pthread_mutex_destroy (&cfg_instance->dispatch_mutex);
 
-	(void)saHandleDestroy (&cfg_hdb, cfg_handle);
+	(void)hdb_handle_destroy (&cfg_hdb, cfg_handle);
 
-	(void)saHandleInstancePut (&cfg_hdb, cfg_handle);
+	(void)hdb_handle_put (&cfg_hdb, cfg_handle);
 
 	return (error);
 }
@@ -317,7 +320,7 @@ corosync_cfg_ring_status_get (
 	cs_error_t error;
 	struct iovec iov;
 
-	error = saHandleInstanceGet (&cfg_hdb, cfg_handle, (void *)&cfg_instance);
+	error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_instance));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -382,7 +385,7 @@ error_free_interface_names:
 	free (*interface_names);
 
 no_error:
-	(void)saHandleInstancePut (&cfg_hdb, cfg_handle);
+	(void)hdb_handle_put (&cfg_hdb, cfg_handle);
 
 	return (error);
 }
@@ -397,7 +400,7 @@ corosync_cfg_ring_reenable (
 	cs_error_t error;
 	struct iovec iov;
 
-	error = saHandleInstanceGet (&cfg_hdb, cfg_handle, (void *)&cfg_instance);
+	error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_instance));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -417,7 +420,7 @@ corosync_cfg_ring_reenable (
 		sizeof (struct res_lib_cfg_ringreenable));
 
 	pthread_mutex_unlock (&cfg_instance->response_mutex);
-	(void)saHandleInstancePut (&cfg_hdb, cfg_handle);
+	(void)hdb_handle_put (&cfg_hdb, cfg_handle);
 
 	return (error);
 }
@@ -434,7 +437,7 @@ corosync_cfg_service_load (
 	cs_error_t error;
 	struct iovec iov;
 
-	error = saHandleInstanceGet (&cfg_hdb, cfg_handle, (void *)&cfg_instance);
+	error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_instance));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -459,7 +462,7 @@ corosync_cfg_service_load (
 		sizeof (struct res_lib_cfg_serviceload));
 
 	pthread_mutex_unlock (&cfg_instance->response_mutex);
-	(void)saHandleInstancePut (&cfg_hdb, cfg_handle);
+	(void)hdb_handle_put (&cfg_hdb, cfg_handle);
 
 	return (error);
 }
@@ -476,7 +479,7 @@ corosync_cfg_service_unload (
 	cs_error_t error;
 	struct iovec iov;
 
-	error = saHandleInstanceGet (&cfg_hdb, cfg_handle, (void *)&cfg_instance);
+	error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_instance));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -501,7 +504,7 @@ corosync_cfg_service_unload (
 		sizeof (struct res_lib_cfg_serviceunload));
 
 	pthread_mutex_unlock (&cfg_instance->response_mutex);
-	(void)saHandleInstancePut (&cfg_hdb, cfg_handle);
+	(void)hdb_handle_put (&cfg_hdb, cfg_handle);
 
 	return (error);
 }
@@ -522,8 +525,8 @@ corosync_cfg_state_track (
 	req_lib_cfg_statetrack.track_flags = track_flags;
 	req_lib_cfg_statetrack.notification_buffer_address = (corosync_cfg_state_notification_t *)notification_buffer;
 
-	error = saHandleInstanceGet (&cfg_hdb, cfg_handle,
-		(void *)&cfg_instance);
+	error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle,
+		(void *)&cfg_instance));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -541,7 +544,7 @@ corosync_cfg_state_track (
 
 	pthread_mutex_unlock (&cfg_instance->response_mutex);
 
-	(void)saHandleInstancePut (&cfg_hdb, cfg_handle);
+	(void)hdb_handle_put (&cfg_hdb, cfg_handle);
 
         return (error == CS_OK ? res_lib_cfg_statetrack.header.error : error);
 }
@@ -556,8 +559,8 @@ corosync_cfg_state_track_stop (
 	cs_error_t error;
 	struct iovec iov;
 
-	error = saHandleInstanceGet (&cfg_hdb, cfg_handle,
-		(void *)&cfg_instance);
+	error = hdb_error_to_cs (hdb_handle_get (&cfg_hdb, cfg_handle,
+		(void *)&cfg_instance));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -577,7 +580,7 @@ corosync_cfg_state_track_stop (
 
 	pthread_mutex_unlock (&cfg_instance->response_mutex);
 
-	(void)saHandleInstancePut (&cfg_hdb, cfg_handle);
+	(void)hdb_handle_put (&cfg_hdb, cfg_handle);
 
         return (error == CS_OK ? res_lib_cfg_statetrackstop.header.error : error);
 }
@@ -597,8 +600,8 @@ corosync_cfg_kill_node (
 	if (strlen(reason) >= CS_MAX_NAME_LENGTH)
 		return CS_ERR_NAME_TOO_LONG;
 
-	error = saHandleInstanceGet (&cfg_hdb, cfg_handle,
-		(void *)&cfg_instance);
+	error = hdb_error_to_cs (hdb_handle_get (&cfg_hdb, cfg_handle,
+		(void *)&cfg_instance));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -624,7 +627,7 @@ corosync_cfg_kill_node (
 
 	pthread_mutex_unlock (&cfg_instance->response_mutex);
 
-	(void)saHandleInstancePut (&cfg_hdb, cfg_handle);
+	(void)hdb_handle_put (&cfg_hdb, cfg_handle);
 
         return (error == CS_OK ? res_lib_cfg_killnode.header.error : error);
 }
@@ -640,8 +643,8 @@ corosync_cfg_try_shutdown (
 	cs_error_t error;
 	struct iovec iov;
 
-	error = saHandleInstanceGet (&cfg_hdb, cfg_handle,
-		(void *)&cfg_instance);
+	error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle,
+		(void *)&cfg_instance));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -663,7 +666,7 @@ corosync_cfg_try_shutdown (
 
 	pthread_mutex_unlock (&cfg_instance->response_mutex);
 
-	(void)saHandleInstancePut (&cfg_hdb, cfg_handle);
+	(void)hdb_handle_put (&cfg_hdb, cfg_handle);
 
         return (error == CS_OK ? res_lib_cfg_tryshutdown.header.error : error);
 }
@@ -679,8 +682,8 @@ corosync_cfg_replyto_shutdown (
 	struct iovec iov;
 	cs_error_t error;
 
-	error = saHandleInstanceGet (&cfg_hdb, cfg_handle,
-		(void *)&cfg_instance);
+	error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle,
+		(void *)&cfg_instance));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -721,8 +724,8 @@ cs_error_t corosync_cfg_get_node_addrs (
 	struct iovec iov;
 	void *return_address;
 
-	error = saHandleInstanceGet (&cfg_hdb, cfg_handle,
-		(void *)&cfg_instance);
+	error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle,
+		(void *)&cfg_instance));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -788,7 +791,7 @@ cs_error_t corosync_cfg_local_get (
 	struct req_lib_cfg_local_get req_lib_cfg_local_get;
 	struct res_lib_cfg_local_get res_lib_cfg_local_get;
 
-	error = saHandleInstanceGet (&cfg_hdb, handle, (void *)&cfg_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, handle, (void *)&cfg_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -819,7 +822,7 @@ cs_error_t corosync_cfg_local_get (
 	*local_nodeid = res_lib_cfg_local_get.local_nodeid;
 
 error_exit:
-	(void)saHandleInstancePut (&cfg_hdb, handle);
+	(void)hdb_handle_put (&cfg_hdb, handle);
 
 	return (error);
 }

+ 62 - 60
lib/confdb.c

@@ -55,6 +55,8 @@
 #include <corosync/ipc_confdb.h>
 #include <corosync/list.h>
 
+#include "util.h"
+
 #include "sa-confdb.h"
 
 #undef MIN
@@ -86,7 +88,7 @@ struct confdb_inst {
 
 static void confdb_instance_destructor (void *instance);
 
-DECLARE_SAHDB_DATABASE(confdb_handle_t_db,confdb_instance_destructor);
+DECLARE_HDB_DATABASE(confdb_handle_t_db,confdb_instance_destructor);
 
 static cs_error_t do_find_destroy(struct confdb_inst *confdb_inst, hdb_handle_t find_handle);
 
@@ -146,12 +148,12 @@ cs_error_t confdb_initialize (
 	cs_error_t error;
 	struct confdb_inst *confdb_inst;
 
-	error = saHandleCreate (&confdb_handle_t_db, sizeof (struct confdb_inst), handle);
+	error = hdb_error_to_cs(hdb_handle_create (&confdb_handle_t_db, sizeof (struct confdb_inst), handle));
 	if (error != CS_OK) {
 		goto error_no_destroy;
 	}
 
-	error = saHandleInstanceGet (&confdb_handle_t_db, *handle, (void *)&confdb_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, *handle, (void *)&confdb_inst));
 	if (error != CS_OK) {
 		goto error_destroy;
 	}
@@ -181,14 +183,14 @@ cs_error_t confdb_initialize (
 	list_init (&confdb_inst->object_iter_head);
 	list_init (&confdb_inst->key_iter_head);
 
-	(void)saHandleInstancePut (&confdb_handle_t_db, *handle);
+	(void)hdb_handle_put (&confdb_handle_t_db, *handle);
 
 	return (CS_OK);
 
 error_put_destroy:
-	(void)saHandleInstancePut (&confdb_handle_t_db, *handle);
+	(void)hdb_handle_put (&confdb_handle_t_db, *handle);
 error_destroy:
-	(void)saHandleDestroy (&confdb_handle_t_db, *handle);
+	(void)hdb_handle_destroy (&confdb_handle_t_db, *handle);
 error_no_destroy:
 	return (error);
 }
@@ -199,7 +201,7 @@ cs_error_t confdb_finalize (
 	struct confdb_inst *confdb_inst;
 	cs_error_t error;
 
-	error = saHandleInstanceGet (&confdb_handle_t_db, handle, (void *)&confdb_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -211,7 +213,7 @@ cs_error_t confdb_finalize (
 	 */
 	if (confdb_inst->finalize) {
 		pthread_mutex_unlock (&confdb_inst->response_mutex);
-		(void)saHandleInstancePut (&confdb_handle_t_db, handle);
+		(void)hdb_handle_put (&confdb_handle_t_db, handle);
 		return (CS_ERR_BAD_HANDLE);
 	}
 
@@ -228,9 +230,9 @@ cs_error_t confdb_finalize (
 		coroipcc_service_disconnect (confdb_inst->ipc_ctx);
 	}
 
-	(void)saHandleDestroy (&confdb_handle_t_db, handle);
+	(void)hdb_handle_destroy (&confdb_handle_t_db, handle);
 
-	(void)saHandleInstancePut (&confdb_handle_t_db, handle);
+	(void)hdb_handle_put (&confdb_handle_t_db, handle);
 
 	return (CS_OK);
 }
@@ -242,14 +244,14 @@ cs_error_t confdb_fd_get (
 	cs_error_t error;
 	struct confdb_inst *confdb_inst;
 
-	error = saHandleInstanceGet (&confdb_handle_t_db, handle, (void *)&confdb_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
 
 	*fd = coroipcc_fd_get (confdb_inst->ipc_ctx);
 
-	(void)saHandleInstancePut (&confdb_handle_t_db, handle);
+	(void)hdb_handle_put (&confdb_handle_t_db, handle);
 
 	return (CS_OK);
 }
@@ -261,14 +263,14 @@ cs_error_t confdb_context_get (
 	cs_error_t error;
 	struct confdb_inst *confdb_inst;
 
-	error = saHandleInstanceGet (&confdb_handle_t_db, handle, (void *)&confdb_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
 
 	*context = confdb_inst->context;
 
-	(void)saHandleInstancePut (&confdb_handle_t_db, handle);
+	(void)hdb_handle_put (&confdb_handle_t_db, handle);
 
 	return (CS_OK);
 }
@@ -280,14 +282,14 @@ cs_error_t confdb_context_set (
 	cs_error_t error;
 	struct confdb_inst *confdb_inst;
 
-	error = saHandleInstanceGet (&confdb_handle_t_db, handle, (void *)&confdb_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
 
 	confdb_inst->context = context;
 
-	(void)saHandleInstancePut (&confdb_handle_t_db, handle);
+	(void)hdb_handle_put (&confdb_handle_t_db, handle);
 
 	return (CS_OK);
 }
@@ -307,7 +309,7 @@ cs_error_t confdb_dispatch (
 	struct res_lib_confdb_object_destroy_callback *res_object_destroyed_pt;
 	coroipc_response_header_t *dispatch_data;
 
-	error = saHandleInstanceGet (&confdb_handle_t_db, handle, (void *)&confdb_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -421,7 +423,7 @@ cs_error_t confdb_dispatch (
 	} while (cont);
 
 error_put:
-	(void)saHandleInstancePut (&confdb_handle_t_db, handle);
+	(void)hdb_handle_put (&confdb_handle_t_db, handle);
 error_noput:
 	return (error);
 }
@@ -439,7 +441,7 @@ cs_error_t confdb_object_create (
 	struct req_lib_confdb_object_create req_lib_confdb_object_create;
 	struct res_lib_confdb_object_create res_lib_confdb_object_create;
 
-	error = saHandleInstanceGet (&confdb_handle_t_db, handle, (void *)&confdb_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -481,7 +483,7 @@ cs_error_t confdb_object_create (
 	*object_handle = res_lib_confdb_object_create.object_handle;
 
 error_exit:
-	(void)saHandleInstancePut (&confdb_handle_t_db, handle);
+	(void)hdb_handle_put (&confdb_handle_t_db, handle);
 
 	return (error);
 }
@@ -496,7 +498,7 @@ cs_error_t confdb_object_destroy (
 	struct req_lib_confdb_object_destroy req_lib_confdb_object_destroy;
 	coroipc_response_header_t res;
 
-	error = saHandleInstanceGet (&confdb_handle_t_db, handle, (void *)&confdb_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -533,7 +535,7 @@ cs_error_t confdb_object_destroy (
 	error = res.error;
 
 error_exit:
-	(void)saHandleInstancePut (&confdb_handle_t_db, handle);
+	(void)hdb_handle_put (&confdb_handle_t_db, handle);
 
 	return (error);
 }
@@ -549,7 +551,7 @@ cs_error_t confdb_object_parent_get (
 	struct req_lib_confdb_object_parent_get req_lib_confdb_object_parent_get;
 	struct res_lib_confdb_object_parent_get res_lib_confdb_object_parent_get;
 
-	error = saHandleInstanceGet (&confdb_handle_t_db, handle, (void *)&confdb_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -587,7 +589,7 @@ cs_error_t confdb_object_parent_get (
 	*parent_object_handle = res_lib_confdb_object_parent_get.parent_object_handle;
 
 error_exit:
-	(void)saHandleInstancePut (&confdb_handle_t_db, handle);
+	(void)hdb_handle_put (&confdb_handle_t_db, handle);
 
 	return (error);
 }
@@ -648,7 +650,7 @@ cs_error_t confdb_object_find_destroy(
 	cs_error_t error;
 	struct confdb_inst *confdb_inst;
 
-	error = saHandleInstanceGet (&confdb_handle_t_db, handle, (void *)&confdb_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -660,7 +662,7 @@ cs_error_t confdb_object_find_destroy(
 		free(context);
 	}
 
-	(void)saHandleInstancePut (&confdb_handle_t_db, handle);
+	(void)hdb_handle_put (&confdb_handle_t_db, handle);
 	return error;
 }
 
@@ -672,7 +674,7 @@ cs_error_t confdb_object_iter_destroy(
 	cs_error_t error;
 	struct confdb_inst *confdb_inst;
 
-	error = saHandleInstanceGet (&confdb_handle_t_db, handle, (void *)&confdb_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -684,7 +686,7 @@ cs_error_t confdb_object_iter_destroy(
 		free(context);
 	}
 
-	(void)saHandleInstancePut (&confdb_handle_t_db, handle);
+	(void)hdb_handle_put (&confdb_handle_t_db, handle);
 	return error;
 }
 
@@ -703,7 +705,7 @@ cs_error_t confdb_key_create (
 	struct req_lib_confdb_key_create req_lib_confdb_key_create;
 	coroipc_response_header_t res;
 
-	error = saHandleInstanceGet (&confdb_handle_t_db, handle, (void *)&confdb_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -746,7 +748,7 @@ cs_error_t confdb_key_create (
 	error = res.error;
 
 error_exit:
-	(void)saHandleInstancePut (&confdb_handle_t_db, handle);
+	(void)hdb_handle_put (&confdb_handle_t_db, handle);
 
 	return (error);
 }
@@ -765,7 +767,7 @@ cs_error_t confdb_key_delete (
 	struct req_lib_confdb_key_delete req_lib_confdb_key_delete;
 	coroipc_response_header_t res;
 
-	error = saHandleInstanceGet (&confdb_handle_t_db, handle, (void *)&confdb_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -808,7 +810,7 @@ cs_error_t confdb_key_delete (
 	error = res.error;
 
 error_exit:
-	(void)saHandleInstancePut (&confdb_handle_t_db, handle);
+	(void)hdb_handle_put (&confdb_handle_t_db, handle);
 
 	return (error);
 }
@@ -827,7 +829,7 @@ cs_error_t confdb_key_get (
 	struct req_lib_confdb_key_get req_lib_confdb_key_get;
 	struct res_lib_confdb_key_get res_lib_confdb_key_get;
 
-	error = saHandleInstanceGet (&confdb_handle_t_db, handle, (void *)&confdb_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -872,7 +874,7 @@ cs_error_t confdb_key_get (
 	}
 
 error_exit:
-	(void)saHandleInstancePut (&confdb_handle_t_db, handle);
+	(void)hdb_handle_put (&confdb_handle_t_db, handle);
 
 	return (error);
 }
@@ -890,7 +892,7 @@ cs_error_t confdb_key_increment (
 	struct req_lib_confdb_key_get req_lib_confdb_key_get;
 	struct res_lib_confdb_key_incdec res_lib_confdb_key_incdec;
 
-	error = saHandleInstanceGet (&confdb_handle_t_db, handle, (void *)&confdb_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -934,7 +936,7 @@ cs_error_t confdb_key_increment (
 	}
 
 error_exit:
-	(void)saHandleInstancePut (&confdb_handle_t_db, handle);
+	(void)hdb_handle_put (&confdb_handle_t_db, handle);
 
 	return (error);
 }
@@ -952,7 +954,7 @@ cs_error_t confdb_key_decrement (
 	struct req_lib_confdb_key_get req_lib_confdb_key_get;
 	struct res_lib_confdb_key_incdec res_lib_confdb_key_incdec;
 
-	error = saHandleInstanceGet (&confdb_handle_t_db, handle, (void *)&confdb_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -996,7 +998,7 @@ cs_error_t confdb_key_decrement (
 	}
 
 error_exit:
-	(void)saHandleInstancePut (&confdb_handle_t_db, handle);
+	(void)hdb_handle_put (&confdb_handle_t_db, handle);
 
 	return (error);
 }
@@ -1017,7 +1019,7 @@ cs_error_t confdb_key_replace (
 	struct req_lib_confdb_key_replace req_lib_confdb_key_replace;
 	coroipc_response_header_t res;
 
-	error = saHandleInstanceGet (&confdb_handle_t_db, handle, (void *)&confdb_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -1062,7 +1064,7 @@ cs_error_t confdb_key_replace (
 	error = res.error;
 
 error_exit:
-	(void)saHandleInstancePut (&confdb_handle_t_db, handle);
+	(void)hdb_handle_put (&confdb_handle_t_db, handle);
 
 	return (error);
 }
@@ -1075,7 +1077,7 @@ cs_error_t confdb_object_iter_start (
 	cs_error_t error = CS_OK;
 	struct iter_context *context;
 
-	error = saHandleInstanceGet (&confdb_handle_t_db, handle, (void *)&confdb_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -1098,7 +1100,7 @@ cs_error_t confdb_object_iter_start (
 		context->find_handle = 0;
 	}
 
-	(void)saHandleInstancePut (&confdb_handle_t_db, handle);
+	(void)hdb_handle_put (&confdb_handle_t_db, handle);
 
 ret:
 	return error;
@@ -1112,7 +1114,7 @@ cs_error_t confdb_key_iter_start (
 	cs_error_t error = CS_OK;
 	struct iter_context *context;
 
-	error = saHandleInstanceGet (&confdb_handle_t_db, handle, (void *)&confdb_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -1131,7 +1133,7 @@ cs_error_t confdb_key_iter_start (
 	context->find_handle = 0;
 	context->next_entry = 0;
 
-	(void)saHandleInstancePut (&confdb_handle_t_db, handle);
+	(void)hdb_handle_put (&confdb_handle_t_db, handle);
 
 ret:
 	return error;
@@ -1145,7 +1147,7 @@ cs_error_t confdb_object_find_start (
 	cs_error_t error = CS_OK;
 	struct iter_context *context;
 
-	error = saHandleInstanceGet (&confdb_handle_t_db, handle, (void *)&confdb_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -1167,7 +1169,7 @@ cs_error_t confdb_object_find_start (
 		context->find_handle = 0;
 	}
 
-	(void)saHandleInstancePut (&confdb_handle_t_db, handle);
+	(void)hdb_handle_put (&confdb_handle_t_db, handle);
 
 ret:
 	return error;
@@ -1187,7 +1189,7 @@ cs_error_t confdb_object_find (
 	struct req_lib_confdb_object_find req_lib_confdb_object_find;
 	struct res_lib_confdb_object_find res_lib_confdb_object_find;
 
-	error = saHandleInstanceGet (&confdb_handle_t_db, handle, (void *)&confdb_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -1239,7 +1241,7 @@ cs_error_t confdb_object_find (
 	context->find_handle = res_lib_confdb_object_find.find_handle;
 
 error_exit:
-	(void)saHandleInstancePut (&confdb_handle_t_db, handle);
+	(void)hdb_handle_put (&confdb_handle_t_db, handle);
 
 	return (error);
 }
@@ -1259,7 +1261,7 @@ cs_error_t confdb_object_iter (
 	struct req_lib_confdb_object_iter req_lib_confdb_object_iter;
 	struct res_lib_confdb_object_iter res_lib_confdb_object_iter;
 
-	error = saHandleInstanceGet (&confdb_handle_t_db, handle, (void *)&confdb_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -1316,7 +1318,7 @@ cs_error_t confdb_object_iter (
 sa_exit:
 
 error_exit:
-	(void)saHandleInstancePut (&confdb_handle_t_db, handle);
+	(void)hdb_handle_put (&confdb_handle_t_db, handle);
 
 	return (error);
 }
@@ -1336,7 +1338,7 @@ cs_error_t confdb_key_iter (
 	struct req_lib_confdb_key_iter req_lib_confdb_key_iter;
 	struct res_lib_confdb_key_iter res_lib_confdb_key_iter;
 
-	error = saHandleInstanceGet (&confdb_handle_t_db, handle, (void *)&confdb_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -1393,7 +1395,7 @@ sa_exit:
 	context->next_entry++;
 
 error_exit:
-	(void)saHandleInstancePut (&confdb_handle_t_db, handle);
+	(void)hdb_handle_put (&confdb_handle_t_db, handle);
 
 	return (error);
 }
@@ -1409,7 +1411,7 @@ cs_error_t confdb_write (
 	coroipc_request_header_t req;
 	struct res_lib_confdb_write res_lib_confdb_write;
 
-	error = saHandleInstanceGet (&confdb_handle_t_db, handle, (void *)&confdb_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst));
 	if (error != CS_OK) {
 		/* FIXME: set error_text */
 		return (error);
@@ -1452,7 +1454,7 @@ cs_error_t confdb_write (
 	}
 
 error_exit:
-	(void)saHandleInstancePut (&confdb_handle_t_db, handle);
+	(void)hdb_handle_put (&confdb_handle_t_db, handle);
 
 	return (error);
 }
@@ -1469,7 +1471,7 @@ cs_error_t confdb_reload (
 	struct res_lib_confdb_reload res_lib_confdb_reload;
 	struct req_lib_confdb_reload req_lib_confdb_reload;
 
-	error = saHandleInstanceGet (&confdb_handle_t_db, handle, (void *)&confdb_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst));
 	if (error != CS_OK) {
 		/* FIXME: set error_text */
 		return (error);
@@ -1514,7 +1516,7 @@ cs_error_t confdb_reload (
 	}
 
 error_exit:
-	(void)saHandleInstancePut (&confdb_handle_t_db, handle);
+	(void)hdb_handle_put (&confdb_handle_t_db, handle);
 
 	return (error);
 }
@@ -1530,7 +1532,7 @@ cs_error_t confdb_track_changes (
 	struct req_lib_confdb_object_track_start req;
 	coroipc_response_header_t res;
 
-	error = saHandleInstanceGet (&confdb_handle_t_db, handle, (void *)&confdb_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -1565,7 +1567,7 @@ cs_error_t confdb_track_changes (
 	error = res.error;
 
 error_exit:
-	(void)saHandleInstancePut (&confdb_handle_t_db, handle);
+	(void)hdb_handle_put (&confdb_handle_t_db, handle);
 
 	return (error);
 }
@@ -1578,7 +1580,7 @@ cs_error_t confdb_stop_track_changes (confdb_handle_t handle)
 	coroipc_request_header_t req;
 	coroipc_response_header_t res;
 
-	error = saHandleInstanceGet (&confdb_handle_t_db, handle, (void *)&confdb_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -1611,7 +1613,7 @@ cs_error_t confdb_stop_track_changes (confdb_handle_t handle)
 	error = res.error;
 
 error_exit:
-	(void)saHandleInstancePut (&confdb_handle_t_db, handle);
+	(void)hdb_handle_put (&confdb_handle_t_db, handle);
 
 	return (error);
 }

+ 0 - 214
lib/coroipcc.c

@@ -63,19 +63,6 @@
 #include <corosync/coroipc_ipc.h>
 #include <corosync/coroipcc.h>
 
-enum SA_HANDLE_STATE {
-	SA_HANDLE_STATE_EMPTY,
-	SA_HANDLE_STATE_PENDINGREMOVAL,
-	SA_HANDLE_STATE_ACTIVE
-};
-
-struct saHandle {
-	int state;
-	void *instance;
-	int refCount;
-	uint32_t check;
-};
-
 struct ipc_segment {
 	int fd;
 	int shmid;
@@ -829,39 +816,6 @@ coroipcc_msg_send_reply_receive_in_buf (
 	return (CS_OK);
 }
 
-#if defined(HAVE_PTHREAD_SPIN_LOCK)
-static void hdb_lock (struct saHandleDatabase *hdb)
-{
-	pthread_spin_lock (&hdb->lock);
-}
-
-static void hdb_unlock (struct saHandleDatabase *hdb)
-{
-	pthread_spin_unlock (&hdb->lock);
-}
-
-void saHandleDatabaseLock_init (struct saHandleDatabase *hdb)
-{
-	pthread_spin_init (&hdb->lock, 0);
-}
-#else
-static void hdb_lock (struct saHandleDatabase *hdb)
-{
-	pthread_mutex_lock (&hdb->lock);
-}
-
-static void hdb_unlock (struct saHandleDatabase *hdb)
-{
-	pthread_mutex_unlock (&hdb->lock);
-}
-
-void saHandleDatabaseLock_init (struct saHandleDatabase *hdb)
-{
-	pthread_mutex_init (&hdb->lock, NULL);
-}
-#endif
-
-
 cs_error_t
 coroipcc_zcb_alloc (
 	void *ipc_context,
@@ -966,171 +920,3 @@ coroipcc_zcb_msg_send_reply_receive (
 
 	return (res);
 }
-
-cs_error_t
-saHandleCreate (
-	struct saHandleDatabase *handleDatabase,
-	int instanceSize,
-	uint64_t *handleOut)
-{
-	uint32_t handle;
-	uint32_t check;
-	void *newHandles = NULL;
-	int found = 0;
-	void *instance;
-	int i;
-
-	hdb_lock (handleDatabase);
-
-	for (handle = 0; handle < handleDatabase->handleCount; handle++) {
-		if (handleDatabase->handles[handle].state == SA_HANDLE_STATE_EMPTY) {
-			found = 1;
-			break;
-		}
-	}
-
-	if (found == 0) {
-		handleDatabase->handleCount += 1;
-		newHandles = (struct saHandle *)realloc (handleDatabase->handles,
-			sizeof (struct saHandle) * handleDatabase->handleCount);
-		if (newHandles == NULL) {
-			hdb_unlock (handleDatabase);
-			return (CS_ERR_NO_MEMORY);
-		}
-		handleDatabase->handles = newHandles;
-	}
-
-	instance = malloc (instanceSize);
-	if (instance == 0) {
-		free (newHandles);
-		hdb_unlock (handleDatabase);
-		return (CS_ERR_NO_MEMORY);
-	}
-
-
-	/*
-	 * This code makes sure the random number isn't zero
-	 * We use 0 to specify an invalid handle out of the 1^64 address space
-	 * If we get 0 200 times in a row, the RNG may be broken
-	 */
-	for (i = 0; i < 200; i++) {
-		check = random();
-		if (check != 0) {
-			break;
-		}
-	}
-
-	memset (instance, 0, instanceSize);
-
-	handleDatabase->handles[handle].state = SA_HANDLE_STATE_ACTIVE;
-
-	handleDatabase->handles[handle].instance = instance;
-
-	handleDatabase->handles[handle].refCount = 1;
-
-	handleDatabase->handles[handle].check = check;
-
-	*handleOut = (uint64_t)((uint64_t)check << 32 | handle);
-
-	hdb_unlock (handleDatabase);
-
-	return (CS_OK);
-}
-
-
-cs_error_t
-saHandleDestroy (
-	struct saHandleDatabase *handleDatabase,
-	uint64_t inHandle)
-{
-	cs_error_t error = CS_OK;
-	uint32_t check = inHandle >> 32;
-	uint32_t handle = inHandle & 0xffffffff;
-
-	hdb_lock (handleDatabase);
-
-	if (check != handleDatabase->handles[handle].check) {
-		hdb_unlock (handleDatabase);
-		error = CS_ERR_BAD_HANDLE;
-		return (error);
-	}
-
-	handleDatabase->handles[handle].state = SA_HANDLE_STATE_PENDINGREMOVAL;
-
-	hdb_unlock (handleDatabase);
-
-	saHandleInstancePut (handleDatabase, inHandle);
-
-	return (error);
-}
-
-
-cs_error_t
-saHandleInstanceGet (
-	struct saHandleDatabase *handleDatabase,
-	uint64_t inHandle,
-	void **instance)
-{
-	uint32_t check = inHandle >> 32;
-	uint32_t handle = inHandle & 0xffffffff;
-
-	cs_error_t error = CS_OK;
-	hdb_lock (handleDatabase);
-
-	if (handle >= (uint64_t)handleDatabase->handleCount) {
-		error = CS_ERR_BAD_HANDLE;
-		goto error_exit;
-	}
-	if (handleDatabase->handles[handle].state != SA_HANDLE_STATE_ACTIVE) {
-		error = CS_ERR_BAD_HANDLE;
-		goto error_exit;
-	}
-	if (check != handleDatabase->handles[handle].check) {
-		error = CS_ERR_BAD_HANDLE;
-		goto error_exit;
-	}
-
-
-	*instance = handleDatabase->handles[handle].instance;
-
-	handleDatabase->handles[handle].refCount += 1;
-
-error_exit:
-	hdb_unlock (handleDatabase);
-
-	return (error);
-}
-
-
-cs_error_t
-saHandleInstancePut (
-	struct saHandleDatabase *handleDatabase,
-	uint64_t inHandle)
-{
-	void *instance;
-	cs_error_t error = CS_OK;
-	uint32_t check = inHandle >> 32;
-	uint32_t handle = inHandle & 0xffffffff;
-
-	hdb_lock (handleDatabase);
-
-	if (check != handleDatabase->handles[handle].check) {
-		error = CS_ERR_BAD_HANDLE;
-		goto error_exit;
-	}
-
-	handleDatabase->handles[handle].refCount -= 1;
-	assert (handleDatabase->handles[handle].refCount >= 0);
-
-	if (handleDatabase->handles[handle].refCount == 0) {
-		instance = (handleDatabase->handles[handle].instance);
-		handleDatabase->handleInstanceDestructor (instance);
-		free (instance);
-		memset (&handleDatabase->handles[handle], 0, sizeof (struct saHandle));
-	}
-
-error_exit:
-	hdb_unlock (handleDatabase);
-
-	return (error);
-}

+ 39 - 36
lib/cpg.c

@@ -51,12 +51,15 @@
 #include <corosync/coroipc_types.h>
 #include <corosync/coroipcc.h>
 #include <corosync/corodefs.h>
+#include <corosync/hdb.h>
 
 #include <corosync/cpg.h>
 #include <corosync/mar_gen.h>
 #include <corosync/mar_cpg.h>
 #include <corosync/ipc_cpg.h>
 
+#include "util.h"
+
 struct cpg_inst {
 	void *ipc_ctx;
 	int finalize;
@@ -68,7 +71,7 @@ struct cpg_inst {
 
 static void cpg_instance_destructor (void *instance);
 
-DECLARE_SAHDB_DATABASE(cpg_handle_t_db,cpg_instance_destructor);
+DECLARE_HDB_DATABASE(cpg_handle_t_db,cpg_instance_destructor);
 
 /*
  * Clean up function for a cpg instance (cpg_nitialize) handle
@@ -96,12 +99,12 @@ cs_error_t cpg_initialize (
 	cs_error_t error;
 	struct cpg_inst *cpg_inst;
 
-	error = saHandleCreate (&cpg_handle_t_db, sizeof (struct cpg_inst), handle);
+	error = hdb_error_to_cs (hdb_handle_create (&cpg_handle_t_db, sizeof (struct cpg_inst), handle));
 	if (error != CS_OK) {
 		goto error_no_destroy;
 	}
 
-	error = saHandleInstanceGet (&cpg_handle_t_db, *handle, (void *)&cpg_inst);
+	error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, *handle, (void *)&cpg_inst));
 	if (error != CS_OK) {
 		goto error_destroy;
 	}
@@ -123,14 +126,14 @@ cs_error_t cpg_initialize (
 
 	pthread_mutex_init (&cpg_inst->dispatch_mutex, NULL);
 
-	saHandleInstancePut (&cpg_handle_t_db, *handle);
+	hdb_handle_put (&cpg_handle_t_db, *handle);
 
 	return (CS_OK);
 
 error_put_destroy:
-	saHandleInstancePut (&cpg_handle_t_db, *handle);
+	hdb_handle_put (&cpg_handle_t_db, *handle);
 error_destroy:
-	saHandleDestroy (&cpg_handle_t_db, *handle);
+	hdb_handle_destroy (&cpg_handle_t_db, *handle);
 error_no_destroy:
 	return (error);
 }
@@ -141,7 +144,7 @@ cs_error_t cpg_finalize (
 	struct cpg_inst *cpg_inst;
 	cs_error_t error;
 
-	error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
+	error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -153,7 +156,7 @@ cs_error_t cpg_finalize (
 	 */
 	if (cpg_inst->finalize) {
 		pthread_mutex_unlock (&cpg_inst->response_mutex);
-		saHandleInstancePut (&cpg_handle_t_db, handle);
+		hdb_handle_put (&cpg_handle_t_db, handle);
 		return (CPG_ERR_BAD_HANDLE);
 	}
 
@@ -163,9 +166,9 @@ cs_error_t cpg_finalize (
 
 	pthread_mutex_unlock (&cpg_inst->response_mutex);
 
-	saHandleDestroy (&cpg_handle_t_db, handle);
+	hdb_handle_destroy (&cpg_handle_t_db, handle);
 
-	saHandleInstancePut (&cpg_handle_t_db, handle);
+	hdb_handle_put (&cpg_handle_t_db, handle);
 
 	return (CPG_OK);
 }
@@ -177,14 +180,14 @@ cs_error_t cpg_fd_get (
 	cs_error_t error;
 	struct cpg_inst *cpg_inst;
 
-	error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
+	error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
 
 	*fd = coroipcc_fd_get (cpg_inst->ipc_ctx);
 
-	saHandleInstancePut (&cpg_handle_t_db, handle);
+	hdb_handle_put (&cpg_handle_t_db, handle);
 
 	return (CS_OK);
 }
@@ -196,14 +199,14 @@ cs_error_t cpg_context_get (
 	cs_error_t error;
 	struct cpg_inst *cpg_inst;
 
-	error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
+	error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
 
 	*context = cpg_inst->context;
 
-	saHandleInstancePut (&cpg_handle_t_db, handle);
+	hdb_handle_put (&cpg_handle_t_db, handle);
 
 	return (CS_OK);
 }
@@ -215,14 +218,14 @@ cs_error_t cpg_context_set (
 	cs_error_t error;
 	struct cpg_inst *cpg_inst;
 
-	error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
+	error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
 
 	cpg_inst->context = context;
 
-	saHandleInstancePut (&cpg_handle_t_db, handle);
+	hdb_handle_put (&cpg_handle_t_db, handle);
 
 	return (CS_OK);
 }
@@ -249,7 +252,7 @@ cs_error_t cpg_dispatch (
 	mar_cpg_address_t *joined_list_start;
 	unsigned int i;
 
-	error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
+	error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -378,7 +381,7 @@ cs_error_t cpg_dispatch (
 	} while (cont);
 
 error_put:
-	saHandleInstancePut (&cpg_handle_t_db, handle);
+	hdb_handle_put (&cpg_handle_t_db, handle);
 	return (error);
 }
 
@@ -392,7 +395,7 @@ cs_error_t cpg_join (
 	struct req_lib_cpg_join req_lib_cpg_join;
 	struct res_lib_cpg_join res_lib_cpg_join;
 
-	error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
+	error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -423,7 +426,7 @@ cs_error_t cpg_join (
 	error = res_lib_cpg_join.header.error;
 
 error_exit:
-	saHandleInstancePut (&cpg_handle_t_db, handle);
+	hdb_handle_put (&cpg_handle_t_db, handle);
 
 	return (error);
 }
@@ -438,7 +441,7 @@ cs_error_t cpg_leave (
 	struct req_lib_cpg_leave req_lib_cpg_leave;
 	struct res_lib_cpg_leave res_lib_cpg_leave;
 
-	error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
+	error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -468,7 +471,7 @@ cs_error_t cpg_leave (
 	error = res_lib_cpg_leave.header.error;
 
 error_exit:
-	saHandleInstancePut (&cpg_handle_t_db, handle);
+	hdb_handle_put (&cpg_handle_t_db, handle);
 
 	return (error);
 }
@@ -486,7 +489,7 @@ cs_error_t cpg_membership_get (
 	struct res_lib_cpg_confchg_callback res_lib_cpg_membership_get;
 	unsigned int i;
 
-	error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
+	error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -524,7 +527,7 @@ cs_error_t cpg_membership_get (
 	}
 
 error_exit:
-	saHandleInstancePut (&cpg_handle_t_db, handle);
+	hdb_handle_put (&cpg_handle_t_db, handle);
 
 	return (error);
 }
@@ -539,7 +542,7 @@ cs_error_t cpg_local_get (
 	struct req_lib_cpg_local_get req_lib_cpg_local_get;
 	struct res_lib_cpg_local_get res_lib_cpg_local_get;
 
-	error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
+	error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -566,7 +569,7 @@ cs_error_t cpg_local_get (
 	*local_nodeid = res_lib_cpg_local_get.local_nodeid;
 
 error_exit:
-	saHandleInstancePut (&cpg_handle_t_db, handle);
+	hdb_handle_put (&cpg_handle_t_db, handle);
 
 	return (error);
 }
@@ -578,14 +581,14 @@ cs_error_t cpg_flow_control_state_get (
 	cs_error_t error;
 	struct cpg_inst *cpg_inst;
 
-	error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
+	error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
 
 	*flow_control_state = coroipcc_dispatch_flow_control_get (cpg_inst->ipc_ctx);
 
-	saHandleInstancePut (&cpg_handle_t_db, handle);
+	hdb_handle_put (&cpg_handle_t_db, handle);
 
 	return (error);
 }
@@ -598,7 +601,7 @@ cs_error_t cpg_zcb_alloc (
 	cs_error_t error;
 	struct cpg_inst *cpg_inst;
 
-	error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
+	error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -608,7 +611,7 @@ cs_error_t cpg_zcb_alloc (
 		size,
 		sizeof (struct req_lib_cpg_mcast));
 
-	saHandleInstancePut (&cpg_handle_t_db, handle);
+	hdb_handle_put (&cpg_handle_t_db, handle);
 	*buffer = ((char *)*buffer) + sizeof (struct req_lib_cpg_mcast);
 
 	return (error);
@@ -621,14 +624,14 @@ cs_error_t cpg_zcb_free (
 	cs_error_t error;
 	struct cpg_inst *cpg_inst;
 
-	error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
+	error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
 
 	coroipcc_zcb_free (cpg_inst->ipc_ctx, ((char *)buffer) - sizeof (struct req_lib_cpg_mcast));
 
-	saHandleInstancePut (&cpg_handle_t_db, handle);
+	hdb_handle_put (&cpg_handle_t_db, handle);
 
 	return (error);
 }
@@ -644,7 +647,7 @@ cs_error_t cpg_zcb_mcast_joined (
 	struct req_lib_cpg_mcast *req_lib_cpg_mcast;
 	struct res_lib_cpg_mcast res_lib_cpg_mcast;
 
-	error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
+	error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -674,7 +677,7 @@ cs_error_t cpg_zcb_mcast_joined (
 	error = res_lib_cpg_mcast.header.error;
 
 error_exit:
-	saHandleInstancePut (&cpg_handle_t_db, handle);
+	hdb_handle_put (&cpg_handle_t_db, handle);
 
 	return (error);
 }
@@ -693,7 +696,7 @@ cs_error_t cpg_mcast_joined (
 	struct res_lib_cpg_mcast res_lib_cpg_mcast;
 	size_t msg_len = 0;
 
-	error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
+	error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -727,7 +730,7 @@ cs_error_t cpg_mcast_joined (
 	error = res_lib_cpg_mcast.header.error;
 
 error_exit:
-	saHandleInstancePut (&cpg_handle_t_db, handle);
+	hdb_handle_put (&cpg_handle_t_db, handle);
 
 	return (error);
 }

+ 27 - 24
lib/evs.c

@@ -53,11 +53,14 @@
 #include <corosync/coroipc_types.h>
 #include <corosync/coroipcc.h>
 #include <corosync/corodefs.h>
+#include <corosync/hdb.h>
 
 #include <corosync/evs.h>
 #include <corosync/mar_gen.h>
 #include <corosync/ipc_evs.h>
 
+#include "util.h"
+
 #undef MIN
 #define MIN(x,y) ((x) < (y) ? (x) : (y))
 
@@ -71,7 +74,7 @@ struct evs_inst {
 
 static void evs_instance_destructor (void *instance);
 
-DECLARE_SAHDB_DATABASE (evs_handle_t_db, evs_instance_destructor);
+DECLARE_HDB_DATABASE (evs_handle_t_db, evs_instance_destructor);
 
 /*
  * Clean up function for an evt instance (saEvtInitialize) handle
@@ -104,12 +107,12 @@ evs_error_t evs_initialize (
 	cs_error_t error;
 	struct evs_inst *evs_inst;
 
-	error = saHandleCreate (&evs_handle_t_db, sizeof (struct evs_inst), handle);
+	error = hdb_error_to_cs(hdb_handle_create (&evs_handle_t_db, sizeof (struct evs_inst), handle));
 	if (error != CS_OK) {
 		goto error_no_destroy;
 	}
 
-	error = saHandleInstanceGet (&evs_handle_t_db, *handle, (void *)&evs_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&evs_handle_t_db, *handle, (void *)&evs_inst));
 	if (error != CS_OK) {
 		goto error_destroy;
 	}
@@ -131,14 +134,14 @@ evs_error_t evs_initialize (
 
 	pthread_mutex_init (&evs_inst->dispatch_mutex, NULL);
 
-	saHandleInstancePut (&evs_handle_t_db, *handle);
+	hdb_handle_put (&evs_handle_t_db, *handle);
 
 	return (CS_OK);
 
 error_put_destroy:
-	saHandleInstancePut (&evs_handle_t_db, *handle);
+	hdb_handle_put (&evs_handle_t_db, *handle);
 error_destroy:
-	saHandleDestroy (&evs_handle_t_db, *handle);
+	hdb_handle_destroy (&evs_handle_t_db, *handle);
 error_no_destroy:
 	return (error);
 }
@@ -149,7 +152,7 @@ evs_error_t evs_finalize (
 	struct evs_inst *evs_inst;
 	cs_error_t error;
 
-	error = saHandleInstanceGet (&evs_handle_t_db, handle, (void *)&evs_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&evs_handle_t_db, handle, (void *)&evs_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -160,7 +163,7 @@ evs_error_t evs_finalize (
 	 */
 	if (evs_inst->finalize) {
 		pthread_mutex_unlock (&evs_inst->response_mutex);
-		saHandleInstancePut (&evs_handle_t_db, handle);
+		hdb_handle_put (&evs_handle_t_db, handle);
 		return (EVS_ERR_BAD_HANDLE);
 	}
 
@@ -170,9 +173,9 @@ evs_error_t evs_finalize (
 
 	pthread_mutex_unlock (&evs_inst->response_mutex);
 
-	saHandleDestroy (&evs_handle_t_db, handle);
+	hdb_handle_destroy (&evs_handle_t_db, handle);
 
-	saHandleInstancePut (&evs_handle_t_db, handle);
+	hdb_handle_put (&evs_handle_t_db, handle);
 
 	return (EVS_OK);
 }
@@ -184,14 +187,14 @@ evs_error_t evs_fd_get (
 	cs_error_t error;
 	struct evs_inst *evs_inst;
 
-	error = saHandleInstanceGet (&evs_handle_t_db, handle, (void *)&evs_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&evs_handle_t_db, handle, (void *)&evs_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
 
 	*fd = coroipcc_fd_get (evs_inst->ipc_ctx);
 
-	saHandleInstancePut (&evs_handle_t_db, handle);
+	hdb_handle_put (&evs_handle_t_db, handle);
 
 	return (CS_OK);
 }
@@ -211,7 +214,7 @@ evs_error_t evs_dispatch (
 	coroipc_response_header_t *dispatch_data;
 	int ignore_dispatch = 0;
 
-	error = saHandleInstanceGet (&evs_handle_t_db, handle, (void *)&evs_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&evs_handle_t_db, handle, (void *)&evs_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -309,7 +312,7 @@ evs_error_t evs_dispatch (
 	} while (cont);
 
 error_put:
-	saHandleInstancePut (&evs_handle_t_db, handle);
+	hdb_handle_put (&evs_handle_t_db, handle);
 	return (error);
 }
 
@@ -324,7 +327,7 @@ evs_error_t evs_join (
 	struct req_lib_evs_join req_lib_evs_join;
 	struct res_lib_evs_join res_lib_evs_join;
 
-	error = saHandleInstanceGet (&evs_handle_t_db, handle, (void *)&evs_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&evs_handle_t_db, handle, (void *)&evs_inst));
 	if (error != EVS_OK) {
 		return (error);
 	}
@@ -353,7 +356,7 @@ evs_error_t evs_join (
 	error = res_lib_evs_join.header.error;
 
 error_exit:
-	saHandleInstancePut (&evs_handle_t_db, handle);
+	hdb_handle_put (&evs_handle_t_db, handle);
 
 	return (error);
 }
@@ -369,7 +372,7 @@ evs_error_t evs_leave (
 	struct req_lib_evs_leave req_lib_evs_leave;
 	struct res_lib_evs_leave res_lib_evs_leave;
 
-	error = saHandleInstanceGet (&evs_handle_t_db, handle, (void *)&evs_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&evs_handle_t_db, handle, (void *)&evs_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -398,7 +401,7 @@ evs_error_t evs_leave (
 	error = res_lib_evs_leave.header.error;
 
 error_exit:
-	saHandleInstancePut (&evs_handle_t_db, handle);
+	hdb_handle_put (&evs_handle_t_db, handle);
 
 	return (error);
 }
@@ -417,7 +420,7 @@ evs_error_t evs_mcast_joined (
 	struct res_lib_evs_mcast_joined res_lib_evs_mcast_joined;
 	size_t msg_len = 0;
 
-	error = saHandleInstanceGet (&evs_handle_t_db, handle, (void *)&evs_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&evs_handle_t_db, handle, (void *)&evs_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -453,7 +456,7 @@ evs_error_t evs_mcast_joined (
 	error = res_lib_evs_mcast_joined.header.error;
 
 error_exit:
-	saHandleInstancePut (&evs_handle_t_db, handle);
+	hdb_handle_put (&evs_handle_t_db, handle);
 
 	return (error);
 }
@@ -474,7 +477,7 @@ evs_error_t evs_mcast_groups (
 	struct res_lib_evs_mcast_groups res_lib_evs_mcast_groups;
 	size_t msg_len = 0;
 
-	error = saHandleInstanceGet (&evs_handle_t_db, handle, (void *)&evs_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&evs_handle_t_db, handle, (void *)&evs_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -509,7 +512,7 @@ evs_error_t evs_mcast_groups (
 	error = res_lib_evs_mcast_groups.header.error;
 
 error_exit:
-	saHandleInstancePut (&evs_handle_t_db, handle);
+	hdb_handle_put (&evs_handle_t_db, handle);
 
 	return (error);
 }
@@ -526,7 +529,7 @@ evs_error_t evs_membership_get (
 	struct req_lib_evs_membership_get req_lib_evs_membership_get;
 	struct res_lib_evs_membership_get res_lib_evs_membership_get;
 
-	error = saHandleInstanceGet (&evs_handle_t_db, handle, (void *)&evs_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&evs_handle_t_db, handle, (void *)&evs_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -567,7 +570,7 @@ evs_error_t evs_membership_get (
 	}
 
 error_exit:
-	saHandleInstancePut (&evs_handle_t_db, handle);
+	hdb_handle_put (&evs_handle_t_db, handle);
 
 	return (error);
 }

+ 0 - 4
lib/libcfg.versions

@@ -27,8 +27,4 @@ COROSYNC_CFG_0.82 {
 		coroipcc_zcb_alloc;
 		coroipcc_zcb_free;
 		coroipcc_zcb_msg_send_reply_receive;
-		saHandleCreate;
-		saHandleDestroy;
-		saHandleInstanceGet;
-		saHandleInstancePut;
 };

+ 0 - 4
lib/libconfdb.versions

@@ -33,8 +33,4 @@ COROSYNC_CONFDB_1.0 {
 		coroipcc_zcb_alloc;
 		coroipcc_zcb_free;
 		coroipcc_zcb_msg_send_reply_receive;
-		saHandleCreate;
-		saHandleDestroy;
-		saHandleInstanceGet;
-		saHandleInstancePut;
 };

+ 0 - 4
lib/libcoroipcc.versions

@@ -12,8 +12,4 @@ COROSYNC_COROIPCC_3.0 {
 		coroipcc_zcb_alloc;
 		coroipcc_zcb_free;
 		coroipcc_zcb_msg_send_reply_receive;
-		saHandleCreate;
-		saHandleDestroy;
-		saHandleInstanceGet;
-		saHandleInstancePut;
 };

+ 0 - 4
lib/libcpg.versions

@@ -26,8 +26,4 @@ COROSYNC_CPG_1.0 {
 		coroipcc_zcb_alloc;
 		coroipcc_zcb_free;
 		coroipcc_zcb_msg_send_reply_receive;
-		saHandleCreate;
-		saHandleDestroy;
-		saHandleInstanceGet;
-		saHandleInstancePut;
 };

+ 0 - 4
lib/libevs.versions

@@ -23,8 +23,4 @@ COROSYNC_EVS_2.0 {
 		coroipcc_zcb_alloc;
 		coroipcc_zcb_free;
 		coroipcc_zcb_msg_send_reply_receive;
-		saHandleCreate;
-		saHandleDestroy;
-		saHandleInstanceGet;
-		saHandleInstancePut;
 };

+ 0 - 4
lib/libpload.versions

@@ -15,8 +15,4 @@ COROSYNC_PLOAD_1.0 {
 		coroipcc_zcb_alloc;
 		coroipcc_zcb_free;
 		coroipcc_zcb_msg_send_reply_receive;
-		saHandleCreate;
-		saHandleDestroy;
-		saHandleInstanceGet;
-		saHandleInstancePut;
 };

+ 0 - 4
lib/libquorum.versions

@@ -20,8 +20,4 @@ COROSYNC_QUORUM_1.0 {
 		coroipcc_zcb_alloc;
 		coroipcc_zcb_free;
 		coroipcc_zcb_msg_send_reply_receive;
-		saHandleCreate;
-		saHandleDestroy;
-		saHandleInstanceGet;
-		saHandleInstancePut;
 };

+ 0 - 4
lib/libvotequorum.versions

@@ -29,8 +29,4 @@ COROSYNC_VOTEQUORUM_1.0 {
 		coroipcc_zcb_alloc;
 		coroipcc_zcb_free;
 		coroipcc_zcb_msg_send_reply_receive;
-		saHandleCreate;
-		saHandleDestroy;
-		saHandleInstanceGet;
-		saHandleInstancePut;
 };

+ 17 - 14
lib/pload.c

@@ -48,6 +48,9 @@
 #include <corosync/ipc_pload.h>
 #include <corosync/pload.h>
 #include <corosync/coroipcc.h>
+#include <corosync/hdb.h>
+
+#include "util.h"
 
 static void pload_instance_destructor (void *instance);
 
@@ -58,7 +61,7 @@ struct pload_inst {
 	unsigned int finalize;
 };
 
-DECLARE_SAHDB_DATABASE(pload_handle_t_db,pload_instance_destructor);
+DECLARE_HDB_DATABASE(pload_handle_t_db,pload_instance_destructor);
 
 /*
  * Clean up function for an evt instance (saEvtInitialize) handle
@@ -91,12 +94,12 @@ unsigned int pload_initialize (
 	cs_error_t error;
 	struct pload_inst *pload_inst;
 
-	error = saHandleCreate (&pload_handle_t_db, sizeof (struct pload_inst), handle);
+	error = hdb_error_to_cs(hdb_handle_create (&pload_handle_t_db, sizeof (struct pload_inst), handle));
 	if (error != CS_OK) {
 		goto error_no_destroy;
 	}
 
-	error = saHandleInstanceGet (&pload_handle_t_db, *handle, (void *)&pload_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&pload_handle_t_db, *handle, (void *)&pload_inst));
 	if (error != CS_OK) {
 		goto error_destroy;
 	}
@@ -116,14 +119,14 @@ unsigned int pload_initialize (
 
 	pthread_mutex_init (&pload_inst->dispatch_mutex, NULL);
 
-	(void)saHandleInstancePut (&pload_handle_t_db, *handle);
+	(void)hdb_handle_put (&pload_handle_t_db, *handle);
 
 	return (CS_OK);
 
 error_put_destroy:
-	(void)saHandleInstancePut (&pload_handle_t_db, *handle);
+	(void)hdb_handle_put (&pload_handle_t_db, *handle);
 error_destroy:
-	(void)saHandleDestroy (&pload_handle_t_db, *handle);
+	(void)hdb_handle_destroy (&pload_handle_t_db, *handle);
 error_no_destroy:
 	return (error);
 }
@@ -134,7 +137,7 @@ unsigned int pload_finalize (
 	struct pload_inst *pload_inst;
 	cs_error_t error;
 
-	error = saHandleInstanceGet (&pload_handle_t_db, handle, (void *)&pload_inst);
+	error = hdb_error_to_cs (hdb_handle_get (&pload_handle_t_db, handle, (void *)&pload_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -146,7 +149,7 @@ unsigned int pload_finalize (
 	 */
 	if (pload_inst->finalize) {
 		pthread_mutex_unlock (&pload_inst->response_mutex);
-		(void)saHandleInstancePut (&pload_handle_t_db, handle);
+		(void)hdb_handle_put (&pload_handle_t_db, handle);
 		return (PLOAD_ERR_BAD_HANDLE);
 	}
 
@@ -156,9 +159,9 @@ unsigned int pload_finalize (
 
 	pthread_mutex_unlock (&pload_inst->response_mutex);
 
-	(void)saHandleDestroy (&pload_handle_t_db, handle);
+	(void)hdb_handle_destroy (&pload_handle_t_db, handle);
 
-	(void)saHandleInstancePut (&pload_handle_t_db, handle);
+	(void)hdb_handle_put (&pload_handle_t_db, handle);
 
 	return (PLOAD_OK);
 }
@@ -170,14 +173,14 @@ unsigned int pload_fd_get (
 	cs_error_t error;
 	struct pload_inst *pload_inst;
 
-	error = saHandleInstanceGet (&pload_handle_t_db, handle, (void *)&pload_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&pload_handle_t_db, handle, (void *)&pload_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
 
 	*fd = coroipcc_fd_get (pload_inst->ipc_ctx);
 
-	(void)saHandleInstancePut (&pload_handle_t_db, handle);
+	(void)hdb_handle_put (&pload_handle_t_db, handle);
 
 	return (CS_OK);
 }
@@ -194,7 +197,7 @@ unsigned int pload_start (
 	struct req_lib_pload_start req_lib_pload_start;
 	struct res_lib_pload_start res_lib_pload_start;
 
-	error = saHandleInstanceGet (&pload_handle_t_db, handle, (void *)&pload_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&pload_handle_t_db, handle, (void *)&pload_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -225,7 +228,7 @@ unsigned int pload_start (
 	error = res_lib_pload_start.header.error;
 
 error_exit:
-	(void)saHandleInstancePut (&pload_handle_t_db, handle);
+	(void)hdb_handle_put (&pload_handle_t_db, handle);
 
 	return (error);
 }

+ 28 - 26
lib/quorum.c

@@ -45,17 +45,19 @@
 #include <sys/socket.h>
 #include <errno.h>
 
-
 #include <corosync/corotypes.h>
 #include <corosync/coroipc_types.h>
 #include <corosync/coroipcc.h>
 #include <corosync/corodefs.h>
+#include <corosync/hdb.h>
 
 #include <corosync/quorum.h>
 #include <corosync/mar_gen.h>
 #include <corosync/mar_cpg.h>
 #include <corosync/ipc_quorum.h>
 
+#include "util.h"
+
 struct quorum_inst {
 	void *ipc_ctx;
 	int finalize;
@@ -67,7 +69,7 @@ struct quorum_inst {
 
 static void quorum_instance_destructor (void *instance);
 
-DECLARE_SAHDB_DATABASE(quorum_handle_t_db,quorum_instance_destructor);
+DECLARE_HDB_DATABASE(quorum_handle_t_db,quorum_instance_destructor);
 
 /*
  * Clean up function for a quorum instance (quorum_initialize) handle
@@ -86,12 +88,12 @@ cs_error_t quorum_initialize (
 	cs_error_t error;
 	struct quorum_inst *quorum_inst;
 
-	error = saHandleCreate (&quorum_handle_t_db, sizeof (struct quorum_inst), handle);
+	error = hdb_error_to_cs(hdb_handle_create (&quorum_handle_t_db, sizeof (struct quorum_inst), handle));
 	if (error != CS_OK) {
 		goto error_no_destroy;
 	}
 
-	error = saHandleInstanceGet (&quorum_handle_t_db, *handle, (void *)&quorum_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&quorum_handle_t_db, *handle, (void *)&quorum_inst));
 	if (error != CS_OK) {
 		goto error_destroy;
 	}
@@ -114,14 +116,14 @@ cs_error_t quorum_initialize (
 	else
 		memset(&quorum_inst->callbacks, 0, sizeof (callbacks));
 
-	(void)saHandleInstancePut (&quorum_handle_t_db, *handle);
+	(void)hdb_handle_put (&quorum_handle_t_db, *handle);
 
 	return (CS_OK);
 
 error_put_destroy:
-	(void)saHandleInstancePut (&quorum_handle_t_db, *handle);
+	(void)hdb_handle_put (&quorum_handle_t_db, *handle);
 error_destroy:
-	(void)saHandleDestroy (&quorum_handle_t_db, *handle);
+	(void)hdb_handle_destroy (&quorum_handle_t_db, *handle);
 error_no_destroy:
 	return (error);
 }
@@ -132,7 +134,7 @@ cs_error_t quorum_finalize (
 	struct quorum_inst *quorum_inst;
 	cs_error_t error;
 
-	error = saHandleInstanceGet (&quorum_handle_t_db, handle, (void *)&quorum_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&quorum_handle_t_db, handle, (void *)&quorum_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -144,7 +146,7 @@ cs_error_t quorum_finalize (
 	 */
 	if (quorum_inst->finalize) {
 		pthread_mutex_unlock (&quorum_inst->response_mutex);
-		(void)saHandleInstancePut (&quorum_handle_t_db, handle);
+		(void)hdb_handle_put (&quorum_handle_t_db, handle);
 		return (CS_ERR_BAD_HANDLE);
 	}
 
@@ -154,9 +156,9 @@ cs_error_t quorum_finalize (
 
 	pthread_mutex_unlock (&quorum_inst->response_mutex);
 
-	(void)saHandleDestroy (&quorum_handle_t_db, handle);
+	(void)hdb_handle_destroy (&quorum_handle_t_db, handle);
 
-	(void)saHandleInstancePut (&quorum_handle_t_db, handle);
+	(void)hdb_handle_put (&quorum_handle_t_db, handle);
 
 	return (CS_OK);
 }
@@ -171,7 +173,7 @@ cs_error_t quorum_getquorate (
 	coroipc_request_header_t req;
 	struct res_lib_quorum_getquorate res_lib_quorum_getquorate;
 
-	error = saHandleInstanceGet (&quorum_handle_t_db, handle, (void *)&quorum_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&quorum_handle_t_db, handle, (void *)&quorum_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -202,7 +204,7 @@ cs_error_t quorum_getquorate (
 	*quorate = res_lib_quorum_getquorate.quorate;
 
 error_exit:
-	(void)saHandleInstancePut (&quorum_handle_t_db, handle);
+	(void)hdb_handle_put (&quorum_handle_t_db, handle);
 
 	return (error);
 }
@@ -214,14 +216,14 @@ cs_error_t quorum_fd_get (
 	cs_error_t error;
 	struct quorum_inst *quorum_inst;
 
-	error = saHandleInstanceGet (&quorum_handle_t_db, handle, (void *)&quorum_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&quorum_handle_t_db, handle, (void *)&quorum_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
 
 	*fd = coroipcc_fd_get (quorum_inst->ipc_ctx);
 
-	(void)saHandleInstancePut (&quorum_handle_t_db, handle);
+	(void)hdb_handle_put (&quorum_handle_t_db, handle);
 
 	return (CS_OK);
 }
@@ -234,14 +236,14 @@ cs_error_t quorum_context_get (
 	cs_error_t error;
 	struct quorum_inst *quorum_inst;
 
-	error = saHandleInstanceGet (&quorum_handle_t_db, handle, (void *)&quorum_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&quorum_handle_t_db, handle, (void *)&quorum_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
 
 	*context = quorum_inst->context;
 
-	(void)saHandleInstancePut (&quorum_handle_t_db, handle);
+	(void)hdb_handle_put (&quorum_handle_t_db, handle);
 
 	return (CS_OK);
 }
@@ -253,14 +255,14 @@ cs_error_t quorum_context_set (
 	cs_error_t error;
 	struct quorum_inst *quorum_inst;
 
-	error = saHandleInstanceGet (&quorum_handle_t_db, handle, (void *)&quorum_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&quorum_handle_t_db, handle, (void *)&quorum_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
 
 	quorum_inst->context = context;
 
-	(void)saHandleInstancePut (&quorum_handle_t_db, handle);
+	(void)hdb_handle_put (&quorum_handle_t_db, handle);
 
 	return (CS_OK);
 }
@@ -276,7 +278,7 @@ cs_error_t quorum_trackstart (
 	struct req_lib_quorum_trackstart req_lib_quorum_trackstart;
 	coroipc_response_header_t res;
 
-	error = saHandleInstanceGet (&quorum_handle_t_db, handle, (void *)&quorum_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&quorum_handle_t_db, handle, (void *)&quorum_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -306,7 +308,7 @@ cs_error_t quorum_trackstart (
 	error = res.error;
 
 error_exit:
-	(void)saHandleInstancePut (&quorum_handle_t_db, handle);
+	(void)hdb_handle_put (&quorum_handle_t_db, handle);
 
 	return (error);
 }
@@ -320,7 +322,7 @@ cs_error_t quorum_trackstop (
 	coroipc_request_header_t req;
 	coroipc_response_header_t res;
 
-	error = saHandleInstanceGet (&quorum_handle_t_db, handle, (void *)&quorum_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&quorum_handle_t_db, handle, (void *)&quorum_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -349,7 +351,7 @@ cs_error_t quorum_trackstop (
 	error = res.error;
 
 error_exit:
-	(void)saHandleInstancePut (&quorum_handle_t_db, handle);
+	(void)hdb_handle_put (&quorum_handle_t_db, handle);
 
 	return (error);
 }
@@ -374,8 +376,8 @@ cs_error_t quorum_dispatch (
 		return (CS_ERR_INVALID_PARAM);
 	}
 
-	error = saHandleInstanceGet (&quorum_handle_t_db, handle,
-		(void *)&quorum_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&quorum_handle_t_db, handle,
+		(void *)&quorum_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -467,6 +469,6 @@ error_unlock:
 	pthread_mutex_unlock (&quorum_inst->dispatch_mutex);
 
 error_put:
-	(void)saHandleInstancePut (&quorum_handle_t_db, handle);
+	(void)hdb_handle_put (&quorum_handle_t_db, handle);
 	return (error);
 }

+ 16 - 109
lib/util.h

@@ -36,115 +36,22 @@
 #ifndef AIS_UTIL_H_DEFINED
 #define AIS_UTIL_H_DEFINED
 
-#include <pthread.h>
-#include <sys/poll.h>
-#include <sys/socket.h>
+#include <errno.h>
+
+static inline cs_error_t hdb_error_to_cs (int res)		\
+{								\
+	if (res == 0) {						\
+		return (CS_OK);					\
+	} else {						\
+		if (errno == EBADF) {				\
+			return (CS_ERR_BAD_HANDLE);		\
+		} else						\
+		if (errno == ENOMEM) {				\
+			return (CS_ERR_NO_MEMORY);		\
+		}						\
+		return (CS_ERR_LIBRARY);			\
+	}							\
+}
 
-#include "../include/ipc_gen.h"
-
-/* Debug macro
- */
-#ifdef DEBUG
-	#define DPRINT(s) printf s
-#else
-	#define DPRINT(s)
-#endif
-
-#ifdef SO_NOSIGPIPE
-#ifndef MSG_NOSIGNAL
-#define MSG_NOSIGNAL 0
-#endif
-void socket_nosigpipe(int s);
-#else
-#define socket_nosigpipe(s)
-#endif
-
-struct saHandleDatabase {
-	unsigned int handleCount;
-	struct saHandle *handles;
-	pthread_mutex_t mutex;
-	void (*handleInstanceDestructor) (void *);
-};
-
-
-struct saVersionDatabase {
-	int versionCount;
-	SaVersionT *versionsSupported;
-};
-
-cs_error_t
-saServiceConnect (
-        int *responseOut,
-        int *callbackOut,
-        enum service_types service);
-
-cs_error_t
-saRecvRetry (
-	int s,
-	void *msg,
-	size_t len);
-
-cs_error_t
-saSendRetry (
-	int s,
-	const void *msg,
-	size_t len);
-
-cs_error_t saSendMsgRetry (
-	int s,
-	struct iovec *iov,
-	unsigned int iov_len);
-
-cs_error_t saSendMsgReceiveReply (
-	int s,
-	struct iovec *iov,
-	unsigned int iov_len,
-	void *responseMessage,
-	int responseLen);
-
-cs_error_t saSendReceiveReply (
-	int s,
-	void *requestMessage,
-	int requestLen,
-	void *responseMessage,
-	int responseLen);
-
-cs_error_t
-saPollRetry (
-	struct pollfd *ufds,
-	unsigned int nfds,
-	int timeout);
-
-cs_error_t
-saHandleCreate (
-	struct saHandleDatabase *handleDatabase,
-	int instanceSize,
-	SaUint64T *handleOut);
-
-cs_error_t
-saHandleDestroy (
-	struct saHandleDatabase *handleDatabase,
-	SaUint64T handle);
-
-cs_error_t
-saHandleInstanceGet (
-	struct saHandleDatabase *handleDatabase,
-	SaUint64T handle,
-	void **instance);
-
-cs_error_t
-saHandleInstancePut (
-	struct saHandleDatabase *handleDatabase,
-	SaUint64T handle);
-
-cs_error_t
-saVersionVerify (
-	struct saVersionDatabase *versionDatabase,
-	SaVersionT *version);
-
-#define offset_of(type,member) (int)(&(((type *)0)->member))
-
-SaTimeT
-clustTimeNow(void);
 
 #endif /* AIS_UTIL_H_DEFINED */

+ 44 - 41
lib/votequorum.c

@@ -51,12 +51,15 @@
 #include <corosync/coroipc_types.h>
 #include <corosync/coroipcc.h>
 #include <corosync/corodefs.h>
+#include <corosync/hdb.h>
 
 #include <corosync/votequorum.h>
 #include <corosync/mar_gen.h>
 #include <corosync/ipc_votequorum.h>
 #include <corosync/mar_gen.h>
 
+#include "util.h"
+
 struct votequorum_inst {
 	void *ipc_ctx;
 	int finalize;
@@ -68,7 +71,7 @@ struct votequorum_inst {
 
 static void votequorum_instance_destructor (void *instance);
 
-DECLARE_SAHDB_DATABASE(votequorum_handle_t_db,votequorum_instance_destructor);
+DECLARE_HDB_DATABASE(votequorum_handle_t_db,votequorum_instance_destructor);
 
 /*
  * Clean up function for a quorum instance (votequorum_initialize) handle
@@ -87,12 +90,12 @@ cs_error_t votequorum_initialize (
 	cs_error_t error;
 	struct votequorum_inst *votequorum_inst;
 
-	error = saHandleCreate (&votequorum_handle_t_db, sizeof (struct votequorum_inst), handle);
+	error = hdb_error_to_cs(hdb_handle_create (&votequorum_handle_t_db, sizeof (struct votequorum_inst), handle));
 	if (error != CS_OK) {
 		goto error_no_destroy;
 	}
 
-	error = saHandleInstanceGet (&votequorum_handle_t_db, *handle, (void *)&votequorum_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&votequorum_handle_t_db, *handle, (void *)&votequorum_inst));
 	if (error != CS_OK) {
 		goto error_destroy;
 	}
@@ -115,14 +118,14 @@ cs_error_t votequorum_initialize (
 	else
 		memset(&votequorum_inst->callbacks, 0, sizeof (*callbacks));
 
-	saHandleInstancePut (&votequorum_handle_t_db, *handle);
+	hdb_handle_put (&votequorum_handle_t_db, *handle);
 
 	return (CS_OK);
 
 error_put_destroy:
-	saHandleInstancePut (&votequorum_handle_t_db, *handle);
+	hdb_handle_put (&votequorum_handle_t_db, *handle);
 error_destroy:
-	saHandleDestroy (&votequorum_handle_t_db, *handle);
+	hdb_handle_destroy (&votequorum_handle_t_db, *handle);
 error_no_destroy:
 	return (error);
 }
@@ -133,7 +136,7 @@ cs_error_t votequorum_finalize (
 	struct votequorum_inst *votequorum_inst;
 	cs_error_t error;
 
-	error = saHandleInstanceGet (&votequorum_handle_t_db, handle, (void *)&votequorum_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&votequorum_handle_t_db, handle, (void *)&votequorum_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -145,7 +148,7 @@ cs_error_t votequorum_finalize (
 	 */
 	if (votequorum_inst->finalize) {
 		pthread_mutex_unlock (&votequorum_inst->response_mutex);
-		saHandleInstancePut (&votequorum_handle_t_db, handle);
+		hdb_handle_put (&votequorum_handle_t_db, handle);
 		return (CS_ERR_BAD_HANDLE);
 	}
 
@@ -155,9 +158,9 @@ cs_error_t votequorum_finalize (
 
 	pthread_mutex_unlock (&votequorum_inst->response_mutex);
 
-	saHandleDestroy (&votequorum_handle_t_db, handle);
+	hdb_handle_destroy (&votequorum_handle_t_db, handle);
 
-	saHandleInstancePut (&votequorum_handle_t_db, handle);
+	hdb_handle_put (&votequorum_handle_t_db, handle);
 
 	return (CS_OK);
 }
@@ -174,7 +177,7 @@ cs_error_t votequorum_getinfo (
 	struct req_lib_votequorum_getinfo req_lib_votequorum_getinfo;
 	struct res_lib_votequorum_getinfo res_lib_votequorum_getinfo;
 
-	error = saHandleInstanceGet (&votequorum_handle_t_db, handle, (void *)&votequorum_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&votequorum_handle_t_db, handle, (void *)&votequorum_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -212,7 +215,7 @@ cs_error_t votequorum_getinfo (
 	info->flags = res_lib_votequorum_getinfo.flags;
 
 error_exit:
-	saHandleInstancePut (&votequorum_handle_t_db, handle);
+	hdb_handle_put (&votequorum_handle_t_db, handle);
 
 	return (error);
 }
@@ -227,7 +230,7 @@ cs_error_t votequorum_setexpected (
 	struct req_lib_votequorum_setexpected req_lib_votequorum_setexpected;
 	struct res_lib_votequorum_status res_lib_votequorum_status;
 
-	error = saHandleInstanceGet (&votequorum_handle_t_db, handle, (void *)&votequorum_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&votequorum_handle_t_db, handle, (void *)&votequorum_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -258,7 +261,7 @@ cs_error_t votequorum_setexpected (
 	error = res_lib_votequorum_status.header.error;
 
 error_exit:
-	saHandleInstancePut (&votequorum_handle_t_db, handle);
+	hdb_handle_put (&votequorum_handle_t_db, handle);
 
 	return (error);
 }
@@ -274,7 +277,7 @@ cs_error_t votequorum_setvotes (
 	struct req_lib_votequorum_setvotes req_lib_votequorum_setvotes;
 	struct res_lib_votequorum_status res_lib_votequorum_status;
 
-	error = saHandleInstanceGet (&votequorum_handle_t_db, handle, (void *)&votequorum_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&votequorum_handle_t_db, handle, (void *)&votequorum_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -305,7 +308,7 @@ cs_error_t votequorum_setvotes (
 	error = res_lib_votequorum_status.header.error;
 
 error_exit:
-	saHandleInstancePut (&votequorum_handle_t_db, handle);
+	hdb_handle_put (&votequorum_handle_t_db, handle);
 
 	return (error);
 }
@@ -324,7 +327,7 @@ cs_error_t votequorum_qdisk_register (
 	if (strlen(name) > VOTEQUORUM_MAX_QDISK_NAME_LEN)
 		return CS_ERR_INVALID_PARAM;
 
-	error = saHandleInstanceGet (&votequorum_handle_t_db, handle, (void *)&votequorum_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&votequorum_handle_t_db, handle, (void *)&votequorum_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -356,7 +359,7 @@ cs_error_t votequorum_qdisk_register (
 	error = res_lib_votequorum_status.header.error;
 
 error_exit:
-	saHandleInstancePut (&votequorum_handle_t_db, handle);
+	hdb_handle_put (&votequorum_handle_t_db, handle);
 
 	return (error);
 }
@@ -371,7 +374,7 @@ cs_error_t votequorum_qdisk_poll (
 	struct req_lib_votequorum_qdisk_poll req_lib_votequorum_qdisk_poll;
 	struct res_lib_votequorum_status res_lib_votequorum_status;
 
-	error = saHandleInstanceGet (&votequorum_handle_t_db, handle, (void *)&votequorum_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&votequorum_handle_t_db, handle, (void *)&votequorum_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -402,7 +405,7 @@ cs_error_t votequorum_qdisk_poll (
 	error = res_lib_votequorum_status.header.error;
 
 error_exit:
-	saHandleInstancePut (&votequorum_handle_t_db, handle);
+	hdb_handle_put (&votequorum_handle_t_db, handle);
 
 	return (error);
 }
@@ -416,7 +419,7 @@ cs_error_t votequorum_qdisk_unregister (
 	struct req_lib_votequorum_general req_lib_votequorum_general;
 	struct res_lib_votequorum_status res_lib_votequorum_status;
 
-	error = saHandleInstanceGet (&votequorum_handle_t_db, handle, (void *)&votequorum_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&votequorum_handle_t_db, handle, (void *)&votequorum_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -445,7 +448,7 @@ cs_error_t votequorum_qdisk_unregister (
 	error = res_lib_votequorum_status.header.error;
 
 error_exit:
-	saHandleInstancePut (&votequorum_handle_t_db, handle);
+	hdb_handle_put (&votequorum_handle_t_db, handle);
 
 	return (error);
 }
@@ -462,7 +465,7 @@ cs_error_t votequorum_qdisk_getinfo (
 	struct req_lib_votequorum_general req_lib_votequorum_general;
 	struct res_lib_votequorum_qdisk_getinfo res_lib_votequorum_qdisk_getinfo;
 
-	error = saHandleInstanceGet (&votequorum_handle_t_db, handle, (void *)&votequorum_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&votequorum_handle_t_db, handle, (void *)&votequorum_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -497,7 +500,7 @@ cs_error_t votequorum_qdisk_getinfo (
 
 
 error_exit:
-	saHandleInstancePut (&votequorum_handle_t_db, handle);
+	hdb_handle_put (&votequorum_handle_t_db, handle);
 
 	return (error);
 }
@@ -511,7 +514,7 @@ cs_error_t votequorum_setstate (
 	struct req_lib_votequorum_general req_lib_votequorum_general;
 	struct res_lib_votequorum_status res_lib_votequorum_status;
 
-	error = saHandleInstanceGet (&votequorum_handle_t_db, handle, (void *)&votequorum_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&votequorum_handle_t_db, handle, (void *)&votequorum_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -540,7 +543,7 @@ cs_error_t votequorum_setstate (
 	error = res_lib_votequorum_status.header.error;
 
 error_exit:
-	saHandleInstancePut (&votequorum_handle_t_db, handle);
+	hdb_handle_put (&votequorum_handle_t_db, handle);
 
 	return (error);
 }
@@ -554,7 +557,7 @@ cs_error_t votequorum_leaving (
 	struct req_lib_votequorum_general req_lib_votequorum_general;
 	struct res_lib_votequorum_status res_lib_votequorum_status;
 
-	error = saHandleInstanceGet (&votequorum_handle_t_db, handle, (void *)&votequorum_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&votequorum_handle_t_db, handle, (void *)&votequorum_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -584,7 +587,7 @@ cs_error_t votequorum_leaving (
 	error = res_lib_votequorum_status.header.error;
 
 error_exit:
-	saHandleInstancePut (&votequorum_handle_t_db, handle);
+	hdb_handle_put (&votequorum_handle_t_db, handle);
 
 	return (error);
 }
@@ -600,7 +603,7 @@ cs_error_t votequorum_trackstart (
 	struct req_lib_votequorum_trackstart req_lib_votequorum_trackstart;
 	struct res_lib_votequorum_status res_lib_votequorum_status;
 
-	error = saHandleInstanceGet (&votequorum_handle_t_db, handle, (void *)&votequorum_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&votequorum_handle_t_db, handle, (void *)&votequorum_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -631,7 +634,7 @@ cs_error_t votequorum_trackstart (
 	error = res_lib_votequorum_status.header.error;
 
 error_exit:
-	saHandleInstancePut (&votequorum_handle_t_db, handle);
+	hdb_handle_put (&votequorum_handle_t_db, handle);
 
 	return (error);
 }
@@ -645,7 +648,7 @@ cs_error_t votequorum_trackstop (
 	struct req_lib_votequorum_general req_lib_votequorum_general;
 	struct res_lib_votequorum_status res_lib_votequorum_status;
 
-	error = saHandleInstanceGet (&votequorum_handle_t_db, handle, (void *)&votequorum_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&votequorum_handle_t_db, handle, (void *)&votequorum_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -674,7 +677,7 @@ cs_error_t votequorum_trackstop (
 	error = res_lib_votequorum_status.header.error;
 
 error_exit:
-	saHandleInstancePut (&votequorum_handle_t_db, handle);
+	hdb_handle_put (&votequorum_handle_t_db, handle);
 
 	return (error);
 }
@@ -687,14 +690,14 @@ cs_error_t votequorum_context_get (
 	cs_error_t error;
 	struct votequorum_inst *votequorum_inst;
 
-	error = saHandleInstanceGet (&votequorum_handle_t_db, handle, (void *)&votequorum_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&votequorum_handle_t_db, handle, (void *)&votequorum_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
 
 	*context = votequorum_inst->context;
 
-	saHandleInstancePut (&votequorum_handle_t_db, handle);
+	hdb_handle_put (&votequorum_handle_t_db, handle);
 
 	return (CS_OK);
 }
@@ -706,14 +709,14 @@ cs_error_t votequorum_context_set (
 	cs_error_t error;
 	struct votequorum_inst *votequorum_inst;
 
-	error = saHandleInstanceGet (&votequorum_handle_t_db, handle, (void *)&votequorum_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&votequorum_handle_t_db, handle, (void *)&votequorum_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
 
 	votequorum_inst->context = context;
 
-	saHandleInstancePut (&votequorum_handle_t_db, handle);
+	hdb_handle_put (&votequorum_handle_t_db, handle);
 
 	return (CS_OK);
 }
@@ -726,14 +729,14 @@ cs_error_t votequorum_fd_get (
 	cs_error_t error;
         struct votequorum_inst *votequorum_inst;
 
-        error = saHandleInstanceGet (&votequorum_handle_t_db, handle, (void *)&votequorum_inst);
+        error = hdb_error_to_cs(hdb_handle_get (&votequorum_handle_t_db, handle, (void *)&votequorum_inst));
         if (error != CS_OK) {
                 return (error);
         }
 
 	*fd = coroipcc_fd_get (votequorum_inst->ipc_ctx);
 
-	(void)saHandleInstancePut (&votequorum_handle_t_db, handle);
+	(void)hdb_handle_put (&votequorum_handle_t_db, handle);
 
 	return (CS_OK);
 }
@@ -759,8 +762,8 @@ cs_error_t votequorum_dispatch (
 		return (CS_ERR_INVALID_PARAM);
 	}
 
-	error = saHandleInstanceGet (&votequorum_handle_t_db, handle,
-		(void *)&votequorum_inst);
+	error = hdb_error_to_cs(hdb_handle_get (&votequorum_handle_t_db, handle,
+		(void *)&votequorum_inst));
 	if (error != CS_OK) {
 		return (error);
 	}
@@ -864,6 +867,6 @@ error_unlock:
 	pthread_mutex_unlock (&votequorum_inst->dispatch_mutex);
 
 error_put:
-	saHandleInstancePut (&votequorum_handle_t_db, handle);
+	hdb_handle_put (&votequorum_handle_t_db, handle);
 	return (error);
 }