From def137bc80f037280c0aa9fb9e635bb32ccd378c Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Mon, 27 Jul 2020 12:57:44 +0200 Subject: [PATCH] nts: scale server listening backlog with number of helpers --- nts_ke_server.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nts_ke_server.c b/nts_ke_server.c index 67500f4..41c0606 100644 --- a/nts_ke_server.c +++ b/nts_ke_server.c @@ -277,8 +277,8 @@ static int open_socket(int family) { IPSockAddr local_addr; + int backlog, sock_fd; char *iface; - int sock_fd; if (!SCK_IsIpFamilyEnabled(family)) return INVALID_SOCK_FD; @@ -293,7 +293,11 @@ open_socket(int family) return INVALID_SOCK_FD; } - if (!SCK_ListenOnSocket(sock_fd, CNF_GetNtsServerConnections())) { + /* Set the maximum number of waiting connections on the socket to the maximum + number of concurrent sessions */ + backlog = MAX(CNF_GetNtsServerProcesses(), 1) * CNF_GetNtsServerConnections(); + + if (!SCK_ListenOnSocket(sock_fd, backlog)) { SCK_CloseSocket(sock_fd); return INVALID_SOCK_FD; }