From 9c69184ce142ea9d85f8a2733f9724c011f8ba85 Mon Sep 17 00:00:00 2001 From: Steven Dake Date: Tue, 9 Jun 2009 20:31:51 +0000 Subject: [PATCH] Resolve bug where config changes are delivered in the wrong order on nodes that join and then open a cpg. git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2225 fd59a12c-fef9-0310-b244-a6a79926bd2f --- services/cpg.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/services/cpg.c b/services/cpg.c index a0327673..49d587ca 100644 --- a/services/cpg.c +++ b/services/cpg.c @@ -654,7 +654,10 @@ static void do_proc_join( int reason) { struct process_info *pi; + struct process_info *pi_entry; mar_cpg_address_t notify_info; + struct list_head *list; + struct list_head *list_to_add = NULL; if (process_info_find (name, pid, nodeid) != NULL) { return ; @@ -668,7 +671,22 @@ static void do_proc_join( pi->pid = pid; memcpy(&pi->group, name, sizeof(*name)); list_init(&pi->list); - list_add(&pi->list, &process_info_list_head); + + /* + * Insert new process in sorted order so synchronization works properly + */ + list_to_add = &process_info_list_head; + for (list = process_info_list_head.next; list != &process_info_list_head; list = list->next) { + + pi_entry = list_entry(list, struct process_info, list); + if (pi_entry->nodeid > pi->nodeid || + (pi_entry->nodeid == pi->nodeid && pi_entry->pid > pi->pid)) { + + break; + } + list_to_add = list; + } + list_splice (&pi->list, list_to_add); notify_info.pid = pi->pid; notify_info.nodeid = nodeid;