Subject: [PATCH] On iOS with nonblocking sockets I experience SSL error which
authorshys <shyswork@zoho.com>
Fri, 25 Oct 2013 13:52:47 +0000 (15:52 +0200)
committerAndy Green <andy.green@linaro.org>
Fri, 25 Oct 2013 14:26:36 +0000 (22:26 +0800)
 is not really an error (
 http://lists.freeradius.org/pipermail/freeradius-users/2009-August/040155.html
 ). Added check for that. Additional fixes for comments and logging.

lib/client.c

index c81f641..561c009 100644 (file)
@@ -196,16 +196,21 @@ int lws_client_socket_service(struct libwebsocket_context *context,
                                 * retry if new data comes until we
                                 * run into the connection timeout or win
                                 */
-
-                               lwsl_err("SSL connect error %lu: %s\n", 
-                                       ERR_get_error(),
-                                       ERR_error_string(ERR_get_error(),
-                                             (char *)context->service_buffer));
-                               return 0;
+                               
+                               n = ERR_get_error();
+                               if (n != SSL_ERROR_NONE) {
+                                       lwsl_err("SSL connect error %lu: %s\n",
+                                               ERR_get_error(),
+                                               ERR_error_string(ERR_get_error(),
+                                                         (char *)context->service_buffer));
+                                       return 0;
+                               }
                        }
                } else
                        wsi->ssl = NULL;
 
+               /* fallthru */
+                       
        case LWS_CONNMODE_WS_CLIENT_WAITING_SSL:
                        
                if (wsi->use_ssl) {
@@ -214,7 +219,7 @@ int lws_client_socket_service(struct libwebsocket_context *context,
                                lws_latency_pre(context, wsi);
                                n = SSL_connect(wsi->ssl);
                                lws_latency(context, wsi,
-                                                       "SSL_connect LWS_CONNMODE_WS_CLIENT_ISSUE_HANDSHAKE",
+                                                       "SSL_connect LWS_CONNMODE_WS_CLIENT_WAITING_SSL",
                                                        n, n > 0);
                                
                                if (n < 0) {
@@ -252,12 +257,14 @@ int lws_client_socket_service(struct libwebsocket_context *context,
                                         * retry if new data comes until we
                                         * run into the connection timeout or win
                                         */
-                                       
-                                       lwsl_err("SSL connect error %lu: %s\n",
-                                                        ERR_get_error(),
-                                                        ERR_error_string(ERR_get_error(),
-                                                                                         (char *)context->service_buffer));
-                                       return 0;
+                                       n = ERR_get_error();
+                                       if (n != SSL_ERROR_NONE) {
+                                               lwsl_err("SSL connect error %lu: %s\n",
+                                                                ERR_get_error(),
+                                                                ERR_error_string(ERR_get_error(),
+                                                                                                 (char *)context->service_buffer));
+                                               return 0;
+                                       }
                                }
                        }