cover-proxy-read-EAGAIN.patch
authorshys <shyswork@zoho.com>
Fri, 25 Oct 2013 13:50:21 +0000 (15:50 +0200)
committerAndy Green <andy.green@linaro.org>
Fri, 25 Oct 2013 14:30:25 +0000 (22:30 +0800)
Subject: [PATCH] Because of nonblocking sockets reading from  proxy might not
 work in one turn. We should check for EAGAIN.

lib/client.c

index 561c009..7e81df5 100644 (file)
@@ -78,6 +78,13 @@ int lws_client_socket_service(struct libwebsocket_context *context,
                n = recv(wsi->sock, context->service_buffer,
                                        sizeof(context->service_buffer), 0);
                if (n < 0) {
+                       
+                       if (errno == EAGAIN) {
+                               lwsl_debug(
+                                                  "Proxy read returned EAGAIN... retrying\n");
+                               return 0;
+                       }
+                       
                        libwebsocket_close_and_free_session(context, wsi,
                                                     LWS_CLOSE_STATUS_NOSTATUS);
                        lwsl_err("ERROR reading from proxy socket\n");