]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
rrl: broken async in defer docs-develop-rrl-loflwy/deployments/4218 rrl-wip-broken
authorLukáš Ondráček <lukas.ondracek@nic.cz>
Wed, 29 May 2024 16:37:48 +0000 (18:37 +0200)
committerLukáš Ondráček <lukas.ondracek@nic.cz>
Wed, 29 May 2024 16:37:48 +0000 (18:37 +0200)
daemon/defer.c
daemon/defer.h
daemon/main.c

index 66b266708573b4fa47b89162758c1a17b9f2009b..ea204b7af11b53f7cb6878cbcd660758ad129ea5 100644 (file)
@@ -1,28 +1,42 @@
 #include "daemon/defer.h"
 #include "lib/kru.h"
 
-// TODO: move kru_defer to another file
-
 #include "daemon/session2.h"
 
+uv_check_t check_handle;
+
 defer_sample_state_t defer_sample_state = {
        .do_sample = true, // FIXME: start with false, set to true based on config when opening KRU
        .is_accounting = 0,
 };
 
 
+struct protolayer_iter_ctx *defer_ctx = NULL;
+
+
 static enum protolayer_iter_cb_result pl_defer_unwrap(
                void *sess_data, void *iter_data,
                struct protolayer_iter_ctx *ctx)
 {
 
-       kr_log_notice(DEVEL, "DEFER: %s\n",
-                       kr_straddr(&defer_sample_state.addr.ip));
+       if (!defer_ctx) {
+               defer_ctx = ctx;
+               return protolayer_async();
+       }
 
        return protolayer_continue(ctx);
-       //return protolayer_async();
 }
 
-void defer_init(void) {
+
+static void defer_queues_check(uv_check_t *handle) {
+       if (defer_ctx) {
+               protolayer_continue(defer_ctx);
+               defer_ctx = NULL;
+       }
+}
+
+void defer_init(uv_loop_t *loop) {
        protolayer_globals[PROTOLAYER_TYPE_DEFER].unwrap = pl_defer_unwrap;
+       uv_check_init(loop, &check_handle);
+       uv_check_start(&check_handle, defer_queues_check);
 }
index 32f7da7be909a11e4d1c7976e3b41407129454f7..d605503be0fa8beb9a929ec6545abba4b4323eba 100644 (file)
@@ -75,4 +75,4 @@ static inline void defer_sample_stop(void)
 }
 
 
-void defer_init(void);
+void defer_init(uv_loop_t *loop);
index c21c2f4b9bc45cb8299f59c26250536a98113bf3..ee53163fd15f550a4888c6787a7ea3ac7639f361 100644 (file)
@@ -589,7 +589,7 @@ int main(int argc, char **argv)
        io_protolayers_init();
        tls_protolayers_init();
        proxy_protolayers_init();
-       defer_init();
+       defer_init(loop);
 #ifdef ENABLE_DOH2
        http_protolayers_init();
 #endif