From f076c67c332c029ba9ef1d1b33cf2fdd245c320f Mon Sep 17 00:00:00 2001 From: Jan Vidar Krey Date: Tue, 6 Oct 2009 15:50:42 +0200 Subject: [PATCH] Added a configurable listen() backlog (defaults to: server_listen_backlog=50) --- src/core/config.c | 4 ++++ src/core/config.h | 1 + src/core/hub.c | 2 +- src/uhub.h | 1 - 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/config.c b/src/core/config.c index 92f08e5..ee345b7 100644 --- a/src/core/config.c +++ b/src/core/config.c @@ -110,6 +110,7 @@ /* default configuration values */ #define DEF_SERVER_BIND_ADDR "any" #define DEF_SERVER_PORT 1511 +#define DEF_SERVER_BACKLOG 50 #define DEF_HUB_NAME "uhub" #define DEF_HUB_DESCRIPTION "" #define DEF_HUB_ENABLED 1 @@ -180,6 +181,7 @@ void config_defaults(struct hub_config* config) DEFAULT_STRING (file_acl, DEF_FILE_ACL); DEFAULT_STRING (file_motd, DEF_FILE_MOTD); DEFAULT_INTEGER(server_port, DEF_SERVER_PORT); + DEFAULT_INTEGER(server_listen_backlog, DEF_SERVER_BACKLOG); DEFAULT_INTEGER(max_users, DEF_MAX_USERS); DEFAULT_INTEGER(max_chat_history, DEF_MAX_CHAT_HISTORY); DEFAULT_INTEGER(max_logout_log, DEF_MAX_LOGOUT_LOG); @@ -249,6 +251,7 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li GET_STR (file_motd); GET_STR (server_bind_addr); GET_INT (server_port); + GET_INT (server_listen_backlog); GET_STR (hub_name); GET_STR (hub_description); GET_BOOL(hub_enabled); @@ -397,6 +400,7 @@ void dump_config(struct hub_config* config, int ignore_defaults) DUMP_STR (file_motd, DEF_FILE_MOTD); DUMP_STR (server_bind_addr, DEF_SERVER_BIND_ADDR); DUMP_INT (server_port, DEF_SERVER_PORT); + DUMP_INT (server_listen_backlog, DEF_SERVER_BACKLOG); DUMP_STR (hub_name, DEF_HUB_NAME); DUMP_STR (hub_description, DEF_HUB_DESCRIPTION); DUMP_BOOL(hub_enabled, DEF_HUB_ENABLED); diff --git a/src/core/config.h b/src/core/config.h index 8a7da9c..010247b 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -24,6 +24,7 @@ struct hub_config { int server_port; /**<<< "Server port to bind to (default: 1511)" */ char* server_bind_addr; /**<<< "Server bind address (default: '0.0.0.0' or '::')" */ + int server_listen_backlog; /**<<< "Server listen backlog (default: 50)" */ int hub_enabled; /**<<< "Is server enabled (default: 1)" */ int show_banner; /**<<< "Show banner on connect (default: 1)" */ int max_users; /**<<< "Maximum number of users allowed on the hub (default: 500)" */ diff --git a/src/core/hub.c b/src/core/hub.c index 902ab7c..2e253fb 100644 --- a/src/core/hub.c +++ b/src/core/hub.c @@ -494,7 +494,7 @@ struct hub_info* hub_start_service(struct hub_config* config) return 0; } - ret = net_listen(server_tcp, SERVER_BACKLOG); + ret = net_listen(server_tcp, config->server_listen_backlog); if (ret == -1) { LOG_FATAL("hub_start_service(): Unable to listen to socket"); diff --git a/src/uhub.h b/src/uhub.h index 4f8e2aa..7d09bda 100644 --- a/src/uhub.h +++ b/src/uhub.h @@ -30,7 +30,6 @@ #define SERVER_PORT 1511 #define SERVER_ADDR_IPV6 "::" #define SERVER_ADDR_IPV4 "0.0.0.0" -#define SERVER_BACKLOG 50 #ifndef WIN32 #define SERVER_CONFIG "/etc/uhub/uhub.conf"