Module: kamailio
Branch: 5.7
Commit: 3644522e041920bf508d16c2992a216df656702b
URL: 
https://github.com/kamailio/kamailio/commit/3644522e041920bf508d16c2992a216df656702b

Author: S-P Chan <shihping.c...@gmail.com>
Committer: S-P Chan <shihping.c...@gmail.com>
Date: 2024-02-04T08:12:52+08:00

db_postgres: init libssl in a thread

From:
- 3426b153d02d9d8d3e909eff9d18cb14108072ca
- 8a1c383f6af5bc0547e32430a4469333160b93e6

---

Modified: src/modules/db_postgres/km_dbase.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/3644522e041920bf508d16c2992a216df656702b.diff
Patch: 
https://github.com/kamailio/kamailio/commit/3644522e041920bf508d16c2992a216df656702b.patch

---

diff --git a/src/modules/db_postgres/km_dbase.c 
b/src/modules/db_postgres/km_dbase.c
index 02cb5c421d5..3d58f1a53e0 100644
--- a/src/modules/db_postgres/km_dbase.c
+++ b/src/modules/db_postgres/km_dbase.c
@@ -43,6 +43,8 @@
 #include "../../core/locking.h"
 #include "../../core/hashes.h"
 #include "../../core/clist.h"
+#define KSR_RTHREAD_NEED_PI
+#include "../../core/rthreads.h"
 #include "km_dbase.h"
 #include "km_pg_con.h"
 #include "km_val.h"
@@ -108,24 +110,37 @@ static void db_postgres_free_query(const db1_con_t *_con);
  * \param _url URL of the database that should be opened
  * \return database connection on success, NULL on error
  * \note this function must be called prior to any database functions
+ *
+ * Init libssl in a thread
  */
-db1_con_t *db_postgres_init(const str *_url)
+static db1_con_t *db_postgres_init0(const str *_url)
 {
        return db_do_init(_url, (void *)db_postgres_new_connection);
 }
 
+db1_con_t *db_postgres_init(const str *_url)
+{
+       return run_threadP((_thread_proto)db_postgres_init0, (void *)_url);
+}
 /*!
  * \brief Initialize database for future queries, specify pooling
  * \param _url URL of the database that should be opened
  * \param pooling whether or not to use a pooled connection
  * \return database connection on success, NULL on error
  * \note this function must be called prior to any database functions
+ *
+ * Init libssl in thread
  */
-db1_con_t *db_postgres_init2(const str *_url, db_pooling_t pooling)
+static db1_con_t *db_postgres_init2_impl(const str *_url, db_pooling_t pooling)
 {
        return db_do_init2(_url, (void *)db_postgres_new_connection, pooling);
 }
 
+db1_con_t *db_postgres_init2(const str *_url, db_pooling_t pooling)
+{
+       return run_threadPI(
+                       (_thread_protoPI)db_postgres_init2_impl, (void *)_url, 
pooling);
+}
 /*!
  * \brief Close database when the database is no longer needed
  * \param _h closed connection, as returned from db_postgres_init

_______________________________________________
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org

Reply via email to