From c4fe6e78e5b21437bbbcf9987bcdb036da675d86 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Mon, 24 Jun 2024 10:30:38 +0200 Subject: [PATCH] [core,tcp] return errno ETIMEDOUT on timeout BIO_C_WAIT_READ and BIO_C_WAIT_WRITE now set errno = ETIMEDOUT if a timeout occurred. --- libfreerdp/core/tcp.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/libfreerdp/core/tcp.c b/libfreerdp/core/tcp.c index f9e216fe2..f424cc048 100644 --- a/libfreerdp/core/tcp.c +++ b/libfreerdp/core/tcp.c @@ -263,8 +263,12 @@ static long transport_bio_simple_ctrl(BIO* bio, int cmd, long arg1, void* arg2) } while ((status < 0) && (errno == EINTR)); #endif + /* Convert timeout to error return */ + if (status == 0) + errno = ETIMEDOUT; } break; + case BIO_C_WAIT_WRITE: { int timeout = (int)arg1; @@ -298,14 +302,12 @@ static long transport_bio_simple_ctrl(BIO* bio, int cmd, long arg1, void* arg2) } while ((status < 0) && (errno == EINTR)); #endif + /* Convert timeout to error return */ + if (status == 0) + errno = ETIMEDOUT; } break; - default: - break; - } - switch (cmd) - { case BIO_C_SET_FD: if (arg2) { @@ -336,11 +338,8 @@ static long transport_bio_simple_ctrl(BIO* bio, int cmd, long arg1, void* arg2) status = 1; break; - case BIO_CTRL_DUP: - status = 1; - break; - case BIO_CTRL_FLUSH: + case BIO_CTRL_DUP: status = 1; break;