Browse code

version with numerous TM fixes; first to withstand heavy load

Jiri Kuthan authored on 07/12/2001 02:12:23
Showing 5 changed files
... ...
@@ -34,8 +34,8 @@ NAME=ser
34 34
 #                  extra error checking (trying to free the same pointer
35 35
 #                  twice, trying to free a pointer alloc'ed with a different
36 36
 #                  malloc etc.)
37
-DEFS=-DNOCR -DMACROEATER -DDNS_IP_HACK  -DSHM_MEM \
38
-	 -DPKG_MALLOC #-DDBG_QM_MALLOC
37
+DEFS=-DDNS_IP_HACK  -DSHM_MEM \
38
+	 -DPKG_MALLOC #-DDBG_QM_MALLOC 
39 39
 #-DEXTRA_DEBUG
40 40
 # -DUSE_SHM_MEM
41 41
 #-DNO_DEBUG 
... ...
@@ -43,9 +43,9 @@ DEFS=-DNOCR -DMACROEATER -DDNS_IP_HACK  -DSHM_MEM \
43 43
 #-DNO_DEBUG#-DSTATS -DNO_DEBUG 
44 44
 #-DNO_LOG
45 45
 
46
-PROFILE=  # -pg #set this if you want profiling
47
-#mode = debug
48
-mode = release
46
+PROFILE=  -pg #set this if you want profiling
47
+mode = debug
48
+#mode = release
49 49
 
50 50
 # platform dependent settings
51 51
 
... ...
@@ -62,8 +62,8 @@ ifeq ($(mode), release)
62 62
 	# executable file, because it's always loaded at a fixed address
63 63
 	# -andrei
64 64
 else
65
-	CFLAGS=-g -Wcast-align -Winline
66
-	LDFLAGS=-g -Wl,-E
65
+	CFLAGS=-g -fPIC -DPIC -Wcast-align -Winline $(PROFILE)
66
+	LDFLAGS=-g -Wl,-E $(PROFILE)
67 67
 endif
68 68
 
69 69
 LEX=flex
... ...
@@ -457,10 +457,24 @@ int t_forward_uri( struct sip_msg* p_msg, char* foo, char* bar  )
457 457
 int t_on_reply_received( struct sip_msg  *p_msg )
458 458
 {
459 459
    unsigned int  branch,len;
460
+   struct sip_msg *clone;
461
+   int relay;
460 462
 
461 463
    global_msg_id = p_msg->id;
462 464
 
463
-   parse_headers( p_msg , HDR_EOH ); /*????*/
465
+   /* parse_headers( p_msg , HDR_EOH ); */ /*????*/
466
+   /* this might be good enough -- is not like with
467
+      generating own responses where I have to 
468
+      parse all vias to copy them
469
+
470
+   /* if a reply received which has not all fields we might want to
471
+      have for stateul forwarding, give the stateless router
472
+      a chance for minimum routing
473
+   */ 
474
+   if ( parse_headers(p_msg, HDR_VIA1|HDR_VIA2|HDR_TO|HDR_CSEQ )==-1 ||
475
+        !p_msg->via1 || !p_msg->via2 || !p_msg->to || !p_msg->cseq )
476
+	return 1;
477
+
464 478
    /* we use label-matching to lookup for T */
465 479
    t_reply_matching( hash_table , p_msg , &T , &branch  );
466 480
 
... ...
@@ -469,6 +483,16 @@ int t_on_reply_received( struct sip_msg  *p_msg )
469 483
       return 1;
470 484
    DBG("DEBUG: t_on_reply_received: Original status =%d\n",T->status);
471 485
 
486
+   /* we were not able to process the response due to memory
487
+      shortage; simply drop it; hopefuly, we will have more
488
+      memory on the next try
489
+   */
490
+   relay = t_should_relay_response( T , p_msg->first_line.u.reply.statuscode );
491
+   if (relay && !(clone=sip_msg_cloner( p_msg )))
492
+	return 0;
493
+
494
+
495
+
472 496
    /* stop retransmission */
473 497
    remove_from_timer( hash_table , (&(T->outbound_request[branch]->tl[RETRASMISSIONS_LIST])) , RETRASMISSIONS_LIST );
474 498
    /* stop final response timer only if I got a final response */
... ...
@@ -490,8 +514,8 @@ int t_on_reply_received( struct sip_msg  *p_msg )
490 514
    #endif
491 515
 
492 516
    /* if the incoming response code is not reliable->drop it*/
493
-   if ( !t_should_relay_response( T , p_msg->first_line.u.reply.statuscode ) )
494
-      return 0;
517
+   if (!relay) 
518
+	return 0;
495 519
 
496 520
    /* restart retransmission if provisional response came for a non_INVITE -> retrasmit at RT_T2*/
497 521
    if ( p_msg->first_line.u.reply.statusclass==1 && T->inbound_request->first_line.u.request.method_value!=METHOD_INVITE )
... ...
@@ -501,7 +525,15 @@ int t_on_reply_received( struct sip_msg  *p_msg )
501 525
    }
502 526
 
503 527
    /*store the inbound reply*/
504
-   t_store_incoming_reply( T , branch , p_msg );
528
+   /* t_store_incoming_reply( T , branch , p_msg ); */
529
+   /* if there is a previous reply, replace it */
530
+   if ( T->inbound_response[branch] ) {
531
+      sip_msg_free( T->inbound_response[branch] ) ;
532
+      DBG("DEBUG: t_store_incoming_reply: sip_msg_free done....\n");
533
+   }
534
+   T->inbound_response[branch] = clone;
535
+   T->status = p_msg->first_line.u.reply.statuscode;
536
+
505 537
    if ( p_msg->first_line.u.reply.statusclass>=3 && p_msg->first_line.u.reply.statusclass<=5 )
506 538
    {
507 539
       if ( t_all_final(T) )
... ...
@@ -863,17 +895,17 @@ nomatch:
863 895
 /* We like this incoming reply, so, let's store it, we'll decide
864 896
   * later what to d with that
865 897
   */
898
+
899
+/*
866 900
 int t_store_incoming_reply( struct cell* Trans, unsigned int branch, struct sip_msg* p_msg )
867 901
 {
868 902
    DBG("DEBUG: t_store_incoming_reply: starting [%d]....\n",branch);
869
-   /* force parsing all the needed headers*/
870 903
    if ( parse_headers(p_msg, HDR_VIA1|HDR_VIA2|HDR_TO|HDR_CSEQ )==-1 ||
871 904
         !p_msg->via1 || !p_msg->via2 || !p_msg->to || !p_msg->cseq )
872 905
    {
873 906
       LOG( L_ERR , "ERROR: t_store_incoming_reply: unable to parse headers !\n"  );
874 907
       return -1;
875 908
    }
876
-   /* if there is a previous reply, replace it */
877 909
    if ( Trans->inbound_response[branch] ) {
878 910
       sip_msg_free( Trans->inbound_response[branch] ) ;
879 911
       DBG("DEBUG: t_store_incoming_reply: sip_msg_free done....\n");
... ...
@@ -887,6 +919,8 @@ int t_store_incoming_reply( struct cell* Trans, unsigned int branch, struct sip_
887 919
    return 1;
888 920
 }
889 921
 
922
+*/
923
+
890 924
 
891 925
 
892 926
 
... ...
@@ -24,6 +24,7 @@ char* via_builder( struct sip_msg *msg ,
24 24
 									unsigned int *len );
25 25
 
26 26
 
27
+char* via_builder( struct sip_msg *msg , unsigned int *len );
27 28
 
28 29
 
29 30
 #endif
... ...
@@ -1,5 +1,5 @@
1 1
 INVITE sip:p2@iptel.org SIP/2.0
2
-Via: SIP/2.0/UDP 193.175.133.193
2
+Via: SIP/2.0/UDP 192.168.99.100:5040
3 3
 From: "GMD FOKUS iptlab" <sip:jiri@iptel.org>;tag=b96b0300ed30f1286-2f5d
4 4
 To: <sip:p2@iptel.org>
5 5
 Call-ID: b96b0300-88d30f-66da-63aa@195.37.78.190
... ...
@@ -20,4 +20,4 @@ t=0 0
20 20
 m=audio 18456 RTP/AVP 0 8 18 101
21 21
 a=rtpmap:0 pcmu/8000
22 22
 a=rtpmap:101 telephone-event/8000
23
-a=fmtp:101 0-11 
24 23
\ No newline at end of file
24
+a=fmtp:101 0-11 
... ...
@@ -1,5 +1,5 @@
1 1
 SIP/2.0 200 Ok
2
-Via: SIP/2.0/UDP 127.0.0.1
2
+Via: SIP/2.0/UDP 192.168.99.100
3 3
 Via: SIP/2.0/UDP 193.175.133.195:5060
4 4
 From: <sip:x@foo.bar>
5 5
 To: <sip:y@bar.foo>