| 1741 | |
| 1742 | |
| 1743 | static int dr_init(void) |
| 1744 | { |
| 1745 | pv_spec_t avp_spec; |
| 1746 | unsigned short dummy; |
| 1747 | str name_w_part; |
| 1748 | struct head_cache *cache = NULL; |
| 1749 | struct head_config * it_head_config = 0; |
| 1750 | struct head_db *db_part = NULL; |
| 1751 | char name_w_buf[MAX_LEN_NAME_W_PART]; |
| 1752 | name_w_part.s = name_w_buf; |
| 1753 | |
| 1754 | LM_INFO("dynamic routing - initializing\n"); |
| 1755 | reload_lock = lock_init_rw(); |
| 1756 | if (!reload_lock) { |
| 1757 | LM_ERR("failed to init rw lock for dr_reload\n"); |
| 1758 | return -1; |
| 1759 | } |
| 1760 | |
| 1761 | n_partitions = shm_malloc(sizeof *n_partitions); |
| 1762 | if (!n_partitions) { |
| 1763 | LM_ERR("oom\n"); |
| 1764 | return -1; |
| 1765 | } |
| 1766 | *n_partitions = 0; |
| 1767 | |
| 1768 | drd_table.len = strlen(drd_table.s); |
| 1769 | drg_table.len = strlen(drg_table.s); |
| 1770 | drr_table.len = strlen(drr_table.s); |
| 1771 | drc_table.len = strlen(drc_table.s); |
| 1772 | extra_id_chars.len = strlen(extra_id_chars.s); |
| 1773 | |
| 1774 | if (dr_rpm_enable) { |
| 1775 | /* if we are using cache, we need to fetch our dr zone */ |
| 1776 | if (rpm_init_mem() < 0) { |
| 1777 | LM_ERR("could not initilize restart persistency memory!\n"); |
| 1778 | return -1; |
| 1779 | } |
| 1780 | dr_cache = (struct head_cache *)rpm_key_get("drouting"); |
| 1781 | if (!dr_cache) |
| 1782 | LM_INFO("starting drouting with empty cache\n"); |
| 1783 | else |
| 1784 | LM_INFO("starting drouting with cache head=%p\n", dr_cache); |
| 1785 | |
| 1786 | LM_NOTICE("using %ld MB of restart-persistent memory, allocator: %s\n", |
| 1787 | rpm_mem_size/1024/1024, mm_str(mem_allocator_rpm)); |
| 1788 | } |
| 1789 | |
| 1790 | /* register dr callbacks for sorting */ |
| 1791 | if (register_dr_cb(DRCB_SORT_DST, no_sort_cb, (void *)NO_SORT, NULL) < 0) { |
| 1792 | LM_ERR("failed to register no_sort cb\n"); |
| 1793 | return -1; |
| 1794 | } |
| 1795 | |
| 1796 | if (register_dr_cb(DRCB_SORT_DST, weight_based_sort_cb, |
| 1797 | (void *)WEIGHT_BASED_SORT, NULL) < 0) { |
| 1798 | LM_ERR("failed to register weight_based_sort cb\n"); |
| 1799 | return -1; |
| 1800 | } |
nothing calls this directly
no test coverage detected