From 27a0b913330b78acee95b4d3c82a10f1d36627df Mon Sep 17 00:00:00 2001 From: Andy Green Date: Sat, 16 Apr 2011 10:54:28 +0100 Subject: [PATCH] fix frgmented server reply Server handshake reply might not come in one packet as pointed out by Pavel Borzenkov. This replaces his fix with one directly in the packet state machine. Signed-off-by: Andy Green --- lib/libwebsockets.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index 05f7a40..95d1249 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -1364,11 +1364,14 @@ issue_hdr: for (n = 0; n < len; n++) libwebsocket_parse(wsi, *p++); - if (wsi->parser_state != WSI_PARSING_COMPLETE) { - fprintf(stderr, "libwebsocket_client_handshake " - "server response failed parsing\n"); - goto bail3; - } + /* + * may be coming in multiple packets, there is a 5-second + * libwebsocket timeout still active here too, so if parsing did + * not complete just wait for next packet coming in this state + */ + + if (wsi->parser_state != WSI_PARSING_COMPLETE) + break; /* * 00 / 76 --> -- 2.7.4