[Openais] gmi_token_callback in AMF

Miyotaka Sakai sakai.miyotaka at nttcom.co.jp
Sun Oct 31 17:36:03 PST 2004


Steve ,

I made the path attached to this E-mail.
Could you review this patch ?

It has implemeted gmi_token_callback in AMF .

Thanks
- Miyotaka Sakai
-------------- next part --------------
--- openais.latest/exec/amf.c	2004-10-31 09:05:16.000000000 +0900
+++ openais/exec/amf.c	2004-11-01 10:13:47.000000000 +0900
@@ -88,7 +88,6 @@
 	AMF_ENABLED_STOPPING
 };
 
-
 /*
  * State machines for states in AMF
  */
@@ -252,6 +251,10 @@
 
 static void amf_synchronize (void *message, struct in_addr source_addr);
 
+static void amf_mcast (struct iovec *iovec, int iov_len, int priority);
+
+static int amf_mcast_retain ();
+
 static int message_handler_req_exec_amf_componentregister (void *message, struct in_addr source_addr);
 
 static int message_handler_req_exec_amf_componentunregister (void *message, struct in_addr source_addr);
@@ -407,6 +410,17 @@
 	.exec_dump_fn				= amf_dump
 };
 
+static DECLARE_LIST_INIT (mcast_list);
+
+struct mcast_data {
+	struct list_head	mlist;
+	struct iovec		*iovec;
+	int			iov_len;
+	int			priority;
+};
+
+static void *tok_call_handle = NULL;
+
 static void grow_amf_track_table (struct conn_info *conn_info, int growby)
 {
 	struct libamf_ci_trackentry *tracks;
@@ -516,7 +530,7 @@
 	iovecs[0].iov_base = (char *)&req_exec_amf_componentunregister;
 	iovecs[0].iov_len = sizeof (req_exec_amf_componentunregister);
 
-	assert (gmi_mcast (&aisexec_groupname, iovecs, 1, priority) == 0);
+	amf_mcast (iovecs, 1, priority);
 }
 
 static void component_unregister (
@@ -561,7 +575,7 @@
 	iovecs[0].iov_base = (char *)&req_exec_amf_componentregister;
 	iovecs[0].iov_len = sizeof (req_exec_amf_componentregister);
 
-	assert (gmi_mcast (&aisexec_groupname, iovecs, 1, priority) == 0);
+	amf_mcast (iovecs, 1, priority);
 }
 
 /***
@@ -784,7 +798,7 @@
 	iovecs[0].iov_base = (char *)&req_exec_amf_hastateset;
 	iovecs[0].iov_len = sizeof (req_exec_amf_hastateset);
 
-	assert (gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_HIGH) == 0);
+	amf_mcast (iovecs, 1, GMI_PRIO_HIGH);
 }
 
 void readinessStateSetApi (struct saAmfComponent *component,
@@ -875,7 +889,7 @@
 	iovecs[0].iov_base = (char *)&req_exec_amf_readinessstateset;
 	iovecs[0].iov_len = sizeof (req_exec_amf_readinessstateset);
 
-	assert (gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_HIGH) == 0);
+	amf_mcast (iovecs, 1, GMI_PRIO_HIGH);
 }
 
 #ifdef CMOPILE_OUT
@@ -1500,7 +1514,7 @@
 	iovecs[0].iov_base = (char *)&req_exec_amf_errorreport;
 	iovecs[0].iov_len = sizeof (req_exec_amf_errorreport);
 
-	assert (gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED) == 0);
+	amf_mcast (iovecs, 1, GMI_PRIO_MED);
 }
 
 int healthcheck_instance = 0;
@@ -2348,7 +2362,7 @@
 	iovecs[0].iov_base = (char *)&req_exec_amf_componentregister;
 	iovecs[0].iov_len = sizeof (req_exec_amf_componentregister);
 
-	assert (gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED) == 0);
+	amf_mcast (iovecs, 1, GMI_PRIO_MED);
 
 	return (0);
 }
@@ -2376,8 +2390,7 @@
 	iovecs[0].iov_base = (char *)&req_exec_amf_componentunregister;
 	iovecs[0].iov_len = sizeof (req_exec_amf_componentunregister);
 
-	assert (gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED) == 0);
-
+	amf_mcast (iovecs, 1, GMI_PRIO_MED);
 	return (0);
 }
 
@@ -2550,7 +2563,7 @@
 //	iovecs[1].iov_base = (char *)&req_lib_amf_errorreport;
 //	iovecs[1].iov_len = sizeof (req_lib_amf_errorreport);
 
-	assert (gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED) == 0);
+	amf_mcast (iovecs, 1, GMI_PRIO_MED);
 
 	return (0);
 }
@@ -2578,7 +2591,7 @@
 //	iovecs[1].iov_base = (char *)&req_lib_amf_errorcancelall;
 //	iovecs[1].iov_len = sizeof (req_lib_amf_errorcancelall);
 
-	assert (gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED) == 0);
+	amf_mcast (iovecs, 1, GMI_PRIO_MED);
 
 	return (0);
 }
@@ -2676,6 +2689,78 @@
 	return (0);
 }
 
+static void amf_mcast (struct iovec *iovec, int iov_len, int priority)
+{
+	int i;
+	int ret;
+	struct mcast_data *mcast;
+	struct iovec *rvec;
+
+	if (mcast_list.next == &mcast_list) {
+		ret = gmi_mcast (&aisexec_groupname, iovec, iov_len, priority);
+		if (ret == 0) {
+			return;
+		}
+		assert (gmi_token_callback_create (&tok_call_handle, amf_mcast_retain, NULL) == 0);
+	}
+
+	mcast = (struct mcast_data *) malloc (sizeof(*mcast));
+	rvec = (struct iovec *) malloc (sizeof (*iovec) * iov_len);
+	assert (rvec != NULL || mcast != NULL);
+
+	for (i=0; i<iov_len; i++) {
+		rvec[i].iov_base = (char *) malloc (iovec[i].iov_len);
+		assert (rvec[i].iov_base != NULL);
+		rvec[i].iov_len = iovec[i].iov_len;
+		memcpy (rvec[i].iov_base, iovec[i].iov_base, rvec[i].iov_len);
+	}
+
+        mcast->iovec = rvec;
+        mcast->iov_len = iov_len;
+        mcast->priority = priority;
+        list_add_tail (&mcast->mlist, &mcast_list);
+
+	return;
+}
+
+static int amf_mcast_retain ()
+{
+	struct list_head *list;
+	struct list_head *list_next;
+	struct mcast_data *mdata;
+	int priority;
+	int i;
+	int ret;
+
+	for (priority=GMI_PRIO_RECOVERY; priority<GMI_PRIO_LOW; priority++) {
+	for (list=mcast_list.next; list != &mcast_list; list=list_next) {
+
+		mdata = list_entry (list, struct mcast_data, mlist);
+		list_next = list->next;
+		if (mdata->priority != priority) {
+			continue;
+		}
+
+		list_del (list);
+
+		ret = gmi_mcast (&aisexec_groupname, mdata->iovec, mdata->iov_len, mdata->priority);
+		if (ret == -1) {
+			list_add (list ,&mcast_list);
+		assert (gmi_token_callback_create (&tok_call_handle, amf_mcast_retain, NULL) == 0);
+			break;
+		}
+
+		for (i=0; i<mdata->iov_len; i++) {
+			free (mdata->iovec[i].iov_base);
+		}
+		free (mdata->iovec);
+		free (mdata);
+	}
+	}
+
+	return (0);
+}
+
 static char disabled_unlocked_state_text[6][64] = {
 	"AMF_DISABLED_UNLOCKED_REGISTEREDORERRORCANCEL",
 	"AMF_DISABLED_UNLOCKED_FAILED",


More information about the Openais mailing list