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

Function cluster_remove_node

modules/clusterer/clusterer_mod.c:1139–1225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1137}
1138
1139static mi_response_t *cluster_remove_node(const mi_params_t *params,
1140 struct mi_handler *async_hdl)
1141{
1142 int cluster_id, node_id;
1143 int rc;
1144 cluster_info_t *cl;
1145 node_info_t *node;
1146 mi_response_t *resp;
1147
1148 if (db_mode)
1149 return init_mi_error(400, MI_SSTR("Running in DB mode"));
1150
1151 if (get_mi_int_param(params, "cluster_id", &cluster_id) < 0)
1152 return init_mi_param_error();
1153 if (cluster_id < 1)
1154 return init_mi_error(400, MI_SSTR("Bad value for 'cluster_id'"));
1155
1156 lock_start_read(cl_list_lock);
1157
1158 cl = get_cluster_by_id(cluster_id);
1159 if (!cl) {
1160 LM_ERR("Unknown cluster id [%d]\n", cluster_id);
1161 resp = init_mi_error(400, MI_SSTR("Unknown cluster id"));
1162 goto error;
1163 }
1164
1165 if (get_mi_int_param(params, "node_id", &node_id) < 0) {
1166 resp = init_mi_param_error();
1167 goto error;
1168 }
1169 if (node_id < 1) {
1170 resp = init_mi_error(400, MI_SSTR("Bad value for 'node_id'"));
1171 goto error;
1172 }
1173
1174 node = get_node_by_id(cl, node_id);
1175 if (!node) {
1176 LM_ERR("Unknown node id [%d]\n", node_id);
1177 resp = init_mi_error(400, MI_SSTR("Unknown node id"));
1178 goto error;
1179 }
1180
1181 lock_stop_read(cl_list_lock);
1182
1183 rc = bcast_remove_node(cluster_id, node_id);
1184 switch (rc) {
1185 case CLUSTERER_SEND_SUCCESS:
1186 LM_DBG("Remove node <%d> command sent\n", node_id);
1187 break;
1188 case CLUSTERER_CURR_DISABLED:
1189 LM_INFO("Local node disabled, remove node <%d> command not sent\n",
1190 node_id);
1191 break;
1192 case CLUSTERER_DEST_DOWN:
1193 LM_ERR("All nodes down, remove node <%d> command not sent\n",
1194 node_id);
1195 break;
1196 case CLUSTERER_SEND_ERR:

Callers

nothing calls this directly

Calls 7

init_mi_errorFunction · 0.85
get_mi_int_paramFunction · 0.85
init_mi_param_errorFunction · 0.85
get_cluster_by_idFunction · 0.85
get_node_by_idFunction · 0.85
bcast_remove_nodeFunction · 0.85
remove_nodeFunction · 0.70

Tested by

no test coverage detected