| 233 | #undef TM_BIN_POP |
| 234 | |
| 235 | int tm_init_cluster(void) |
| 236 | { |
| 237 | str cid; |
| 238 | |
| 239 | if (tm_repl_cluster == 0) { |
| 240 | LM_DBG("tm_replication_cluster not set - not engaging!\n"); |
| 241 | return 0; |
| 242 | } |
| 243 | |
| 244 | /* fix clusterer param */ |
| 245 | tm_cluster_param.len = strlen(tm_cluster_param.s); |
| 246 | |
| 247 | if (tm_repl_cluster < 0) { |
| 248 | LM_ERR("Invalid value for tm_replication_cluster must be " |
| 249 | "a positive cluster id\n"); |
| 250 | return -1; |
| 251 | } |
| 252 | |
| 253 | if (load_clusterer_api(&cluster_api) < 0) { |
| 254 | LM_WARN("failed to load clusterer API - is the clusterer module loaded?\n"); |
| 255 | return -1; |
| 256 | } |
| 257 | if (cluster_api.register_capability(&tm_repl_cap, receive_tm_repl, NULL, |
| 258 | tm_repl_cluster, 0, NODE_CMP_ANY) < 0) { |
| 259 | LM_ERR("cannot register tm bin processing function\n"); |
| 260 | /* overwrite structure to disable clusterer */ |
| 261 | goto cluster_error; |
| 262 | } |
| 263 | tm_node_id = cluster_api.get_my_id(); |
| 264 | |
| 265 | /* build the via param */ |
| 266 | cid.s = int2str(tm_node_id, &cid.len); |
| 267 | tm_cid.s = pkg_malloc(1/*;*/ + tm_cluster_param.len + 1/*=*/ + cid.len); |
| 268 | if (!tm_cid.s) { |
| 269 | LM_ERR("out of pkg memory!\n"); |
| 270 | goto cluster_error; |
| 271 | } |
| 272 | tm_cid.len = 0; |
| 273 | tm_cid.s[tm_cid.len++] = ';'; |
| 274 | memcpy(tm_cid.s + tm_cid.len, tm_cluster_param.s, tm_cluster_param.len); |
| 275 | tm_cid.len += tm_cluster_param.len; |
| 276 | tm_cid.s[tm_cid.len++] = '='; |
| 277 | memcpy(tm_cid.s + tm_cid.len, cid.s, cid.len); |
| 278 | tm_cid.len += cid.len; |
| 279 | |
| 280 | return 0; |
| 281 | |
| 282 | cluster_error: |
| 283 | cluster_api.register_capability = 0; |
| 284 | return -1; |
| 285 | } |
| 286 | |
| 287 | #define TM_BIN_PUSH(_t, _f, _d) \ |
| 288 | do { \ |
no test coverage detected