~ubuntu-branches/ubuntu/precise/corosync/precise-proposed

« back to all changes in this revision

Viewing changes to services/cpg.c

  • Committer: Bazaar Package Importer
  • Author(s): Andres Rodriguez
  • Date: 2010-07-02 01:24:53 UTC
  • mfrom: (1.1.4 upstream) (5.1.9 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100702012453-qky79tg6hjly2dmq
Tags: 1.2.1-1ubuntu1
* Merge from debian unstable (LP: #600900). Remaining changes:
  - Raised consensus time out to 5000ms
  - debian/control, debian/rules: Removing now-unnecessary quilt build-dep

Show diffs side-by-side

added added

removed removed

Lines of Context:
214
214
 
215
215
static void message_handler_req_lib_cpg_leave (void *conn, const void *message);
216
216
 
 
217
static void message_handler_req_lib_cpg_finalize (void *conn, const void *message);
 
218
 
217
219
static void message_handler_req_lib_cpg_mcast (void *conn, const void *message);
218
220
 
219
221
static void message_handler_req_lib_cpg_membership (void *conn,
240
242
 
241
243
static int cpg_exec_send_joinlist(void);
242
244
 
243
 
static void cpg_sync_init (
 
245
static void cpg_sync_init_v2 (
 
246
        const unsigned int *trans_list,
 
247
        size_t trans_list_entries,
244
248
        const unsigned int *member_list,
245
249
        size_t member_list_entries,
246
250
        const struct memb_ring_id *ring_id);
288
292
                .lib_handler_fn                         = message_handler_req_lib_cpg_iteration_finalize,
289
293
                .flow_control                           = CS_LIB_FLOW_CONTROL_NOT_REQUIRED
290
294
        },
 
295
        { /* 8 */
 
296
                .lib_handler_fn                         = message_handler_req_lib_cpg_finalize,
 
297
                .flow_control                           = CS_LIB_FLOW_CONTROL_REQUIRED
 
298
        },
291
299
};
292
300
 
293
301
static struct corosync_exec_handler cpg_exec_engine[] =
329
337
        .exec_dump_fn                           = NULL,
330
338
        .exec_engine                            = cpg_exec_engine,
331
339
        .exec_engine_count                      = sizeof (cpg_exec_engine) / sizeof (struct corosync_exec_handler),
332
 
        .sync_mode                              = CS_SYNC_V1,
333
 
        .sync_init                              = cpg_sync_init,
 
340
        .sync_mode                              = CS_SYNC_V1_APIV2,
 
341
        .sync_init                              = (sync_init_v1_fn_t)cpg_sync_init_v2,
334
342
        .sync_process                           = cpg_sync_process,
335
343
        .sync_activate                          = cpg_sync_activate,
336
344
        .sync_abort                             = cpg_sync_abort
406
414
 
407
415
static struct req_exec_cpg_downlist g_req_exec_cpg_downlist;
408
416
 
409
 
static void cpg_sync_init (
 
417
static void cpg_sync_init_v2 (
 
418
        const unsigned int *trans_list,
 
419
        size_t trans_list_entries,
410
420
        const unsigned int *member_list,
411
421
        size_t member_list_entries,
412
422
        const struct memb_ring_id *ring_id)
435
445
                 */
436
446
                for (i = 0; i < my_old_member_list_entries; i++) {
437
447
                        found = 0;
438
 
                        for (j = 0; j < my_member_list_entries; j++) {
439
 
                                if (my_old_member_list[i] == my_member_list[j]) {
 
448
                        for (j = 0; j < trans_list_entries; j++) {
 
449
                                if (my_old_member_list[i] == trans_list[j]) {
440
450
                                        found = 1;
441
451
                                        break;
442
452
                                }
1063
1073
                }
1064
1074
        }
1065
1075
 
 
1076
        /*
 
1077
         * Same check must be done in process info list, because there may be not yet delivered
 
1078
         * leave of client.
 
1079
         */
 
1080
        for (iter = process_info_list_head.next; iter != &process_info_list_head; iter = iter->next) {
 
1081
                struct process_info *pi = list_entry (iter, struct process_info, list);
 
1082
 
 
1083
                if (pi->nodeid == api->totem_nodeid_get () && pi->pid == req_lib_cpg_join->pid &&
 
1084
                    mar_name_compare(&req_lib_cpg_join->group_name, &pi->group) == 0) {
 
1085
                        /* We have same pid and group name joined -> return error */
 
1086
                        error = CPG_ERR_TRY_AGAIN;
 
1087
                        goto response_send;
 
1088
                }
 
1089
        }
 
1090
 
1066
1091
        switch (cpd->cpd_state) {
1067
1092
        case CPD_STATE_UNJOINED:
1068
1093
                error = CPG_OK;
1130
1155
        api->ipc_response_send(conn, &res_lib_cpg_leave, sizeof(res_lib_cpg_leave));
1131
1156
}
1132
1157
 
 
1158
/* Finalize message from library */
 
1159
static void message_handler_req_lib_cpg_finalize (
 
1160
        void *conn,
 
1161
        const void *message)
 
1162
{
 
1163
        struct cpg_pd *cpd = (struct cpg_pd *)api->ipc_private_data_get (conn);
 
1164
        struct res_lib_cpg_finalize res_lib_cpg_finalize;
 
1165
        cs_error_t error = CS_OK;
 
1166
 
 
1167
        log_printf (LOGSYS_LEVEL_DEBUG, "cpg finalize for conn=%p\n", conn);
 
1168
 
 
1169
        /*
 
1170
         * We will just remove cpd from list. After this call, connection will be
 
1171
         * closed on lib side, and cpg_lib_exit_fn will be called
 
1172
         */
 
1173
        list_del (&cpd->list);
 
1174
        list_init (&cpd->list);
 
1175
 
 
1176
        res_lib_cpg_finalize.header.size = sizeof (res_lib_cpg_finalize);
 
1177
        res_lib_cpg_finalize.header.id = MESSAGE_RES_CPG_FINALIZE;
 
1178
        res_lib_cpg_finalize.header.error = error;
 
1179
 
 
1180
        api->ipc_response_send (conn, &res_lib_cpg_finalize,
 
1181
                sizeof (res_lib_cpg_finalize));
 
1182
}
 
1183
 
1133
1184
/* Mcast message from the library */
1134
1185
static void message_handler_req_lib_cpg_mcast (void *conn, const void *message)
1135
1186
{