[sr-dev] git:pd/websocket: core: fixed an issue where big websocket requests ( single WS frame but across multiple packets) weren't handled

Peter Dunkley peter.dunkley at crocodile-rcs.com
Thu Jun 28 18:58:47 CEST 2012


Module: sip-router
Branch: pd/websocket
Commit: d07a57f6849e94764302939541157c71d73eae6a
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=d07a57f6849e94764302939541157c71d73eae6a

Author: Peter Dunkley <peter.dunkley at crocodile-rcs.com>
Committer: Peter Dunkley <peter.dunkley at crocodile-rcs.com>
Date:   Thu Jun 28 17:55:53 2012 +0100

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

---

 tcp_read.c |   24 +++++++++---------------
 1 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/tcp_read.c b/tcp_read.c
index e33984b..b524727 100644
--- a/tcp_read.c
+++ b/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;
 




More information about the sr-dev mailing list