ssl treat WANT_READ and WRITE separately
Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
parent
ae7b27c77a
commit
1c6e7bffb7
1 changed files with 17 additions and 18 deletions
35
lib/client.c
35
lib/client.c
|
@ -215,8 +215,10 @@ int lws_client_socket_service(struct libwebsocket_context *context,
|
|||
if (n < 0) {
|
||||
n = SSL_get_error(wsi->ssl, n);
|
||||
|
||||
if (n == SSL_ERROR_WANT_READ ||
|
||||
n == SSL_ERROR_WANT_WRITE) {
|
||||
if (n == SSL_ERROR_WANT_READ)
|
||||
goto some_wait;
|
||||
|
||||
if (n == SSL_ERROR_WANT_WRITE) {
|
||||
/*
|
||||
* wants us to retry connect due to
|
||||
* state of the underlying ssl layer...
|
||||
|
@ -231,10 +233,10 @@ int lws_client_socket_service(struct libwebsocket_context *context,
|
|||
*/
|
||||
|
||||
lwsl_info(
|
||||
"SSL_connect WANT_... retrying\n");
|
||||
"SSL_connect WANT_WRITE... retrying\n");
|
||||
libwebsocket_callback_on_writable(
|
||||
context, wsi);
|
||||
|
||||
some_wait:
|
||||
wsi->mode = LWS_CONNMODE_WS_CLIENT_WAITING_SSL;
|
||||
|
||||
return 0; /* no error */
|
||||
|
@ -270,14 +272,16 @@ 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_WAITING_SSL",
|
||||
n, n > 0);
|
||||
"SSL_connect LWS_CONNMODE_WS_CLIENT_WAITING_SSL",
|
||||
n, n > 0);
|
||||
|
||||
if (n < 0) {
|
||||
n = SSL_get_error(wsi->ssl, n);
|
||||
|
||||
if (n == SSL_ERROR_WANT_READ ||
|
||||
n == SSL_ERROR_WANT_WRITE) {
|
||||
if (n == SSL_ERROR_WANT_READ)
|
||||
goto some_wait;
|
||||
|
||||
if (n == SSL_ERROR_WANT_WRITE) {
|
||||
/*
|
||||
* wants us to retry connect due to
|
||||
* state of the underlying ssl layer...
|
||||
|
@ -291,14 +295,10 @@ int lws_client_socket_service(struct libwebsocket_context *context,
|
|||
* us to get called back when writable.
|
||||
*/
|
||||
|
||||
lwsl_info(
|
||||
"SSL_connect WANT_... retrying\n");
|
||||
libwebsocket_callback_on_writable(
|
||||
context, wsi);
|
||||
lwsl_info("SSL_connect WANT_WRITE... retrying\n");
|
||||
libwebsocket_callback_on_writable(context, wsi);
|
||||
|
||||
wsi->mode = LWS_CONNMODE_WS_CLIENT_WAITING_SSL;
|
||||
|
||||
return 0; /* no error */
|
||||
goto some_wait;
|
||||
}
|
||||
n = -1;
|
||||
}
|
||||
|
@ -311,9 +311,8 @@ int lws_client_socket_service(struct libwebsocket_context *context,
|
|||
n = ERR_get_error();
|
||||
if (n != SSL_ERROR_NONE) {
|
||||
lwsl_err("SSL connect error %lu: %s\n",
|
||||
n,
|
||||
ERR_error_string(n,
|
||||
(char *)context->service_buffer));
|
||||
n, ERR_error_string(n,
|
||||
(char *)context->service_buffer));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue