Skip to content

Commit 58977a9

Browse files
author
Your Name
committed
tls_openssl: fix openssl_tls_async_connect
The `fd` value here is used with `poll()`/`select()` in the event that `SSL_connect()` gives an `SSL_ERROR_WANT_WRITE` error. So we need to be polling/selecting on the fd that is used by the underlying socket, which is the fd passed as an argument to the function, rather than `con->fd`. It seems to me that `handle_io()` updates `con->fd` to match the received fd number only when the socket wants reading and not when it wants writing. When the socket wants writing the correct fd to use is the one that is passed in the function argument, not the one that is in `con->fd`. The reasons this mostly worked before are: 1. on a box that is not heavily-loaded you often end up with the same worker setting up the TLS session as opened the socket in the first place, so the fd in `con->fd happens to be correct. 2. if `SSL_connect()` happily connects straight away, without an `SSL_ERROR_WANT_WRITE`, then you never run into a code path that uses the value in `fd` anyway.
1 parent 9c5e1bc commit 58977a9

1 file changed

Lines changed: 0 additions & 1 deletion

File tree

modules/tls_openssl/openssl_conn_ops.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,6 @@ int openssl_tls_async_connect(struct tcp_connection *con, int fd,
657657
poll_err=0;
658658
elapsed = 0;
659659
to = timeout*1000;
660-
fd = con->fd;
661660

662661
#if defined(HAVE_SELECT) && defined(BLOCKING_USE_SELECT)
663662
FD_ZERO(&orig_set);

0 commit comments

Comments
 (0)