Module: kamailio
Branch: 5.7
Commit: 6f037a48f706e6108a063883f9e9a324bea56da9
URL:
https://github.com/kamailio/kamailio/commit/6f037a48f706e6108a063883f9e9a32…
Author: S-P Chan <shihping.chan(a)gmail.com>
Committer: S-P Chan <shihping.chan(a)gmail.com>
Date: 2024-02-06T13:13:23+08:00
core/rthread.h: add prototype for db queries
(cherry-pick from ba921b2112e87625fba5789d1b049161bb611073)
---
Modified: src/core/rthreads.h
---
Diff:
https://github.com/kamailio/kamailio/commit/6f037a48f706e6108a063883f9e9a32…
Patch:
https://github.com/kamailio/kamailio/commit/6f037a48f706e6108a063883f9e9a32…
---
diff --git a/src/core/rthreads.h b/src/core/rthreads.h
index a5ad7670dae..a416ad2ca50 100644
--- a/src/core/rthreads.h
+++ b/src/core/rthreads.h
@@ -98,3 +98,60 @@ static void run_threadV(_thread_protoV fn)
pthread_join(tid, NULL);
}
#endif
+
+/*
+ * prototype: int fn(void *, void *) { ... }
+ */
+#ifdef KSR_RTHREAD_NEED_4PP
+typedef int (*_thread_proto4PP)(void *, void *);
+struct _thread_args4PP
+{
+ _thread_proto4PP fn;
+ void *arg1;
+ void *arg2;
+ int *ret;
+};
+static void *run_thread_wrap4PP(struct _thread_args4PP *args)
+{
+ *args->ret = (*args->fn)(args->arg1, args->arg2);
+ return NULL;
+}
+
+static int run_thread4PP(_thread_proto4PP fn, void *arg1, void *arg2)
+{
+ pthread_t tid;
+ int ret;
+
+ pthread_create(&tid, NULL, (_thread_proto)run_thread_wrap4PP,
+ &(struct _thread_args4PP){fn, arg1, arg2, &ret});
+ pthread_join(tid, NULL);
+
+ return ret;
+}
+#endif
+
+/*
+ * prototype: void fn(void *) { ... }
+ */
+#ifdef KSR_RTHREAD_NEED_0P
+typedef void (*_thread_proto0P)(void *);
+struct _thread_args0P
+{
+ _thread_proto0P fn;
+ void *arg1;
+};
+static void *run_thread_wrap0P(struct _thread_args0P *args)
+{
+ (*args->fn)(args->arg1);
+ return NULL;
+}
+
+static void run_thread0P(_thread_proto0P fn, void *arg1)
+{
+ pthread_t tid;
+
+ pthread_create(&tid, NULL, (_thread_proto)run_thread_wrap0P,
+ &(struct _thread_args0P){fn, arg1});
+ pthread_join(tid, NULL);
+}
+#endif