aboutsummaryrefslogtreecommitdiff
path: root/apps/lib/s_socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/lib/s_socket.c')
-rw-r--r--apps/lib/s_socket.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/apps/lib/s_socket.c b/apps/lib/s_socket.c
index 059afe47b904..8c6020d01692 100644
--- a/apps/lib/s_socket.c
+++ b/apps/lib/s_socket.c
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -380,6 +380,12 @@ int do_server(int *accept_sock, const char *host, const char *port,
BIO_closesocket(asock);
break;
}
+
+ if (naccept != -1)
+ naccept--;
+ if (naccept == 0)
+ BIO_closesocket(asock);
+
BIO_set_tcp_ndelay(sock, 1);
i = (*cb)(sock, type, protocol, context);
@@ -410,11 +416,12 @@ int do_server(int *accept_sock, const char *host, const char *port,
BIO_closesocket(sock);
} else {
+ if (naccept != -1)
+ naccept--;
+
i = (*cb)(asock, type, protocol, context);
}
- if (naccept != -1)
- naccept--;
if (i < 0 || naccept == 0) {
BIO_closesocket(asock);
ret = i;