From 9eec9ae8492611149a5824f7bec172e81d0f2f58 Mon Sep 17 00:00:00 2001 From: Tim Laszlo Date: Fri, 20 Jun 2014 09:00:43 -0500 Subject: [PATCH] network: set ttl before opening server sockets If TimeToLive is defined in collectd.conf after Server options, the net_config_ttl value is updated after network_config_add_server and the desired ttl is not used. --- src/network.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/network.c b/src/network.c index 9c9e83cc..5d485ba3 100644 --- a/src/network.c +++ b/src/network.c @@ -3252,6 +3252,14 @@ static int network_config (oconfig_item_t *ci) /* {{{ */ { int i; + /* The options need to be applied first */ + for (i = 0; i < ci->children_num; i++) + { + oconfig_item_t *child = ci->children + i; + if (strcasecmp ("TimeToLive", child->key) == 0) + network_config_set_ttl (child); + } + for (i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; @@ -3260,8 +3268,9 @@ static int network_config (oconfig_item_t *ci) /* {{{ */ network_config_add_listen (child); else if (strcasecmp ("Server", child->key) == 0) network_config_add_server (child); - else if (strcasecmp ("TimeToLive", child->key) == 0) - network_config_set_ttl (child); + else if (strcasecmp ("TimeToLive", child->key) == 0) { + /* Handled earlier */ + } else if (strcasecmp ("MaxPacketSize", child->key) == 0) network_config_set_buffer_size (child); else if (strcasecmp ("Forward", child->key) == 0) -- 2.30.2