MCPcopy Create free account
hub / github.com/corosync/corosync / main

Function main

test/testcfg.c:64–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62
63
64int main (int argc, char *argv[]) {
65 corosync_cfg_handle_t cfg_handle;
66 corosync_cfg_handle_t cfg_handle1;
67 unsigned int local_nodeid;
68 int i;
69 int res;
70 struct corosync_cfg_node_status_v1 ns;
71 pthread_t thread;
72 corosync_cfg_callbacks_t callbacks = {
73 .corosync_cfg_shutdown_callback = shutdown_callback
74 };
75
76 res = corosync_cfg_initialize(&cfg_handle, &callbacks);
77 if (res != CS_OK) {
78 fprintf(stderr, "corosync_Cfg_initialize(0) failed: %d\n", res);
79 return 1;
80 }
81
82 /* Start a new handle & thread to prevent the shutdown we request later on */
83 res = corosync_cfg_initialize(&cfg_handle1, &callbacks);
84 if (res != CS_OK) {
85 fprintf(stderr, "corosync_cfg_initialize(1) failed: %d\n", res);
86 return 1;
87 }
88 res = corosync_cfg_trackstart(cfg_handle1, 0);
89 if (res != CS_OK) {
90 fprintf(stderr, "corosync_cfg_initialize(1) failed: %d\n", res);
91 return 1;
92 }
93 res = pthread_create(&thread, NULL, dispatch_thread, (void*)cfg_handle1);
94 if (res != 0) {
95 perror("pthread_create failed");
96 return 1;
97 }
98
99 /* Exercise a few functions */
100 res = corosync_cfg_local_get(cfg_handle, &local_nodeid);
101 if (res != CS_OK) {
102 fprintf(stderr, "corosync_cfg_local_get failed: %d\n", res);
103 return 1;
104 }
105
106 printf("Local nodeid is %d\n", local_nodeid);
107
108 /*
109 * Test node_status_get.
110 * node status for the local node looks odd (cos it's the loopback connection), so
111 * we try for a node ID one less or more than us just to get output that looks
112 * sensible to the user.
113 */
114 res = corosync_cfg_node_status_get(cfg_handle, local_nodeid-1, CFG_NODE_STATUS_V1, &ns);
115 if (res != CS_OK) {
116 res = corosync_cfg_node_status_get(cfg_handle, local_nodeid+1, CFG_NODE_STATUS_V1, &ns);
117 }
118 if (res != CS_OK) {
119 fprintf(stderr, "corosync_cfg_node_status_get failed: %d\n", res);
120 return 1;
121 }

Callers

nothing calls this directly

Calls 6

corosync_cfg_initializeFunction · 0.85
corosync_cfg_trackstartFunction · 0.85
corosync_cfg_local_getFunction · 0.85
corosync_cfg_trackstopFunction · 0.85

Tested by

no test coverage detected