|
@@ -44,6 +44,7 @@
|
|
#include "publish.h"
|
|
#include "publish.h"
|
|
#include "hash.h"
|
|
#include "hash.h"
|
|
#include "utils_func.h"
|
|
#include "utils_func.h"
|
|
|
|
+#include "presence_dmq.h"
|
|
|
|
|
|
|
|
|
|
/* base priority value (20150101T000000) */
|
|
/* base priority value (20150101T000000) */
|
|
@@ -425,7 +426,7 @@ int delete_presentity_if_dialog_id_exists(presentity_t* presentity, char* dialog
|
|
|
|
|
|
LM_WARN("Presentity already exists - deleting it\n");
|
|
LM_WARN("Presentity already exists - deleting it\n");
|
|
|
|
|
|
- if(delete_presentity(&old_presentity)<0) {
|
|
|
|
|
|
+ if(delete_presentity(&old_presentity, NULL)<0) {
|
|
LM_ERR("failed to delete presentity\n");
|
|
LM_ERR("failed to delete presentity\n");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -555,20 +556,21 @@ int is_dialog_terminated(presentity_t* presentity)
|
|
}
|
|
}
|
|
|
|
|
|
int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body,
|
|
int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body,
|
|
- int new_t, int* sent_reply, char* sphere)
|
|
|
|
|
|
+ int new_t, int* sent_reply, char* sphere, str* etag_override, str* ruid)
|
|
{
|
|
{
|
|
- db_key_t query_cols[13], update_keys[9], result_cols[6];
|
|
|
|
- db_op_t query_ops[13];
|
|
|
|
- db_val_t query_vals[13], update_vals[9];
|
|
|
|
|
|
+ db_key_t query_cols[14], rquery_cols[2], update_keys[9], result_cols[7];
|
|
|
|
+ db_op_t query_ops[14], rquery_ops[2];
|
|
|
|
+ db_val_t query_vals[14], rquery_vals[2], update_vals[9];
|
|
db1_res_t *result= NULL;
|
|
db1_res_t *result= NULL;
|
|
int n_query_cols = 0;
|
|
int n_query_cols = 0;
|
|
|
|
+ int n_rquery_cols = 0;
|
|
int n_update_cols = 0;
|
|
int n_update_cols = 0;
|
|
char* dot= NULL;
|
|
char* dot= NULL;
|
|
str etag= {0, 0};
|
|
str etag= {0, 0};
|
|
str cur_etag= {0, 0};
|
|
str cur_etag= {0, 0};
|
|
str* rules_doc= NULL;
|
|
str* rules_doc= NULL;
|
|
str pres_uri= {0, 0};
|
|
str pres_uri= {0, 0};
|
|
- int rez_body_col, rez_sender_col, n_result_cols= 0;
|
|
|
|
|
|
+ int rez_body_col, rez_sender_col, rez_ruid_col, n_result_cols= 0;
|
|
db_row_t *row = NULL ;
|
|
db_row_t *row = NULL ;
|
|
db_val_t *row_vals = NULL;
|
|
db_val_t *row_vals = NULL;
|
|
str old_body, sender;
|
|
str old_body, sender;
|
|
@@ -578,6 +580,8 @@ int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body,
|
|
int db_record_exists = 0;
|
|
int db_record_exists = 0;
|
|
int num_watchers = 0;
|
|
int num_watchers = 0;
|
|
char *old_dialog_id = NULL, *dialog_id = NULL;
|
|
char *old_dialog_id = NULL, *dialog_id = NULL;
|
|
|
|
+ str cur_ruid= {0, 0};
|
|
|
|
+ str p_ruid = {0, 0};
|
|
|
|
|
|
if (sent_reply) *sent_reply= 0;
|
|
if (sent_reply) *sent_reply= 0;
|
|
if(pres_notifier_processes == 0 && presentity->event->req_auth)
|
|
if(pres_notifier_processes == 0 && presentity->event->req_auth)
|
|
@@ -628,9 +632,22 @@ int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body,
|
|
|
|
|
|
result_cols[rez_body_col= n_result_cols++] = &str_body_col;
|
|
result_cols[rez_body_col= n_result_cols++] = &str_body_col;
|
|
result_cols[rez_sender_col= n_result_cols++] = &str_sender_col;
|
|
result_cols[rez_sender_col= n_result_cols++] = &str_sender_col;
|
|
|
|
+ result_cols[rez_ruid_col= n_result_cols++] = &str_ruid_col;
|
|
|
|
|
|
if(new_t)
|
|
if(new_t)
|
|
{
|
|
{
|
|
|
|
+ LM_DBG("new presentity with etag %.*s\n", presentity->etag.len, presentity->etag.s);
|
|
|
|
+
|
|
|
|
+ if (ruid) {
|
|
|
|
+ /* use the provided ruid */
|
|
|
|
+ p_ruid = *ruid;
|
|
|
|
+ } else {
|
|
|
|
+ /* generate a new ruid */
|
|
|
|
+ if(sruid_next(&pres_sruid)<0)
|
|
|
|
+ goto error;
|
|
|
|
+ p_ruid = pres_sruid.uid;
|
|
|
|
+ }
|
|
|
|
+
|
|
/* insert new record in hash_table */
|
|
/* insert new record in hash_table */
|
|
|
|
|
|
if ( publ_cache_enabled &&
|
|
if ( publ_cache_enabled &&
|
|
@@ -640,6 +657,8 @@ int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body,
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ LM_DBG("new htable record added\n");
|
|
|
|
+
|
|
/* insert new record into database */
|
|
/* insert new record into database */
|
|
query_cols[n_query_cols] = &str_sender_col;
|
|
query_cols[n_query_cols] = &str_sender_col;
|
|
query_vals[n_query_cols].type = DB1_STR;
|
|
query_vals[n_query_cols].type = DB1_STR;
|
|
@@ -672,6 +691,12 @@ int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body,
|
|
query_vals[n_query_cols].val.int_val = presentity->priority;
|
|
query_vals[n_query_cols].val.int_val = presentity->priority;
|
|
n_query_cols++;
|
|
n_query_cols++;
|
|
|
|
|
|
|
|
+ query_cols[n_query_cols] = &str_ruid_col;
|
|
|
|
+ query_vals[n_query_cols].type = DB1_STR;
|
|
|
|
+ query_vals[n_query_cols].nul = 0;
|
|
|
|
+ query_vals[n_query_cols].val.str_val = p_ruid;
|
|
|
|
+ n_query_cols++;
|
|
|
|
+
|
|
if (presentity->expires != -1)
|
|
if (presentity->expires != -1)
|
|
{
|
|
{
|
|
/* A real PUBLISH */
|
|
/* A real PUBLISH */
|
|
@@ -765,6 +790,21 @@ int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body,
|
|
else
|
|
else
|
|
{
|
|
{
|
|
|
|
|
|
|
|
+ LM_DBG("updating existing presentity with etag %.*s\n", presentity->etag.len, presentity->etag.s);
|
|
|
|
+
|
|
|
|
+ if (ruid) {
|
|
|
|
+ p_ruid = *ruid;
|
|
|
|
+
|
|
|
|
+ rquery_cols[n_rquery_cols] = &str_ruid_col;
|
|
|
|
+ rquery_ops[n_rquery_cols] = OP_EQ;
|
|
|
|
+ rquery_vals[n_rquery_cols].type = DB1_STR;
|
|
|
|
+ rquery_vals[n_rquery_cols].nul = 0;
|
|
|
|
+ rquery_vals[n_rquery_cols].val.str_val = p_ruid;
|
|
|
|
+ n_rquery_cols++;
|
|
|
|
+
|
|
|
|
+ // TODO: check for out-of-sequence updates
|
|
|
|
+ }
|
|
|
|
+
|
|
if (pa_dbf.use_table(pa_db, &presentity_table) < 0)
|
|
if (pa_dbf.use_table(pa_db, &presentity_table) < 0)
|
|
{
|
|
{
|
|
LM_ERR("unsuccessful sql use table\n");
|
|
LM_ERR("unsuccessful sql use table\n");
|
|
@@ -783,8 +823,10 @@ int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body,
|
|
if(EVENT_DIALOG_SLA(presentity->event->evp))
|
|
if(EVENT_DIALOG_SLA(presentity->event->evp))
|
|
{
|
|
{
|
|
|
|
|
|
- if (pa_dbf.query (pa_db, query_cols, query_ops, query_vals,
|
|
|
|
- result_cols, n_query_cols, n_result_cols, 0, &result) < 0)
|
|
|
|
|
|
+ if (pa_dbf.query (pa_db, ruid?rquery_cols:query_cols,
|
|
|
|
+ ruid?rquery_ops:query_ops, ruid?rquery_vals:query_vals,
|
|
|
|
+ result_cols, ruid?n_rquery_cols:n_query_cols, n_result_cols,
|
|
|
|
+ 0, &result) < 0)
|
|
{
|
|
{
|
|
LM_ERR("unsuccessful sql query\n");
|
|
LM_ERR("unsuccessful sql query\n");
|
|
goto error;
|
|
goto error;
|
|
@@ -800,6 +842,19 @@ int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body,
|
|
row = &result->rows[0];
|
|
row = &result->rows[0];
|
|
row_vals = ROW_VALUES(row);
|
|
row_vals = ROW_VALUES(row);
|
|
|
|
|
|
|
|
+ /* store current ruid if we don't already know it */
|
|
|
|
+ if (!p_ruid.s && row_vals[rez_ruid_col].val.string_val) {
|
|
|
|
+ cur_ruid.len = strlen((char *) row_vals[rez_ruid_col].val.string_val);
|
|
|
|
+ cur_ruid.s = (char *) pkg_malloc(sizeof(char) * cur_ruid.len);
|
|
|
|
+ if (!cur_ruid.s)
|
|
|
|
+ {
|
|
|
|
+ LM_ERR("no private memory\n");
|
|
|
|
+ goto error;
|
|
|
|
+ }
|
|
|
|
+ memcpy(cur_ruid.s, (char *) row_vals[rez_ruid_col].val.string_val, cur_ruid.len);
|
|
|
|
+ p_ruid = cur_ruid;
|
|
|
|
+ }
|
|
|
|
+
|
|
old_body.s = (char*)row_vals[rez_body_col].val.string_val;
|
|
old_body.s = (char*)row_vals[rez_body_col].val.string_val;
|
|
old_body.len = strlen(old_body.s);
|
|
old_body.len = strlen(old_body.s);
|
|
if(check_if_dialog(*body, &is_dialog, &dialog_id)< 0)
|
|
if(check_if_dialog(*body, &is_dialog, &dialog_id)< 0)
|
|
@@ -864,8 +919,10 @@ after_dialog_check:
|
|
|
|
|
|
if (!db_record_exists)
|
|
if (!db_record_exists)
|
|
{
|
|
{
|
|
- if (pa_dbf.query (pa_db, query_cols, query_ops, query_vals,
|
|
|
|
- result_cols, n_query_cols, n_result_cols, 0, &result) < 0)
|
|
|
|
|
|
+ if (pa_dbf.query (pa_db, ruid?rquery_cols:query_cols,
|
|
|
|
+ ruid?rquery_ops:query_ops, ruid?rquery_vals:query_vals,
|
|
|
|
+ result_cols, ruid?n_rquery_cols:n_query_cols, n_result_cols,
|
|
|
|
+ 0, &result) < 0)
|
|
{
|
|
{
|
|
LM_ERR("unsuccessful sql query\n");
|
|
LM_ERR("unsuccessful sql query\n");
|
|
goto error;
|
|
goto error;
|
|
@@ -878,6 +935,22 @@ after_dialog_check:
|
|
|
|
|
|
db_record_exists = 1;
|
|
db_record_exists = 1;
|
|
|
|
|
|
|
|
+ row = &result->rows[0];
|
|
|
|
+ row_vals = ROW_VALUES(row);
|
|
|
|
+
|
|
|
|
+ /* store current ruid if we don't already know it */
|
|
|
|
+ if (!p_ruid.s && row_vals[rez_ruid_col].val.string_val) {
|
|
|
|
+ cur_ruid.len = strlen((char *) row_vals[rez_ruid_col].val.string_val);
|
|
|
|
+ cur_ruid.s = (char *) pkg_malloc(sizeof(char) * cur_ruid.len);
|
|
|
|
+ if (!cur_ruid.s)
|
|
|
|
+ {
|
|
|
|
+ LM_ERR("no private memory\n");
|
|
|
|
+ goto error;
|
|
|
|
+ }
|
|
|
|
+ memcpy(cur_ruid.s, (char *) row_vals[rez_ruid_col].val.string_val, cur_ruid.len);
|
|
|
|
+ p_ruid = cur_ruid;
|
|
|
|
+ }
|
|
|
|
+
|
|
pa_dbf.free_result(pa_db, result);
|
|
pa_dbf.free_result(pa_db, result);
|
|
result = NULL;
|
|
result = NULL;
|
|
}
|
|
}
|
|
@@ -899,7 +972,7 @@ after_dialog_check:
|
|
|
|
|
|
if (num_watchers > 0)
|
|
if (num_watchers > 0)
|
|
{
|
|
{
|
|
- if (mark_presentity_for_delete(presentity) < 0)
|
|
|
|
|
|
+ if (mark_presentity_for_delete(presentity, &p_ruid) < 0)
|
|
{
|
|
{
|
|
LM_ERR("Marking presentities\n");
|
|
LM_ERR("Marking presentities\n");
|
|
goto error;
|
|
goto error;
|
|
@@ -917,7 +990,7 @@ after_dialog_check:
|
|
|
|
|
|
if (pres_notifier_processes == 0 || num_watchers == 0)
|
|
if (pres_notifier_processes == 0 || num_watchers == 0)
|
|
{
|
|
{
|
|
- if (delete_presentity(presentity) < 0)
|
|
|
|
|
|
+ if (delete_presentity(presentity, &p_ruid) < 0)
|
|
{
|
|
{
|
|
LM_ERR("Deleting presentity\n");
|
|
LM_ERR("Deleting presentity\n");
|
|
goto error;
|
|
goto error;
|
|
@@ -953,8 +1026,15 @@ after_dialog_check:
|
|
goto done;
|
|
goto done;
|
|
}
|
|
}
|
|
|
|
|
|
- if(presentity->event->etag_not_new== 0)
|
|
|
|
|
|
+ if(presentity->event->etag_not_new== 0 || etag_override)
|
|
{
|
|
{
|
|
|
|
+ if (etag_override) {
|
|
|
|
+ /* use the supplied etag */
|
|
|
|
+ LM_DBG("updating with supplied etag %.*s\n", etag_override->len, etag_override->s);
|
|
|
|
+ cur_etag = *etag_override;
|
|
|
|
+ goto after_etag_generation;
|
|
|
|
+ }
|
|
|
|
+
|
|
/* generate another etag */
|
|
/* generate another etag */
|
|
unsigned int publ_nr;
|
|
unsigned int publ_nr;
|
|
str str_publ_nr= {0, 0};
|
|
str str_publ_nr= {0, 0};
|
|
@@ -988,10 +1068,12 @@ after_dialog_check:
|
|
|
|
|
|
cur_etag= etag;
|
|
cur_etag= etag;
|
|
|
|
|
|
|
|
+after_etag_generation:
|
|
|
|
+
|
|
update_keys[n_update_cols] = &str_etag_col;
|
|
update_keys[n_update_cols] = &str_etag_col;
|
|
update_vals[n_update_cols].type = DB1_STR;
|
|
update_vals[n_update_cols].type = DB1_STR;
|
|
update_vals[n_update_cols].nul = 0;
|
|
update_vals[n_update_cols].nul = 0;
|
|
- update_vals[n_update_cols].val.str_val = etag;
|
|
|
|
|
|
+ update_vals[n_update_cols].val.str_val = cur_etag;
|
|
n_update_cols++;
|
|
n_update_cols++;
|
|
|
|
|
|
}
|
|
}
|
|
@@ -1068,11 +1150,14 @@ after_dialog_check:
|
|
n_update_cols++;
|
|
n_update_cols++;
|
|
}
|
|
}
|
|
|
|
|
|
- /* if there is no support for affected_rows and no previous query has been done, do query */
|
|
|
|
- if (!pa_dbf.affected_rows && !db_record_exists)
|
|
|
|
|
|
+ /* if there is no support for affected_rows and no previous query has been done,
|
|
|
|
+ * or dmq replication is enabled and we don't already know the ruid, do query */
|
|
|
|
+ if ((!pa_dbf.affected_rows && !db_record_exists) || (pres_enable_dmq > 0 && !p_ruid.s))
|
|
{
|
|
{
|
|
- if (pa_dbf.query (pa_db, query_cols, query_ops, query_vals,
|
|
|
|
- result_cols, n_query_cols, n_result_cols, 0, &result) < 0)
|
|
|
|
|
|
+ if (pa_dbf.query (pa_db, ruid?rquery_cols:query_cols,
|
|
|
|
+ ruid?rquery_ops:query_ops, ruid?rquery_vals:query_vals,
|
|
|
|
+ result_cols, ruid?n_rquery_cols:n_query_cols, n_result_cols,
|
|
|
|
+ 0, &result) < 0)
|
|
{
|
|
{
|
|
LM_ERR("unsuccessful sql query\n");
|
|
LM_ERR("unsuccessful sql query\n");
|
|
goto error;
|
|
goto error;
|
|
@@ -1084,12 +1169,33 @@ after_dialog_check:
|
|
goto send_412;
|
|
goto send_412;
|
|
|
|
|
|
db_record_exists = 1;
|
|
db_record_exists = 1;
|
|
|
|
+ affected_rows = result->n;
|
|
|
|
+
|
|
|
|
+ row = &result->rows[0];
|
|
|
|
+ row_vals = ROW_VALUES(row);
|
|
|
|
+
|
|
|
|
+ /* store current ruid if we don't already know it */
|
|
|
|
+ if (!p_ruid.s && row_vals[rez_ruid_col].val.string_val) {
|
|
|
|
+ cur_ruid.len = strlen((char *) row_vals[rez_ruid_col].val.string_val);
|
|
|
|
+ cur_ruid.s = (char *) pkg_malloc(sizeof(char) * cur_ruid.len);
|
|
|
|
+ if (!cur_ruid.s)
|
|
|
|
+ {
|
|
|
|
+ LM_ERR("no private memory\n");
|
|
|
|
+ goto error;
|
|
|
|
+ }
|
|
|
|
+ memcpy(cur_ruid.s, (char *) row_vals[rez_ruid_col].val.string_val, cur_ruid.len);
|
|
|
|
+ p_ruid = cur_ruid;
|
|
|
|
+
|
|
|
|
+ LM_DBG("existing ruid %.*s\n", p_ruid.len, p_ruid.s);
|
|
|
|
+ }
|
|
|
|
+
|
|
pa_dbf.free_result(pa_db, result);
|
|
pa_dbf.free_result(pa_db, result);
|
|
result = NULL;
|
|
result = NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- if( pa_dbf.update( pa_db,query_cols, query_ops, query_vals,
|
|
|
|
- update_keys, update_vals, n_query_cols, n_update_cols )<0)
|
|
|
|
|
|
+ if (pa_dbf.update (pa_db, ruid?rquery_cols:query_cols,
|
|
|
|
+ ruid?rquery_ops:query_ops, ruid?rquery_vals:query_vals,
|
|
|
|
+ update_keys, update_vals, ruid?n_rquery_cols:n_query_cols, n_update_cols) < 0)
|
|
{
|
|
{
|
|
LM_ERR("updating published info in database\n");
|
|
LM_ERR("updating published info in database\n");
|
|
goto error;
|
|
goto error;
|
|
@@ -1108,7 +1214,7 @@ after_dialog_check:
|
|
|
|
|
|
|
|
|
|
/*if either affected_rows (if exists) or select query show that there is no line in database*/
|
|
/*if either affected_rows (if exists) or select query show that there is no line in database*/
|
|
- if ((pa_dbf.affected_rows && !affected_rows) || (!pa_dbf.affected_rows && !db_record_exists))
|
|
|
|
|
|
+ if ((pa_dbf.affected_rows && !affected_rows && !db_record_exists) || (!pa_dbf.affected_rows && !db_record_exists))
|
|
goto send_412;
|
|
goto send_412;
|
|
|
|
|
|
/* send 200OK */
|
|
/* send 200OK */
|
|
@@ -1148,6 +1254,15 @@ send_notify:
|
|
}
|
|
}
|
|
|
|
|
|
done:
|
|
done:
|
|
|
|
+
|
|
|
|
+ if (pres_enable_dmq>0) {
|
|
|
|
+ pres_dmq_replicate_presentity(presentity, body, new_t, &cur_etag, sphere, &p_ruid, NULL);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(cur_ruid.s)
|
|
|
|
+ pkg_free(cur_ruid.s);
|
|
|
|
+ cur_ruid.s= NULL;
|
|
|
|
+
|
|
if(rules_doc)
|
|
if(rules_doc)
|
|
{
|
|
{
|
|
if(rules_doc->s)
|
|
if(rules_doc->s)
|
|
@@ -1173,7 +1288,12 @@ done:
|
|
|
|
|
|
send_412:
|
|
send_412:
|
|
|
|
|
|
- LM_ERR("No E_Tag match %*s\n", presentity->etag.len, presentity->etag.s);
|
|
|
|
|
|
+ if (!ruid) {
|
|
|
|
+ LM_ERR("No E_Tag match %*s\n", presentity->etag.len, presentity->etag.s);
|
|
|
|
+ } else {
|
|
|
|
+ LM_ERR("No ruid match %*s\n", ruid->len, ruid->s);
|
|
|
|
+ }
|
|
|
|
+
|
|
if (msg != NULL)
|
|
if (msg != NULL)
|
|
{
|
|
{
|
|
if (slb.freply(msg, 412, &pu_412_rpl) < 0)
|
|
if (slb.freply(msg, 412, &pu_412_rpl) < 0)
|
|
@@ -1198,6 +1318,8 @@ error:
|
|
if(pres_uri.s) {
|
|
if(pres_uri.s) {
|
|
pkg_free(pres_uri.s);
|
|
pkg_free(pres_uri.s);
|
|
}
|
|
}
|
|
|
|
+ if(cur_ruid.s)
|
|
|
|
+ pkg_free(cur_ruid.s);
|
|
|
|
|
|
if (pa_dbf.abort_transaction) {
|
|
if (pa_dbf.abort_transaction) {
|
|
if (pa_dbf.abort_transaction(pa_db) < 0) {
|
|
if (pa_dbf.abort_transaction(pa_db) < 0) {
|
|
@@ -1521,7 +1643,7 @@ error:
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-int mark_presentity_for_delete(presentity_t *pres)
|
|
|
|
|
|
+int mark_presentity_for_delete(presentity_t *pres, str *ruid)
|
|
{
|
|
{
|
|
db_key_t query_cols[4], result_cols[1], update_cols[3];
|
|
db_key_t query_cols[4], result_cols[1], update_cols[3];
|
|
db_val_t query_vals[4], update_vals[3], *value;
|
|
db_val_t query_vals[4], update_vals[3], *value;
|
|
@@ -1535,7 +1657,7 @@ int mark_presentity_for_delete(presentity_t *pres)
|
|
if (pres->event->agg_nbody == NULL)
|
|
if (pres->event->agg_nbody == NULL)
|
|
{
|
|
{
|
|
/* Nothing clever to do here... just delete */
|
|
/* Nothing clever to do here... just delete */
|
|
- if (delete_presentity(pres) < 0)
|
|
|
|
|
|
+ if (delete_presentity(pres, NULL) < 0)
|
|
{
|
|
{
|
|
LM_ERR("deleting presentity\n");
|
|
LM_ERR("deleting presentity\n");
|
|
goto error;
|
|
goto error;
|
|
@@ -1549,29 +1671,37 @@ int mark_presentity_for_delete(presentity_t *pres)
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
|
|
|
|
- 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 = pres->user;
|
|
|
|
- n_query_cols++;
|
|
|
|
|
|
+ if (!ruid) {
|
|
|
|
+ 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 = pres->user;
|
|
|
|
+ n_query_cols++;
|
|
|
|
|
|
- query_cols[n_query_cols] = &str_domain_col;
|
|
|
|
- query_vals[n_query_cols].type = DB1_STR;
|
|
|
|
- query_vals[n_query_cols].nul = 0;
|
|
|
|
- query_vals[n_query_cols].val.str_val = pres->domain;
|
|
|
|
- n_query_cols++;
|
|
|
|
|
|
+ query_cols[n_query_cols] = &str_domain_col;
|
|
|
|
+ query_vals[n_query_cols].type = DB1_STR;
|
|
|
|
+ query_vals[n_query_cols].nul = 0;
|
|
|
|
+ query_vals[n_query_cols].val.str_val = pres->domain;
|
|
|
|
+ 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 = pres->event->name;
|
|
|
|
- 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 = pres->event->name;
|
|
|
|
+ n_query_cols++;
|
|
|
|
|
|
- query_cols[n_query_cols] = &str_etag_col;
|
|
|
|
- query_vals[n_query_cols].type = DB1_STR;
|
|
|
|
- query_vals[n_query_cols].nul = 0;
|
|
|
|
- query_vals[n_query_cols].val.str_val = pres->etag;
|
|
|
|
- n_query_cols++;
|
|
|
|
|
|
+ query_cols[n_query_cols] = &str_etag_col;
|
|
|
|
+ query_vals[n_query_cols].type = DB1_STR;
|
|
|
|
+ query_vals[n_query_cols].nul = 0;
|
|
|
|
+ query_vals[n_query_cols].val.str_val = pres->etag;
|
|
|
|
+ n_query_cols++;
|
|
|
|
+ } else {
|
|
|
|
+ query_cols[n_query_cols] = &str_ruid_col;
|
|
|
|
+ query_vals[n_query_cols].type = DB1_STR;
|
|
|
|
+ query_vals[n_query_cols].nul = 0;
|
|
|
|
+ query_vals[n_query_cols].val.str_val = *ruid;
|
|
|
|
+ n_query_cols++;
|
|
|
|
+ }
|
|
|
|
|
|
result_cols[0] = &str_body_col;
|
|
result_cols[0] = &str_body_col;
|
|
|
|
|
|
@@ -1601,7 +1731,7 @@ int mark_presentity_for_delete(presentity_t *pres)
|
|
* it anyway */
|
|
* it anyway */
|
|
LM_ERR("Found %d presentities - expected 1\n", RES_ROW_N(result));
|
|
LM_ERR("Found %d presentities - expected 1\n", RES_ROW_N(result));
|
|
|
|
|
|
- if (delete_presentity(pres) < 0)
|
|
|
|
|
|
+ if (delete_presentity(pres, ruid) < 0)
|
|
{
|
|
{
|
|
LM_ERR("deleting presentity\n");
|
|
LM_ERR("deleting presentity\n");
|
|
goto error;
|
|
goto error;
|
|
@@ -1669,7 +1799,7 @@ error:
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
-int delete_presentity(presentity_t *pres)
|
|
|
|
|
|
+int delete_presentity(presentity_t *pres, str *ruid)
|
|
{
|
|
{
|
|
db_key_t query_cols[4];
|
|
db_key_t query_cols[4];
|
|
db_val_t query_vals[4];
|
|
db_val_t query_vals[4];
|
|
@@ -1681,29 +1811,37 @@ int delete_presentity(presentity_t *pres)
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
|
|
|
|
- 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 = pres->user;
|
|
|
|
- n_query_cols++;
|
|
|
|
|
|
+ if (!ruid) {
|
|
|
|
+ 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 = pres->user;
|
|
|
|
+ n_query_cols++;
|
|
|
|
|
|
- query_cols[n_query_cols] = &str_domain_col;
|
|
|
|
- query_vals[n_query_cols].type = DB1_STR;
|
|
|
|
- query_vals[n_query_cols].nul = 0;
|
|
|
|
- query_vals[n_query_cols].val.str_val = pres->domain;
|
|
|
|
- n_query_cols++;
|
|
|
|
|
|
+ query_cols[n_query_cols] = &str_domain_col;
|
|
|
|
+ query_vals[n_query_cols].type = DB1_STR;
|
|
|
|
+ query_vals[n_query_cols].nul = 0;
|
|
|
|
+ query_vals[n_query_cols].val.str_val = pres->domain;
|
|
|
|
+ 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 = pres->event->name;
|
|
|
|
- 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 = pres->event->name;
|
|
|
|
+ n_query_cols++;
|
|
|
|
|
|
- query_cols[n_query_cols] = &str_etag_col;
|
|
|
|
- query_vals[n_query_cols].type = DB1_STR;
|
|
|
|
- query_vals[n_query_cols].nul = 0;
|
|
|
|
- query_vals[n_query_cols].val.str_val = pres->etag;
|
|
|
|
- n_query_cols++;
|
|
|
|
|
|
+ query_cols[n_query_cols] = &str_etag_col;
|
|
|
|
+ query_vals[n_query_cols].type = DB1_STR;
|
|
|
|
+ query_vals[n_query_cols].nul = 0;
|
|
|
|
+ query_vals[n_query_cols].val.str_val = pres->etag;
|
|
|
|
+ n_query_cols++;
|
|
|
|
+ } else {
|
|
|
|
+ query_cols[n_query_cols] = &str_ruid_col;
|
|
|
|
+ query_vals[n_query_cols].type = DB1_STR;
|
|
|
|
+ query_vals[n_query_cols].nul = 0;
|
|
|
|
+ query_vals[n_query_cols].val.str_val = *ruid;
|
|
|
|
+ n_query_cols++;
|
|
|
|
+ }
|
|
|
|
|
|
if(pa_dbf.delete(pa_db, query_cols, 0, query_vals, n_query_cols) < 0)
|
|
if(pa_dbf.delete(pa_db, query_cols, 0, query_vals, n_query_cols) < 0)
|
|
{
|
|
{
|