Browse Source

Merge trunk revision 2369:
r2369 | sdake | 2009-07-22 15:10:35 -0700 (Wed, 22 Jul 2009) | 3 lines

Optimization of totemsrp and below by removing hdb usage. cpgbench shows
results of 4% to 20% increase in tps and mbs depending on hardware.



git-svn-id: http://svn.fedorahosted.org/svn/corosync/branches/flatiron@2488 fd59a12c-fef9-0310-b244-a6a79926bd2f

Steven Dake 16 years ago
parent
commit
4fdd82b846
11 changed files with 358 additions and 1016 deletions
  1. 54 168
      exec/totemiba.c
  2. 15 15
      exec/totemiba.h
  3. 13 13
      exec/totemmrp.c
  4. 73 214
      exec/totemnet.c
  5. 15 15
      exec/totemnet.h
  6. 48 205
      exec/totemrrp.c
  7. 16 14
      exec/totemrrp.h
  8. 50 154
      exec/totemsrp.c
  9. 12 12
      exec/totemsrp.h
  10. 47 191
      exec/totemudp.c
  11. 15 15
      exec/totemudp.h

+ 54 - 168
exec/totemiba.c

@@ -73,8 +73,6 @@ struct totemiba_instance {
 	int dummy;
 };
 
-DECLARE_HDB_DATABASE (totemiba_instance_database,NULL);
-
 static void totemiba_instance_initialize (struct totemiba_instance *instance)
 {
 	memset (instance, 0, sizeof (struct totemiba_instance));
@@ -91,41 +89,25 @@ do {									\
 } while (0);
 
 
-int totemiba_crypto_set (hdb_handle_t handle,
+int totemiba_crypto_set (void *iba_context,
 			 unsigned int type)
 {
-	struct totemiba_instance *instance;
+	struct totemiba_instance *instance = (struct totemiba_instance *)iba_context;
 	int res = 0;
 
-	res = hdb_handle_get (&totemiba_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
-	hdb_handle_put (&totemiba_instance_database, handle);
+	instance = NULL;
 
-error_exit:
-	return res;
+	return (res);
 }
 
 int totemiba_finalize (
-	hdb_handle_t handle)
+	void *iba_context)
 {
-	struct totemiba_instance *instance;
+	struct totemiba_instance *instance = (struct totemiba_instance *)iba_context;
 	int res = 0;
 
-	res = hdb_handle_get (&totemiba_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
+	instance = NULL;
 
-	hdb_handle_put (&totemiba_instance_database, handle);
-
-error_exit:
 	return (res);
 }
 
@@ -134,7 +116,7 @@ error_exit:
  */
 int totemiba_initialize (
 	hdb_handle_t poll_handle,
-	hdb_handle_t *handle,
+	void **iba_context,
 	struct totem_config *totem_config,
 	int interface_no,
 	void *context,
@@ -149,240 +131,144 @@ int totemiba_initialize (
 		const struct totem_ip_address *iface_address))
 {
 	struct totemiba_instance *instance;
-	unsigned int res;
+	int res = 0;
 
-	res = hdb_handle_create (&totemiba_instance_database,
-		sizeof (struct totemiba_instance), handle);
-	if (res != 0) {
-		goto error_exit;
-	}
-	res = hdb_handle_get (&totemiba_instance_database, *handle,
-		(void *)&instance);
-	if (res != 0) {
-		goto error_destroy;
+	instance = malloc (sizeof (struct totemiba_instance));
+	if (instance == NULL) {
+		return (-1);
 	}
 
 	totemiba_instance_initialize (instance);
 
-error_exit:
-	hdb_handle_put (&totemiba_instance_database, *handle);
-	return (0);
-
-error_destroy:
-	hdb_handle_destroy (&totemiba_instance_database, *handle);
-	return (-1);
+	return (res);
 }
 
 int totemiba_processor_count_set (
-	hdb_handle_t handle,
+	void *iba_context,
 	int processor_count)
 {
-	struct totemiba_instance *instance;
+	struct totemiba_instance *instance = (struct totemiba_instance *)iba_context;
 	int res = 0;
 
-	res = hdb_handle_get (&totemiba_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
-	hdb_handle_put (&totemiba_instance_database, handle);
+	instance = NULL;
 
-error_exit:
 	return (res);
 }
 
-int totemiba_recv_flush (hdb_handle_t handle)
+int totemiba_recv_flush (void *iba_context)
 {
-	struct totemiba_instance *instance;
+	struct totemiba_instance *instance = (struct totemiba_instance *)iba_context;
 	int res = 0;
 
-	res = hdb_handle_get (&totemiba_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
-	hdb_handle_put (&totemiba_instance_database, handle);
+	instance = NULL;
 
-error_exit:
 	return (res);
 }
 
-int totemiba_send_flush (hdb_handle_t handle)
+int totemiba_send_flush (void *iba_context)
 {
-	struct totemiba_instance *instance;
+	struct totemiba_instance *instance = (struct totemiba_instance *)iba_context;
 	int res = 0;
 
-	res = hdb_handle_get (&totemiba_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
-	hdb_handle_put (&totemiba_instance_database, handle);
+	instance = NULL;
 
-error_exit:
 	return (res);
 }
 
 int totemiba_token_send (
-	hdb_handle_t handle,
+	void *iba_context,
 	const void *msg,
 	unsigned int msg_len)
 {
-	struct totemiba_instance *instance;
+	struct totemiba_instance *instance = (struct totemiba_instance *)iba_context;
 	int res = 0;
 
-	res = hdb_handle_get (&totemiba_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
-	hdb_handle_put (&totemiba_instance_database, handle);
+	instance = NULL;
 
-error_exit:
 	return (res);
 }
+
 int totemiba_mcast_flush_send (
-	hdb_handle_t handle,
+	void *iba_context,
 	const void *msg,
 	unsigned int msg_len)
 {
-	struct totemiba_instance *instance;
+	struct totemiba_instance *instance = (struct totemiba_instance *)iba_context;
 	int res = 0;
 
-	res = hdb_handle_get (&totemiba_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
-	hdb_handle_put (&totemiba_instance_database, handle);
+	instance = NULL;
 
-error_exit:
 	return (res);
 }
 
 int totemiba_mcast_noflush_send (
-	hdb_handle_t handle,
+	void *iba_context,
 	const void *msg,
 	unsigned int msg_len)
 {
-	struct totemiba_instance *instance;
+	struct totemiba_instance *instance = (struct totemiba_instance *)iba_context;
 	int res = 0;
 
-	res = hdb_handle_get (&totemiba_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
+	instance = NULL;
 
-	hdb_handle_put (&totemiba_instance_database, handle);
-error_exit:
 	return (res);
 }
 
-extern int totemiba_iface_check (hdb_handle_t handle)
+extern int totemiba_iface_check (void *iba_context)
 {
-	struct totemiba_instance *instance;
+	struct totemiba_instance *instance = (struct totemiba_instance *)iba_context;
 	int res = 0;
 
-	res = hdb_handle_get (&totemiba_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
+	instance = NULL;
 
-	hdb_handle_put (&totemiba_instance_database, handle);
-error_exit:
 	return (res);
 }
 
-extern void totemiba_net_mtu_adjust (hdb_handle_t handle, struct totem_config *totem_config)
+extern void totemiba_net_mtu_adjust (void *iba_context, struct totem_config *totem_config)
 {
+	struct totemiba_instance *instance = (struct totemiba_instance *)iba_context;
+	instance = NULL;
 }
 
-const char *totemiba_iface_print (hdb_handle_t handle)  {
-	struct totemiba_instance *instance;
-	int res = 0;
-	const char *ret_char;
-
-	res = hdb_handle_get (&totemiba_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		ret_char = "Invalid totemiba handle";
-		goto error_exit;
-	}
+const char *totemiba_iface_print (void *iba_context)  {
+	struct totemiba_instance *instance = (struct totemiba_instance *)iba_context;
+	instance = NULL;
 
-	hdb_handle_put (&totemiba_instance_database, handle);
-error_exit:
-	return (ret_char);
+	return (NULL);
 }
 
 int totemiba_iface_get (
-	hdb_handle_t handle,
+	void *iba_context,
 	struct totem_ip_address *addr)
 {
-	struct totemiba_instance *instance;
-	unsigned int res;
-
-	res = hdb_handle_get (&totemiba_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		goto error_exit;
-	}
+	struct totemiba_instance *instance = (struct totemiba_instance *)iba_context;
+	int res = 0;
 
-	hdb_handle_put (&totemiba_instance_database, handle);
+	instance = NULL;
 
-error_exit:
 	return (res);
 }
 
 int totemiba_token_target_set (
-	hdb_handle_t handle,
+	void *iba_context,
 	const struct totem_ip_address *token_target)
 {
-	struct totemiba_instance *instance;
-	unsigned int res;
-
-	res = hdb_handle_get (&totemiba_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		goto error_exit;
-	}
+	struct totemiba_instance *instance = (struct totemiba_instance *)iba_context;
+	int res = 0;
 
-	hdb_handle_put (&totemiba_instance_database, handle);
+	instance = NULL;
 
-error_exit:
 	return (res);
 }
 
 extern int totemiba_recv_mcast_empty (
-	hdb_handle_t handle)
+	void *iba_context)
 {
-	struct totemiba_instance *instance;
-	unsigned int res;
-
-	res = hdb_handle_get (&totemiba_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		goto error_exit;
-	}
-
-	hdb_handle_put (&totemiba_instance_database, handle);
+	struct totemiba_instance *instance = (struct totemiba_instance *)iba_context;
+	int res = 0;
 
-	return (0);
+	instance = NULL;
 
-error_exit:
 	return (res);
 }
 

+ 15 - 15
exec/totemiba.h

@@ -45,7 +45,7 @@
  */
 extern int totemiba_initialize (
 	hdb_handle_t poll_handle,
-	hdb_handle_t *handle,
+	void **iba_handle,
 	struct totem_config *totem_config,
 	int interface_no,
 	void *context,
@@ -60,49 +60,49 @@ extern int totemiba_initialize (
 		const struct totem_ip_address *iface_address));
 
 extern int totemiba_processor_count_set (
-	hdb_handle_t handle,
+	void *iba_context,
 	int processor_count);
 
 extern int totemiba_token_send (
-	hdb_handle_t handle,
+	void *iba_context,
 	const void *msg,
 	unsigned int msg_len);
 
 extern int totemiba_mcast_flush_send (
-	hdb_handle_t handle,
+	void *iba_context,
 	const void *msg,
 	unsigned int msg_len);
 
 extern int totemiba_mcast_noflush_send (
-	hdb_handle_t handle,
+	void *iba_context,
 	const void *msg,
 	unsigned int msg_len);
 
-extern int totemiba_recv_flush (hdb_handle_t handle);
+extern int totemiba_recv_flush (void *iba_context);
 
-extern int totemiba_send_flush (hdb_handle_t handle);
+extern int totemiba_send_flush (void *iba_context);
 
-extern int totemiba_iface_check (hdb_handle_t handle);
+extern int totemiba_iface_check (void *iba_context);
 
-extern int totemiba_finalize (hdb_handle_t handle);
+extern int totemiba_finalize (void *iba_context);
 
-extern void totemiba_net_mtu_adjust (hdb_handle_t handle, struct totem_config *totem_config);
+extern void totemiba_net_mtu_adjust (void *iba_context, struct totem_config *totem_config);
 
-extern const char *totemiba_iface_print (hdb_handle_t handle);
+extern const char *totemiba_iface_print (void *iba_context);
 
 extern int totemiba_iface_get (
-	hdb_handle_t handle,
+	void *iba_context,
 	struct totem_ip_address *addr);
 
 extern int totemiba_token_target_set (
-	hdb_handle_t handle,
+	void *iba_context,
 	const struct totem_ip_address *token_target);
 
 extern int totemiba_crypto_set (
-	hdb_handle_t handle,
+	void *iba_context,
 	unsigned int type);
 
 extern int totemiba_recv_mcast_empty (
-	hdb_handle_t handle);
+	void *iba_context);
 
 #endif /* TOTEMIBA_H_DEFINED */

+ 13 - 13
exec/totemmrp.c

@@ -62,7 +62,7 @@
 #include "totemmrp.h"
 #include "totemsrp.h"
 
-hdb_handle_t totemsrp_handle_in;
+void *totemsrp_context;
 
 void totemmrp_deliver_fn (
 	unsigned int nodeid,
@@ -138,7 +138,7 @@ int totemmrp_initialize (
 
 	result = totemsrp_initialize (
 		poll_handle,
-		&totemsrp_handle_in,
+		&totemsrp_context,
 		totem_config,
 		totemmrp_deliver_fn,
 		totemmrp_confchg_fn);
@@ -148,7 +148,7 @@ int totemmrp_initialize (
 
 void totemmrp_finalize (void)
 {
-	totemsrp_finalize (totemsrp_handle_in);
+	totemsrp_finalize (totemsrp_context);
 }
 
 /*
@@ -159,7 +159,7 @@ int totemmrp_mcast (
 	unsigned int iov_len,
 	int priority)
 {
-	return totemsrp_mcast (totemsrp_handle_in, iovec, iov_len, priority);
+	return totemsrp_mcast (totemsrp_context, iovec, iov_len, priority);
 }
 
 /*
@@ -167,7 +167,7 @@ int totemmrp_mcast (
  */
 int totemmrp_avail (void)
 {
-	return (totemsrp_avail (totemsrp_handle_in));
+	return (totemsrp_avail (totemsrp_context));
 }
 
 int totemmrp_callback_token_create (
@@ -177,17 +177,17 @@ int totemmrp_callback_token_create (
 	int (*callback_fn) (enum totem_callback_token_type type, const void *),
 	const void *data)
 {
-	return totemsrp_callback_token_create (totemsrp_handle_in, handle_out, type, delete, callback_fn, data);
+	return totemsrp_callback_token_create (totemsrp_context, handle_out, type, delete, callback_fn, data);
 }
 
 void totemmrp_callback_token_destroy (
 	void *handle_out)
 {
-	totemsrp_callback_token_destroy (totemsrp_handle_in, handle_out);
+	totemsrp_callback_token_destroy (totemsrp_context, handle_out);
 }
 
 void totemmrp_new_msg_signal (void) {
-	totemsrp_new_msg_signal (totemsrp_handle_in);
+	totemsrp_new_msg_signal (totemsrp_context);
 }
 
 int totemmrp_ifaces_get (
@@ -199,7 +199,7 @@ int totemmrp_ifaces_get (
 	int res;
 
 	res = totemsrp_ifaces_get (
-		totemsrp_handle_in,
+		totemsrp_context,
 		nodeid,
 		interfaces,
 		status,
@@ -211,18 +211,18 @@ int totemmrp_ifaces_get (
 int totemmrp_crypto_set (
 	unsigned int type)
 {
-	return totemsrp_crypto_set (totemsrp_handle_in,
+	return totemsrp_crypto_set (totemsrp_context,
 				    type);
 }
 
 unsigned int totemmrp_my_nodeid_get (void)
 {
-	return (totemsrp_my_nodeid_get (totemsrp_handle_in));
+	return (totemsrp_my_nodeid_get (totemsrp_context));
 }
 
 int totemmrp_my_family_get (void)
 {
-	return (totemsrp_my_family_get (totemsrp_handle_in));
+	return (totemsrp_my_family_get (totemsrp_context));
 }
 
 extern int totemmrp_ring_reenable (void)
@@ -230,7 +230,7 @@ extern int totemmrp_ring_reenable (void)
 	int res;
 
 	res = totemsrp_ring_reenable (
-		totemsrp_handle_in);
+		totemsrp_context);
 
 	return (res);
 }

+ 73 - 214
exec/totemnet.c

@@ -45,7 +45,7 @@ struct transport {
 	
 	int (*initialize) (
 		hdb_handle_t poll_handle,
-		hdb_handle_t *handle,
+		void **transport_instance,
 		struct totem_config *totem_config,
 		int interface_no,
 		void *context,
@@ -60,51 +60,51 @@ struct transport {
 			const struct totem_ip_address *iface_address));
 
 	int (*processor_count_set) (
-		hdb_handle_t handle,
+		void *transport_context,
 		int processor_count);
 
 	int (*token_send) (
-		hdb_handle_t handle,
+		void *transport_context,
 		const void *msg,
 		unsigned int msg_len);
 
 	int (*mcast_flush_send) (
-		hdb_handle_t handle,
+		void *transport_context,
 		const void *msg,
 		unsigned int msg_len);
 
 
 	int (*mcast_noflush_send) (
-		hdb_handle_t handle,
+		void *transport_context,
 		const void *msg,
 		unsigned int msg_len);
 
-	int (*recv_flush) (hdb_handle_t handle);
+	int (*recv_flush) (void *transport_context);
 
-	int (*send_flush) (hdb_handle_t handle);
+	int (*send_flush) (void *transport_context);
 
-	int (*iface_check) (hdb_handle_t handle);
+	int (*iface_check) (void *transport_context);
 
-	int (*finalize) (hdb_handle_t handle);
+	int (*finalize) (void *transport_context);
 
-	void (*net_mtu_adjust) (hdb_handle_t handle, struct totem_config *totem_config);
+	void (*net_mtu_adjust) (void *transport_context, struct totem_config *totem_config);
 
-	const char *(*iface_print) (hdb_handle_t handle);
+	const char *(*iface_print) (void *transport_context);
 
 	int (*iface_get) (
-		hdb_handle_t handle,
+		void *transport_context,
 		struct totem_ip_address *addr);
 
 	int (*token_target_set) (
-		hdb_handle_t handle,
+		void *transport_context,
 		const struct totem_ip_address *token_target);
 
 	int (*crypto_set) (
-		hdb_handle_t handle,
+		void *transport_context,
 		unsigned int type);
 
 	int (*recv_mcast_empty) (
-		hdb_handle_t handle);
+		void *transport_context);
 };
 
 struct transport transport_entries[] = {
@@ -148,63 +148,42 @@ struct transport transport_entries[] = {
 };
 	
 struct totemnet_instance {
-	hdb_handle_t transport_handle;
+	void *transport_context;
 
 	struct transport *transport;
 };
 
-DECLARE_HDB_DATABASE (totemnet_instance_database,NULL);
-
 static void totemnet_instance_initialize (struct totemnet_instance *instance)
 {
 	instance->transport = &transport_entries[0];
 }
 
-int totemnet_crypto_set (hdb_handle_t handle,
-			 unsigned int type)
+int totemnet_crypto_set (
+	void *net_context,
+	 unsigned int type)
 {
-	struct totemnet_instance *instance;
+	struct totemnet_instance *instance = (struct totemnet_instance *)net_context;
 	int res = 0;
 
-	res = hdb_handle_get (&totemnet_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
-	res = instance->transport->crypto_set (instance->transport_handle, type);
+	res = instance->transport->crypto_set (instance->transport_context, type);
 
-	hdb_handle_put (&totemnet_instance_database, handle);
-
-error_exit:
 	return res;
 }
 
 int totemnet_finalize (
-	hdb_handle_t handle)
+	void *net_context)
 {
-	struct totemnet_instance *instance;
+	struct totemnet_instance *instance = (struct totemnet_instance *)net_context;
 	int res = 0;
 
-	res = hdb_handle_get (&totemnet_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
-	res = instance->transport->finalize (instance->transport_handle);
+	res = instance->transport->finalize (instance->transport_context);
 
-	hdb_handle_put (&totemnet_instance_database, handle);
-
-error_exit:
 	return (res);
 }
 
 int totemnet_initialize (
 	hdb_handle_t poll_handle,
-	hdb_handle_t *handle,
+	void **net_context,
 	struct totem_config *totem_config,
 	int interface_no,
 	void *context,
@@ -221,275 +200,155 @@ int totemnet_initialize (
 	struct totemnet_instance *instance;
 	unsigned int res;
 
-	res = hdb_handle_create (&totemnet_instance_database,
-		sizeof (struct totemnet_instance), handle);
-	if (res != 0) {
-		goto error_exit;
-	}
-	res = hdb_handle_get (&totemnet_instance_database, *handle,
-		(void *)&instance);
-	if (res != 0) {
-		goto error_destroy;
+	instance = malloc (sizeof (struct totemnet_instance));
+	if (instance == NULL) {
+		return (-1);
 	}
-
 	totemnet_instance_initialize (instance);
 
-	res = instance->transport->initialize (poll_handle, &instance->transport_handle, totem_config,
+	res = instance->transport->initialize (poll_handle,
+		&instance->transport_context, totem_config,
 		interface_no, context, deliver_fn, iface_change_fn);
 
-error_exit:
-	hdb_handle_put (&totemnet_instance_database, *handle);
+	if (res == -1) {
+		goto error_destroy;
+	}
+
+	*net_context = instance;
 	return (0);
 
 error_destroy:
-	hdb_handle_destroy (&totemnet_instance_database, *handle);
+	free (instance);
 	return (-1);
 }
 
 int totemnet_processor_count_set (
-	hdb_handle_t handle,
+	void *net_context,
 	int processor_count)
 {
-	struct totemnet_instance *instance;
+	struct totemnet_instance *instance = (struct totemnet_instance *)net_context;
 	int res = 0;
 
-	res = hdb_handle_get (&totemnet_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
-	res = instance->transport->processor_count_set (handle, processor_count);
-
-	hdb_handle_put (&totemnet_instance_database, instance->transport_handle);
-
-error_exit:
+	res = instance->transport->processor_count_set (instance->transport_context, processor_count);
 	return (res);
 }
 
-int totemnet_recv_flush (hdb_handle_t handle)
+int totemnet_recv_flush (void *net_context)
 {
-	struct totemnet_instance *instance;
+	struct totemnet_instance *instance = (struct totemnet_instance *)net_context;
 	int res = 0;
 
-	res = hdb_handle_get (&totemnet_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
-	res = instance->transport->recv_flush (instance->transport_handle);
-
-	hdb_handle_put (&totemnet_instance_database, handle);
+	res = instance->transport->recv_flush (instance->transport_context);
 
-error_exit:
 	return (res);
 }
 
-int totemnet_send_flush (hdb_handle_t handle)
+int totemnet_send_flush (void *net_context)
 {
-	struct totemnet_instance *instance;
+	struct totemnet_instance *instance = (struct totemnet_instance *)net_context;
 	int res = 0;
 
-	res = hdb_handle_get (&totemnet_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
-	res = instance->transport->send_flush (instance->transport_handle);
-
-	hdb_handle_put (&totemnet_instance_database, handle);
+	res = instance->transport->send_flush (instance->transport_context);
 
-error_exit:
 	return (res);
 }
 
 int totemnet_token_send (
-	hdb_handle_t handle,
+	void *net_context,
 	const void *msg,
 	unsigned int msg_len)
 {
-	struct totemnet_instance *instance;
+	struct totemnet_instance *instance = (struct totemnet_instance *)net_context;
 	int res = 0;
 
-	res = hdb_handle_get (&totemnet_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
-	res = instance->transport->token_send (instance->transport_handle, msg, msg_len);
-
-	hdb_handle_put (&totemnet_instance_database, handle);
+	res = instance->transport->token_send (instance->transport_context, msg, msg_len);
 
-error_exit:
 	return (res);
 }
 int totemnet_mcast_flush_send (
-	hdb_handle_t handle,
+	void *net_context,
 	const void *msg,
 	unsigned int msg_len)
 {
-	struct totemnet_instance *instance;
+	struct totemnet_instance *instance = (struct totemnet_instance *)net_context;
 	int res = 0;
 
-	res = hdb_handle_get (&totemnet_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
-	res = instance->transport->mcast_flush_send (instance->transport_handle, msg, msg_len);
-
-	hdb_handle_put (&totemnet_instance_database, handle);
+	res = instance->transport->mcast_flush_send (instance->transport_context, msg, msg_len);
 
-error_exit:
 	return (res);
 }
 
 int totemnet_mcast_noflush_send (
-	hdb_handle_t handle,
+	void *net_context,
 	const void *msg,
 	unsigned int msg_len)
 {
-	struct totemnet_instance *instance;
+	struct totemnet_instance *instance = (struct totemnet_instance *)net_context;
 	int res = 0;
 
-	res = hdb_handle_get (&totemnet_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
-	res = instance->transport->mcast_noflush_send (instance->transport_handle, msg, msg_len);
+	res = instance->transport->mcast_noflush_send (instance->transport_context, msg, msg_len);
 
-	hdb_handle_put (&totemnet_instance_database, handle);
-error_exit:
 	return (res);
 }
 
-extern int totemnet_iface_check (hdb_handle_t handle)
+extern int totemnet_iface_check (void *net_context)
 {
-	struct totemnet_instance *instance;
+	struct totemnet_instance *instance = (struct totemnet_instance *)net_context;
 	int res = 0;
 
-	res = hdb_handle_get (&totemnet_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
-	res = instance->transport->iface_check (instance->transport_handle);
+	res = instance->transport->iface_check (instance->transport_context);
 
-	hdb_handle_put (&totemnet_instance_database, handle);
-error_exit:
 	return (res);
 }
 
-extern int totemnet_net_mtu_adjust (hdb_handle_t handle, struct totem_config *totem_config)
+extern int totemnet_net_mtu_adjust (void *net_context, struct totem_config *totem_config)
 {
-	struct totemnet_instance *instance;
+	struct totemnet_instance *instance = (struct totemnet_instance *)net_context;
 	int res = 0;
 
-	res = hdb_handle_get (&totemnet_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
-	instance->transport->net_mtu_adjust (instance->transport_handle, totem_config);
-
-	hdb_handle_put (&totemnet_instance_database, handle);
-error_exit:
+	instance->transport->net_mtu_adjust (instance->transport_context, totem_config);
 	return (res);
 }
 
-const char *totemnet_iface_print (hdb_handle_t handle)  {
-	struct totemnet_instance *instance;
-	int res = 0;
+const char *totemnet_iface_print (void *net_context)  {
+	struct totemnet_instance *instance = (struct totemnet_instance *)net_context;
 	const char *ret_char;
 
-	res = hdb_handle_get (&totemnet_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		ret_char = "Invalid totemnet handle";
-		goto error_exit;
-	}
-
-	ret_char = instance->transport->iface_print (instance->transport_handle);
-
-	hdb_handle_put (&totemnet_instance_database, handle);
-error_exit:
+	ret_char = instance->transport->iface_print (instance->transport_context);
 	return (ret_char);
 }
 
 int totemnet_iface_get (
-	hdb_handle_t handle,
+	void *net_context,
 	struct totem_ip_address *addr)
 {
-	struct totemnet_instance *instance;
+	struct totemnet_instance *instance = (struct totemnet_instance *)net_context;
 	unsigned int res;
 
-	res = hdb_handle_get (&totemnet_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		goto error_exit;
-	}
-
-	res = instance->transport->iface_get (instance->transport_handle, addr);
+	res = instance->transport->iface_get (instance->transport_context, addr);
 	
-	hdb_handle_put (&totemnet_instance_database, handle);
-
-error_exit:
 	return (res);
 }
 
 int totemnet_token_target_set (
-	hdb_handle_t handle,
+	void *net_context,
 	const struct totem_ip_address *token_target)
 {
-	struct totemnet_instance *instance;
+	struct totemnet_instance *instance = (struct totemnet_instance *)net_context;
 	unsigned int res;
 
-	res = hdb_handle_get (&totemnet_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		goto error_exit;
-	}
-
-	res = instance->transport->token_target_set (instance->transport_handle, token_target);
+	res = instance->transport->token_target_set (instance->transport_context, token_target);
 
-	hdb_handle_put (&totemnet_instance_database, handle);
-
-error_exit:
 	return (res);
 }
 
 extern int totemnet_recv_mcast_empty (
-	hdb_handle_t handle)
+	void *net_context)
 {
-	struct totemnet_instance *instance;
-	unsigned int res = 0;
-
-	res = hdb_handle_get (&totemnet_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		goto error_exit;
-	}
-
-	res = instance->transport->recv_mcast_empty (instance->transport_handle);
+	struct totemnet_instance *instance = (struct totemnet_instance *)net_context;
+	unsigned int res;
 
-	hdb_handle_put (&totemnet_instance_database, handle);
+	res = instance->transport->recv_mcast_empty (instance->transport_context);
 
-error_exit:
 	return (res);
 }

+ 15 - 15
exec/totemnet.h

@@ -52,7 +52,7 @@
  */
 extern int totemnet_initialize (
 	hdb_handle_t poll_handle,
-	hdb_handle_t *handle,
+	void **net_context,
 	struct totem_config *totem_config,
 	int interface_no,
 	void *context,
@@ -67,49 +67,49 @@ extern int totemnet_initialize (
 		const struct totem_ip_address *iface_address));
 
 extern int totemnet_processor_count_set (
-	hdb_handle_t handle,
+	void *net_context,
 	int processor_count);
 
 extern int totemnet_token_send (
-	hdb_handle_t handle,
+	void *net_context,
 	const void *msg,
 	unsigned int msg_len);
 
 extern int totemnet_mcast_flush_send (
-	hdb_handle_t handle,
+	void *net_context,
 	const void *msg,
 	unsigned int msg_len);
 
 extern int totemnet_mcast_noflush_send (
-	hdb_handle_t handle,
+	void *net_context,
 	const void *msg,
 	unsigned int msg_len);
 
-extern int totemnet_recv_flush (hdb_handle_t handle);
+extern int totemnet_recv_flush (void *net_context);
 
-extern int totemnet_send_flush (hdb_handle_t handle);
+extern int totemnet_send_flush (void *net_context);
 
-extern int totemnet_iface_check (hdb_handle_t handle);
+extern int totemnet_iface_check (void *net_context);
 
-extern int totemnet_finalize (hdb_handle_t handle);
+extern int totemnet_finalize (void *net_context);
 
-extern int totemnet_net_mtu_adjust (hdb_handle_t handle, struct totem_config *totem_config);
+extern int totemnet_net_mtu_adjust (void *net_context, struct totem_config *totem_config);
 
-extern const char *totemnet_iface_print (hdb_handle_t handle);
+extern const char *totemnet_iface_print (void *net_context);
 
 extern int totemnet_iface_get (
-	hdb_handle_t handle,
+	void *net_context,
 	struct totem_ip_address *addr);
 
 extern int totemnet_token_target_set (
-	hdb_handle_t handle,
+	void *net_context,
 	const struct totem_ip_address *token_target);
 
 extern int totemnet_crypto_set (
-	hdb_handle_t handle,
+	void *net_context,
 	unsigned int type);
 
 extern int totemnet_recv_mcast_empty (
-	hdb_handle_t handle);
+	void *net_context);
 
 #endif /* TOTEMNET_H_DEFINED */

+ 48 - 205
exec/totemrrp.c

@@ -169,7 +169,7 @@ struct rrp_algo {
 };
 
 struct totemrrp_instance {
-	hdb_handle_t totemrrp_poll_handle;
+	hdb_handle_t poll_handle;
 
 	struct totem_interface *interfaces;
 
@@ -218,16 +218,12 @@ struct totemrrp_instance {
 		int line,
 		const char *format, ...)__attribute__((format(printf, 5, 6)));
 
-	hdb_handle_t handle;
-
-	hdb_handle_t *net_handles;
+	void **net_handles;
 
 	void *rrp_algo_instance;
 
 	int interface_count;
 
-	hdb_handle_t poll_handle;
-
 	int processor_count;
 
 	struct totem_config *totem_config;
@@ -483,11 +479,6 @@ struct rrp_algo *rrp_algos[] = {
 
 #define RRP_ALGOS_COUNT 3
 
-/*
- * All instances in one database
- */
-DECLARE_HDB_DATABASE (totemrrp_instance_database,NULL);
-
 #define log_printf(level, format, args...)				\
 do {									\
 	rrp_instance->totemrrp_log_printf (				\
@@ -1429,27 +1420,16 @@ void rrp_iface_change_fn (
 }
 
 int totemrrp_finalize (
-	hdb_handle_t handle)
+	void *rrp_context)
 {
-	struct totemrrp_instance *instance;
-	int res = 0;
+	struct totemrrp_instance *instance = (struct totemrrp_instance *)rrp_context;
 	int i;
 
-	res = hdb_handle_get (&totemrrp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
 	for (i = 0; i < instance->interface_count; i++) {
 		totemnet_finalize (instance->net_handles[i]);
 	}
 
-	hdb_handle_put (&totemrrp_instance_database, handle);
-
-error_exit:
-	return (res);
+	return (0);
 }
 
 /*
@@ -1462,7 +1442,7 @@ error_exit:
  */
 int totemrrp_initialize (
 	hdb_handle_t poll_handle,
-	hdb_handle_t *handle,
+	void **rrp_context,
 	struct totem_config *totem_config,
 	void *context,
 
@@ -1487,15 +1467,9 @@ int totemrrp_initialize (
 	unsigned int res;
 	int i;
 
-	res = hdb_handle_create (&totemrrp_instance_database,
-	sizeof (struct totemrrp_instance), handle);
-	if (res != 0) {
-		goto error_exit;
-	}
-	res = hdb_handle_get (&totemrrp_instance_database, *handle,
-		(void *)&instance);
-	if (res != 0) {
-		goto error_destroy;
+	instance = malloc (sizeof (struct totemrrp_instance));
+	if (instance == 0) {
+		return (-1);
 	}
 
 	totemrrp_instance_initialize (instance);
@@ -1506,7 +1480,7 @@ int totemrrp_initialize (
 		instance->totem_config,
 		instance);
 	if (res == -1) {
-		goto error_put;
+		goto error_destroy;
 	}
 
 	/*
@@ -1522,7 +1496,7 @@ int totemrrp_initialize (
 
 	instance->interfaces = totem_config->interfaces;
 
-	instance->totemrrp_poll_handle = poll_handle;
+	instance->poll_handle = poll_handle;
 
 	instance->totemrrp_deliver_fn = deliver_fn;
 
@@ -1534,7 +1508,7 @@ int totemrrp_initialize (
 
 	instance->interface_count = totem_config->interface_count;
 
-	instance->net_handles = malloc (sizeof (hdb_handle_t) * totem_config->interface_count);
+	instance->net_handles = malloc (sizeof (void *) * totem_config->interface_count);
 
 	instance->context = context;
 
@@ -1557,168 +1531,89 @@ int totemrrp_initialize (
 			(void *)deliver_fn_context,
 			rrp_deliver_fn,
 			rrp_iface_change_fn);
+
+		totemnet_net_mtu_adjust (instance->net_handles[i], totem_config);
 	}
 
-	totemnet_net_mtu_adjust (instance->net_handles[i], totem_config);
 
-error_exit:
-	hdb_handle_put (&totemrrp_instance_database, *handle);
+	*rrp_context = instance;
 	return (0);
 
-error_put:
-	hdb_handle_put (&totemrrp_instance_database, *handle);
 error_destroy:
-	hdb_handle_destroy (&totemrrp_instance_database, *handle);
+	free (instance);
 	return (res);
 }
 
 int totemrrp_processor_count_set (
-	hdb_handle_t handle,
+	void *rrp_context,
 	unsigned int processor_count)
 {
-	struct totemrrp_instance *instance;
-	int res = 0;
-
-	res = hdb_handle_get (&totemrrp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
+	struct totemrrp_instance *instance = (struct totemrrp_instance *)rrp_context;
 	instance->rrp_algo->processor_count_set (instance, processor_count);
 
 	instance->processor_count = processor_count;
 
-	hdb_handle_put (&totemrrp_instance_database, handle);
-
-error_exit:
-	return (res);
+	return (0);
 }
 
 int totemrrp_token_target_set (
-	hdb_handle_t handle,
+	void *rrp_context,
 	struct totem_ip_address *addr,
 	unsigned int iface_no)
 {
-	struct totemrrp_instance *instance;
-	int res = 0;
-
-	res = hdb_handle_get (&totemrrp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
+	struct totemrrp_instance *instance = (struct totemrrp_instance *)rrp_context;
 	instance->rrp_algo->token_target_set (instance, addr, iface_no);
 
-	hdb_handle_put (&totemrrp_instance_database, handle);
-
-error_exit:
-	return (res);
+	return (0);
 }
-int totemrrp_recv_flush (hdb_handle_t handle)
+int totemrrp_recv_flush (void *rrp_context)
 {
-	struct totemrrp_instance *instance;
-	int res = 0;
-
-	res = hdb_handle_get (&totemrrp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
+	struct totemrrp_instance *instance = (struct totemrrp_instance *)rrp_context;
 
 	instance->rrp_algo->recv_flush (instance);
 
-	hdb_handle_put (&totemrrp_instance_database, handle);
-
-error_exit:
-	return (res);
+	return (0);
 }
 
-int totemrrp_send_flush (hdb_handle_t handle)
+int totemrrp_send_flush (void *rrp_context)
 {
-	struct totemrrp_instance *instance;
-	int res = 0;
-
-	res = hdb_handle_get (&totemrrp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
+	struct totemrrp_instance *instance = (struct totemrrp_instance *)rrp_context;
 	instance->rrp_algo->send_flush (instance);
 
-	hdb_handle_put (&totemrrp_instance_database, handle);
-
-error_exit:
-	return (res);
+	return (0);
 }
 
 int totemrrp_token_send (
-	hdb_handle_t handle,
+	void *rrp_context,
 	const void *msg,
 	unsigned int msg_len)
 {
-	struct totemrrp_instance *instance;
-	int res = 0;
-
-	res = hdb_handle_get (&totemrrp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
+	struct totemrrp_instance *instance = (struct totemrrp_instance *)rrp_context;
 	instance->rrp_algo->token_send (instance, msg, msg_len);
 
-	hdb_handle_put (&totemrrp_instance_database, handle);
-
-error_exit:
-	return (res);
+	return (0);
 }
 
 int totemrrp_mcast_flush_send (
-	hdb_handle_t handle,
+	void *rrp_context,
 	const void *msg,
 	unsigned int msg_len)
 {
-	struct totemrrp_instance *instance;
+	struct totemrrp_instance *instance = (struct totemrrp_instance *)rrp_context;
 	int res = 0;
 
-	res = hdb_handle_get (&totemrrp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
 // TODO this needs to return the result
 	instance->rrp_algo->mcast_flush_send (instance, msg, msg_len);
 
-	hdb_handle_put (&totemrrp_instance_database, handle);
-error_exit:
 	return (res);
 }
 
 int totemrrp_mcast_noflush_send (
-	hdb_handle_t handle,
+	void *rrp_context,
 	const void *msg,
 	unsigned int msg_len)
 {
-	struct totemrrp_instance *instance;
-	int res = 0;
-
-	res = hdb_handle_get (&totemrrp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
+	struct totemrrp_instance *instance = (struct totemrrp_instance *)rrp_context;
 	/*
 	 * merge detects go out through mcast_flush_send so it is safe to
 	 * flush these messages if we are only one processor.  This avoids
@@ -1730,122 +1625,70 @@ int totemrrp_mcast_noflush_send (
 		instance->rrp_algo->mcast_noflush_send (instance, msg, msg_len);
 	}
 
-	hdb_handle_put (&totemrrp_instance_database, handle);
-error_exit:
-	return (res);
+	return (0);
 }
 
-int totemrrp_iface_check (hdb_handle_t handle)
+int totemrrp_iface_check (void *rrp_context)
 {
-	struct totemrrp_instance *instance;
-	int res = 0;
-
-	res = hdb_handle_get (&totemrrp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
+	struct totemrrp_instance *instance = (struct totemrrp_instance *)rrp_context;
 
 	instance->rrp_algo->iface_check (instance);
 
-	hdb_handle_put (&totemrrp_instance_database, handle);
-error_exit:
-	return (res);
+	return (0);
 }
 
 int totemrrp_ifaces_get (
-        hdb_handle_t handle,
+	void *rrp_context,
 	char ***status,
 	unsigned int *iface_count)
 {
-	struct totemrrp_instance *instance;
-	int res = 0;
-
-	res = hdb_handle_get (&totemrrp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
+	struct totemrrp_instance *instance = (struct totemrrp_instance *)rrp_context;
 	*status = instance->status;
 
 	if (iface_count) {
 		*iface_count = instance->interface_count;
 	}
 
-	hdb_handle_put (&totemrrp_instance_database, handle);
-
-error_exit:
-	return (res);
+	return (0);
 }
 
 int totemrrp_crypto_set (
-	hdb_handle_t handle,
+	void *rrp_context,
 	unsigned int type)
 {
+	struct totemrrp_instance *instance = (struct totemrrp_instance *)rrp_context;
 	int res;
-	struct totemrrp_instance *instance;
-
-	res = hdb_handle_get (&totemrrp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		return (0);
-	}
 
 	res = totemnet_crypto_set(instance->net_handles[0], type);
 
-	hdb_handle_put (&totemrrp_instance_database, handle);
 	return (res);
 }
 
 
 int totemrrp_ring_reenable (
-        hdb_handle_t handle)
+        void *rrp_context)
 {
-	struct totemrrp_instance *instance;
+	struct totemrrp_instance *instance = (struct totemrrp_instance *)rrp_context;
 	int res = 0;
 	unsigned int i;
 
-printf ("totemrrp ring reenable\n");
-	res = hdb_handle_get (&totemrrp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
 	instance->rrp_algo->ring_reenable (instance);
 
 	for (i = 0; i < instance->interface_count; i++) {
 		sprintf (instance->status[i], "ring %d active with no faults", i);
 	}
 
-	hdb_handle_put (&totemrrp_instance_database, handle);
-
-error_exit:
 	return (res);
 }
 
 extern int totemrrp_mcast_recv_empty (
-        hdb_handle_t handle)
+	void *rrp_context)
 {
-	struct totemrrp_instance *instance;
+	struct totemrrp_instance *instance = (struct totemrrp_instance *)rrp_context;
 	int res;
 
-	res = hdb_handle_get (&totemrrp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
 	res = instance->rrp_algo->mcast_recv_empty (instance);
 
-	hdb_handle_put (&totemrrp_instance_database, handle);
-
-error_exit:
 	return (res);
 }
 

+ 16 - 14
exec/totemrrp.h

@@ -53,7 +53,7 @@
  */
 extern int totemrrp_initialize (
 	hdb_handle_t poll_handle,
-	hdb_handle_t *handle,
+	void **rrp_context,
 	struct totem_config *totem_config,
 	void *context,
 
@@ -76,50 +76,52 @@ extern int totemrrp_initialize (
 
 
 extern int totemrrp_processor_count_set (
-	hdb_handle_t handle,
+	void *rrp_context,
 	unsigned int processor_count);
 
 extern int totemrrp_token_send (
-	hdb_handle_t handle,
+	void *rrp_context,
 	const void *msg,
 	unsigned int msg_len);
 
 extern int totemrrp_mcast_noflush_send (
-	hdb_handle_t handle,
+	void *rrp_context,
 	const void *msg,
 	unsigned int msg_len);
 
 extern int totemrrp_mcast_flush_send (
-	hdb_handle_t handle,
+	void *rrp_context,
 	const void *msg,
 	unsigned int msg_len);
 
-extern int totemrrp_recv_flush (hdb_handle_t handle);
+extern int totemrrp_recv_flush (
+	void *rrp_context);
 
-extern int totemrrp_send_flush (hdb_handle_t handle);
+extern int totemrrp_send_flush (
+	void *rrp_context);
 
 extern int totemrrp_token_target_set (
-	hdb_handle_t handle,
+	void *rrp_context,
 	struct totem_ip_address *target,
 	unsigned int iface_no);
 
-extern int totemrrp_iface_check (hdb_handle_t handle);
+extern int totemrrp_iface_check (void *rrp_context);
 
-extern int totemrrp_finalize (hdb_handle_t handle);
+extern int totemrrp_finalize (void *rrp_context);
 
 extern int totemrrp_ifaces_get (
-	hdb_handle_t handle,
+	void *rrp_context,
 	char ***status,
 	unsigned int *iface_count);
 
 extern int totemrrp_crypto_set (
-	hdb_handle_t handle,
+	void *rrp_context,
 	unsigned int type);
 
 extern int totemrrp_ring_reenable (
-	hdb_handle_t handle);
+	void *rrp_context);
 
 extern int totemrrp_mcast_recv_empty (
-	hdb_handle_t handle);
+	void *rrp_context);
 
 #endif /* TOTEMRRP_H_DEFINED */

+ 50 - 154
exec/totemsrp.c

@@ -483,7 +483,7 @@ struct totemsrp_instance {
 
 	struct timeval tv_old;
 
-	hdb_handle_t totemrrp_handle;
+	void *totemrrp_context;
 
 	struct totem_config *totem_config;
 
@@ -607,11 +607,6 @@ void main_iface_change_fn (
 	const struct totem_ip_address *iface_address,
 	unsigned int iface_no);
 
-/*
- * All instances in one database
- */
-DECLARE_HDB_DATABASE (totemsrp_instance_database,NULL);
-
 struct message_handlers totemsrp_message_handlers = {
 	6,
 	{
@@ -696,7 +691,7 @@ static int pause_flush (struct totemsrp_instance *instance)
 		 * -1 indicates an error from recvmsg
 		 */
 		do {
-			res = totemrrp_mcast_recv_empty (instance->totemrrp_handle);
+			res = totemrrp_mcast_recv_empty (instance->totemrrp_context);
 		} while (res == -1);
 	}
 	return (res);
@@ -707,7 +702,7 @@ static int pause_flush (struct totemsrp_instance *instance)
  */
 int totemsrp_initialize (
 	hdb_handle_t poll_handle,
-	hdb_handle_t *handle,
+	void **srp_context,
 	struct totem_config *totem_config,
 
 	void (*deliver_fn) (
@@ -726,16 +721,10 @@ int totemsrp_initialize (
 	struct totemsrp_instance *instance;
 	unsigned int res;
 
-	res = hdb_handle_create (&totemsrp_instance_database,
-		sizeof (struct totemsrp_instance), handle);
-	if (res != 0) {
+	instance = malloc (sizeof (struct totemsrp_instance));
+	if (instance == NULL) {
 		goto error_exit;
 	}
-	res = hdb_handle_get (&totemsrp_instance_database, *handle,
-		(void *)&instance);
-	if (res != 0) {
-		goto error_destroy;
-	}
 
 	rundir = getenv ("COROSYNC_RUN_DIR");
 	if (rundir == NULL) {
@@ -744,12 +733,12 @@ int totemsrp_initialize (
 
 	res = mkdir (rundir, 0700);
 	if (res == -1 && errno != EEXIST) {
-		goto error_put;
+		goto error_destroy;
 	}
 
 	res = chdir (rundir);
 	if (res == -1) {
-		goto error_put;
+		goto error_destroy;
 	}
 
 	totemsrp_instance_initialize (instance);
@@ -866,7 +855,7 @@ int totemsrp_initialize (
 
 	totemrrp_initialize (
 		poll_handle,
-		&instance->totemrrp_handle,
+		&instance->totemrrp_context,
 		totem_config,
 		instance,
 		main_deliver_fn,
@@ -881,54 +870,37 @@ int totemsrp_initialize (
 		MESSAGE_QUEUE_MAX,
 		sizeof (struct message_item));
 
-	hdb_handle_put (&totemsrp_instance_database, *handle);
-
+	*srp_context = instance;
 	return (0);
 
-error_put:
-	hdb_handle_put (&totemsrp_instance_database, *handle);
-
 error_destroy:
-	hdb_handle_destroy (&totemsrp_instance_database, *handle);
+	free (instance);
 
 error_exit:
 	return (-1);
 }
 
 void totemsrp_finalize (
-	hdb_handle_t handle)
+	void *srp_context)
 {
-	struct totemsrp_instance *instance;
-	unsigned int res;
+	struct totemsrp_instance *instance = (struct totemsrp_instance *)srp_context;
 
-	res = hdb_handle_get (&totemsrp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		return;
-	}
 	memb_leave_message_send (instance);
-
-	hdb_handle_put (&totemsrp_instance_database, handle);
+	free (srp_context);
 }
 
 int totemsrp_ifaces_get (
-	hdb_handle_t handle,
+	void *srp_context,
 	unsigned int nodeid,
 	struct totem_ip_address *interfaces,
 	char ***status,
 	unsigned int *iface_count)
 {
-	struct totemsrp_instance *instance;
+	struct totemsrp_instance *instance = (struct totemsrp_instance *)srp_context;
 	int res;
 	unsigned int found = 0;
 	unsigned int i;
 
-	res = hdb_handle_get (&totemsrp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		goto error_exit;
-	}
-
 	for (i = 0; i < instance->my_memb_entries; i++) {
 		if (instance->my_memb_list[i].addr[0].nodeid == nodeid) {
 			found = 1;
@@ -959,87 +931,54 @@ int totemsrp_ifaces_get (
 	}
 
 finish:
-	totemrrp_ifaces_get (instance->totemrrp_handle, status, NULL);
-
-	hdb_handle_put (&totemsrp_instance_database, handle);
-error_exit:
+	totemrrp_ifaces_get (instance->totemrrp_context, status, NULL);
 	return (res);
 }
 
 int totemsrp_crypto_set (
-	hdb_handle_t handle,
+	void *srp_context,
 	unsigned int type)
 {
+	struct totemsrp_instance *instance = (struct totemsrp_instance *)srp_context;
 	int res;
-	struct totemsrp_instance *instance;
-
-	res = hdb_handle_get (&totemsrp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		return (0);
-	}
 
-	res = totemrrp_crypto_set(instance->totemrrp_handle, type);
+	res = totemrrp_crypto_set(instance->totemrrp_context, type);
 
-	hdb_handle_put (&totemsrp_instance_database, handle);
 	return (res);
 }
 
 
 unsigned int totemsrp_my_nodeid_get (
-	hdb_handle_t handle)
+	void *srp_context)
 {
-	struct totemsrp_instance *instance;
+	struct totemsrp_instance *instance = (struct totemsrp_instance *)srp_context;
 	unsigned int res;
 
-	res = hdb_handle_get (&totemsrp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		return (0);
-	}
-
 	res = instance->totem_config->interfaces[0].boundto.nodeid;
 
-	hdb_handle_put (&totemsrp_instance_database, handle);
 	return (res);
 }
 
 int totemsrp_my_family_get (
-	hdb_handle_t handle)
+	void *srp_context)
 {
-	struct totemsrp_instance *instance;
+	struct totemsrp_instance *instance = (struct totemsrp_instance *)srp_context;
 	int res;
 
-	res = hdb_handle_get (&totemsrp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		return (0);
-	}
-
 	res = instance->totem_config->interfaces[0].boundto.family;
 
-	hdb_handle_put (&totemsrp_instance_database, handle);
 	return (res);
 }
 
 
 int totemsrp_ring_reenable (
-        hdb_handle_t handle)
+        void *srp_context)
 {
-	struct totemsrp_instance *instance;
-	int res;
+	struct totemsrp_instance *instance = (struct totemsrp_instance *)srp_context;
 
-	res = hdb_handle_get (&totemsrp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		goto error_exit;
-	}
+	totemrrp_ring_reenable (instance->totemrrp_context);
 
-	totemrrp_ring_reenable (instance->totemrrp_handle);
-
-	hdb_handle_put (&totemsrp_instance_database, handle);
-error_exit:
-	return (res);
+	return (0);
 }
 
 
@@ -1527,7 +1466,7 @@ static void timer_function_orf_token_timeout (void *data)
 				"The token was lost in the OPERATIONAL state.\n");
 			log_printf (instance->totemsrp_log_level_notice,
 				"A processor failed, forming new configuration.\n");
-			totemrrp_iface_check (instance->totemrrp_handle);
+			totemrrp_iface_check (instance->totemrrp_context);
 			memb_state_gather_enter (instance, 2);
 			break;
 
@@ -1921,7 +1860,7 @@ static void memb_state_recovery_enter (
 	 * Build regular configuration
 	 */
  	totemrrp_processor_count_set (
-		instance->totemrrp_handle,
+		instance->totemrrp_context,
 		commit_token->addr_entries);
 
 	/*
@@ -2067,43 +2006,26 @@ originated:
 	return;
 }
 
-int totemsrp_new_msg_signal (hdb_handle_t handle)
+int totemsrp_new_msg_signal (void *srp_context)
 {
-	struct totemsrp_instance *instance;
-	unsigned int res;
-
-	res = hdb_handle_get (&totemsrp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		goto error_exit;
-	}
+	struct totemsrp_instance *instance = (struct totemsrp_instance *)srp_context;
 
 	token_hold_cancel_send (instance);
 
-	hdb_handle_put (&totemsrp_instance_database, handle);
 	return (0);
-error_exit:
-	return (-1);
 }
 
 int totemsrp_mcast (
-	hdb_handle_t handle,
+	void *srp_context,
 	struct iovec *iovec,
 	unsigned int iov_len,
 	int guarantee)
 {
+	struct totemsrp_instance *instance = (struct totemsrp_instance *)srp_context;
 	int i;
 	struct message_item message_item;
-	struct totemsrp_instance *instance;
 	char *addr;
 	unsigned int addr_idx;
-	unsigned int res;
-
-	res = hdb_handle_get (&totemsrp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		goto error_exit;
-	}
 
 	if (cs_queue_is_full (&instance->new_message_queue)) {
 		log_printf (instance->totemsrp_log_level_debug, "queue full\n");
@@ -2144,39 +2066,23 @@ int totemsrp_mcast (
 	log_printf (instance->totemsrp_log_level_debug, "mcasted message added to pending queue\n");
 	cs_queue_item_add (&instance->new_message_queue, &message_item);
 
-	hdb_handle_put (&totemsrp_instance_database, handle);
 	return (0);
 
 error_mcast:
-	hdb_handle_put (&totemsrp_instance_database, handle);
-
-error_exit:
 	return (-1);
 }
 
 /*
  * Determine if there is room to queue a new message
  */
-int totemsrp_avail (hdb_handle_t handle)
+int totemsrp_avail (void *srp_context)
 {
+	struct totemsrp_instance *instance = (struct totemsrp_instance *)srp_context;
 	int avail;
-	struct totemsrp_instance *instance;
-	unsigned int res;
-
-	res = hdb_handle_get (&totemsrp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		goto error_exit;
-	}
 
 	cs_queue_avail (&instance->new_message_queue, &avail);
 
-	hdb_handle_put (&totemsrp_instance_database, handle);
-
 	return (avail);
-
-error_exit:
-	return (0);
 }
 
 /*
@@ -2218,7 +2124,7 @@ static int orf_token_remcast (
 	sort_queue_item = ptr;
 
 	totemrrp_mcast_noflush_send (
-		instance->totemrrp_handle,
+		instance->totemrrp_context,
 		sort_queue_item->mcast,
 		sort_queue_item->msg_len);
 
@@ -2381,7 +2287,7 @@ static int orf_token_mcast (
 			&sort_queue_item, message_item->mcast->seq);
 
 		totemrrp_mcast_noflush_send (
-			instance->totemrrp_handle,
+			instance->totemrrp_context,
 			message_item->mcast,
 			message_item->msg_len);
 
@@ -2529,7 +2435,7 @@ static int orf_token_rtr (
 
 static void token_retransmit (struct totemsrp_instance *instance)
 {
-	totemrrp_token_send (instance->totemrrp_handle,
+	totemrrp_token_send (instance->totemrrp_context,
 		instance->orf_token_retransmit,
 		instance->orf_token_retransmit_size);
 }
@@ -2613,7 +2519,7 @@ static int token_send (
 		return (0);
 	}
 
-	totemrrp_token_send (instance->totemrrp_handle,
+	totemrrp_token_send (instance->totemrrp_context,
 		orf_token,
 		orf_token_size);
 
@@ -2642,7 +2548,7 @@ static int token_hold_cancel_send (struct totemsrp_instance *instance)
 		sizeof (struct memb_ring_id));
 	assert (token_hold_cancel.header.nodeid);
 
-	totemrrp_mcast_flush_send (instance->totemrrp_handle, &token_hold_cancel,
+	totemrrp_mcast_flush_send (instance->totemrrp_context, &token_hold_cancel,
 		sizeof (struct token_hold_cancel));
 
 	return (0);
@@ -2766,7 +2672,7 @@ static void memb_state_commit_token_target_set (
 
 	for (i = 0; i < instance->totem_config->interface_count; i++) {
 		totemrrp_token_target_set (
-			instance->totemrrp_handle,
+			instance->totemrrp_context,
 			&addr[commit_token->memb_index %
 				commit_token->addr_entries].addr[i],
 			i);
@@ -2794,7 +2700,7 @@ static int memb_state_commit_token_send (
 	memcpy (instance->orf_token_retransmit, commit_token, commit_token_size);
 	instance->orf_token_retransmit_size = commit_token_size;
 
-	totemrrp_token_send (instance->totemrrp_handle,
+	totemrrp_token_send (instance->totemrrp_context,
 		commit_token,
 		commit_token_size);
 
@@ -2930,7 +2836,7 @@ static void memb_join_message_send (struct totemsrp_instance *instance)
 	}
 
 	totemrrp_mcast_flush_send (
-		instance->totemrrp_handle,
+		instance->totemrrp_context,
 		memb_join,
 		addr_idx);
 }
@@ -2999,7 +2905,7 @@ static void memb_leave_message_send (struct totemsrp_instance *instance)
 	}
 
 	totemrrp_mcast_flush_send (
-		instance->totemrrp_handle,
+		instance->totemrrp_context,
 		memb_join,
 		addr_idx);
 }
@@ -3017,7 +2923,7 @@ static void memb_merge_detect_transmit (struct totemsrp_instance *instance)
 		sizeof (struct memb_ring_id));
 	assert (memb_merge_detect.header.nodeid);
 
-	totemrrp_mcast_flush_send (instance->totemrrp_handle,
+	totemrrp_mcast_flush_send (instance->totemrrp_context,
 		&memb_merge_detect,
 		sizeof (struct memb_merge_detect));
 }
@@ -3092,22 +2998,15 @@ static void memb_ring_id_set_and_store (
 }
 
 int totemsrp_callback_token_create (
-	hdb_handle_t handle,
+	void *srp_context,
 	void **handle_out,
 	enum totem_callback_token_type type,
 	int delete,
 	int (*callback_fn) (enum totem_callback_token_type type, const void *),
 	const void *data)
 {
+	struct totemsrp_instance *instance = (struct totemsrp_instance *)srp_context;
 	struct token_callback_instance *callback_handle;
-	struct totemsrp_instance *instance;
-	unsigned int res;
-
-	res = hdb_handle_get (&totemsrp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		goto error_exit;
-	}
 
 	token_hold_cancel_send (instance);
 
@@ -3130,13 +3029,10 @@ int totemsrp_callback_token_create (
 		break;
 	}
 
-	hdb_handle_put (&totemsrp_instance_database, handle);
-
-error_exit:
 	return (0);
 }
 
-void totemsrp_callback_token_destroy (hdb_handle_t handle, void **handle_out)
+void totemsrp_callback_token_destroy (void *srp_context, void **handle_out)
 {
 	struct token_callback_instance *h;
 
@@ -3350,7 +3246,7 @@ static int message_handler_orf_token (
 	}
 #endif
 
-	totemrrp_recv_flush (instance->totemrrp_handle);
+	totemrrp_recv_flush (instance->totemrrp_context);
 
 	/*
 	 * Determine if we should hold (in reality drop) the token
@@ -3538,7 +3434,7 @@ static int message_handler_orf_token (
 				}
 			}
 
-			totemrrp_send_flush (instance->totemrrp_handle);
+			totemrrp_send_flush (instance->totemrrp_context);
 			token_send (instance, token, forward_token);
 
 #ifdef GIVEINFO

+ 12 - 12
exec/totemsrp.h

@@ -48,7 +48,7 @@
  */
 int totemsrp_initialize (
 	hdb_handle_t poll_handle,
-	hdb_handle_t *handle,
+	void **srp_context,
 	struct totem_config *totem_config,
 
 	void (*deliver_fn) (
@@ -63,13 +63,13 @@ int totemsrp_initialize (
 		const unsigned int *joined_list, size_t joined_list_entries,
 		const struct memb_ring_id *ring_id));
 
-void totemsrp_finalize (hdb_handle_t handle);
+void totemsrp_finalize (void *srp_context);
 
 /*
  * Multicast a message
  */
 int totemsrp_mcast (
-	hdb_handle_t handle,
+	void *srp_context,
 	struct iovec *iovec,
 	unsigned int iov_len,
 	int priority);
@@ -77,10 +77,10 @@ int totemsrp_mcast (
 /*
  * Return number of available messages that can be queued
  */
-int totemsrp_avail (hdb_handle_t handle);
+int totemsrp_avail (void *srp_context);
 
 int totemsrp_callback_token_create (
-	hdb_handle_t handle,
+	void *srp_context,
 	void **handle_out,
 	enum totem_callback_token_type type,
 	int delete,
@@ -88,31 +88,31 @@ int totemsrp_callback_token_create (
 	const void *data);
 
 void totemsrp_callback_token_destroy (
-	hdb_handle_t handle,
+	void *srp_context,
 	void **handle_out);
 
-int totemsrp_new_msg_signal (hdb_handle_t handle);
+int totemsrp_new_msg_signal (void *srp_context);
 
 extern void totemsrp_net_mtu_adjust (struct totem_config *totem_config);
 
 extern int totemsrp_ifaces_get (
-	hdb_handle_t handle,
+	void *srp_context,
 	unsigned int nodeid,
 	struct totem_ip_address *interfaces,
 	char ***status,
 	unsigned int *iface_count);
 
 extern unsigned int totemsrp_my_nodeid_get (
-	hdb_handle_t handle);
+	void *srp_context);
 
 extern int totemsrp_my_family_get (
-	hdb_handle_t handle);
+	void *srp_context);
 
 extern int totemsrp_crypto_set (
-	hdb_handle_t handle,
+	void *srp_context,
 	unsigned int type);
 
 extern int totemsrp_ring_reenable (
-	hdb_handle_t handle);
+	void *srp_context);
 
 #endif /* TOTEMSRP_H_DEFINED */

+ 47 - 191
exec/totemudp.c

@@ -165,7 +165,7 @@ struct totemudp_instance {
 		const char *format,
 		...)__attribute__((format(printf, 5, 6)));
 
-	hdb_handle_t handle;
+	void *udp_context;
 
 	char iov_buffer[FRAME_SIZE_MAX];
 
@@ -212,8 +212,6 @@ struct work_item {
 	struct totemudp_instance *instance;
 };
 
-static void netif_down_check (struct totemudp_instance *instance);
-
 static int totemudp_build_sockets (
 	struct totemudp_instance *instance,
 	struct totem_ip_address *bindnet_address,
@@ -223,8 +221,6 @@ static int totemudp_build_sockets (
 
 static struct totem_ip_address localhost;
 
-DECLARE_HDB_DATABASE (totemudp_instance_database,NULL);
-
 static void totemudp_instance_initialize (struct totemudp_instance *instance)
 {
 	memset (instance, 0, sizeof (struct totemudp_instance));
@@ -847,19 +843,13 @@ static void init_crypto(
 #endif
 }
 
-int totemudp_crypto_set (hdb_handle_t handle,
-			 unsigned int type)
+int totemudp_crypto_set (
+	void *udp_context,
+	 unsigned int type)
 {
-	struct totemudp_instance *instance;
+	struct totemudp_instance *instance = (struct totemudp_instance *)udp_context;
 	int res = 0;
 
-	res = hdb_handle_get (&totemudp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
 	/*
 	 * Can't set crypto type if OLD is selected
 	 */
@@ -883,10 +873,8 @@ int totemudp_crypto_set (hdb_handle_t handle,
 				break;
 		}
 	}
-	hdb_handle_put (&totemudp_instance_database, handle);
 
-error_exit:
-	return res;
+	return (res);
 }
 
 
@@ -1123,18 +1111,11 @@ static void totemudp_mcast_worker_fn (void *thread_state, void *work_item_in)
 }
 
 int totemudp_finalize (
-	hdb_handle_t handle)
+	void *udp_context)
 {
-	struct totemudp_instance *instance;
+	struct totemudp_instance *instance = (struct totemudp_instance *)udp_context;
 	int res = 0;
 
-	res = hdb_handle_get (&totemudp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
 	worker_thread_group_exit (&instance->worker_thread_group);
 
 	if (instance->totemudp_sockets.mcast_recv > 0) {
@@ -1151,9 +1132,6 @@ int totemudp_finalize (
 			instance->totemudp_sockets.token);
 	}
 
-	hdb_handle_put (&totemudp_instance_database, handle);
-
-error_exit:
 	return (res);
 }
 
@@ -1400,16 +1378,6 @@ static void timer_function_netif_check_timeout (
 	}
 }
 
-
-/*
- * Check if an interface is down and reconfigure
- * totemudp waiting for it to come back up
- */
-static void netif_down_check (struct totemudp_instance *instance)
-{
-	timer_function_netif_check_timeout (instance);
-}
-
 /* Set the socket priority to INTERACTIVE to ensure
    that our messages don't get queued behind anything else */
 static void totemudp_traffic_control_set(struct totemudp_instance *instance, int sock)
@@ -1727,7 +1695,7 @@ static int totemudp_build_sockets (
  */
 int totemudp_initialize (
 	hdb_handle_t poll_handle,
-	hdb_handle_t *handle,
+	void **udp_context,
 	struct totem_config *totem_config,
 	int interface_no,
 	void *context,
@@ -1742,17 +1710,10 @@ int totemudp_initialize (
 		const struct totem_ip_address *iface_address))
 {
 	struct totemudp_instance *instance;
-	unsigned int res;
 
-	res = hdb_handle_create (&totemudp_instance_database,
-		sizeof (struct totemudp_instance), handle);
-	if (res != 0) {
-		goto error_exit;
-	}
-	res = hdb_handle_get (&totemudp_instance_database, *handle,
-		(void *)&instance);
-	if (res != 0) {
-		goto error_destroy;
+	instance = malloc (sizeof (struct totemudp_instance));
+	if (instance == NULL) {
+		return (-1);
 	}
 
 	totemudp_instance_initialize (instance);
@@ -1808,35 +1769,29 @@ int totemudp_initialize (
 
 	instance->totemudp_iface_change_fn = iface_change_fn;
 
-	instance->handle = *handle;
-
 	totemip_localhost (instance->mcast_address.family, &localhost);
 
-	netif_down_check (instance);
+	/*
+	 * RRP layer isn't ready to receive message because it hasn't
+	 * initialized yet.  Add short timer to check the interfaces.
+	 */
+	poll_timer_add (instance->totemudp_poll_handle,
+		100,
+		(void *)instance,
+		timer_function_netif_check_timeout,
+		&instance->timer_netif_check_timeout);
 
-error_exit:
-	hdb_handle_put (&totemudp_instance_database, *handle);
+	*udp_context = instance;
 	return (0);
-
-error_destroy:
-	hdb_handle_destroy (&totemudp_instance_database, *handle);
-	return (-1);
 }
 
 int totemudp_processor_count_set (
-	hdb_handle_t handle,
+	void *udp_context,
 	int processor_count)
 {
-	struct totemudp_instance *instance;
+	struct totemudp_instance *instance = (struct totemudp_instance *)udp_context;
 	int res = 0;
 
-	res = hdb_handle_get (&totemudp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
 	instance->my_memb_entries = processor_count;
 	poll_timer_delete (instance->totemudp_poll_handle,
 		instance->timer_netif_check_timeout);
@@ -1847,26 +1802,17 @@ int totemudp_processor_count_set (
 			timer_function_netif_check_timeout,
 			&instance->timer_netif_check_timeout);
 	}
-	hdb_handle_put (&totemudp_instance_database, handle);
 
-error_exit:
 	return (res);
 }
 
-int totemudp_recv_flush (hdb_handle_t handle)
+int totemudp_recv_flush (void *udp_context)
 {
-	struct totemudp_instance *instance;
+	struct totemudp_instance *instance = (struct totemudp_instance *)udp_context;
 	struct pollfd ufd;
 	int nfds;
 	int res = 0;
 
-	res = hdb_handle_get (&totemudp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
 	instance->flushing = 1;
 
 	do {
@@ -1881,93 +1827,53 @@ int totemudp_recv_flush (hdb_handle_t handle)
 
 	instance->flushing = 0;
 
-	hdb_handle_put (&totemudp_instance_database, handle);
-
-error_exit:
 	return (res);
 }
 
-int totemudp_send_flush (hdb_handle_t handle)
+int totemudp_send_flush (void *udp_context)
 {
-	struct totemudp_instance *instance;
+	struct totemudp_instance *instance = (struct totemudp_instance *)udp_context;
 	int res = 0;
 
-	res = hdb_handle_get (&totemudp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
 	worker_thread_group_wait (&instance->worker_thread_group);
 
-	hdb_handle_put (&totemudp_instance_database, handle);
-
-error_exit:
 	return (res);
 }
 
 int totemudp_token_send (
-	hdb_handle_t handle,
+	void *udp_context,
 	const void *msg,
 	unsigned int msg_len)
 {
-	struct totemudp_instance *instance;
+	struct totemudp_instance *instance = (struct totemudp_instance *)udp_context;
 	int res = 0;
 
-	res = hdb_handle_get (&totemudp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
 	ucast_sendmsg (instance, &instance->token_target, msg, msg_len);
 
-	hdb_handle_put (&totemudp_instance_database, handle);
-
-error_exit:
 	return (res);
 }
 int totemudp_mcast_flush_send (
-	hdb_handle_t handle,
+	void *udp_context,
 	const void *msg,
 	unsigned int msg_len)
 {
-	struct totemudp_instance *instance;
+	struct totemudp_instance *instance = (struct totemudp_instance *)udp_context;
 	int res = 0;
 
-	res = hdb_handle_get (&totemudp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
 	mcast_sendmsg (instance, msg, msg_len);
 
-	hdb_handle_put (&totemudp_instance_database, handle);
-
-error_exit:
 	return (res);
 }
 
 int totemudp_mcast_noflush_send (
-	hdb_handle_t handle,
+	void *udp_context,
 	const void *msg,
 	unsigned int msg_len)
 {
-	struct totemudp_instance *instance;
+	struct totemudp_instance *instance = (struct totemudp_instance *)udp_context;
 	struct work_item work_item;
 	int res = 0;
 
-	res = hdb_handle_get (&totemudp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
 	if (instance->totem_config->threads) {
 		work_item.msg = msg;
 		work_item.msg_len = msg_len;
@@ -1979,31 +1885,20 @@ int totemudp_mcast_noflush_send (
 		mcast_sendmsg (instance, msg, msg_len);
 	}
 
-	hdb_handle_put (&totemudp_instance_database, handle);
-error_exit:
 	return (res);
 }
 
-extern int totemudp_iface_check (hdb_handle_t handle)
+extern int totemudp_iface_check (void *udp_context)
 {
-	struct totemudp_instance *instance;
+	struct totemudp_instance *instance = (struct totemudp_instance *)udp_context;
 	int res = 0;
 
-	res = hdb_handle_get (&totemudp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		res = ENOENT;
-		goto error_exit;
-	}
-
 	timer_function_netif_check_timeout (instance);
 
-	hdb_handle_put (&totemudp_instance_database, handle);
-error_exit:
 	return (res);
 }
 
-extern void totemudp_net_mtu_adjust (hdb_handle_t handle, struct totem_config *totem_config)
+extern void totemudp_net_mtu_adjust (void *udp_context, struct totem_config *totem_config)
 {
 #define UDPIP_HEADER_SIZE (20 + 8) /* 20 bytes for ip 8 bytes for udp */
 	if (totem_config->secauth == 1) {
@@ -2014,72 +1909,44 @@ extern void totemudp_net_mtu_adjust (hdb_handle_t handle, struct totem_config *t
 	}
 }
 
-const char *totemudp_iface_print (hdb_handle_t handle)  {
-	struct totemudp_instance *instance;
-	int res = 0;
+const char *totemudp_iface_print (void *udp_context)  {
+	struct totemudp_instance *instance = (struct totemudp_instance *)udp_context;
 	const char *ret_char;
 
-	res = hdb_handle_get (&totemudp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		ret_char = "Invalid totemudp handle";
-		goto error_exit;
-	}
-
 	ret_char = totemip_print (&instance->my_id);
 
-	hdb_handle_put (&totemudp_instance_database, handle);
-error_exit:
 	return (ret_char);
 }
 
 int totemudp_iface_get (
-	hdb_handle_t handle,
+	void *udp_context,
 	struct totem_ip_address *addr)
 {
-	struct totemudp_instance *instance;
-	unsigned int res;
-
-	res = hdb_handle_get (&totemudp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		goto error_exit;
-	}
+	struct totemudp_instance *instance = (struct totemudp_instance *)udp_context;
+	int res = 0;
 
 	memcpy (addr, &instance->my_id, sizeof (struct totem_ip_address));
 
-	hdb_handle_put (&totemudp_instance_database, handle);
-
-error_exit:
 	return (res);
 }
 
 int totemudp_token_target_set (
-	hdb_handle_t handle,
+	void *udp_context,
 	const struct totem_ip_address *token_target)
 {
-	struct totemudp_instance *instance;
-	unsigned int res;
-
-	res = hdb_handle_get (&totemudp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		goto error_exit;
-	}
+	struct totemudp_instance *instance = (struct totemudp_instance *)udp_context;
+	int res = 0;
 
 	memcpy (&instance->token_target, token_target,
 		sizeof (struct totem_ip_address));
 
-	hdb_handle_put (&totemudp_instance_database, handle);
-
-error_exit:
 	return (res);
 }
 
 extern int totemudp_recv_mcast_empty (
-	hdb_handle_t handle)
+	void *udp_context)
 {
-	struct totemudp_instance *instance;
+	struct totemudp_instance *instance = (struct totemudp_instance *)udp_context;
 	unsigned int res;
 	struct sockaddr_storage system_from;
 	struct msghdr msg_recv;
@@ -2087,12 +1954,6 @@ extern int totemudp_recv_mcast_empty (
 	int nfds;
 	int msg_processed = 0;
 
-	res = hdb_handle_get (&totemudp_instance_database, handle,
-		(void *)&instance);
-	if (res != 0) {
-		goto error_exit;
-	}
-
 	/*
 	 * Receive datagram
 	 */
@@ -2123,11 +1984,6 @@ extern int totemudp_recv_mcast_empty (
 		}
 	} while (nfds == 1);
 
-	hdb_handle_put (&totemudp_instance_database, handle);
-
 	return (msg_processed);
-
-error_exit:
-	return (res);
 }
 

+ 15 - 15
exec/totemudp.h

@@ -45,7 +45,7 @@
  */
 extern int totemudp_initialize (
 	hdb_handle_t poll_handle,
-	hdb_handle_t *handle,
+	void **udp_context,
 	struct totem_config *totem_config,
 	int interface_no,
 	void *context,
@@ -60,49 +60,49 @@ extern int totemudp_initialize (
 		const struct totem_ip_address *iface_address));
 
 extern int totemudp_processor_count_set (
-	hdb_handle_t handle,
+	void *udp_context,
 	int processor_count);
 
 extern int totemudp_token_send (
-	hdb_handle_t handle,
+	void *udp_context,
 	const void *msg,
 	unsigned int msg_len);
 
 extern int totemudp_mcast_flush_send (
-	hdb_handle_t handle,
+	void *udp_context,
 	const void *msg,
 	unsigned int msg_len);
 
 extern int totemudp_mcast_noflush_send (
-	hdb_handle_t handle,
+	void *udp_context,
 	const void *msg,
 	unsigned int msg_len);
 
-extern int totemudp_recv_flush (hdb_handle_t handle);
+extern int totemudp_recv_flush (void *udp_context);
 
-extern int totemudp_send_flush (hdb_handle_t handle);
+extern int totemudp_send_flush (void *udp_context);
 
-extern int totemudp_iface_check (hdb_handle_t handle);
+extern int totemudp_iface_check (void *udp_context);
 
-extern int totemudp_finalize (hdb_handle_t handle);
+extern int totemudp_finalize (void *udp_context);
 
-extern void totemudp_net_mtu_adjust (hdb_handle_t handle, struct totem_config *totem_config);
+extern void totemudp_net_mtu_adjust (void *udp_context, struct totem_config *totem_config);
 
-extern const char *totemudp_iface_print (hdb_handle_t handle);
+extern const char *totemudp_iface_print (void *udp_context);
 
 extern int totemudp_iface_get (
-	hdb_handle_t handle,
+	void *udp_context,
 	struct totem_ip_address *addr);
 
 extern int totemudp_token_target_set (
-	hdb_handle_t handle,
+	void *udp_context,
 	const struct totem_ip_address *token_target);
 
 extern int totemudp_crypto_set (
-	hdb_handle_t handle,
+	void *udp_context,
 	unsigned int type);
 
 extern int totemudp_recv_mcast_empty (
-	hdb_handle_t handle);
+	void *udp_context);
 
 #endif /* TOTEMUDP_H_DEFINED */