Skip to content

Commit

Permalink
...G...PS. [ZBX-7933] added configurable parameter for TCP queue maxi…
Browse files Browse the repository at this point in the history
…mum size
  • Loading branch information
Dmitrijs Goloscapovs committed Jul 27, 2021
1 parent 0986309 commit 3131b97
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 2 deletions.
1 change: 1 addition & 0 deletions ChangeLog.d/bugfix/ZBX-7933
@@ -0,0 +1 @@
...G...PS. [ZBX-7933] added configurable parameter for TCP queue maximum size (dgoloscapov)
11 changes: 11 additions & 0 deletions conf/zabbix_agentd.conf
Expand Up @@ -511,3 +511,14 @@ Hostname=Zabbix server
# Mandatory: no
# Default:
# TLSCipherAll=

####### For advanced users - TCP-related fine-tuning parameters #######

## Option: ListenBacklog
# The maximum number of pending connections in the queue. This parameter is passed to
# listen() function as argument 'backlog' (see "man listen").
#
# Mandatory: no
# Range: 0 - INT_MAX (depends on system, too large values may be silently truncated to implementation-specified maximum)
# Default: SOMAXCONN (hard-coded constant, depends on system)
# ListenBacklog=
11 changes: 11 additions & 0 deletions conf/zabbix_agentd.win.conf
Expand Up @@ -470,3 +470,14 @@ Hostname=Windows host
# Mandatory: no
# Default:
# TLSCipherAll=

####### For advanced users - TCP-related fine-tuning parameters #######

## Option: ListenBacklog
# The maximum number of pending connections in the queue. This parameter is passed to
# listen() function as argument 'backlog' (see "man listen").
#
# Mandatory: no
# Range: 0 - INT_MAX (depends on system, too large values may be silently truncated to implementation-specified maximum)
# Default: SOMAXCONN (hard-coded constant, depends on system)
# ListenBacklog=
10 changes: 10 additions & 0 deletions conf/zabbix_proxy.conf
Expand Up @@ -901,3 +901,13 @@ StatsAllowedIP=127.0.0.1
# Default:
# VaultDBPath=

####### For advanced users - TCP-related fine-tuning parameters #######

## Option: ListenBacklog
# The maximum number of pending connections in the queue. This parameter is passed to
# listen() function as argument 'backlog' (see "man listen").
#
# Mandatory: no
# Range: 0 - INT_MAX (depends on system, too large values may be silently truncated to implementation-specified maximum)
# Default: SOMAXCONN (hard-coded constant, depends on system)
# ListenBacklog=
11 changes: 11 additions & 0 deletions conf/zabbix_server.conf
Expand Up @@ -933,3 +933,14 @@ StatsAllowedIP=127.0.0.1
# Range: 1-3600
# Default:
# ProblemHousekeepingFrequency=60

####### For advanced users - TCP-related fine-tuning parameters #######

## Option: ListenBacklog
# The maximum number of pending connections in the queue. This parameter is passed to
# listen() function as argument 'backlog' (see "man listen").
#
# Mandatory: no
# Range: 0 - INT_MAX (depends on system, too large values may be silently truncated to implementation-specified maximum)
# Default: SOMAXCONN (hard-coded constant, depends on system)
# ListenBacklog=
1 change: 1 addition & 0 deletions src/go/pkg/zbxlib/globals_linux.go
Expand Up @@ -86,6 +86,7 @@ char *CONFIG_TLS_CIPHER_CMD = NULL;
int CONFIG_PASSIVE_FORKS = 0;
int CONFIG_ACTIVE_FORKS = 0;
int CONFIG_TCP_MAX_BACKLOG_SIZE = SOMAXCONN;
const char *progname = NULL;
const char title_message[] = "agent";
Expand Down
2 changes: 2 additions & 0 deletions src/go/pkg/zbxlib/globals_windows.go
Expand Up @@ -59,6 +59,8 @@ int CONFIG_UNSAFE_USER_PARAMETERS= 0;
int CONFIG_ENABLE_REMOTE_COMMANDS= 0;
char *CONFIG_SOURCE_IP = NULL;
int CONFIG_TCP_MAX_BACKLOG_SIZE = SOMAXCONN;
const char *progname = NULL;
const char title_message[] = "agent";
const char *usage_message[] = {};
Expand Down
5 changes: 3 additions & 2 deletions src/libs/zbxcomms/comms.c
Expand Up @@ -48,6 +48,7 @@ extern ZBX_THREAD_LOCAL char info_buf[256];
#endif

extern int CONFIG_TIMEOUT;
extern int CONFIG_TCP_MAX_BACKLOG_SIZE;

/******************************************************************************
* *
Expand Down Expand Up @@ -1146,7 +1147,7 @@ int zbx_tcp_listen(zbx_socket_t *s, const char *listen_ip, unsigned short listen
goto out;
}

if (ZBX_PROTO_ERROR == listen(s->sockets[s->num_socks], SOMAXCONN))
if (ZBX_PROTO_ERROR == listen(s->sockets[s->num_socks], CONFIG_TCP_MAX_BACKLOG_SIZE))
{
zbx_set_socket_strerror("listen() for [[%s]:%s] failed: %s",
NULL != ip ? ip : "-", port,
Expand Down Expand Up @@ -1319,7 +1320,7 @@ int zbx_tcp_listen(zbx_socket_t *s, const char *listen_ip, unsigned short listen
goto out;
}

if (ZBX_PROTO_ERROR == listen(s->sockets[s->num_socks], SOMAXCONN))
if (ZBX_PROTO_ERROR == listen(s->sockets[s->num_socks], CONFIG_TCP_MAX_BACKLOG_SIZE))
{
zbx_set_socket_strerror("listen() for [[%s]:%hu] failed: %s",
NULL != ip ? ip : "-", listen_port,
Expand Down
4 changes: 4 additions & 0 deletions src/zabbix_agent/zabbix_agentd.c
Expand Up @@ -93,6 +93,8 @@ char *CONFIG_TLS_CIPHER_ALL = NULL;
char *CONFIG_TLS_CIPHER_CMD13 = NULL; /* not used in agent, defined for linking with tls.c */
char *CONFIG_TLS_CIPHER_CMD = NULL; /* not used in agent, defined for linking with tls.c */

int CONFIG_TCP_MAX_BACKLOG_SIZE = SOMAXCONN;

#ifndef _WINDOWS
# include "../libs/zbxnix/control.h"
# include "zbxmodules.h"
Expand Down Expand Up @@ -951,6 +953,8 @@ static void zbx_load_config(int requirement, ZBX_TASK_EX *task)
PARM_OPT, 0, 0},
{"DenyKey", load_key_access_rule, TYPE_CUSTOM,
PARM_OPT, 0, 0},
{"ListenBacklog", &CONFIG_TCP_MAX_BACKLOG_SIZE, TYPE_INT,
PARM_OPT, 0, INT_MAX},
{NULL}
};

Expand Down
2 changes: 2 additions & 0 deletions src/zabbix_get/zabbix_get.c
Expand Up @@ -184,6 +184,8 @@ char *CONFIG_TLS_CIPHER_CMD = NULL; /* parameter '--tls-cipher' from zabbix_get
int CONFIG_PASSIVE_FORKS = 0; /* not used in zabbix_get, just for linking with tls.c */
int CONFIG_ACTIVE_FORKS = 0; /* not used in zabbix_get, just for linking with tls.c */

int CONFIG_TCP_MAX_BACKLOG_SIZE = SOMAXCONN;

/* COMMAND LINE OPTIONS */

/* long options */
Expand Down
3 changes: 3 additions & 0 deletions src/zabbix_proxy/proxy.c
Expand Up @@ -309,6 +309,7 @@ char *CONFIG_HISTORY_STORAGE_OPTS = NULL;
int CONFIG_HISTORY_STORAGE_PIPELINES = 0;

char *CONFIG_STATS_ALLOWED_IP = NULL;
int CONFIG_TCP_MAX_BACKLOG_SIZE = SOMAXCONN;

int CONFIG_DOUBLE_PRECISION = ZBX_DB_DBL_PRECISION_ENABLED;

Expand Down Expand Up @@ -869,6 +870,8 @@ static void zbx_load_config(ZBX_TASK_EX *task)
PARM_OPT, 1, 1000},
{"StartHistoryPollers", &CONFIG_HISTORYPOLLER_FORKS, TYPE_INT,
PARM_OPT, 0, 1000},
{"ListenBacklog", &CONFIG_TCP_MAX_BACKLOG_SIZE, TYPE_INT,
PARM_OPT, 0, INT_MAX},
{NULL}
};

Expand Down
2 changes: 2 additions & 0 deletions src/zabbix_sender/win32/zabbix_sender.c
Expand Up @@ -31,6 +31,8 @@ const char *help_message[] = {NULL};

unsigned char program_type = ZBX_PROGRAM_TYPE_SENDER;

int CONFIG_TCP_MAX_BACKLOG_SIZE = SOMAXCONN;

int zabbix_sender_send_values(const char *address, unsigned short port, const char *source,
const zabbix_sender_value_t *values, int count, char **result)
{
Expand Down
4 changes: 4 additions & 0 deletions src/zabbix_sender/zabbix_sender.c
Expand Up @@ -293,6 +293,8 @@ char *CONFIG_TLS_CIPHER_CMD = NULL; /* parameter '--tls-cipher' from sender com
int CONFIG_PASSIVE_FORKS = 0; /* not used in zabbix_sender, just for linking with tls.c */
int CONFIG_ACTIVE_FORKS = 0; /* not used in zabbix_sender, just for linking with tls.c */

int CONFIG_TCP_MAX_BACKLOG_SIZE = SOMAXCONN;

/* COMMAND LINE OPTIONS */

/* long options */
Expand Down Expand Up @@ -870,6 +872,8 @@ static void zbx_load_config(const char *config_file)
PARM_OPT, 0, 0},
{"TLSCipherPSK", &cfg_tls_cipher_psk, TYPE_STRING,
PARM_OPT, 0, 0},
{"ListenBacklog", &CONFIG_TCP_MAX_BACKLOG_SIZE, TYPE_INT,
PARM_OPT, 0, INT_MAX},
{NULL}
};

Expand Down
3 changes: 3 additions & 0 deletions src/zabbix_server/server.c
Expand Up @@ -333,6 +333,7 @@ char *CONFIG_HISTORY_STORAGE_OPTS = NULL;
int CONFIG_HISTORY_STORAGE_PIPELINES = 0;

char *CONFIG_STATS_ALLOWED_IP = NULL;
int CONFIG_TCP_MAX_BACKLOG_SIZE = SOMAXCONN;

int CONFIG_DOUBLE_PRECISION = ZBX_DB_DBL_PRECISION_ENABLED;

Expand Down Expand Up @@ -934,6 +935,8 @@ static void zbx_load_config(ZBX_TASK_EX *task)
PARM_OPT, 1, 3600},
{"ServiceManagerSyncFrequency", &CONFIG_SERVICEMAN_SYNC_FREQUENCY, TYPE_INT,
PARM_OPT, 1, 3600},
{"ListenBacklog", &CONFIG_TCP_MAX_BACKLOG_SIZE, TYPE_INT,
PARM_OPT, 0, INT_MAX},
{NULL}
};

Expand Down
3 changes: 3 additions & 0 deletions tests/zbxmocktest.c
Expand Up @@ -177,6 +177,9 @@ char *CONFIG_HISTORY_STORAGE_URL = NULL;
char *CONFIG_HISTORY_STORAGE_OPTS = NULL;
int CONFIG_HISTORY_STORAGE_PIPELINES = 0;

/* not used in tests, defined for linking with comms.c */
int CONFIG_TCP_MAX_BACKLOG_SIZE = SOMAXCONN;

const char title_message[] = "mock_title_message";
const char *usage_message[] = {"mock_usage_message", NULL};
const char *help_message[] = {"mock_help_message", NULL};
Expand Down

0 comments on commit 3131b97

Please sign in to comment.