Module: kamailio
Branch: master
Commit: 4baa76cd3e0d4052baf037c663a898fd11c54514
URL:
https://github.com/kamailio/kamailio/commit/4baa76cd3e0d4052baf037c663a898f…
Author: S-P Chan <shihping.chan(a)gmail.com>
Committer: S-P Chan <shihping.chan(a)gmail.com>
Date: 2024-02-09T07:05:17+08:00
core/rthreads.h: thread wrapper for db_XXXX_query
---
Modified: src/core/rthreads.h
---
Diff:
https://github.com/kamailio/kamailio/commit/4baa76cd3e0d4052baf037c663a898f…
Patch:
https://github.com/kamailio/kamailio/commit/4baa76cd3e0d4052baf037c663a898f…
---
diff --git a/src/core/rthreads.h b/src/core/rthreads.h
index 2f922be5a75..e96f45c9395 100644
--- a/src/core/rthreads.h
+++ b/src/core/rthreads.h
@@ -201,3 +201,56 @@ static void run_thread0P(_thread_proto0P fn, void *arg1)
#endif
}
#endif
+
+/*
+ * prototype:
+ * db_unixodbc_query(const db1_con_t *_h, const db_key_t *_k,
+ * const db_op_t *_op, const db_val_t *_v, const db_key_t *_c,
+ * const int _n, const int _nc, const db_key_t _o, db1_res_t **_r)
+ */
+#ifdef KSR_RTHREAD_NEED_4P5I2P2
+typedef int (*_thread_proto4P5I2P2)(
+ void *, void *, void *, void *, void *, int, int, void *, void *);
+struct _thread_args4P5I2P2
+{
+ _thread_proto4P5I2P2 fn;
+ void *arg1;
+ void *arg2;
+ void *arg3;
+ void *arg4;
+ void *arg5;
+ int arg6;
+ int arg7;
+ void *arg8;
+ void *arg9;
+ int *ret;
+};
+static void *run_thread_wrap4P5I2P2(struct _thread_args4P5I2P2 *args)
+{
+ *args->ret = (*args->fn)(args->arg1, args->arg2, args->arg3,
args->arg4,
+ args->arg5, args->arg6, args->arg7, args->arg8, args->arg9);
+ return NULL;
+}
+
+static int run_thread4P5I2P2(_thread_proto4P5I2P2 fn, void *arg1, void *arg2,
+ void *arg3, void *arg4, void *arg5, int arg6, int arg7, void *arg8,
+ void *arg9)
+{
+#ifdef USE_TLS
+ pthread_t tid;
+ int ret;
+
+ if(likely(ksr_tls_threads_mode == 0
+ || (ksr_tls_threads_mode == 1 && process_no > 0))) {
+ return fn(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
+ }
+ pthread_create(&tid, NULL, (_thread_proto)run_thread_wrap4P5I2P2,
+ &(struct _thread_args4P5I2P2){fn, arg1, arg2, arg3, arg4, arg5,
+ arg6, arg7, arg8, arg9, &ret});
+ pthread_join(tid, NULL);
+ return ret;
+#else
+ return fn(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
+#endif
+}
+#endif