MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / lb_init_cluster

Function lb_init_cluster

modules/load_balancer/lb_clustering.c:173–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171}
172
173int lb_init_cluster(void)
174{
175 if (load_clusterer_api(&c_api)!=0) {
176 LM_ERR("failed to find clusterer API - is clusterer "
177 "module loaded?\n");
178 return -1;
179 }
180
181 /* register handler for processing load-balancer packets
182 * to the clusterer module */
183 if (c_api.register_capability( &status_repl_cap,
184 receive_lb_binary_packet, receive_lb_cluster_event, lb_cluster_id, 1,
185 NODE_CMP_ANY) < 0) {
186 LM_ERR("cannot register binary packet callback to "
187 "clusterer module!\n");
188 return -1;
189 }
190
191 /* "register" the sharing tag */
192 if (lb_cluster_shtag.s) {
193 lb_cluster_shtag.len = strlen(lb_cluster_shtag.s);
194 if (c_api.shtag_get( &lb_cluster_shtag, lb_cluster_id)<0) {
195 LM_ERR("failed to initialized the sharing tag <%.*s>\n",
196 lb_cluster_shtag.len, lb_cluster_shtag.s);
197 return -1;
198 }
199 } else {
200 lb_cluster_shtag.len = 0;
201 }
202
203 if (c_api.request_sync(&status_repl_cap, lb_cluster_id, 0) < 0) {
204 LM_ERR("Sync request failed\n");
205 return -1;
206 }
207
208 if (lb_cluster_sync() < 0)
209 return -1;
210
211 return 0;
212}

Callers 1

mod_initFunction · 0.85

Calls 2

load_clusterer_apiFunction · 0.85
lb_cluster_syncFunction · 0.85

Tested by

no test coverage detected