| 171 | } |
| 172 | |
| 173 | int 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 | } |
no test coverage detected