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

Function provision_current

modules/clusterer/node_info.c:781–846  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

779}
780
781int provision_current(modparam_t type, void *val)
782{
783 int int_vals[NO_DB_INT_VALS];
784 str str_vals[NO_DB_STR_VALS];
785 node_info_t *new_info;
786 str prov_str;
787
788 if (db_mode) {
789 LM_INFO("Running in db mode, provisioning from the script is ignored\n");
790 return 0;
791 }
792
793 prov_str.s = (char*)val;
794 prov_str.len = strlen(prov_str.s);
795
796 if (parse_param_node_info(&prov_str, int_vals, str_vals) < 0) {
797 LM_ERR("Unable to define local node\n");
798 return -1;
799 }
800
801 if (int_vals[INT_VALS_CLUSTER_ID_COL] == -1 || str_vals[STR_VALS_URL_COL].s == NULL) {
802 LM_ERR("At least the cluster ID and url are required for the local node\n");
803 return -1;
804 }
805
806 if (int_vals[INT_VALS_NODE_ID_COL] == -1 && current_id == -1) {
807 LM_ERR("Node ID not defined. Set either the value of the 'node_id' proprety"
808 " of 'my_node_info' or set 'my_node_id' parameter before 'my_node_info'!\n");
809 return -1;
810 }
811 if (current_id != -1 && int_vals[INT_VALS_NODE_ID_COL] != -1 &&
812 int_vals[INT_VALS_NODE_ID_COL] != current_id) {
813 LM_ERR("Bad value in 'my_node_info' parameter, node_id: %d different"
814 " than 'my_node_id' parameter\n", int_vals[INT_VALS_NODE_ID_COL]);
815 return -1;
816 }
817 if (int_vals[INT_VALS_NODE_ID_COL] != -1)
818 current_id = int_vals[INT_VALS_NODE_ID_COL];
819 else
820 int_vals[INT_VALS_NODE_ID_COL] = current_id;
821
822 int_vals[INT_VALS_STATE_COL] = 1;
823 if (int_vals[INT_VALS_NO_PING_RETRIES_COL] == -1)
824 int_vals[INT_VALS_NO_PING_RETRIES_COL] = DEFAULT_NO_PING_RETRIES;
825 if (int_vals[INT_VALS_PRIORITY_COL] == -1)
826 int_vals[INT_VALS_PRIORITY_COL] = DEFAULT_NO_PING_RETRIES;
827
828 str_vals[STR_VALS_DESCRIPTION_COL].s = NULL;
829 int_vals[INT_VALS_ID_COL] = -1;
830
831 if (cluster_list == NULL) {
832 cluster_list = shm_malloc(sizeof *cluster_list);
833 if (!cluster_list) {
834 LM_CRIT("No more shm memory\n");
835 return -1;
836 }
837 *cluster_list = NULL;
838 }

Callers

nothing calls this directly

Calls 3

parse_param_node_infoFunction · 0.85
shm_mallocFunction · 0.85
add_node_infoFunction · 0.85

Tested by

no test coverage detected