Skip to content

Commit

Permalink
registrar: print number of contacts and max limit in logs and formatt…
Browse files Browse the repository at this point in the history
…ing updates

(cherry picked from commit a88f805)
  • Loading branch information
miconda committed Sep 14, 2022
1 parent 9d473f9 commit 5ffbbaa
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/modules/registrar/save.c
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand All @@ -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;
}
Expand All @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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");
}
Expand Down

0 comments on commit 5ffbbaa

Please sign in to comment.