Browse Source

outbound: pass recv info struct by address

- fix performance inefficiency for passing large structs by value

(cherry picked from commit 56ea88ef9a0628d7ca644f31840101ffe573e5c3)
(cherry picked from commit 40e3773f28faf392475b142f54f301d7c0ec6f6e)
Daniel-Constantin Mierla 5 years ago
parent
commit
8eb99e94d4
2 changed files with 11 additions and 11 deletions
  1. 1 1
      src/modules/outbound/api.h
  2. 10 10
      src/modules/outbound/outbound_mod.c

+ 1 - 1
src/modules/outbound/api.h

@@ -30,7 +30,7 @@
 #include "../../core/str.h"
 #include "../../core/sr_module.h"
 
-typedef int (*encode_flow_token_t)(str *, struct receive_info);
+typedef int (*encode_flow_token_t)(str *, struct receive_info *);
 typedef int (*decode_flow_token_t)(struct sip_msg *, struct receive_info **, str);
 typedef int (*use_outbound_t)(struct sip_msg *);
 

+ 10 - 10
src/modules/outbound/outbound_mod.c

@@ -156,7 +156,7 @@ static void destroy(void)
 static unsigned char unenc_flow_token[UNENC_FLOW_TOKEN_MAX_LENGTH];
 static unsigned char hmac_sha1[EVP_MAX_MD_SIZE];
 
-int encode_flow_token(str *flow_token, struct receive_info rcv)
+int encode_flow_token(str *flow_token, struct receive_info *rcv)
 {
 	int pos = FLOW_TOKEN_START_POS, i;
 
@@ -168,19 +168,19 @@ int encode_flow_token(str *flow_token, struct receive_info rcv)
 
 	/* Encode protocol information */
 	unenc_flow_token[pos++] =
-		(rcv.dst_ip.af == AF_INET6 ? 0x80 : 0x00) | rcv.proto;
+		(rcv->dst_ip.af == AF_INET6 ? 0x80 : 0x00) | rcv->proto;
 
 	/* Encode destination address */
-	for (i = 0; i < (rcv.dst_ip.af == AF_INET6 ? 16 : 4); i++)
-		unenc_flow_token[pos++] = rcv.dst_ip.u.addr[i];
-	unenc_flow_token[pos++] = (rcv.dst_port >> 8) & 0xff;
-	unenc_flow_token[pos++] =  rcv.dst_port       & 0xff;
+	for (i = 0; i < (rcv->dst_ip.af == AF_INET6 ? 16 : 4); i++)
+		unenc_flow_token[pos++] = rcv->dst_ip.u.addr[i];
+	unenc_flow_token[pos++] = (rcv->dst_port >> 8) & 0xff;
+	unenc_flow_token[pos++] =  rcv->dst_port       & 0xff;
 
 	/* Encode source address */
-	for (i = 0; i < (rcv.src_ip.af == AF_INET6 ? 16 : 4); i++)
-		unenc_flow_token[pos++] = rcv.src_ip.u.addr[i];
-	unenc_flow_token[pos++] = (rcv.src_port >> 8) & 0xff;
-	unenc_flow_token[pos++] =  rcv.src_port       & 0xff;
+	for (i = 0; i < (rcv->src_ip.af == AF_INET6 ? 16 : 4); i++)
+		unenc_flow_token[pos++] = rcv->src_ip.u.addr[i];
+	unenc_flow_token[pos++] = (rcv->src_port >> 8) & 0xff;
+	unenc_flow_token[pos++] =  rcv->src_port       & 0xff;
 
 	/* HMAC-SHA1 the calculated flow-token, truncate to 80 bits, and
 	   prepend onto the flow-token */