Module: sip-router Branch: 3.3 Commit: 0c5d596371712e98b2b59fe6b3b0911f2252fcd0 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=0c5d5963...
Author: Peter Dunkley peter.dunkley@crocodile-rcs.com Committer: Peter Dunkley peter.dunkley@crocodile-rcs.com Date: Tue Sep 11 13:08:38 2012 +0100
modules_k/rls: Fixed issues with for() loops in DB only mode
- Found and fixed by Hugh Waite @ Crocodile RCS Ltd (cherry picked from commit 7b64e538b350ebd520b80f668045b9f3c7d68fb9)
---
modules_k/rls/rls_db.c | 15 +++++++++------ modules_k/rls/subscribe.c | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/modules_k/rls/rls_db.c b/modules_k/rls/rls_db.c index 5728a2f..938f3b7 100644 --- a/modules_k/rls/rls_db.c +++ b/modules_k/rls/rls_db.c @@ -121,7 +121,7 @@ int delete_expired_subs_rlsdb( void ) db1_res_t *result = NULL; int n_query_cols = 0, n_result_cols = 0; int r_callid_col = 0, r_to_tag_col = 0, r_from_tag_col = 0; - int i; + int i, nr_rows; subs_t subs; str rlsubs_did = {0, 0};
@@ -157,10 +157,13 @@ int delete_expired_subs_rlsdb( void )
if(result == NULL) goto error;
- for (i = 0; i <RES_ROW_N(result); i++) + rows = RES_ROWS(result); + nr_rows = RES_ROW_N(result); + + for (i = 0; i < nr_rows; i++) { - rows = RES_ROWS(result); - values = ROW_VALUES(rows); + memset(&subs, 0, sizeof(subs_t)); + values = ROW_VALUES(&rows[i]);
subs.callid.s = (char *) VAL_STRING(&values[r_callid_col]); subs.callid.len = strlen(subs.callid.s); @@ -415,11 +418,11 @@ int update_all_subs_rlsdb(str *watcher_user, str *watcher_domain, str *evt)
nr_rows = RES_ROW_N(result);
+ rows = RES_ROWS(result); /* get the results and fill in return data structure */ for (loop=0; loop <nr_rows; loop++) { - rows = RES_ROWS(result); - values = ROW_VALUES(rows); + values = ROW_VALUES(&rows[loop]);
size= sizeof(subs_t) + ( strlen(VAL_STRING(values+r_pres_uri_col)) diff --git a/modules_k/rls/subscribe.c b/modules_k/rls/subscribe.c index 1126762..9b7f31d 100644 --- a/modules_k/rls/subscribe.c +++ b/modules_k/rls/subscribe.c @@ -327,7 +327,7 @@ int reply_200(struct sip_msg* msg, str* contact, int expires) LM_ERR("no more pkg memory\n"); return -1; } - hdr_append.len = sprintf(hdr_append.s, "Expires: %d\r\n", expires); + hdr_append.len = sprintf(hdr_append.s, "Expires: %d\r\n", expires); if(hdr_append.len< 0) { LM_ERR("unsuccessful sprintf\n");