Преглед изворни кода

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

Daniel-Constantin Mierla пре 11 година
родитељ
комит
9d9e7399b7
2 измењених фајлова са 21 додато и 0 уклоњено
  1. 19 0
      forward.c
  2. 2 0
      forward.h

+ 19 - 0
forward.c

@@ -121,6 +121,12 @@
 static int mhomed_sock_cache_disabled = 0;
 static int mhomed_sock_cache_disabled = 0;
 static int sock_inet = -1;
 static int sock_inet = -1;
 static int sock_inet6 = -1;
 static int sock_inet6 = -1;
+static int _forward_set_send_info = 0;
+
+void forward_set_send_info(int v)
+{
+	_forward_set_send_info = v;
+}
 
 
 static void apply_force_send_socket(struct dest_info* dst, struct sip_msg* msg);
 static void apply_force_send_socket(struct dest_info* dst, struct sip_msg* msg);
 
 
@@ -497,6 +503,7 @@ int forward_request(struct sip_msg* msg, str* dst, unsigned short port,
 	int ret;
 	int ret;
 	struct ip_addr ip; /* debugging only */
 	struct ip_addr ip; /* debugging only */
 	char proto;
 	char proto;
+	struct onsend_info onsnd_info = {0};
 #ifdef USE_DNS_FAILOVER
 #ifdef USE_DNS_FAILOVER
 	struct socket_info* prev_send_sock;
 	struct socket_info* prev_send_sock;
 	int err;
 	int err;
@@ -623,7 +630,18 @@ int forward_request(struct sip_msg* msg, str* dst, unsigned short port,
 			}
 			}
 		}
 		}
 #endif
 #endif
+
+		if(unlikely(_forward_set_send_info==1)) {
+			onsnd_info.to=&send_info->to;
+			onsnd_info.send_sock=send_info->send_sock;
+			onsnd_info.buf=buf;
+			onsnd_info.len=len;
+			onsnd_info.msg=msg;
+			p_onsend=&onsnd_info;
+		}
+
 		if (msg_send(send_info, buf, len)<0){
 		if (msg_send(send_info, buf, len)<0){
+			p_onsend=0;
 			ret=ser_error=E_SEND;
 			ret=ser_error=E_SEND;
 #ifdef USE_DST_BLACKLIST
 #ifdef USE_DST_BLACKLIST
 			(void)dst_blacklist_add(BLST_ERR_SEND, send_info, msg);
 			(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,
 			goto error;
 			goto error;
 #endif
 #endif
 		}else{
 		}else{
+			p_onsend=0;
 			ret=ser_error=E_OK;
 			ret=ser_error=E_OK;
 			/* sent requests stats */
 			/* sent requests stats */
 			STATS_TX_REQUEST(  msg->first_line.u.request.method_value );
 			STATS_TX_REQUEST(  msg->first_line.u.request.method_value );

+ 2 - 0
forward.h

@@ -109,6 +109,8 @@ int update_sock_struct_from_via( union sockaddr_union* to,
 int forward_reply( struct sip_msg* msg);
 int forward_reply( struct sip_msg* msg);
 int forward_reply_nocb( struct sip_msg* msg);
 int forward_reply_nocb( struct sip_msg* msg);
 
 
+void forward_set_send_info(int v);
+
 int is_check_self_func_list_set(void);
 int is_check_self_func_list_set(void);