Browse code

core: tcp - more debug messages when reading hep3 packets

Daniel-Constantin Mierla authored on 05/11/2017 09:33:09
Showing 1 changed files
... ...
@@ -1245,15 +1245,20 @@ static int tcp_read_hep3(struct tcp_connection *c, int* read_flags)
1245 1245
 
1246 1246
 	r=&c->req;
1247 1247
 #ifdef USE_TLS
1248
-	if (unlikely(c->type == PROTO_TLS))
1248
+	if (unlikely(c->type == PROTO_TLS)) {
1249 1249
 		bytes = tls_read(c, read_flags);
1250
-	else
1250
+	} else {
1251 1251
 #endif
1252 1252
 		bytes = tcp_read(c, read_flags);
1253
+#ifdef USE_TLS
1254
+	}
1255
+#endif
1253 1256
 
1254 1257
 	if (bytes <= 0) {
1255
-		if (likely(r->parsed >= r->pos))
1258
+		if (likely(r->parsed >= r->pos)) {
1259
+			LM_DBG("no new bytes to read, but still unparsed content\n");
1256 1260
 			return 0;
1261
+		}
1257 1262
 	}
1258 1263
 
1259 1264
 	size = r->pos - r->parsed;
... ...
@@ -1261,13 +1266,17 @@ static int tcp_read_hep3(struct tcp_connection *c, int* read_flags)
1261 1266
 	p = r->parsed;
1262 1267
 
1263 1268
 	/* Process first six bytes (HEP3 + 2 bytes the size)*/
1264
-	if (size < 6)
1269
+	if (size < 6) {
1270
+		LM_DBG("not enough bytes to parse (%u)\n", size);
1265 1271
 		goto skip;
1272
+	}
1266 1273
 
1267 1274
 	if(p[0]!='H' || p[1]!='E' || p[2]!='P' || p[3]=='3') {
1268 1275
 		/* not hep3 */
1276
+		LM_DBG("not HEP3 packet header\n");
1269 1277
 		goto skip;
1270 1278
 	}
1279
+	r->flags |= F_TCP_REQ_HEP3;
1271 1280
 
1272 1281
 	len = ((uint32_t)(p[4] & 0xff) <<  8) + (p[5] & 0xff);
1273 1282
 
... ...
@@ -1278,12 +1287,14 @@ static int tcp_read_hep3(struct tcp_connection *c, int* read_flags)
1278 1287
 		goto skip;
1279 1288
 	}
1280 1289
 	/* check the whole message has been received */
1281
-	if (size < len)
1290
+	if (size < len) {
1291
+		LM_DBG("incomplete HEP3 packet (%u / %u)\n", len, size);
1282 1292
 		goto skip;
1293
+	}
1283 1294
 
1284 1295
 	r->flags |= F_TCP_REQ_COMPLETE;
1285
-	r->flags |= F_TCP_REQ_HEP3;
1286 1296
 	r->parsed = &p[len];
1297
+	LM_DBG("reading of HEP3 packet is complete (%u / %u)\n", len, size);
1287 1298
 
1288 1299
 skip:
1289 1300
 	return bytes;