diff options
author | Vicky Shrestha <vicky@geeks.net.np> | 2018-01-17 06:10:15 +0100 |
---|---|---|
committer | Petr Špaček <petr.spacek@nic.cz> | 2018-04-12 12:05:05 +0200 |
commit | f2c1ca64b6d605c5c37ca7cea9a46fd933ab2de9 (patch) | |
tree | ef301c11957591d128f0a5e9e836ad7d2bb8f826 /daemon/network.c | |
parent | Merge !554: ci: GIT_STRATEGY: clone (diff) | |
download | knot-resolver-f2c1ca64b6d605c5c37ca7cea9a46fd933ab2de9.tar.xz knot-resolver-f2c1ca64b6d605c5c37ca7cea9a46fd933ab2de9.zip |
Always create a endpoint in network_listen_fd
There is no need to check for unique addr+port for FDs passed
by a supervisor process like systemd.
Diffstat (limited to 'daemon/network.c')
-rw-r--r-- | daemon/network.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/daemon/network.c b/daemon/network.c index b3564567..4a047ab6 100644 --- a/daemon/network.c +++ b/daemon/network.c @@ -265,23 +265,17 @@ int network_listen_fd(struct network *net, int fd, bool use_tls) } else { return kr_error(EAFNOSUPPORT); } - /* Fetch or create endpoint for this fd */ - size_t index = 0; - endpoint_array_t *ep_array = network_get(net, addr_str, port, &index); - if (!ep_array) { - struct endpoint *ep = malloc(sizeof(*ep)); - memset(ep, 0, sizeof(*ep)); - ep->flags = NET_DOWN; - ep->port = port; - ret = insert_endpoint(net, addr_str, ep); - if (ret != 0) { - return ret; - } - ep_array = network_get(net, addr_str, port, &index); + + /* always create endpoint for supervisor supplied fd + * even if addr+port is not unique */ + struct endpoint *ep = malloc(sizeof(*ep)); + memset(ep, 0, sizeof(*ep)); + ep->flags = NET_DOWN; + ep->port = port; + ret = insert_endpoint(net, addr_str, ep); + if (ret != 0) { + return ret; } - /* Open fd in found/created endpoint. */ - struct endpoint *ep = ep_array->at[index]; - assert(ep != NULL); /* Create a libuv struct for this socket. */ return open_endpoint_fd(net, ep, fd, sock_type, use_tls); } |