summaryrefslogtreecommitdiffstats
path: root/daemon/session2.c
diff options
context:
space:
mode:
authorOto Šťáva <oto.stava@nic.cz>2023-08-01 16:36:53 +0200
committerVladimír Čunát <vladimir.cunat@nic.cz>2023-08-22 13:38:27 +0200
commit7aec8ebdf1428afcb7f5bc62764149ffeaf3d3fe (patch)
tree95183cf8c0654c6c4fafcd1299d4b661471d00f8 /daemon/session2.c
parentMerge !1444: manager: datamodel: fix /cache/ttl-max default (diff)
downloadknot-resolver-7aec8ebdf1428afcb7f5bc62764149ffeaf3d3fe.tar.xz
knot-resolver-7aec8ebdf1428afcb7f5bc62764149ffeaf3d3fe.zip
daemon: more avoidance of excessive TCP reconnections
Previously this penalization was only triggered if the remote server closed TCP. Now it's extended to us closing it when the server (only) sends back some nonsense. At least for the cases which I could see immediately. That's just three trivial one-line additions; the rest is refactoring. Adapted to 6.0 from commit 6468ab22 by Oto Šťáva <oto.stava@nic.cz> Co-Authored-By: Vladimír Čunat <vladimir.cunat@nic.cz>
Diffstat (limited to 'daemon/session2.c')
-rw-r--r--daemon/session2.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/daemon/session2.c b/daemon/session2.c
index 491f0e6a..c3d5765a 100644
--- a/daemon/session2.c
+++ b/daemon/session2.c
@@ -1154,6 +1154,25 @@ void session2_waitinglist_finalize(struct session2 *session, int status)
}
}
+void session2_penalize(struct session2 *session)
+{
+ if (session->was_useful || !session->outgoing)
+ return;
+
+ /* We want to penalize the IP address, if a task is asking a query.
+ * It might not be the right task, but that doesn't matter so much
+ * for attributing the useless session to the IP address. */
+ struct qr_task *t = session2_tasklist_get_first(session);
+ struct kr_query *qry = NULL;
+ if (t) {
+ struct kr_request *req = worker_task_request(t);
+ qry = array_tail(req->rplan.pending);
+ }
+ if (qry) /* We reuse the error for connection, as it's quite similar. */
+ qry->server_selection.error(qry, worker_task_get_transport(t),
+ KR_SELECTION_TCP_CONNECT_FAILED);
+}
+
int session2_unwrap(struct session2 *s, struct protolayer_payload payload,
const struct comm_info *comm, protolayer_finished_cb cb,
void *baton)