Module: kamailio
Branch: master
Commit: a88f805236ef0549ce8a8079142b202d569bf3f1
URL:
https://github.com/kamailio/kamailio/commit/a88f805236ef0549ce8a8079142b202…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2022-08-18T11:34:44+02:00
registrar: print number of contacts and max limit in logs and formatting updates
---
Modified: src/modules/registrar/save.c
---
Diff:
https://github.com/kamailio/kamailio/commit/a88f805236ef0549ce8a8079142b202…
Patch:
https://github.com/kamailio/kamailio/commit/a88f805236ef0549ce8a8079142b202…
---
diff --git a/src/modules/registrar/save.c b/src/modules/registrar/save.c
index e90ae82bb78..5356f74c547 100644
--- a/src/modules/registrar/save.c
+++ b/src/modules/registrar/save.c
@@ -323,7 +323,8 @@ static inline ucontact_info_t* pack_ci( struct sip_msg* _m, contact_t*
_c,
ci.instance = _c->instance->body;
LM_DBG("set instance[%.*s]\n", ci.instance.len, ci.instance.s);
}
- if(_use_regid && _c->instance!=NULL && _c->reg_id!=NULL
&& _c->reg_id->body.len>0) {
+ if(_use_regid && _c->instance!=NULL && _c->reg_id!=NULL
+ && _c->reg_id->body.len>0) {
if(str2int(&_c->reg_id->body, &ci.reg_id)<0 || ci.reg_id==0)
{
LM_ERR("invalid reg-id value\n");
@@ -459,7 +460,8 @@ int reg_get_crt_max_contacts(void)
* and insert all contacts from the message that have expires
* > 0
*/
-static inline int insert_contacts(struct sip_msg* _m, udomain_t* _d, str* _a, int
_use_regid, int novariation)
+static inline int insert_contacts(struct sip_msg* _m, udomain_t* _d, str* _a,
+ int _use_regid, int novariation)
{
ucontact_info_t* ci;
urecord_t* r = NULL;
@@ -551,7 +553,8 @@ static inline int insert_contacts(struct sip_msg* _m, udomain_t* _d,
str* _a, in
if (parse_uri( _c->uri.s, _c->uri.len, &uri)<0) {
LM_ERR("failed to parse contact <%.*s>\n",
_c->uri.len, _c->uri.s);
- } else if (uri.proto==PROTO_TCP || uri.proto==PROTO_TLS || uri.proto==PROTO_WS ||
uri.proto==PROTO_WSS) {
+ } else if (uri.proto==PROTO_TCP || uri.proto==PROTO_TLS
+ || uri.proto==PROTO_WS || uri.proto==PROTO_WSS) {
if (e_max) {
LM_WARN("multiple TCP contacts on single REGISTER\n");
if (expires>e_max) e_max = expires;
@@ -604,7 +607,7 @@ static int test_max_contacts(struct sip_msg* _m, urecord_t* _r,
contact_t* _c,
}
ptr = ptr->next;
}
- LM_DBG("%d valid contacts\n", num);
+ LM_DBG("%d valid contacts before update\n", num);
for( ; _c ; _c = get_next_contact(_c) ) {
/* calculate expires */
@@ -626,12 +629,13 @@ static int test_max_contacts(struct sip_msg* _m, urecord_t* _r,
contact_t* _c,
}
}
- LM_DBG("%d contacts after commit\n", num);
if (num > mc) {
- LM_INFO("too many contacts for AOR <%.*s>\n", _r->aor.len,
_r->aor.s);
+ LM_INFO("too many contacts for AOR <%.*s> (n:%d max:%d)\n",
+ _r->aor.len, _r->aor.s, num, mc);
rerrno = R_TOO_MANY;
return -1;
}
+ LM_DBG("%d contacts when update is done (max: %d)\n", num, mc);
return 0;
}
@@ -648,7 +652,8 @@ static int test_max_contacts(struct sip_msg* _m, urecord_t* _r,
contact_t* _c,
* 3) If contact in usrloc exists and expires
* == 0, delete contact
*/
-static inline int update_contacts(struct sip_msg* _m, urecord_t* _r, int _mode, int
_use_regid, int novariation)
+static inline int update_contacts(struct sip_msg* _m, urecord_t* _r, int _mode,
+ int _use_regid, int novariation)
{
ucontact_info_t *ci;
ucontact_t *c, *ptr, *ptr0;
@@ -683,7 +688,8 @@ static inline int update_contacts(struct sip_msg* _m, urecord_t* _r,
int _mode,
#ifdef USE_TCP
if ( (_m->flags&tcp_persistent_flag) &&
- (_m->rcv.proto==PROTO_TCP||_m->rcv.proto==PROTO_TLS||_m->rcv.proto==PROTO_WS||_m->rcv.proto==PROTO_WSS))
{
+ (_m->rcv.proto==PROTO_TCP||_m->rcv.proto==PROTO_TLS
+ ||_m->rcv.proto==PROTO_WS||_m->rcv.proto==PROTO_WSS)) {
e_max = -1;
tcp_check = 1;
} else {
@@ -805,7 +811,8 @@ static inline int update_contacts(struct sip_msg* _m, urecord_t* _r,
int _mode,
if (parse_uri( _c->uri.s, _c->uri.len, &uri)<0) {
LM_ERR("failed to parse contact <%.*s>\n",
_c->uri.len, _c->uri.s);
- } else if (uri.proto==PROTO_TCP || uri.proto==PROTO_TLS || uri.proto==PROTO_WS ||
uri.proto==PROTO_WSS) {
+ } else if (uri.proto==PROTO_TCP || uri.proto==PROTO_TLS
+ || uri.proto==PROTO_WS || uri.proto==PROTO_WSS) {
if (e_max>0) {
LM_WARN("multiple TCP contacts on single REGISTER\n");
}