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

Function update_db_state

modules/clusterer/node_info.c:848–889  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

846}
847
848int update_db_state(int cluster_id, int node_id, int state) {
849 db_key_t node_id_key = &node_id_col;
850 db_val_t node_id_val;
851 db_key_t cl_node_id_keys[2] = {&node_id_col, &cluster_id_col};
852 db_val_t cl_node_id_vals[2];
853 db_key_t update_key;
854 db_val_t update_val;
855
856 CON_OR_RESET(db_hdl);
857 if (dr_dbf.use_table(db_hdl, &db_table) < 0) {
858 LM_ERR("cannot select table: \"%.*s\"\n", db_table.len, db_table.s);
859 return -1;
860 }
861
862 update_key = &state_col;
863 VAL_TYPE(&update_val) = DB_INT;
864 VAL_NULL(&update_val) = 0;
865 VAL_INT(&update_val) = state;
866
867 if (node_id == current_id) {
868 VAL_TYPE(&node_id_val) = DB_INT;
869 VAL_NULL(&node_id_val) = 0;
870 VAL_INT(&node_id_val) = current_id;
871
872 if (dr_dbf.update(db_hdl, &node_id_key, 0, &node_id_val, &update_key,
873 &update_val, 1, 1) < 0)
874 return -1;
875 } else {
876 VAL_TYPE(&cl_node_id_vals[0]) = DB_INT;
877 VAL_NULL(&cl_node_id_vals[0]) = 0;
878 VAL_INT(&cl_node_id_vals[0]) = node_id;
879 VAL_TYPE(&cl_node_id_vals[1]) = DB_INT;
880 VAL_NULL(&cl_node_id_vals[1]) = 0;
881 VAL_INT(&cl_node_id_vals[1]) = cluster_id;
882
883 if (dr_dbf.update(db_hdl, cl_node_id_keys, 0, cl_node_id_vals, &update_key,
884 &update_val, 2, 1) < 0)
885 return -1;
886 }
887
888 return 0;
889}
890
891void free_node_info(node_info_t *info)
892{

Callers 1

cl_set_stateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected