Browse code

registrar: print number of contacts and max limit in logs and formatting updates

Daniel-Constantin Mierla authored on 18/08/2022 09:34:44
Showing 1 changed files
... ...
@@ -323,7 +323,8 @@ static inline ucontact_info_t* pack_ci( struct sip_msg* _m, contact_t* _c,
323 323
 				ci.instance = _c->instance->body;
324 324
 				LM_DBG("set instance[%.*s]\n", ci.instance.len, ci.instance.s);
325 325
 			}
326
-			if(_use_regid && _c->instance!=NULL && _c->reg_id!=NULL && _c->reg_id->body.len>0) {
326
+			if(_use_regid && _c->instance!=NULL && _c->reg_id!=NULL
327
+					&& _c->reg_id->body.len>0) {
327 328
 				if(str2int(&_c->reg_id->body, &ci.reg_id)<0 || ci.reg_id==0)
328 329
 				{
329 330
 					LM_ERR("invalid reg-id value\n");
... ...
@@ -459,7 +460,8 @@ int reg_get_crt_max_contacts(void)
459 460
  * and insert all contacts from the message that have expires
460 461
  * > 0
461 462
  */
462
-static inline int insert_contacts(struct sip_msg* _m, udomain_t* _d, str* _a, int _use_regid, int novariation)
463
+static inline int insert_contacts(struct sip_msg* _m, udomain_t* _d, str* _a,
464
+		int _use_regid, int novariation)
463 465
 {
464 466
 	ucontact_info_t* ci;
465 467
 	urecord_t* r = NULL;
... ...
@@ -551,7 +553,8 @@ static inline int insert_contacts(struct sip_msg* _m, udomain_t* _d, str* _a, in
551 553
 			if (parse_uri( _c->uri.s, _c->uri.len, &uri)<0) {
552 554
 				LM_ERR("failed to parse contact <%.*s>\n",
553 555
 						_c->uri.len, _c->uri.s);
554
-			} else if (uri.proto==PROTO_TCP || uri.proto==PROTO_TLS || uri.proto==PROTO_WS || uri.proto==PROTO_WSS) {
556
+			} else if (uri.proto==PROTO_TCP || uri.proto==PROTO_TLS
557
+					|| uri.proto==PROTO_WS || uri.proto==PROTO_WSS) {
555 558
 				if (e_max) {
556 559
 					LM_WARN("multiple TCP contacts on single REGISTER\n");
557 560
 					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,
604 607
 		}
605 608
 		ptr = ptr->next;
606 609
 	}
607
-	LM_DBG("%d valid contacts\n", num);
610
+	LM_DBG("%d valid contacts before update\n", num);
608 611
 
609 612
 	for( ; _c ; _c = get_next_contact(_c) ) {
610 613
 		/* calculate expires */
... ...
@@ -626,12 +629,13 @@ static int test_max_contacts(struct sip_msg* _m, urecord_t* _r, contact_t* _c,
626 629
 		}
627 630
 	}
628 631
 
629
-	LM_DBG("%d contacts after commit\n", num);
630 632
 	if (num > mc) {
631
-		LM_INFO("too many contacts for AOR <%.*s>\n", _r->aor.len, _r->aor.s);
633
+		LM_INFO("too many contacts for AOR <%.*s> (n:%d max:%d)\n",
634
+				_r->aor.len, _r->aor.s, num, mc);
632 635
 		rerrno = R_TOO_MANY;
633 636
 		return -1;
634 637
 	}
638
+	LM_DBG("%d contacts when update is done (max: %d)\n", num, mc);
635 639
 
636 640
 	return 0;
637 641
 }
... ...
@@ -648,7 +652,8 @@ static int test_max_contacts(struct sip_msg* _m, urecord_t* _r, contact_t* _c,
648 652
  * 3) If contact in usrloc exists and expires
649 653
  *    == 0, delete contact
650 654
  */
651
-static inline int update_contacts(struct sip_msg* _m, urecord_t* _r, int _mode, int _use_regid, int novariation)
655
+static inline int update_contacts(struct sip_msg* _m, urecord_t* _r, int _mode,
656
+		int _use_regid, int novariation)
652 657
 {
653 658
 	ucontact_info_t *ci;
654 659
 	ucontact_t *c, *ptr, *ptr0;
... ...
@@ -683,7 +688,8 @@ static inline int update_contacts(struct sip_msg* _m, urecord_t* _r, int _mode,
683 688
 
684 689
 #ifdef USE_TCP
685 690
 	if ( (_m->flags&tcp_persistent_flag) &&
686
-			(_m->rcv.proto==PROTO_TCP||_m->rcv.proto==PROTO_TLS||_m->rcv.proto==PROTO_WS||_m->rcv.proto==PROTO_WSS)) {
691
+			(_m->rcv.proto==PROTO_TCP||_m->rcv.proto==PROTO_TLS
692
+			 ||_m->rcv.proto==PROTO_WS||_m->rcv.proto==PROTO_WSS)) {
687 693
 		e_max = -1;
688 694
 		tcp_check = 1;
689 695
 	} else {
... ...
@@ -805,7 +811,8 @@ static inline int update_contacts(struct sip_msg* _m, urecord_t* _r, int _mode,
805 811
 			if (parse_uri( _c->uri.s, _c->uri.len, &uri)<0) {
806 812
 				LM_ERR("failed to parse contact <%.*s>\n",
807 813
 						_c->uri.len, _c->uri.s);
808
-			} else if (uri.proto==PROTO_TCP || uri.proto==PROTO_TLS || uri.proto==PROTO_WS || uri.proto==PROTO_WSS) {
814
+			} else if (uri.proto==PROTO_TCP || uri.proto==PROTO_TLS
815
+					|| uri.proto==PROTO_WS || uri.proto==PROTO_WSS) {
809 816
 				if (e_max>0) {
810 817
 					LM_WARN("multiple TCP contacts on single REGISTER\n");
811 818
 				}