diff options
author | Oto Šťáva <oto.stava@nic.cz> | 2023-03-10 13:15:16 +0100 |
---|---|---|
committer | Oto Šťáva <oto.stava@nic.cz> | 2023-03-17 08:18:43 +0100 |
commit | 9d6cc0bf7f8409db06ef2d0ff61c55bfb496daa8 (patch) | |
tree | fb312009a66e5478cdc40aec2c2544e8ef9a16f3 /daemon/io.c | |
parent | daemon: optimize memory consumption for outgoing UDP (diff) | |
download | knot-resolver-9d6cc0bf7f8409db06ef2d0ff61c55bfb496daa8.tar.xz knot-resolver-9d6cc0bf7f8409db06ef2d0ff61c55bfb496daa8.zip |
daemon: improve session closure readability
Until now, sessions were closed by explicitly sending `_CLOSE` events
via the `session2_event()` function to them, which I think is not
signalling the intent very well. It might look as though the session
has been/is being closed by some part of the code that contains the
`session2_event()` call and a relevant event is being fired now. This
commit introduces `session2_close()` and `session2_force_close()` inline
functions, which do the same thing, but I think the intent behind
calling them is slightly clearer.
Diffstat (limited to 'daemon/io.c')
-rw-r--r-- | daemon/io.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/daemon/io.c b/daemon/io.c index 485f5b29..1014c046 100644 --- a/daemon/io.c +++ b/daemon/io.c @@ -309,7 +309,7 @@ static enum protolayer_iter_cb_result pl_tcp_unwrap( worker_end_tcp(s); return protolayer_break(ctx, kr_error(ECONNRESET)); } else if (trimmed == 0) { - session2_event(s, PROTOLAYER_EVENT_CLOSE, NULL); + session2_close(s); return protolayer_break(ctx, kr_error(ECONNRESET)); } @@ -552,7 +552,7 @@ static void _tcp_accept(uv_stream_t *master, int status, enum protolayer_grp grp if (uv_accept(master, (uv_stream_t *)client) != 0) { /* close session, close underlying uv handles and * deallocate (or return to memory pool) memory. */ - session2_event(s, PROTOLAYER_EVENT_CLOSE, NULL); + session2_close(s); return; } @@ -562,14 +562,14 @@ static void _tcp_accept(uv_stream_t *master, int status, enum protolayer_grp grp int sa_len = sizeof(struct sockaddr_in6); int ret = uv_tcp_getpeername(client, sa, &sa_len); if (ret || sa->sa_family == AF_UNSPEC) { - session2_event(s, PROTOLAYER_EVENT_CLOSE, NULL); + session2_close(s); return; } sa = session2_get_sockname(s); sa_len = sizeof(struct sockaddr_in6); ret = uv_tcp_getsockname(client, sa, &sa_len); if (ret || sa->sa_family == AF_UNSPEC) { - session2_event(s, PROTOLAYER_EVENT_CLOSE, NULL); + session2_close(s); return; } |