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

Function add_node_info

modules/clusterer/node_info.c:79–305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77int load_cluster_bridges(cluster_info_t *cl_list);
78
79int add_node_info(node_info_t **new_info, cluster_info_t **cl_list, int *int_vals,
80 str *str_vals)
81{
82 char *host;
83 int hlen, port;
84 int proto;
85 struct hostent *he;
86 int cluster_id;
87 cluster_info_t *cluster = NULL;
88 struct timeval t;
89 str st;
90 str seed_flag = str_init(SEED_NODE_FLAG_STR);
91
92 cluster_id = int_vals[INT_VALS_CLUSTER_ID_COL];
93 /* new_info is checked whether it is initialized or not in case of error,
94 * so we have to initialize it as soon as possible */
95 *new_info = NULL;
96
97 for (cluster = *cl_list; cluster && cluster->cluster_id != cluster_id;
98 cluster = cluster->next) ;
99
100 if (!cluster) {
101 cluster = shm_malloc(sizeof *cluster);
102 if (!cluster) {
103 LM_ERR("no more shm memory\n");
104 goto error;
105 }
106 memset(cluster, 0, sizeof *cluster);
107
108 cluster->cluster_id = cluster_id;
109 cluster->next = *cl_list;
110 if ((cluster->lock = lock_alloc()) == NULL) {
111 LM_CRIT("Failed to allocate lock\n");
112 goto error;
113 }
114 if (!lock_init(cluster->lock)) {
115 lock_dealloc(cluster->lock);
116 LM_CRIT("Failed to init lock\n");
117 goto error;
118 }
119 *cl_list = cluster;
120 }
121
122 if (get_node_by_id(cluster, int_vals[INT_VALS_NODE_ID_COL])) {
123 LM_DBG("Node [%d] already exists\n", int_vals[INT_VALS_NODE_ID_COL]);
124 return 0;
125 }
126
127 *new_info = shm_malloc(sizeof **new_info);
128 if (!*new_info) {
129 LM_ERR("no more shm memory\n");
130 goto error;
131 }
132 memset(*new_info, 0, sizeof **new_info);
133
134 (*new_info)->flags = 0;
135
136 (*new_info)->id = int_vals[INT_VALS_ID_COL];

Callers 4

load_db_infoFunction · 0.85
provision_neighborFunction · 0.85
provision_currentFunction · 0.85
add_nodeFunction · 0.85

Calls 9

shm_mallocFunction · 0.85
lock_initFunction · 0.85
get_node_by_idFunction · 0.85
parse_phostportFunction · 0.85
sip_resolvehostFunction · 0.85
hostent2suFunction · 0.85
su2ip_addrFunction · 0.85
ip_addr2aFunction · 0.85
shm_freeFunction · 0.85

Tested by

no test coverage detected