summaryrefslogtreecommitdiff
path: root/src/core/thread_sync.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/thread_sync.c')
-rw-r--r--src/core/thread_sync.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/core/thread_sync.c b/src/core/thread_sync.c
new file mode 100644
index 0000000..19b430a
--- /dev/null
+++ b/src/core/thread_sync.c
@@ -0,0 +1,75 @@
+/* BSD-2-Clause license
+ *
+ * Copyright (c) 2018-2023 NST <www.newinfosec.ru>, sss <sss at dark-alexandr dot net>.
+ *
+ */
+
+#include <stdint.h>
+#include <stddef.h>
+#include <stdio.h>
+
+#include "globals.h"
+#include "thread_sync.h"
+#include "thread_impl.h"
+
+static void
+remove_ws_backend_from_list(user_pool_msg *pmsg)
+{
+ if (!LIST_EMPTY(&(g_globals.backends_head)))
+ {
+ struct backend_s *t1 = LIST_FIRST(&(g_globals.backends_head));
+ while (t1)
+ {
+ if (!t1->backend || t1->backend == pmsg->backend)
+ {
+ LIST_REMOVE(t1, entries);
+ free(t1);
+ break;
+ }
+ t1 = LIST_NEXT(t1, entries);
+ }
+ }
+
+ free(pmsg->backend);
+}
+
+void
+pool_message_handler(void *user_data)
+{
+ user_pool_msg *pmsg = user_data;
+ if (!pmsg)
+ {
+ return;
+ }
+ switch (pmsg->type)
+ {
+ case msg_type_destroy_ws_backend_info:
+ {
+ remove_ws_backend_from_list(pmsg);
+ }
+ break;
+ case msg_type_backend_created:
+ {
+ struct backend_s *t;
+ t = calloc(1, sizeof(struct backend_s));
+ if (!t)
+ {
+ perror("calloc");
+ free(pmsg);
+ return;
+ }
+ t->backend = pmsg->backend;
+ LIST_INSERT_HEAD(
+ &(g_globals.backends_head), t, entries);
+ }
+ break;
+ default:
+ break;
+ }
+ free(pmsg);
+}
+
+void
+thread_message_handler(void *user_data)
+{
+}