Fix tls_init bug

This commit is contained in:
Zhi Guan
2026-05-27 18:17:43 +08:00
parent 4df5b2c898
commit 711da7985a
3 changed files with 13 additions and 12 deletions

View File

@@ -2684,6 +2684,7 @@ int tls_init(TLS_CONNECT *conn, TLS_CTX *ctx)
memset(conn, 0, sizeof(*conn));
conn->is_client = ctx->is_client; // TODO: remove conn->is_client
conn->protocol = ctx->protocol;
/*

View File

@@ -82,7 +82,7 @@ int tls_send_record(TLS_CONNECT *conn)
while (left) {
n = tls_socket_send(conn->sock, conn->record + conn->record_offset, left, 0);
if (n < 0) {
if (errno == EAGAIN && errno == EWOULDBLOCK) {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
return TLS_ERROR_SEND_AGAIN;
} else if (errno == EINTR) {
continue;
@@ -2722,13 +2722,13 @@ int tls12_do_connect(TLS_CONNECT *conn)
} else if (ret == TLS_ERROR_SEND_AGAIN) {
FD_ZERO(&rfds);
FD_ZERO(&wfds);
FD_SET(conn->sock, &rfds);
FD_SET(conn->sock, &wfds);
select(conn->sock + 1, &rfds, &wfds, NULL, NULL);
} else if (ret == TLS_ERROR_RECV_AGAIN) {
FD_ZERO(&rfds);
FD_ZERO(&wfds);
FD_SET(conn->sock, &wfds);
FD_SET(conn->sock, &rfds);
select(conn->sock + 1, &rfds, &wfds, NULL, NULL);
} else {