Bläddra i källkod

ACK_FORKLING_HACK introduced

Jiri Kuthan 23 år sedan
förälder
incheckning
a1f160e7ec
2 ändrade filer med 36 tillägg och 0 borttagningar
  1. 9 0
      modules/tm/config.h
  2. 27 0
      modules/tm/t_funcs.c

+ 9 - 0
modules/tm/config.h

@@ -57,4 +57,13 @@
 #define CANCEL_DONE "ok -- no more pending branches"
 #define CANCELLED "Request cancelled"
 
+/* ACKnowledgement forking hack -- that is good for phones
+   which send ACKs to the same outbound proxy; if forking is
+   enabled, the proxy wouldn't know to which branch to forward;
+   without forking, it could forward to other branch than from
+   which a reply came back, resulting in UAS never seeing it;
+   this hack has not been tested yet
+*/
+#undef ACK_FORKING_HACK
+
 #endif

+ 27 - 0
modules/tm/t_funcs.c

@@ -14,6 +14,7 @@
 #include "t_funcs.h"
 #include "t_fwd.h"
 #include "t_lookup.h"
+#include "config.h"
 
 /* pointer to the big table where all the transaction data
    lives
@@ -201,6 +202,10 @@ int t_relay_to( struct sip_msg  *p_msg , struct proxy_l *proxy,
 	int reply_ret;
 	/* struct hdr_field *hdr; */
 	struct cell *t;
+#ifdef ACK_FORKING_HACK
+	str ack_uri;
+	str backup_uri;
+#endif
 
 	ret=0;
 
@@ -238,8 +243,30 @@ int t_relay_to( struct sip_msg  *p_msg , struct proxy_l *proxy,
 			ret=forward_request( p_msg , proxy ) ;
 			free_proxy( proxy );	
 			free( proxy );
+#ifdef ACK_FORKING_HACK
+			backup_uri=p_msg->new_uri;
+			init_branch_iterator();
+			while((ack_uri.s=next_branch(&ack_uri.len))) {
+				p_msg->new_uri=ack_uri;
+				proxy=uri2proxy(ack_uri);
+				if (proxy==0) continue;
+				forward_request(p_msg, proxy);
+				free_proxy( proxy );	
+				free( proxy );
+			}
+			p_msg->new_uri=backup_uri;
+#endif
 		} else {
 			ret=forward_request( p_msg , proxy ) ;
+#ifdef ACK_FORKING_HACK
+			backup_uri=p_msg->new_uri;
+			init_branch_iterator();
+			while((ack_uri.s=next_branch(&ack_uri.len))) {
+				p_msg->new_uri=ack_uri;
+				forward_request(p_msg, proxy);
+			}
+			p_msg->new_uri=backup_uri;
+#endif
 		}
 		goto done;
 	}