From: Alan T. DeKok Date: Mon, 1 Sep 2025 22:55:58 +0000 (-0400) Subject: add backlog parameter for the listen() API X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=95e056f3863cbacbcae692c396312e9ce7e5345c;p=thirdparty%2Ffreeradius-server.git add backlog parameter for the listen() API --- diff --git a/src/lib/bio/fd.c b/src/lib/bio/fd.c index 5dabcca8387..8f71ec0a036 100644 --- a/src/lib/bio/fd.c +++ b/src/lib/bio/fd.c @@ -919,10 +919,7 @@ int fr_bio_fd_init_listen(fr_bio_fd_t *my) my->bio.read = fr_bio_null_read; my->bio.write = fr_bio_null_write; - /* - * @todo - make the backlog configurable. - */ - if (listen(my->info.socket.fd, 8) < 0) { + if (listen(my->info.socket.fd, my->info.cfg->backlog_is_set ? my->info.cfg->backlog : 8) < 0) { fr_strerror_printf("Failed calling listen() %s", fr_syserror(errno)); return fr_bio_error(IO); } diff --git a/src/lib/bio/fd.h b/src/lib/bio/fd.h index 64d256f6bca..60e32201ce3 100644 --- a/src/lib/bio/fd.h +++ b/src/lib/bio/fd.h @@ -96,6 +96,8 @@ typedef struct { char const *interface; //!< for binding to an interface + uint32_t backlog; //!< for listen() + uint32_t recv_buff; //!< How big the kernel's receive buffer should be. uint32_t send_buff; //!< How big the kernel's send buffer should be. @@ -117,6 +119,7 @@ typedef struct { */ bool recv_buff_is_set; //!< Whether we were provided with a recv_buf bool send_buff_is_set; //!< Whether we were provided with a send_buf + bool backlog_is_set; //!< Whether we were provided with a backlog } fr_bio_fd_config_t; extern const conf_parser_t fr_bio_fd_client_config[]; diff --git a/src/lib/bio/fd_config.c b/src/lib/bio/fd_config.c index 97b2dc10114..c259ac7f69e 100644 --- a/src/lib/bio/fd_config.c +++ b/src/lib/bio/fd_config.c @@ -319,6 +319,8 @@ static const conf_parser_t server_tcp_sub_config[] = { { FR_CONF_OFFSET("interface", fr_bio_fd_config_t, interface) }, + { FR_CONF_OFFSET_IS_SET("backlog", FR_TYPE_UINT32, 0, fr_bio_fd_config_t, backlog) }, + { FR_CONF_OFFSET_IS_SET("recv_buff", FR_TYPE_UINT32, 0, fr_bio_fd_config_t, recv_buff) }, { FR_CONF_OFFSET_IS_SET("send_buff", FR_TYPE_UINT32, 0, fr_bio_fd_config_t, send_buff) },