Browse code

core: option to specify whether the send info has to be set before sending out

Daniel-Constantin Mierla authored on 26/05/2014 12:16:49
Showing 2 changed files
... ...
@@ -121,6 +121,12 @@
121 121
 static int mhomed_sock_cache_disabled = 0;
122 122
 static int sock_inet = -1;
123 123
 static int sock_inet6 = -1;
124
+static int _forward_set_send_info = 0;
125
+
126
+void forward_set_send_info(int v)
127
+{
128
+	_forward_set_send_info = v;
129
+}
124 130
 
125 131
 static void apply_force_send_socket(struct dest_info* dst, struct sip_msg* msg);
126 132
 
... ...
@@ -497,6 +503,7 @@ int forward_request(struct sip_msg* msg, str* dst, unsigned short port,
497 497
 	int ret;
498 498
 	struct ip_addr ip; /* debugging only */
499 499
 	char proto;
500
+	struct onsend_info onsnd_info = {0};
500 501
 #ifdef USE_DNS_FAILOVER
501 502
 	struct socket_info* prev_send_sock;
502 503
 	int err;
... ...
@@ -623,7 +630,18 @@ int forward_request(struct sip_msg* msg, str* dst, unsigned short port,
623 623
 			}
624 624
 		}
625 625
 #endif
626
+
627
+		if(unlikely(_forward_set_send_info==1)) {
628
+			onsnd_info.to=&send_info->to;
629
+			onsnd_info.send_sock=send_info->send_sock;
630
+			onsnd_info.buf=buf;
631
+			onsnd_info.len=len;
632
+			onsnd_info.msg=msg;
633
+			p_onsend=&onsnd_info;
634
+		}
635
+
626 636
 		if (msg_send(send_info, buf, len)<0){
637
+			p_onsend=0;
627 638
 			ret=ser_error=E_SEND;
628 639
 #ifdef USE_DST_BLACKLIST
629 640
 			(void)dst_blacklist_add(BLST_ERR_SEND, send_info, msg);
... ...
@@ -634,6 +652,7 @@ int forward_request(struct sip_msg* msg, str* dst, unsigned short port,
634 634
 			goto error;
635 635
 #endif
636 636
 		}else{
637
+			p_onsend=0;
637 638
 			ret=ser_error=E_OK;
638 639
 			/* sent requests stats */
639 640
 			STATS_TX_REQUEST(  msg->first_line.u.request.method_value );
... ...
@@ -109,6 +109,8 @@ int update_sock_struct_from_via( union sockaddr_union* to,
109 109
 int forward_reply( struct sip_msg* msg);
110 110
 int forward_reply_nocb( struct sip_msg* msg);
111 111
 
112
+void forward_set_send_info(int v);
113
+
112 114
 int is_check_self_func_list_set(void);
113 115
 
114 116