| 1346 | static void clean_profiles(unsigned int ticks, void *param); |
| 1347 | |
| 1348 | int repl_prof_init(void) |
| 1349 | { |
| 1350 | if (!profile_repl_cluster) |
| 1351 | return 0; |
| 1352 | |
| 1353 | if (repl_prof_timer_check < 0) { |
| 1354 | LM_ERR("negative replicate timer for profiles check %d\n", |
| 1355 | repl_prof_timer_check); |
| 1356 | return -1; |
| 1357 | } |
| 1358 | |
| 1359 | if (repl_prof_timer_expire < 0) { |
| 1360 | LM_ERR("negative replicate expire timer for profiles %d\n", |
| 1361 | repl_prof_timer_expire); |
| 1362 | return -1; |
| 1363 | } |
| 1364 | |
| 1365 | if (register_timer("dialog-repl-profiles-timer", clean_profiles, NULL, |
| 1366 | repl_prof_timer_check, TIMER_FLAG_DELAY_ON_DELAY) < 0) { |
| 1367 | LM_ERR("failed to register profiles utimer\n"); |
| 1368 | return -1; |
| 1369 | } |
| 1370 | |
| 1371 | if (repl_prof_utimer < 0) { |
| 1372 | LM_ERR("negative replicate timer for profiles %d\n", repl_prof_utimer); |
| 1373 | return -1; |
| 1374 | } |
| 1375 | |
| 1376 | if (repl_prof_buffer_th < 0) { |
| 1377 | LM_ERR("negative replicate buffer threshold for profiles %d\n", |
| 1378 | repl_prof_buffer_th); |
| 1379 | return -1; |
| 1380 | } |
| 1381 | |
| 1382 | if (register_utimer("dialog-repl-profiles-utimer", broadcast_profiles, NULL, |
| 1383 | repl_prof_utimer * 1000, TIMER_FLAG_DELAY_ON_DELAY) < 0) { |
| 1384 | LM_ERR("failed to register profiles utimer\n"); |
| 1385 | return -1; |
| 1386 | } |
| 1387 | |
| 1388 | |
| 1389 | if (repl_prof_buffer_th > (BUF_SIZE * 0.9)) { |
| 1390 | LM_WARN("Buffer size too big %d - profiles information might get lost", |
| 1391 | repl_prof_buffer_th); |
| 1392 | return -1; |
| 1393 | } |
| 1394 | |
| 1395 | return 0; |
| 1396 | } |
| 1397 | |
| 1398 | /* profiles replication */ |
| 1399 | static inline void dlg_replicate_profiles(bin_packet_t *packet) |
no test coverage detected