From 7e8da9a6fc5896aa14606083ecc01a87171d78f0 Mon Sep 17 00:00:00 2001 From: Jan Friesse Date: Thu, 4 Mar 2010 12:12:24 +0000 Subject: [PATCH] Cpg join with undelivered leave message Patch handles situation, when on one node, one process: - join cpg - do same actions - leave cpg - join cpg again Following sequence can (racy) end with broken process_info list. To solve this problem, one more check is done in message_handler_req_lib_cpg_join so if process_info with same pid and group as new join request exists, CPG_ERR_TRY_AGAIN is returned. git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2675 fd59a12c-fef9-0310-b244-a6a79926bd2f --- services/cpg.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/services/cpg.c b/services/cpg.c index 68bd1ed1..af5f6c4e 100644 --- a/services/cpg.c +++ b/services/cpg.c @@ -1067,6 +1067,21 @@ static void message_handler_req_lib_cpg_join (void *conn, const void *message) } } + /* + * Same check must be done in process info list, because there may be not yet delivered + * leave of client. + */ + for (iter = process_info_list_head.next; iter != &process_info_list_head; iter = iter->next) { + struct process_info *pi = list_entry (iter, struct process_info, list); + + if (pi->nodeid == api->totem_nodeid_get () && pi->pid == req_lib_cpg_join->pid && + mar_name_compare(&req_lib_cpg_join->group_name, &pi->group) == 0) { + /* We have same pid and group name joined -> return error */ + error = CPG_ERR_TRY_AGAIN; + goto response_send; + } + } + switch (cpd->cpd_state) { case CPD_STATE_UNJOINED: error = CPG_OK;