Module: kamailio Branch: master Commit: 1dceaa24ded727aba5870f28fb63e26ed98464f3 URL: https://github.com/kamailio/kamailio/commit/1dceaa24ded727aba5870f28fb63e26e...
Author: Chocolatbuddha chocolatbuddha@gmail.com Committer: Chocolatbuddha chocolatbuddha@gmail.com Date: 2016-10-17T11:13:22+02:00
Presence: Fix startup inconsistency in presentity hash table
pres_htable_restore(): Remove check of expired presentity entries when initially filling the hash table to represent the number of expired + valid entries. Because hash.c::delete_phtable() decrements publ_count on removal of _every_ expired DB entry. get_p_notify_body(): Compensate the fix on hash table restore by checking for the expires time on building the NOTIFY. This also fixes a problem when a SUBSCRIBE is received for an expired entry before the cleaner can remove the entry from the DB.
---
Modified: modules/presence/notify.c Modified: modules/presence/presentity.c
---
Diff: https://github.com/kamailio/kamailio/commit/1dceaa24ded727aba5870f28fb63e26e... Patch: https://github.com/kamailio/kamailio/commit/1dceaa24ded727aba5870f28fb63e26e...
---
diff --git a/modules/presence/notify.c b/modules/presence/notify.c index 82ebf6b..acb052d 100644 --- a/modules/presence/notify.c +++ b/modules/presence/notify.c @@ -584,8 +584,9 @@ str* build_empty_bla_body(str pres_uri) str* get_p_notify_body(str pres_uri, pres_ev_t* event, str* etag, str* contact) { - db_key_t query_cols[3]; - db_val_t query_vals[3]; + db_key_t query_cols[4]; + db_val_t query_vals[4]; + db_op_t query_ops[4]; db_key_t result_cols[3]; db1_res_t *result = NULL; int body_col, etag_col= 0, sender_col; @@ -635,18 +636,28 @@ str* get_p_notify_body(str pres_uri, pres_ev_t* event, str* etag, query_vals[n_query_cols].type = DB1_STR; query_vals[n_query_cols].nul = 0; query_vals[n_query_cols].val.str_val = uri.host; + query_ops[n_query_cols] = OP_EQ; n_query_cols++;
query_cols[n_query_cols] = &str_username_col; query_vals[n_query_cols].type = DB1_STR; query_vals[n_query_cols].nul = 0; query_vals[n_query_cols].val.str_val = uri.user; + query_ops[n_query_cols] = OP_EQ; n_query_cols++;
query_cols[n_query_cols] = &str_event_col; query_vals[n_query_cols].type = DB1_STR; query_vals[n_query_cols].nul = 0; query_vals[n_query_cols].val.str_val= event->name; + query_ops[n_query_cols] = OP_EQ; + n_query_cols++; + + query_cols[n_query_cols] = &str_expires_col; + query_vals[n_query_cols].type = DB1_INT; + query_vals[n_query_cols].nul = 0; + query_vals[n_query_cols].val.int_val= (int)time(NULL); + query_ops[n_query_cols] = OP_GT; n_query_cols++;
result_cols[body_col=n_result_cols++] = &str_body_col; @@ -664,7 +675,7 @@ str* get_p_notify_body(str pres_uri, pres_ev_t* event, str* etag, } else { query_str = str_received_time_col; } - if (pa_dbf.query (pa_db, query_cols, 0, query_vals, + if (pa_dbf.query (pa_db, query_cols, query_ops, query_vals, result_cols, n_query_cols, n_result_cols, &query_str , &result) < 0) { LM_ERR("failed to query %.*s table\n", presentity_table.len, presentity_table.s); diff --git a/modules/presence/presentity.c b/modules/presence/presentity.c index 00fdbfd..3a72cff 100644 --- a/modules/presence/presentity.c +++ b/modules/presence/presentity.c @@ -1231,9 +1231,6 @@ int pres_htable_restore(void) row = &result->rows[i]; row_vals = ROW_VALUES(row);
- if(row_vals[expires_col].val.int_val< (int)time(NULL)) - continue; - sphere= NULL; user.s= (char*)row_vals[user_col].val.string_val; user.len= strlen(user.s);