From c405b47b6cd766756c17429d6be0a5dc91318aeb Mon Sep 17 00:00:00 2001
From: Kubat <mael.martin31@gmail.com>
Date: Sat, 2 May 2020 13:15:49 +0200
Subject: [PATCH] Some fixes to lektord and lkt, queue commands for add and
 insert are working, but they are really slow

---
 src/commands.c | 12 ++++++++----
 src/main/lkt.c |  2 +-
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/commands.c b/src/commands.c
index 08d54f20..8dbff5b2 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -465,14 +465,16 @@ static bool
 lkt_callback_insert_v1(struct lkt_state *srv, size_t c, int id, int id_len, const char *sql_row)
 {
     UNUSED(sql_row, id_len, c);
-    return database_queue_add_id(srv->db, id, 5);
+    return database_queue_add_id(srv->db, id, 5) &&
+           lkt_callback_send_row_v2(srv, c, id, id_len, sql_row);
 }
 
 static bool
-lkt_callback_add_v1(struct lkt_state *srv, size_t c, int id, int id_len, const char *sql_row)
+lkt_callback_add_v2(struct lkt_state *srv, size_t c, int id, int id_len, const char *sql_row)
 {
     UNUSED(sql_row, id_len, c);
-    return database_queue_add_id(srv->db, id, 1);
+    return database_queue_add_id(srv->db, id, 1) &&
+           lkt_callback_send_row_v2(srv, c, id, id_len, sql_row);
 }
 
 static bool
@@ -506,7 +508,9 @@ __find(struct lkt_state *srv, size_t c, char *cmd_args[LKT_MESSAGE_ARGS_MAX], lo
         srv->mpd_idle_events |= MPD_IDLE_PLAYLIST;
         break;
     case LKT_FND_ACT_ADD:
-        search.call = (void(*)(void)) lkt_callback_add_v1;
+        search.call = (void(*)(void)) lkt_callback_add_v2;
+        srv->mpd_idle_events |= MPD_IDLE_PLAYLIST;
+        break;
     default:
         return false;
     }
diff --git a/src/main/lkt.c b/src/main/lkt.c
index cbf08f2c..6b4dfd27 100644
--- a/src/main/lkt.c
+++ b/src/main/lkt.c
@@ -193,7 +193,7 @@ restart__(struct lkt_cmd_args *args)
 {
     if (args->argc != 0)
         fail("Invalid argument, the previous command takes no arguments");
-    simple_send_with_password__("restart");
+    simple_send_with_password__("__restart");
 }
 
 noreturn void
-- 
GitLab