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

Fix race condition in cpg service.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2201 fd59a12c-fef9-0310-b244-a6a79926bd2f
Steven Dake 16 лет назад
Родитель
Сommit
6bda597dbc
1 измененных файлов с 11 добавлено и 7 удалено
  1. 11 7
      services/cpg.c

+ 11 - 7
services/cpg.c

@@ -455,9 +455,19 @@ static int notify_lib_joinlist(
 		for (iter = cpg_pd_list_head.next; iter != &cpg_pd_list_head; iter = iter->next) {
 			struct cpg_pd *cpd = list_entry (iter, struct cpg_pd, list);
 			if (mar_name_compare (&cpd->group_name, group_name) == 0) {
-				api->ipc_dispatch_send (cpd->conn, buf, size);
 				assert (left_list_entries <= 1);
 				assert (joined_list_entries <= 1);
+				if (joined_list_entries) {
+					if (joined_list[0].pid == cpd->pid &&
+						joined_list[0].nodeid == api->totem_nodeid_get()) {
+						cpd->cpd_state = CPD_STATE_JOIN_COMPLETED;
+					}
+				}
+				if (cpd->cpd_state == CPD_STATE_JOIN_COMPLETED ||
+					cpd->cpd_state == CPD_STATE_LEAVE_STARTED) {
+
+					api->ipc_dispatch_send (cpd->conn, buf, size);
+				}
 				if (left_list_entries) {
 					if (left_list[0].pid == cpd->pid &&
 						left_list[0].nodeid == api->totem_nodeid_get()) {
@@ -467,12 +477,6 @@ static int notify_lib_joinlist(
 						cpd->cpd_state = CPD_STATE_UNJOINED;
 					}
 				}
-				if (joined_list_entries) {
-					if (joined_list[0].pid == cpd->pid &&
-						joined_list[0].nodeid == api->totem_nodeid_get()) {
-						cpd->cpd_state = CPD_STATE_JOIN_COMPLETED;
-					}
-				}
 			}
 		}
 	}