Browse code

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

- reported by GH #748

(cherry picked from commit 71b9765462d3df1686274c4b6380c71cf02dc099)

Daniel-Constantin Mierla authored on 31/08/2016 12:54:13
Showing 1 changed files
... ...
@@ -1300,7 +1300,7 @@ int tcp_read_req(struct tcp_connection* con, int* bytes_read, int* read_flags)
1300 1300
 	struct dest_info dst;
1301 1301
 	char c;
1302 1302
 	int ret;
1303
-		
1303
+
1304 1304
 		bytes=-1;
1305 1305
 		total_bytes=0;
1306 1306
 		resp=CONN_RELEASE;
... ...
@@ -1314,6 +1314,15 @@ again:
1314 1314
 			else
1315 1315
 #endif
1316 1316
 				bytes=tcp_read_headers(con, read_flags);
1317
+
1318
+			if (unlikely(bytes==-1)){
1319
+				LOG(cfg_get(core, core_cfg, corelog),
1320
+						"ERROR: tcp_read_req: error reading - c: %p r: %p\n",
1321
+						con, req);
1322
+				resp=CONN_ERROR;
1323
+				goto end_req;
1324
+			}
1325
+
1317 1326
 #ifdef EXTRA_DEBUG
1318 1327
 						/* if timeout state=0; goto end__req; */
1319 1328
 			LM_DBG("read= %d bytes, parsed=%d, state=%d, error=%d\n",
... ...
@@ -1323,12 +1332,6 @@ again:
1323 1323
 					*(req->parsed-1), (int)(req->parsed-req->start),
1324 1324
 					req->start);
1325 1325
 #endif
1326
-			if (unlikely(bytes==-1)){
1327
-				LOG(cfg_get(core, core_cfg, corelog),
1328
-						"ERROR: tcp_read_req: error reading \n");
1329
-				resp=CONN_ERROR;
1330
-				goto end_req;
1331
-			}
1332 1326
 			total_bytes+=bytes;
1333 1327
 			/* eof check:
1334 1328
 			 * is EOF if eof on fd and req.  not complete yet,