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

Function dr_state_flusher

modules/drouting/drouting.c:997–1101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

995
996
997static void dr_state_flusher(struct head_db* hd)
998{
999 static db_ps_t cr_ps=NULL, gw_ps=NULL;
1000 pgw_t *gw;
1001 pcr_t *cr;
1002 db_key_t key_cmp;
1003 db_val_t val_cmp;
1004 db_key_t key_set;
1005 db_val_t val_set;
1006
1007 void** dest;
1008 map_iterator_t it;
1009
1010 if(!hd) {
1011 LM_ERR(" Bug - no head supplied to dr_state_flusher\n");
1012 }
1013
1014 /* is data avaialable? */
1015 if (!hd || !hd->rdata)
1016 return;
1017
1018 val_cmp.type = DB_STR;
1019 val_cmp.nul = 0;
1020
1021 val_set.type = DB_INT;
1022 val_set.nul = 0;
1023
1024 /* update the gateways */
1025 if ((hd->db_funcs).use_table( (*hd->db_con), &(hd->drd_table)) < 0) {
1026 LM_ERR("cannot select table \"%.*s\"\n", hd->drd_table.len, hd->drd_table.s);
1027 return;
1028 }
1029 key_cmp = &gwid_drd_col;
1030 key_set = &state_drd_col;
1031
1032 /* iterate the gateways */
1033 for (map_first(hd->rdata->pgw_tree , &it);
1034 iterator_is_valid(&it); iterator_next(&it)) {
1035
1036 dest = iterator_val(&it);
1037 if (dest==NULL)
1038 break;
1039
1040 gw = (pgw_t*)*dest;
1041
1042 if ( (gw->flags & DR_DST_STAT_DIRT_FLAG)==0 )
1043 /* nothing to do for this gateway */
1044 continue;
1045
1046 /* populate the update */
1047 val_cmp.val.str_val = gw->id;
1048 val_set.val.int_val = (gw->flags&DR_DST_STAT_DSBL_FLAG) ? ((gw->flags&DR_DST_STAT_NOEN_FLAG)?1:2) : (0);
1049
1050 /* update the state of this gateway */
1051 LM_DBG("updating the state of gw <%.*s> to %d\n",
1052 gw->id.len, gw->id.s, val_set.val.int_val);
1053
1054 CON_SET_CURR_PS(*hd->db_con, gw_ps);

Callers 2

dr_state_timerFunction · 0.85
dr_exitFunction · 0.85

Calls 4

map_firstFunction · 0.85
iterator_is_validFunction · 0.85
iterator_nextFunction · 0.85
iterator_valFunction · 0.85

Tested by

no test coverage detected