浏览代码

core: fixed an issue where big websocket requests (single WS frame but across multiple packets) weren't handled

Peter Dunkley 13 年之前
父节点
当前提交
d07a57f684
共有 1 个文件被更改,包括 9 次插入15 次删除
  1. 9 15
      tcp_read.c

+ 9 - 15
tcp_read.c

@@ -1024,27 +1024,21 @@ static int tcp_read_ws(struct tcp_connection *c, int* read_flags)
 	struct tcp_req *r;
 
 	r=&c->req;
-	if (unlikely(r->parsed < r->pos))
-	{
-		LM_ERR("next frame...\n");
-		bytes = 0;
-		size = r->pos - r->parsed;
-	}
-	else
-	{
 #ifdef USE_TLS
-		if (unlikely(c->type == PROTO_TLS))
-			bytes = tls_read(c, read_flags);
-		else
+	if (unlikely(c->type == PROTO_TLS))
+		bytes = tls_read(c, read_flags);
+	else
 #endif
-			bytes = tcp_read(c, read_flags);
+		bytes = tcp_read(c, read_flags);
 
-		if (bytes <= 0)
+	if (bytes <= 0)
+	{
+		if (likely(r->parsed >= r->pos))
 			return 0;
-
-		size = bytes;
 	}
 
+	size = r->pos - r->parsed;
+
 	p = r->parsed;
 	pos = 0;