[sr-dev] git:master:5a84ca7a: core: receive.c optimization, add a few unlikely compiler builtin in error path

Henning Westerholt hw at kamailio.org
Mon Mar 12 22:02:06 CET 2018


Module: kamailio
Branch: master
Commit: 5a84ca7a2e3f3cdcde0ff444aee272eb0a8c5561
URL: https://github.com/kamailio/kamailio/commit/5a84ca7a2e3f3cdcde0ff444aee272eb0a8c5561

Author: Henning Westerholt <hw at kamailio.org>
Committer: Henning Westerholt <hw at kamailio.org>
Date: 2018-03-12T21:59:10+01:00

core: receive.c optimization, add a few unlikely compiler builtin in error path

---

Modified: src/core/receive.c

---

Diff:  https://github.com/kamailio/kamailio/commit/5a84ca7a2e3f3cdcde0ff444aee272eb0a8c5561.diff
Patch: https://github.com/kamailio/kamailio/commit/5a84ca7a2e3f3cdcde0ff444aee272eb0a8c5561.patch

---

diff --git a/src/core/receive.c b/src/core/receive.c
index 3b98438e34..27d4bd9986 100644
--- a/src/core/receive.c
+++ b/src/core/receive.c
@@ -189,7 +189,7 @@ int receive_msg(char *buf, unsigned int len, struct receive_info *rcv_info)
 	len = inb.len;
 
 	msg = pkg_malloc(sizeof(struct sip_msg));
-	if(msg == 0) {
+	if(unlikely(msg == 0)) {
 		LM_ERR("no mem for sip_msg\n");
 		goto error00;
 	}
@@ -225,8 +225,8 @@ int receive_msg(char *buf, unsigned int len, struct receive_info *rcv_info)
 			goto error02;
 	}
 
-	if(parse_headers(msg, HDR_FROM_F | HDR_TO_F | HDR_CALLID_F | HDR_CSEQ_F, 0)
-			< 0) {
+	if(unlikely(parse_headers(msg, HDR_FROM_F | HDR_TO_F | HDR_CALLID_F | HDR_CSEQ_F, 0)
+			< 0)) {
 		LM_WARN("parsing relevant headers failed\n");
 	}
 	LM_DBG("--- received sip message - %s - call-id: [%.*s] - cseq: [%.*s]\n",
@@ -259,7 +259,7 @@ int receive_msg(char *buf, unsigned int len, struct receive_info *rcv_info)
 			}
 		}
 		/* sanity checks */
-		if((msg->via1 == 0) || (msg->via1->error != PARSE_OK)) {
+		if(unlikely((msg->via1 == 0) || (msg->via1->error != PARSE_OK))) {
 			/* no via, send back error ? */
 			LM_ERR("no via found in request\n");
 			STATS_BAD_MSG();




More information about the sr-dev mailing list