[PATCH 1/2] Allow only one connection per (node, pid, grp)

Jan Friesse jfriesse at redhat.com
Mon Mar 1 09:09:50 PST 2010


This patch allows only one connection per (node, pid, grp_name) tuple.
This means, you cannot make more connection from one process to same
group_name. This is (I hope) how cpg should behave. In case, you will
try to do that, CPG_ERR_EXISTS error is returned.

Of course, there is no problem with creating:
- more connection with same (pid, grp) if nodeid is different
- more connection with same (node, grp) if pid is different (for example
  after fork, or two distinct processes)
- more connection with same (node, pid) if grp is different (connect
  one process to more cpgs).
---
 branches/whitetank/exec/cpg.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/branches/whitetank/exec/cpg.c b/branches/whitetank/exec/cpg.c
index 5323db2..7a61f1a 100644
--- a/branches/whitetank/exec/cpg.c
+++ b/branches/whitetank/exec/cpg.c
@@ -954,6 +954,20 @@ static void message_handler_req_lib_cpg_join (void *conn, void *message)
 	struct cpg_pd *cpd = (struct cpg_pd *)openais_conn_private_data_get (conn);
 	struct res_lib_cpg_join res_lib_cpg_join;
 	SaAisErrorT error = CPG_OK;
+	struct list_head *iter;
+
+	/* Test, if we don't have same pid and group name joined */
+	for (iter = cpg_pd_list_head.next; iter != &cpg_pd_list_head; iter = iter->next) {
+		struct cpg_pd *cpd_item = list_entry (iter, struct cpg_pd, list);
+
+		if (cpd_item->pid == req_lib_cpg_join->pid &&
+			mar_name_compare(&req_lib_cpg_join->group_name, &cpd_item->group_name) == 0) {
+
+			/* We have same pid and group name joined -> return error */
+			error = CPG_ERR_EXIST;
+			goto response_send;
+		}
+	}
 
 	switch (cpd->cpd_state) {
 	case CPD_STATE_UNJOINED:
@@ -978,6 +992,7 @@ static void message_handler_req_lib_cpg_join (void *conn, void *message)
 		break;
 	}
 
+response_send:
 	res_lib_cpg_join.header.size = sizeof(res_lib_cpg_join);
         res_lib_cpg_join.header.id = MESSAGE_RES_CPG_JOIN;
         res_lib_cpg_join.header.error = error;
-- 
1.5.5.6


--------------000205060808000906040704
Content-Type: text/plain;
 name="0002-Cpg-join-with-undelivered-leave-message.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="0002-Cpg-join-with-undelivered-leave-message.patch"



More information about the Openais mailing list