Browse code

*** empty log message ***

Bogdan-Andrei Iancu authored on 02/12/2001 18:33:25
Showing 5 changed files
... ...
@@ -13,7 +13,7 @@ depends= $(sources:.c=.d)
13 13
 NAME=tm.so
14 14
 
15 15
 SHLIB_LD_FLAGS= -shared
16
-LIBS= #-lpthread
16
+LIBS= -lpthread
17 17
 
18 18
 ifeq ($(ARCH), SunOS)
19 19
 LDFLAGS=-O2 -G
... ...
@@ -3,9 +3,7 @@
3 3
 
4 4
 #include <stdio.h>
5 5
 #include <stdlib.h>
6
-#ifdef THREADS
7 6
 #include <pthread.h>
8
-#endif
9 7
 #include <arpa/inet.h>
10 8
 
11 9
 #include "../../msg_parser.h"
... ...
@@ -198,6 +198,8 @@ int t_lookup_request( struct sip_msg* p_msg, char* foo, char* bar  )
198 198
  */
199 199
 int t_forward( struct sip_msg* p_msg , unsigned int dest_ip_param , unsigned int dest_port_param )
200 200
 {
201
+   unsigned int dest_ip     = dest_ip_param;
202
+   unsigned int dest_port  = dest_port_param;
201 203
    int	branch = 0;	/* we don't do any forking right now */
202 204
 
203 205
    /* it's about the same transaction or not? */
... ...
@@ -226,8 +228,6 @@ int t_forward( struct sip_msg* p_msg , unsigned int dest_ip_param , unsigned int
226 228
    /* if it's forwarded for the first time ; else the request is retransmited from the transaction buffer */
227 229
    if ( T->outbound_request[branch]==NULL )
228 230
    {
229
-      unsigned int dest_ip     = dest_ip_param;
230
-      unsigned int dest_port  = dest_port_param;
231 231
       unsigned int len;
232 232
       char               *buf;
233 233
 
... ...
@@ -265,11 +265,7 @@ int t_forward( struct sip_msg* p_msg , unsigned int dest_ip_param , unsigned int
265 265
       /* store */
266 266
       DBG("DEBUG: t_forward: building outbound request\n");
267 267
       T->outbound_request[branch]->tl[RETRASMISSIONS_LIST].payload = &(T->outbound_request[branch]);
268
-      T->outbound_request[branch]->dest_ip         = dest_ip;
269
-      T->outbound_request[branch]->dest_port      = dest_port;
270 268
       T->outbound_request[branch]->to.sin_family = AF_INET;
271
-      T->outbound_request[branch]->to.sin_port     =  dest_port;
272
-      T->outbound_request[branch]->to.sin_addr.s_addr =  dest_ip;
273 269
 
274 270
       if (add_branch_label( T, p_msg , branch )==-1) return -1;
275 271
       buf = build_req_buf_from_sip_req  ( p_msg, &len);
... ...
@@ -286,7 +282,7 @@ int t_forward( struct sip_msg* p_msg , unsigned int dest_ip_param , unsigned int
286 282
 
287 283
       DBG("DEBUG: t_forward: starting timers (retrans and FR)\n");
288 284
       /*sets and starts the FINAL RESPONSE timer */
289
-      add_to_tail_of_timer_list( hash_table , &(T->outbound_request[branch]->tl[FR_TIMER_LIST]) , FR_TIMER_LIST, FR_TIME_OUT );
285
+      //add_to_tail_of_timer_list( hash_table , &(T->outbound_request[branch]->tl[FR_TIMER_LIST]) , FR_TIMER_LIST, FR_TIME_OUT );
290 286
 
291 287
       /* sets and starts the RETRANS timer */
292 288
       T->outbound_request[branch]->timeout_ceiling  = RETR_T2;
... ...
@@ -298,6 +294,10 @@ int t_forward( struct sip_msg* p_msg , unsigned int dest_ip_param , unsigned int
298 294
 	T->outbound_request[branch]->bufflen, T->outbound_request[branch]->bufflen,
299 295
 	 T->outbound_request[branch]->buffer);
300 296
    /* send the request */
297
+   T->outbound_request[branch]->dest_ip         = dest_ip;
298
+   T->outbound_request[branch]->dest_port      = dest_port;
299
+   T->outbound_request[branch]->to.sin_port     =  dest_port;
300
+   T->outbound_request[branch]->to.sin_addr.s_addr =  dest_ip;
301 301
    udp_send( T->outbound_request[branch]->buffer , T->outbound_request[branch]->bufflen ,
302 302
                     (struct sockaddr*)&(T->outbound_request[branch]->to) , sizeof(struct sockaddr_in) );
303 303
    return 1;
... ...
@@ -1006,7 +1006,7 @@ int t_build_and_send_ACK( struct cell *Trans, unsigned int branch)
1006 1006
    memcpy( p, MY_BRANCH, MY_BRANCH_LEN );
1007 1007
    p+=MY_BRANCH_LEN;
1008 1008
 
1009
-   n=snprintf( p, ack_buf + MAX_ACK_LEN - p, 
1009
+   n=snprintf( p, ack_buf + MAX_ACK_LEN - p,
1010 1010
                  ".%x.%x.%x%s",
1011 1011
                  Trans->hash_index, Trans->label, branch, CRLF );
1012 1012
 
... ...
@@ -1037,8 +1037,8 @@ int t_build_and_send_ACK( struct cell *Trans, unsigned int branch)
1037 1037
 	goto error;
1038 1038
    }
1039 1039
    /* CSeq, EoH */
1040
-   n=snprintf( p, ack_buf + MAX_ACK_LEN - p, 
1041
-                 "Cseq: %*s ACK%s%s", get_cseq(p_msg)->number.len, 
1040
+   n=snprintf( p, ack_buf + MAX_ACK_LEN - p,
1041
+                 "Cseq: %*s ACK%s%s", get_cseq(p_msg)->number.len,
1042 1042
 		get_cseq(p_msg)->number.s, CRLF, CRLF );
1043 1043
    if (n==-1) {
1044 1044
 	LOG(L_ERR, "ERROR: t_build_and_send_ACK: no enough memory for Cseq\n");
... ...
@@ -1069,16 +1069,20 @@ void retransmission_handler( void *attr)
1069 1069
    struct retrans_buff* r_buf = (struct retrans_buff*)attr;
1070 1070
 
1071 1071
    /* the transaction is already removed from RETRANSMISSION_LIST by the timer */
1072
+   DBG("DEBUG: retransmission_handler : payload received=%p\n",attr);
1072 1073
 
1073 1074
    /* computs the new timeout. */
1074 1075
    if ( r_buf->timeout_value<r_buf->timeout_ceiling )
1075 1076
       r_buf->timeout_value *=2;
1076 1077
 
1077 1078
    /* retransmision */
1078
-   udp_send( r_buf->buffer, r_buf->bufflen, (struct sockaddr*)&(r_buf->to) , sizeof(struct sockaddr_in) );
1079
+   DBG("DEBUG: retransmission_handler : resending\n");
1080
+   //udp_send( r_buf->buffer, r_buf->bufflen, (struct sockaddr*)&(r_buf->to) , sizeof(struct sockaddr_in) );
1079 1081
 
1080 1082
    /* re-insert into RETRASMISSIONS_LIST */
1083
+   DBG("DEBUG: retransmission_handler : before insert\n");
1081 1084
    insert_into_timer_list( hash_table , &(r_buf->tl[RETRASMISSIONS_LIST]) , RETRASMISSIONS_LIST , r_buf->timeout_value );
1085
+   DBG("DEBUG: retransmission_handler : after insert\n");
1082 1086
 }
1083 1087
 
1084 1088
 
... ...
@@ -1090,6 +1094,7 @@ void final_response_handler( void *attr)
1090 1094
 
1091 1095
    /* the transaction is already removed from FR_LIST by the timer */
1092 1096
    /* send a 408 */
1097
+   DBG("DEBUG: final_response_handler : sending 408\n");
1093 1098
    t_send_reply( p_cell->inbound_request , 408 , "Request Timeout" );
1094 1099
    /* put it on WT_LIST - transaction is over */
1095 1100
    t_put_on_wait(  p_cell->inbound_request );
... ...
@@ -1104,6 +1109,7 @@ void wait_handler( void *attr)
1104 1109
 
1105 1110
    /* the transaction is already removed from WT_LIST by the timer */
1106 1111
    /* the cell is removed from the hash table */
1112
+   DBG("DEBUG: wait_handler : removing from table\n");
1107 1113
     remove_from_hash_table( hash_table, p_cell );
1108 1114
    /* put it on DEL_LIST - sch for del */
1109 1115
     add_to_tail_of_timer_list( hash_table, &(p_cell->dele_tl), DELETE_LIST, DEL_TIME_OUT );
... ...
@@ -1119,12 +1125,21 @@ void delete_handler( void *attr)
1119 1125
    /* the transaction is already removed from DEL_LIST by the timer */
1120 1126
     /* if is not refenceted -> is deleted*/
1121 1127
     if ( p_cell->ref_counter==0 )
1128
+    {
1129
+       DBG("DEBUG: delete_handler : delete transaction\n");
1122 1130
        free_cell( p_cell );
1131
+    }
1123 1132
     else
1133
+    {
1134
+       DBG("DEBUG: delete_handler : re post for delete\n");
1124 1135
        /* else it's readded to del list for future del */
1125 1136
        add_to_tail_of_timer_list( hash_table, &(p_cell->dele_tl), DELETE_LIST, DEL_TIME_OUT );
1137
+    }
1126 1138
 }
1127 1139
 
1140
+
1141
+
1142
+
1128 1143
 /* append appropriate branch labels for fast reply-transaction matching
1129 1144
    to outgoing requests
1130 1145
 */
... ...
@@ -1133,7 +1148,7 @@ int add_branch_label( struct cell *trans, struct sip_msg *p_msg, int branch )
1133 1148
 	char *c;
1134 1149
 	short n;
1135 1150
 
1136
-	n=snprintf( p_msg->add_to_branch_s+p_msg->add_to_branch_len, 
1151
+	n=snprintf( p_msg->add_to_branch_s+p_msg->add_to_branch_len,
1137 1152
 		  MAX_BRANCH_PARAM_LEN - p_msg->add_to_branch_len,
1138 1153
 		 ".%x.%x.%x",
1139 1154
 		 trans->hash_index, trans->label, branch );
... ...
@@ -1141,8 +1156,5 @@ int add_branch_label( struct cell *trans, struct sip_msg *p_msg, int branch )
1141 1156
 	if (n==-1) {
1142 1157
 		LOG(L_ERR, "ERROR: add_branch_label: too small branch buffer\n");
1143 1158
 		return -1;
1144
-	} else {
1145
-		p_msg->add_to_branch_len += n;
1146
-		return 0;
1147
-	}
1159
+	} else return 0;
1148 1160
 }
... ...
@@ -1,4 +1,5 @@
1 1
 #include "timer.h"
2
+#include "../../dprint.h"
2 3
 
3 4
 
4 5
 /* put a new cell into a list nr. list_id within a hash_table;
... ...
@@ -10,6 +11,7 @@ void add_to_tail_of_timer_list( struct s_table* hash_table , struct timer_link*
10 11
 
11 12
    tl->time_out = time_out + hash_table->time;
12 13
    tl->next_tl= 0;
14
+   DBG("DEBUG: add_to_tail_of_timer[%d]: %d, %p\n",list_id,tl->time_out,tl);
13 15
 
14 16
    /* the entire timer list is locked now -- noone else can manipulate it */
15 17
    lock( timer_list->mutex );
... ...
@@ -38,16 +40,19 @@ void insert_into_timer_list( struct s_table* hash_table , struct timer_link* new
38 40
    struct timer_link  *tl;
39 41
 
40 42
    new_tl->time_out = time_out + hash_table->time;
43
+   DBG("DEBUG: insert_into_timer[%d]: %d, %p\n",list_id,new_tl->time_out,new_tl);
41 44
 
42 45
     /* if we have an empty list*/
43 46
    if ( !timer_list->first_tl )
44 47
    {
48
+      DBG("DEBUG: insert_into_timer[%d]: empty list\n",list_id);
45 49
       new_tl->next_tl= 0;
46 50
       new_tl->prev_tl = 0;
47 51
       lock( timer_list->mutex );
48 52
       timer_list->first_tl = new_tl;
49 53
       timer_list->last_tl = new_tl;
50 54
       unlock( timer_list->mutex );
55
+      return;
51 56
    }
52 57
 
53 58
    for( tl=timer_list->first_tl ; tl && tl->time_out<new_tl->time_out ; tl=tl->next_tl );
... ...
@@ -83,6 +88,7 @@ void insert_into_timer_list( struct s_table* hash_table , struct timer_link* new
83 88
 void remove_from_timer_list( struct s_table* hash_table , struct timer_link* tl , int list_id)
84 89
 {
85 90
    struct timer* timers=&(hash_table->timers[ list_id ]);
91
+   DBG("DEBUG: remove_from_timer[%d]: %d, %p \n",list_id,tl->time_out,tl);
86 92
 
87 93
    if (tl->next_tl || tl->prev_tl || (!tl->next_tl && !tl->prev_tl && tl==timers->first_tl)   )
88 94
    {
... ...
@@ -113,16 +119,20 @@ struct timer_link  *remove_from_timer_list_from_head( struct s_table* hash_table
113 119
 
114 120
    if  (tl)
115 121
    {
122
+      DBG("DEBUG: remove_from_timer_head[%d]: %d , p=%p , next=%p\n",list_id,tl->time_out,tl,tl->next_tl);
116 123
       lock( timers->mutex  );
117 124
       timers->first_tl = tl->next_tl;
118
-     if (!timers->first_tl)
125
+      if (!timers->first_tl)
119 126
          timers->last_tl=0;
120
-     else
127
+      else
121 128
          tl->next_tl->prev_tl = 0;
122 129
       unlock( timers->mutex );
123 130
       tl->next_tl = 0;
124 131
       tl->prev_tl = 0;
125 132
    }
133
+   else
134
+      DBG("DEBUG: remove_from_timer_head[%d]: list is empty! nothing to remove!\n",list_id);
135
+
126 136
 
127 137
    return tl;
128 138
 }
... ...
@@ -147,7 +157,7 @@ void * timer_routine(void * attr)
147 157
       a_sec.tv_usec = 0;
148 158
       select( 0 , 0 , 0 ,0 , &a_sec );
149 159
       (*time)++;
150
-      printf("%d\n", *time);
160
+      DBG("%d\n", *time);
151 161
 
152 162
       for( id=0 ; id<NR_OF_TIMER_LISTS ; id++ )
153 163
          while ( timers[ id ].first_tl && timers[ id ].first_tl->time_out <= *time )
... ...
@@ -12,11 +12,11 @@ enum lists { RETRASMISSIONS_LIST, FR_TIMER_LIST, WT_TIMER_LIST, DELETE_LIST, NR_
12 12
 
13 13
 /* FINAL_RESPONSE_TIMER ... tells how long should the transaction engine
14 14
    wait if no final response comes back*/
15
-#define FR_TIME_OUT     64
15
+#define FR_TIME_OUT     8
16 16
 
17 17
 /* WAIT timer ... tells how long state should persist in memory after
18 18
    a transaction was finalized*/
19
-#define WT_TIME_OUT      16
19
+#define WT_TIME_OUT      8
20 20
 
21 21
 /* DELETE timer ... tells how long should the transaction persist in memory
22 22
    after it was removed from the hash table and before it will be deleted */