Update tls.c

`tls_set_socket` checks whether socket is in blocking mode
This commit is contained in:
Zhi Guan
2024-02-04 11:40:28 +08:00
parent a5c54cca38
commit 3f05cf98c8

View File

@@ -2308,21 +2308,17 @@ void tls_cleanup(TLS_CONNECT *conn)
int tls_set_socket(TLS_CONNECT *conn, tls_socket_t sock) int tls_set_socket(TLS_CONNECT *conn, tls_socket_t sock)
{ {
#if 0 int flags;
int opts;
// FIXME: do we still need this? when using select? if ((flags = fcntl(sock, F_GETFL)) == -1) {
if ((opts = fcntl(sock, F_GETFL)) < 0) {
error_print(); error_print();
perror("tls_set_socket"); perror("fcntl error");
return -1; return -1;
} }
opts &= ~O_NONBLOCK; if (flags & O_NONBLOCK) {
if (fcntl(sock, F_SETFL, opts) < 0) { error_puts("socket should be in blocking mode");
error_print();
return -1; return -1;
} }
#endif
conn->sock = sock; conn->sock = sock;
return 1; return 1;
} }