summaryrefslogtreecommitdiffstats
path: root/crypto/bio
diff options
context:
space:
mode:
authorHugo Landau <hlandau@openssl.org>2024-04-01 09:03:20 +0100
committerTomas Mraz <tomas@openssl.org>2024-04-02 19:04:10 +0200
commit56736800224eff5783e314fd334c047224081c58 (patch)
tree0d0db4912d8aed068c1aa8efed99790a3a719ac0 /crypto/bio
parent15585af97ec682182f40f815741e66f1ec40f941 (diff)
BIO_s_connect: Do not set keepalive on dgram sockets
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Neil Horman <nhorman@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/24015)
Diffstat (limited to 'crypto/bio')
-rw-r--r--crypto/bio/bss_conn.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/crypto/bio/bss_conn.c b/crypto/bio/bss_conn.c
index fb3c4d2ba3..c7a19a5538 100644
--- a/crypto/bio/bss_conn.c
+++ b/crypto/bio/bss_conn.c
@@ -110,7 +110,7 @@ err:
static int conn_state(BIO *b, BIO_CONNECT *c)
{
- int ret = -1, i;
+ int ret = -1, i, opts;
BIO_info_cb *cb = NULL;
if (c->info_callback != NULL)
@@ -188,8 +188,12 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
case BIO_CONN_S_CONNECT:
BIO_clear_retry_flags(b);
ERR_set_mark();
- ret = BIO_connect(b->num, BIO_ADDRINFO_address(c->addr_iter),
- BIO_SOCK_KEEPALIVE | c->connect_mode);
+
+ opts = c->connect_mode;
+ if (BIO_ADDRINFO_socktype(c->addr_iter) == SOCK_STREAM)
+ opts |= BIO_SOCK_KEEPALIVE;
+
+ ret = BIO_connect(b->num, BIO_ADDRINFO_address(c->addr_iter), opts);
b->retry_reason = 0;
if (ret == 0) {
if (BIO_sock_should_retry(ret)) {