Skip to content

Commit 5673680

Browse files
hlandaut8m
authored andcommitted
BIO_s_connect: Do not set keepalive on dgram sockets
Reviewed-by: Matt Caswell <[email protected]> Reviewed-by: Neil Horman <[email protected]> Reviewed-by: Tomas Mraz <[email protected]> (Merged from openssl#24015)
1 parent 15585af commit 5673680

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

crypto/bio/bss_conn.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static int conn_create_dgram_bio(BIO *b, BIO_CONNECT *c)
110110

111111
static int conn_state(BIO *b, BIO_CONNECT *c)
112112
{
113-
int ret = -1, i;
113+
int ret = -1, i, opts;
114114
BIO_info_cb *cb = NULL;
115115

116116
if (c->info_callback != NULL)
@@ -188,8 +188,12 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
188188
case BIO_CONN_S_CONNECT:
189189
BIO_clear_retry_flags(b);
190190
ERR_set_mark();
191-
ret = BIO_connect(b->num, BIO_ADDRINFO_address(c->addr_iter),
192-
BIO_SOCK_KEEPALIVE | c->connect_mode);
191+
192+
opts = c->connect_mode;
193+
if (BIO_ADDRINFO_socktype(c->addr_iter) == SOCK_STREAM)
194+
opts |= BIO_SOCK_KEEPALIVE;
195+
196+
ret = BIO_connect(b->num, BIO_ADDRINFO_address(c->addr_iter), opts);
193197
b->retry_reason = 0;
194198
if (ret == 0) {
195199
if (BIO_sock_should_retry(ret)) {

0 commit comments

Comments
 (0)