Good evening Daniel.
I've tested the change and now it behaves better but I'm having other
problems when several UAs REGISTER to both REGISTRAR servers with same
credentials.
I'd like to deep inspect before answering you (it's difficult to trace).
Hope to have time this week.
Best regards.
Eduardo Lejarreta.
El 04.11.2014 16:34, Daniel-Constantin Mierla escribió:
Module: sip-router
Branch: master
Commit: e070257321853d799a6325ac5e94f69b4ccb85e7
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e070257…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Tue Nov 4 16:32:13 2014 +0100
pua_reginfo: avoid sending notify when processing location record
action triggered by itself
---
modules/pua_reginfo/notify.c | 21 +++++++++++++++------
modules/pua_reginfo/usrloc_cb.c | 12 ++++++++++++
modules/pua_reginfo/usrloc_cb.h | 6 ++++++
3 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/modules/pua_reginfo/notify.c
b/modules/pua_reginfo/notify.c
index 6cc1e67..b209577 100644
--- a/modules/pua_reginfo/notify.c
+++ b/modules/pua_reginfo/notify.c
@@ -28,6 +28,7 @@
#include "../../modules/usrloc/usrloc.h"
#include "../../lib/srutils/sruid.h"
#include <libxml/parser.h>
+#include "usrloc_cb.h"
#include "pua_reginfo.h"
/*<?xml version="1.0"?>
@@ -71,7 +72,9 @@ int process_contact(udomain_t * domain, urecord_t **
ul_record, str aor, str cal
static str no_ua = str_init("n/a");
static ucontact_info_t ci;
ucontact_t * ul_contact;
+ int ret;
+ pua_reginfo_update_self_op(1);
if (*ul_record == NULL) {
switch(event) {
case EVENT_REGISTERED:
@@ -81,14 +84,15 @@ int process_contact(udomain_t * domain, urecord_t
** ul_record, str aor, str cal
create a new entry for this user in the usrloc-DB */
if (ul.insert_urecord(domain, &aor, ul_record) < 0) {
LM_ERR("failed to insert new user-record\n");
- return RESULT_ERROR;
+ ret = RESULT_ERROR;
+ goto done;
}
break;
default:
/* No entry in usrloc and the contact is expired, deleted,
unregistered, whatever:
We do not need to do anything. */
- return RESULT_NO_CONTACTS;
- break;
+ ret = RESULT_NO_CONTACTS;
+ goto done;
}
}
@@ -118,12 +122,14 @@ int process_contact(udomain_t * domain,
urecord_t ** ul_record, str aor, str cal
|| (ul.get_ucontact(*ul_record, &contact_uri, &callid, &no_str,
cseq+1, &ul_contact) != 0)) {
if (ul.insert_ucontact(*ul_record, &contact_uri, &ci, &ul_contact) <
0) {
LM_ERR("failed to insert new contact\n");
- return RESULT_ERROR;
+ ret = RESULT_ERROR;
+ goto done;
}
} else {
if (ul.update_ucontact(*ul_record, ul_contact, &ci) < 0) {
LM_ERR("failed to update contact\n");
- return RESULT_ERROR;
+ ret = RESULT_ERROR;
+ goto done;
}
}
ul_contact = (*ul_record)->contacts;
@@ -132,7 +138,10 @@ int process_contact(udomain_t * domain, urecord_t
** ul_record, str aor, str cal
ul_contact = ul_contact->next;
}
- return RESULT_NO_CONTACTS;
+ ret = RESULT_NO_CONTACTS;
+done:
+ pua_reginfo_update_self_op(0);
+ return ret;
}
xmlNodePtr xmlGetNodeByName(xmlNodePtr parent, const char *name) {
diff --git a/modules/pua_reginfo/usrloc_cb.c
b/modules/pua_reginfo/usrloc_cb.c
index 2360a70..0164a67 100644
--- a/modules/pua_reginfo/usrloc_cb.c
+++ b/modules/pua_reginfo/usrloc_cb.c
@@ -49,6 +49,12 @@ Call-ID: 9ad9f89f-164d-bb86-1072-52e7e9eb5025.
.</registration>
</reginfo> */
+static int _pua_reginfo_self_op = 0;
+
+void pua_reginfo_update_self_op(int v)
+{
+ _pua_reginfo_self_op = v;
+}
str* build_reginfo_full(urecord_t * record, str uri, ucontact_t* c,
int type) {
xmlDocPtr doc = NULL;
@@ -221,6 +227,12 @@ void reginfo_usrloc_cb(ucontact_t* c, int type,
void* param) {
char id_buf[512];
int id_buf_len;
+ if(_pua_reginfo_self_op == 1) {
+ LM_DBG("operation triggered by own action for aor: %.*s (%d)\n",
+ c->aor->len, c->aor->s, type);
+ return;
+ }
+
content_type.s = "application/reginfo+xml";
content_type.len = 23;
diff --git a/modules/pua_reginfo/usrloc_cb.h
b/modules/pua_reginfo/usrloc_cb.h
index 0bdd1ca..f0e565e 100644
--- a/modules/pua_reginfo/usrloc_cb.h
+++ b/modules/pua_reginfo/usrloc_cb.h
@@ -21,6 +21,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
+#ifndef __PUA_REGINFO_USRLOC_CB__
+#define __PUA_REGINFO_USRLOC_CB__
+
#include "../usrloc/usrloc.h"
void reginfo_usrloc_cb(ucontact_t* c, int type, void* param);
+void pua_reginfo_update_self_op(int v);
+
+#endif
_______________________________________________
sr-dev mailing list
sr-dev(a)lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev