diff options
author | Vladimír Čunát <vladimir.cunat@nic.cz> | 2019-04-12 15:06:02 +0200 |
---|---|---|
committer | Vladimír Čunát <vladimir.cunat@nic.cz> | 2019-04-18 09:44:12 +0200 |
commit | 8cecbf0d51e508d5c8fbd4b2b5e077178ad697f0 (patch) | |
tree | d3076a99fbb94317a9f84de21be01d338ea20192 /daemon/io.h | |
parent | net.listen(): return false on failure, not nil (diff) | |
download | knot-resolver-8cecbf0d51e508d5c8fbd4b2b5e077178ad697f0.tar.xz knot-resolver-8cecbf0d51e508d5c8fbd4b2b5e077178ad697f0.zip |
simplify approach to bind()
The complication is that we need to work with addresses and
just file-descriptors passed from some parent process.
The former approach lead to logical duplication of some steps;
now we add a step converting addresses to file-descriptors.
Thanks to that we always do bind() without touching libuv,
so the problem with forking disappears :-)
Diffstat (limited to 'daemon/io.h')
-rw-r--r-- | daemon/io.h | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/daemon/io.h b/daemon/io.h index 8262a309..711194fb 100644 --- a/daemon/io.h +++ b/daemon/io.h @@ -25,12 +25,13 @@ struct tls_ctx_t; struct tls_client_ctx_t; -int udp_bind(uv_udp_t *handle, const struct sockaddr *addr); -int udp_bindfd(uv_udp_t *handle, int fd); -int tcp_bind(uv_tcp_t *handle, const struct sockaddr *addr, int tcp_backlog); -int tcp_bind_tls(uv_tcp_t *handle, const struct sockaddr *addr, int tcp_backlog); -int tcp_bindfd(uv_tcp_t *handle, int fd, int tcp_backlog); -int tcp_bindfd_tls(uv_tcp_t *handle, int fd, int tcp_backlog); +/** Bind address into a file-descriptor (only, no libuv). type is e.g. SOCK_DGRAM */ +int io_bind(const struct sockaddr *addr, int type); +/** Initialize a UDP handle and start listening. */ +int io_listen_udp(uv_loop_t *loop, uv_udp_t *handle, int fd); +/** Initialize a TCP handle and start listening. */ +int io_listen_tcp(uv_loop_t *loop, uv_tcp_t *handle, int fd, int tcp_backlog, bool has_tls); + void tcp_timeout_trigger(uv_timer_t *timer); /** Initialize the handle, incl. ->data = struct session * instance. |