[sr-dev] git:master:71b97654: core: handle return code for tcp read headers/ws before printing extra debug logs

Daniel-Constantin Mierla miconda at gmail.com
Wed Aug 31 14:56:26 CEST 2016


Module: kamailio
Branch: master
Commit: 71b9765462d3df1686274c4b6380c71cf02dc099
URL: https://github.com/kamailio/kamailio/commit/71b9765462d3df1686274c4b6380c71cf02dc099

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2016-08-31T14:54:13+02:00

core: handle return code for tcp read headers/ws before printing extra debug logs

- reported by GH #748

---

Modified: tcp_read.c

---

Diff:  https://github.com/kamailio/kamailio/commit/71b9765462d3df1686274c4b6380c71cf02dc099.diff
Patch: https://github.com/kamailio/kamailio/commit/71b9765462d3df1686274c4b6380c71cf02dc099.patch

---

diff --git a/tcp_read.c b/tcp_read.c
index a31d3a2..3141b67 100644
--- a/tcp_read.c
+++ b/tcp_read.c
@@ -1300,7 +1300,7 @@ int tcp_read_req(struct tcp_connection* con, int* bytes_read, int* read_flags)
 	struct dest_info dst;
 	char c;
 	int ret;
-		
+
 		bytes=-1;
 		total_bytes=0;
 		resp=CONN_RELEASE;
@@ -1314,6 +1314,15 @@ int tcp_read_req(struct tcp_connection* con, int* bytes_read, int* read_flags)
 			else
 #endif
 				bytes=tcp_read_headers(con, read_flags);
+
+			if (unlikely(bytes==-1)){
+				LOG(cfg_get(core, core_cfg, corelog),
+						"ERROR: tcp_read_req: error reading - c: %p r: %p\n",
+						con, req);
+				resp=CONN_ERROR;
+				goto end_req;
+			}
+
 #ifdef EXTRA_DEBUG
 						/* if timeout state=0; goto end__req; */
 			LM_DBG("read= %d bytes, parsed=%d, state=%d, error=%d\n",
@@ -1323,12 +1332,6 @@ int tcp_read_req(struct tcp_connection* con, int* bytes_read, int* read_flags)
 					*(req->parsed-1), (int)(req->parsed-req->start),
 					req->start);
 #endif
-			if (unlikely(bytes==-1)){
-				LOG(cfg_get(core, core_cfg, corelog),
-						"ERROR: tcp_read_req: error reading \n");
-				resp=CONN_ERROR;
-				goto end_req;
-			}
 			total_bytes+=bytes;
 			/* eof check:
 			 * is EOF if eof on fd and req.  not complete yet,




More information about the sr-dev mailing list