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

« back to all changes in this revision

Viewing changes to services/cfg.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Loschwitz
  • Date: 2011-10-19 14:32:18 UTC
  • mfrom: (1.1.6 upstream) (5.1.16 sid)
  • Revision ID: james.westby@ubuntu.com-20111019143218-ew8phl0raqyog844
Tags: 1.4.2-1
* Changed my email address in debian/control
* Add corosync-blackbox to the corosync package
* Imported Upstream version 1.4.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
379
379
{
380
380
        struct req_exec_cfg_shutdown req_exec_cfg_shutdown;
381
381
        struct iovec iovec;
 
382
        int result;
382
383
 
383
384
        ENTER();
384
385
        req_exec_cfg_shutdown.header.size =
389
390
        iovec.iov_base = (char *)&req_exec_cfg_shutdown;
390
391
        iovec.iov_len = sizeof (struct req_exec_cfg_shutdown);
391
392
 
392
 
        assert (api->totem_mcast (&iovec, 1, TOTEM_SAFE) == 0);
 
393
        result = api->totem_mcast (&iovec, 1, TOTEM_SAFE);
393
394
 
394
395
        LEAVE();
395
 
        return 0;
 
396
        return (result);
396
397
}
397
398
 
398
399
static void send_test_shutdown(void *only_conn, void *exclude_conn, int status)
426
427
 
427
428
static void check_shutdown_status(void)
428
429
{
 
430
        int result;
 
431
        cs_error_t error = CS_OK;
 
432
 
429
433
        ENTER();
430
434
 
431
435
        /*
448
452
                    shutdown_flags == CFG_SHUTDOWN_FLAG_REGARDLESS) {
449
453
                        TRACE1("shutdown confirmed");
450
454
 
 
455
                        /*
 
456
                         * Tell other nodes we are going down
 
457
                         */
 
458
                        result = send_shutdown();
 
459
                        if (result == -1) {
 
460
                                error = CS_ERR_TRY_AGAIN;
 
461
                        }
 
462
 
451
463
                        res_lib_cfg_tryshutdown.header.size = sizeof(struct res_lib_cfg_tryshutdown);
452
464
                        res_lib_cfg_tryshutdown.header.id = MESSAGE_RES_CFG_TRYSHUTDOWN;
453
 
                        res_lib_cfg_tryshutdown.header.error = CS_OK;
 
465
                        res_lib_cfg_tryshutdown.header.error = error;
454
466
 
455
467
                        /*
456
468
                         * Tell originator that shutdown was confirmed
459
471
                                                    sizeof(res_lib_cfg_tryshutdown));
460
472
                        shutdown_con = NULL;
461
473
 
462
 
                        /*
463
 
                         * Tell other nodes we are going down
464
 
                         */
465
 
                        send_shutdown();
466
474
 
467
475
                }
468
476
                else {
584
592
                        req_exec_cfg_ringreenable->source.conn,
585
593
                        &res_lib_cfg_ringreenable,
586
594
                        sizeof (struct res_lib_cfg_ringreenable));
 
595
 
 
596
                api->ipc_refcnt_dec(req_exec_cfg_ringreenable->source.conn);
587
597
        }
588
598
        LEAVE();
589
599
}
696
706
        const void *msg)
697
707
{
698
708
        struct req_exec_cfg_ringreenable req_exec_cfg_ringreenable;
 
709
        struct res_lib_cfg_ringreenable res_lib_cfg_ringreenable;
699
710
        struct iovec iovec;
 
711
        int result;
700
712
 
701
713
        ENTER();
702
714
        req_exec_cfg_ringreenable.header.size =
704
716
        req_exec_cfg_ringreenable.header.id = SERVICE_ID_MAKE (CFG_SERVICE,
705
717
                MESSAGE_REQ_EXEC_CFG_RINGREENABLE);
706
718
        api->ipc_source_set (&req_exec_cfg_ringreenable.source, conn);
 
719
        api->ipc_refcnt_inc(conn);
707
720
 
708
721
        iovec.iov_base = (char *)&req_exec_cfg_ringreenable;
709
722
        iovec.iov_len = sizeof (struct req_exec_cfg_ringreenable);
710
723
 
711
 
        assert (api->totem_mcast (&iovec, 1, TOTEM_SAFE) == 0);
 
724
        result = api->totem_mcast (&iovec, 1, TOTEM_SAFE);
 
725
 
 
726
        if (result == -1) {
 
727
                res_lib_cfg_ringreenable.header.id = MESSAGE_RES_CFG_RINGREENABLE;
 
728
                res_lib_cfg_ringreenable.header.size = sizeof (struct res_lib_cfg_ringreenable);
 
729
                res_lib_cfg_ringreenable.header.error = CS_ERR_TRY_AGAIN;
 
730
                api->ipc_response_send (
 
731
                        conn,
 
732
                        &res_lib_cfg_ringreenable,
 
733
                        sizeof (struct res_lib_cfg_ringreenable));
 
734
 
 
735
                api->ipc_refcnt_dec(conn);
 
736
        }
712
737
 
713
738
        LEAVE();
714
739
}
833
858
        struct res_lib_cfg_killnode res_lib_cfg_killnode;
834
859
        struct req_exec_cfg_killnode req_exec_cfg_killnode;
835
860
        struct iovec iovec;
836
 
        int res;
 
861
        int result;
 
862
        cs_error_t error = CS_OK;
837
863
 
838
864
        ENTER();
839
865
        req_exec_cfg_killnode.header.size =
846
872
        iovec.iov_base = (char *)&req_exec_cfg_killnode;
847
873
        iovec.iov_len = sizeof (struct req_exec_cfg_killnode);
848
874
 
849
 
        res = api->totem_mcast (&iovec, 1, TOTEM_SAFE);
 
875
        result = api->totem_mcast (&iovec, 1, TOTEM_SAFE);
 
876
        if (result == -1) {
 
877
                error = CS_ERR_TRY_AGAIN;
 
878
        }
850
879
 
851
880
        res_lib_cfg_killnode.header.size = sizeof(struct res_lib_cfg_killnode);
852
881
        res_lib_cfg_killnode.header.id = MESSAGE_RES_CFG_KILLNODE;
853
 
        res_lib_cfg_killnode.header.error = CS_OK;
 
882
        res_lib_cfg_killnode.header.error = error;
854
883
 
855
884
        api->ipc_response_send(conn, &res_lib_cfg_killnode,
856
885
                                    sizeof(res_lib_cfg_killnode));
866
895
        struct cfg_info *ci = (struct cfg_info *)api->ipc_private_data_get (conn);
867
896
        const struct req_lib_cfg_tryshutdown *req_lib_cfg_tryshutdown = msg;
868
897
        struct list_head *iter;
 
898
        int result;
 
899
        cs_error_t error = CS_OK;
869
900
 
870
901
        ENTER();
871
902
 
875
906
                /*
876
907
                 * Tell other nodes
877
908
                 */
878
 
                send_shutdown();
 
909
                result = send_shutdown();
 
910
                if (result == -1) {
 
911
                        error = CS_ERR_TRY_AGAIN;
 
912
                }
879
913
 
880
914
                res_lib_cfg_tryshutdown.header.size = sizeof(struct res_lib_cfg_tryshutdown);
881
915
                res_lib_cfg_tryshutdown.header.id = MESSAGE_RES_CFG_TRYSHUTDOWN;
882
 
                res_lib_cfg_tryshutdown.header.error = CS_OK;
 
916
                res_lib_cfg_tryshutdown.header.error = error;
883
917
                api->ipc_response_send(conn, &res_lib_cfg_tryshutdown,
884
918
                                            sizeof(res_lib_cfg_tryshutdown));
885
919
 
934
968
        if (shutdown_expected == 0) {
935
969
                struct res_lib_cfg_tryshutdown res_lib_cfg_tryshutdown;
936
970
 
 
971
                result = send_shutdown();
 
972
                if (result == -1) {
 
973
                        error = CS_ERR_TRY_AGAIN;
 
974
                }
 
975
 
937
976
                res_lib_cfg_tryshutdown.header.size = sizeof(struct res_lib_cfg_tryshutdown);
938
977
                res_lib_cfg_tryshutdown.header.id = MESSAGE_RES_CFG_TRYSHUTDOWN;
939
 
                res_lib_cfg_tryshutdown.header.error = CS_OK;
 
978
                res_lib_cfg_tryshutdown.header.error = error;
940
979
 
941
980
                /*
942
981
                 * Tell originator that shutdown was confirmed
944
983
                api->ipc_response_send(conn, &res_lib_cfg_tryshutdown,
945
984
                                       sizeof(res_lib_cfg_tryshutdown));
946
985
 
947
 
                send_shutdown();
948
986
                LEAVE();
949
987
                return;
950
988
        }
1040
1078
        const struct req_lib_cfg_get_node_addrs *req_lib_cfg_get_node_addrs = msg;
1041
1079
        struct res_lib_cfg_get_node_addrs *res_lib_cfg_get_node_addrs = (struct res_lib_cfg_get_node_addrs *)buf;
1042
1080
        unsigned int nodeid = req_lib_cfg_get_node_addrs->nodeid;
 
1081
        char *addr_buf;
1043
1082
 
1044
1083
        if (nodeid == 0)
1045
1084
                nodeid = api->totem_nodeid_get();
1052
1091
        res_lib_cfg_get_node_addrs->num_addrs = num_interfaces;
1053
1092
        if (num_interfaces) {
1054
1093
                res_lib_cfg_get_node_addrs->family = node_ifs[0].family;
1055
 
                for (i = 0; i<num_interfaces; i++) {
1056
 
                        memcpy(&res_lib_cfg_get_node_addrs->addrs[i][0], node_ifs[i].addr, TOTEMIP_ADDRLEN);
 
1094
                for (i = 0, addr_buf = (char *)res_lib_cfg_get_node_addrs->addrs;
 
1095
                    i < num_interfaces; i++, addr_buf += TOTEMIP_ADDRLEN) {
 
1096
                        memcpy(addr_buf, node_ifs[i].addr, TOTEMIP_ADDRLEN);
1057
1097
                }
1058
1098
        }
1059
1099
        else {
1084
1124
        struct res_lib_cfg_crypto_set res_lib_cfg_crypto_set;
1085
1125
        struct req_exec_cfg_crypto_set req_exec_cfg_crypto_set;
1086
1126
        struct iovec iovec;
1087
 
        int ret = CS_ERR_INVALID_PARAM;
 
1127
        cs_error_t error = CS_ERR_INVALID_PARAM;
 
1128
        int result;
1088
1129
 
1089
1130
        req_exec_cfg_crypto_set.header.size =
1090
1131
                sizeof (struct req_exec_cfg_crypto_set);
1100
1141
 
1101
1142
                iovec.iov_base = (char *)&req_exec_cfg_crypto_set;
1102
1143
                iovec.iov_len = sizeof (struct req_exec_cfg_crypto_set);
1103
 
                assert (api->totem_mcast (&iovec, 1, TOTEM_SAFE) == 0);
1104
 
                ret = CS_OK;
 
1144
                result = api->totem_mcast (&iovec, 1, TOTEM_SAFE);
 
1145
                if (result == -1) {
 
1146
                        error = CS_ERR_TRY_AGAIN;
 
1147
                } else {
 
1148
                        error = CS_OK;
 
1149
                }
1105
1150
        }
1106
1151
 
1107
1152
        res_lib_cfg_crypto_set.header.size = sizeof(res_lib_cfg_crypto_set);
1108
1153
        res_lib_cfg_crypto_set.header.id = MESSAGE_RES_CFG_CRYPTO_SET;
1109
 
        res_lib_cfg_crypto_set.header.error = ret;
 
1154
        res_lib_cfg_crypto_set.header.error = error;
1110
1155
 
1111
1156
        api->ipc_response_send(conn, &res_lib_cfg_crypto_set,
1112
1157
                sizeof(res_lib_cfg_crypto_set));