[sr-dev] Working with arrays in MongoDB documents

2024-02-05 Thread Mario Pereira via sr-dev
Hi everybody,

I normally use MongoDB as DB engine in my projects and I would like to get all 
MongoDB advantages when working with Kamailio. For this reason, I need to deal 
with arrays of information inside a document (for example, an array of contacts 
inside a document).

And now the question: is it possible to insert, update and search info in a 
MongoDB document by using arrays via srdb1 lib? If yes, how? And if not, are 
you thinking about implementing it in the future?

Thank you very much for your time.

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


[sr-dev] git:master:faaad7e0: rtpengine: docs for ping_mode parameter

2024-02-05 Thread Daniel-Constantin Mierla via sr-dev
Module: kamailio
Branch: master
Commit: faaad7e0e654359e744d0c18253cc0dc84cd906e
URL: 
https://github.com/kamailio/kamailio/commit/faaad7e0e654359e744d0c18253cc0dc84cd906e

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2024-02-05T16:19:20+01:00

rtpengine: docs for ping_mode parameter

---

Modified: src/modules/rtpengine/doc/rtpengine_admin.xml

---

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

---

diff --git a/src/modules/rtpengine/doc/rtpengine_admin.xml 
b/src/modules/rtpengine/doc/rtpengine_admin.xml
index fea67a665a2..adb3af92bdd 100644
--- a/src/modules/rtpengine/doc/rtpengine_admin.xml
+++ b/src/modules/rtpengine/doc/rtpengine_admin.xml
@@ -2348,6 +2348,28 @@ modparam("rtpengine", "dtmf_events_sock", 
"127.0.0.1:2223")


 
+   
+   ping_mode (integer)
+   
+   Specify if the RTPEngine instances have to be pinged at startup 
to
+   detect if they are active. Set it to 0 to disable pinging and 
to 1
+   to activate pinging.
+   
+   
+   
+   Default value is 1.
+   
+   
+   
+   Set ping_mode parameter
+   
+...
+modparam("rtpengine", "ping_mode", 0)
+...
+
+   
+   
+

 
 

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


[sr-dev] git:master:10b86323: influxdbc: convert string value to double

2024-02-05 Thread Daniel-Constantin Mierla via sr-dev
Module: kamailio
Branch: master
Commit: 10b86323cc47f29b41c21fd601d5b309cca050e6
URL: 
https://github.com/kamailio/kamailio/commit/10b86323cc47f29b41c21fd601d5b309cca050e6

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2024-02-05T16:19:20+01:00

influxdbc: convert string value to double

---

Modified: src/modules/influxdbc/influxdbc_mod.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/10b86323cc47f29b41c21fd601d5b309cca050e6.diff
Patch: 
https://github.com/kamailio/kamailio/commit/10b86323cc47f29b41c21fd601d5b309cca050e6.patch

---

diff --git a/src/modules/influxdbc/influxdbc_mod.c 
b/src/modules/influxdbc/influxdbc_mod.c
index b1c79b4b494..2c2f8804bb4 100644
--- a/src/modules/influxdbc/influxdbc_mod.c
+++ b/src/modules/influxdbc/influxdbc_mod.c
@@ -242,6 +242,8 @@ static int w_influxdbc_double(sip_msg_t *msg, char *pname, 
char *pvalue)
return -1;
}
 
+   dval = strtod(sval.s, NULL);
+
ic_double(sname.s, dval);
 
return 1;

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


[sr-dev] git:master:ba2d0e17: influxdbc: docs for several parameters and functions

2024-02-05 Thread Daniel-Constantin Mierla via sr-dev
Module: kamailio
Branch: master
Commit: ba2d0e171b0171ba98bc7219a420dcda7677d366
URL: 
https://github.com/kamailio/kamailio/commit/ba2d0e171b0171ba98bc7219a420dcda7677d366

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2024-02-05T16:19:20+01:00

influxdbc: docs for several parameters and functions

---

Modified: src/modules/influxdbc/doc/influxdbc_admin.xml

---

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

---

diff --git a/src/modules/influxdbc/doc/influxdbc_admin.xml 
b/src/modules/influxdbc/doc/influxdbc_admin.xml
index c59fe92a126..a02af97e048 100644
--- a/src/modules/influxdbc/doc/influxdbc_admin.xml
+++ b/src/modules/influxdbc/doc/influxdbc_admin.xml
@@ -68,6 +68,44 @@
 ...
 modparam("influxdbc", "server", "127.0.0.1")
 ...
+
+   
+   
+   
+   port (int)
+   
+   Address of InfluxDB server.
+   
+   
+   
+   Default value is 8086.
+   
+   
+   
+   Set port parameter
+   
+...
+modparam("influxdbc", "port", 8808)
+...
+
+   
+   
+   
+   database (int)
+   
+   Database of InfluxDB server.
+   
+   
+   
+   Default value is empty.
+   
+   
+   
+   Set database parameter
+   
+...
+modparam("influxdbc", "database", "stats")
+...
 


@@ -86,7 +124,7 @@ modparam("influxdbc", "server", "127.0.0.1")
This function can be used from ANY_ROUTE.


-   async_route usage
+   influxdbc_measure() usage

 ...
 request_route {
@@ -95,6 +133,53 @@ request_route {
 ...
 }
 ...
+
+   
+   
+   
+   
+   influxdbc_measureend()
+   
+   
+   End the current measure group.
+   
+   
+   This function can be used from ANY_ROUTE.
+   
+   
+   influxdbc_measureend() usage
+   
+...
+request_route {
+...
+influxdbc_measureend();
+...
+}
+...
+
+   
+   
+   
+   
+   influxdbc_long(name, value)
+   
+   
+   Save the pair with provided name and value. Both 
parameters can
+   have variables.
+   
+   
+   This function can be used from ANY_ROUTE.
+   
+   
+   influxdbc_long() usage
+   
+...
+request_route {
+...
+influxdbc_long("active", "$shv(active)");
+...
+}
+...
 



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


[sr-dev] git:master:2ab212cc: modules: readme files regenerated - influxdbc ... [skip ci]

2024-02-05 Thread Kamailio Dev via sr-dev
Module: kamailio
Branch: master
Commit: 2ab212ccf0b4ecd7a0671235641e2a80feb251ff
URL: 
https://github.com/kamailio/kamailio/commit/2ab212ccf0b4ecd7a0671235641e2a80feb251ff

Author: Kamailio Dev 
Committer: Kamailio Dev 
Date: 2024-02-05T16:32:00+01:00

modules: readme files regenerated - influxdbc ... [skip ci]

---

Modified: src/modules/influxdbc/README
Modified: src/modules/rtpengine/README

---

Diff:  
https://github.com/kamailio/kamailio/commit/2ab212ccf0b4ecd7a0671235641e2a80feb251ff.diff
Patch: 
https://github.com/kamailio/kamailio/commit/2ab212ccf0b4ecd7a0671235641e2a80feb251ff.patch

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


[sr-dev] Re: Working with arrays in MongoDB documents

2024-02-05 Thread Henning Westerholt via sr-dev
Hello,

why do you would like to use the generic Kamailio DB1 (v1) API with db_mongodb, 
when there is a ndb_mongodb module available which supports native queries and 
also provide functions to iterate over multiple documents?

Cheers,

Henning

> -Original Message-
> From: Mario Pereira via sr-dev 
> Sent: Montag, 5. Februar 2024 09:56
> To: sr-dev@lists.kamailio.org
> Cc: mario.pere...@quobis.com
> Subject: [sr-dev] Working with arrays in MongoDB documents
> 
> Hi everybody,
> 
> I normally use MongoDB as DB engine in my projects and I would like to get all
> MongoDB advantages when working with Kamailio. For this reason, I need to
> deal with arrays of information inside a document (for example, an array of
> contacts inside a document).
> 
> And now the question: is it possible to insert, update and search info in a
> MongoDB document by using arrays via srdb1 lib? If yes, how? And if not, are
> you thinking about implementing it in the future?
> 
> Thank you very much for your time.
> 
> Regards,
> Mario
> ___
> Kamailio (SER) - Development Mailing List To unsubscribe send an email to sr-
> dev-le...@lists.kamailio.org
___
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org


[sr-dev] git:master:d638c774: db_postgres: handle SSL and submit query

2024-02-05 Thread S-P Chan via sr-dev
Module: kamailio
Branch: master
Commit: d638c774ed816eec800e72ba2546004215cfe097
URL: 
https://github.com/kamailio/kamailio/commit/d638c774ed816eec800e72ba2546004215cfe097

Author: S-P Chan 
Committer: S-P Chan 
Date: 2024-02-06T10:17:53+08:00

db_postgres: handle SSL and submit query

---

Modified: src/modules/db_postgres/km_dbase.c

---

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

---

diff --git a/src/modules/db_postgres/km_dbase.c 
b/src/modules/db_postgres/km_dbase.c
index 3d58f1a53e0..7948ff0075f 100644
--- a/src/modules/db_postgres/km_dbase.c
+++ b/src/modules/db_postgres/km_dbase.c
@@ -44,6 +44,7 @@
 #include "../../core/hashes.h"
 #include "../../core/clist.h"
 #define KSR_RTHREAD_NEED_PI
+#define KSR_RTHREAD_NEED_4PP
 #include "../../core/rthreads.h"
 #include "km_dbase.h"
 #include "km_pg_con.h"
@@ -158,7 +159,7 @@ void db_postgres_close(db1_con_t *_h)
  * \param _s query string
  * \return 0 on success, negative on failure
  */
-static int db_postgres_submit_query(const db1_con_t *_con, const str *_s)
+static int db_postgres_submit_query_impl(const db1_con_t *_con, const str *_s)
 {
char *s = NULL;
int i, retries;
@@ -286,6 +287,12 @@ static int db_postgres_submit_query(const db1_con_t *_con, 
const str *_s)
return -1;
 }
 
+static int db_postgres_submit_query(const db1_con_t *_con, const str *_s)
+{
+   return run_thread4PP((_thread_proto4PP)db_postgres_submit_query_impl,
+   (void *)_con, (void *)_s);
+}
+
 void db_postgres_async_exec_task(void *param)
 {
str *p;

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


[sr-dev] git:master:7d917e66: db_unixodbc: handle SSL and submit query

2024-02-05 Thread S-P Chan via sr-dev
Module: kamailio
Branch: master
Commit: 7d917e6649be7188bb9ab152ada75bc7199b2980
URL: 
https://github.com/kamailio/kamailio/commit/7d917e6649be7188bb9ab152ada75bc7199b2980

Author: S-P Chan 
Committer: S-P Chan 
Date: 2024-02-06T10:17:53+08:00

db_unixodbc: handle SSL and submit query

---

Modified: src/modules/db_unixodbc/dbase.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/7d917e6649be7188bb9ab152ada75bc7199b2980.diff
Patch: 
https://github.com/kamailio/kamailio/commit/7d917e6649be7188bb9ab152ada75bc7199b2980.patch

---

diff --git a/src/modules/db_unixodbc/dbase.c b/src/modules/db_unixodbc/dbase.c
index c4ba64b019c..7a5f2bdb09e 100644
--- a/src/modules/db_unixodbc/dbase.c
+++ b/src/modules/db_unixodbc/dbase.c
@@ -25,6 +25,7 @@
 #include "../../core/mem/mem.h"
 #include "../../core/dprint.h"
 #include "../../core/async_task.h"
+#define KSR_RTHREAD_NEED_4PP
 #include "../../core/rthreads.h"
 #include "../../lib/srdb1/db_query.h"
 #include "val.h"
@@ -81,7 +82,7 @@ static int reconnect(const db1_con_t *_h)
 /*
  * Send an SQL query to the server
  */
-static int db_unixodbc_submit_query(const db1_con_t *_h, const str *_s)
+static int db_unixodbc_submit_query_impl(const db1_con_t *_h, const str *_s)
 {
int ret = 0;
SQLCHAR sqlstate[7];
@@ -155,6 +156,11 @@ static int db_unixodbc_submit_query(const db1_con_t *_h, 
const str *_s)
return ret;
 }
 
+static int db_unixodbc_submit_query(const db1_con_t *_h, const str *_s)
+{
+   return run_thread4PP((_thread_proto4PP)db_unixodbc_submit_query_impl,
+   (void *)_h, (void *)_s);
+}
 /**
  *
  */

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


[sr-dev] git:master:51d9f92e: db_mysql: handle SSL and submit query

2024-02-05 Thread S-P Chan via sr-dev
Module: kamailio
Branch: master
Commit: 51d9f92eca3ef1044052581c9438af6e643652a1
URL: 
https://github.com/kamailio/kamailio/commit/51d9f92eca3ef1044052581c9438af6e643652a1

Author: S-P Chan 
Committer: S-P Chan 
Date: 2024-02-06T10:17:53+08:00

db_mysql: handle SSL and submit query

---

Modified: src/modules/db_mysql/km_dbase.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/51d9f92eca3ef1044052581c9438af6e643652a1.diff
Patch: 
https://github.com/kamailio/kamailio/commit/51d9f92eca3ef1044052581c9438af6e643652a1.patch

---

diff --git a/src/modules/db_mysql/km_dbase.c b/src/modules/db_mysql/km_dbase.c
index 9cd238b78ab..e86e4a0391b 100644
--- a/src/modules/db_mysql/km_dbase.c
+++ b/src/modules/db_mysql/km_dbase.c
@@ -38,6 +38,8 @@
 #include "../../core/mem/mem.h"
 #include "../../core/dprint.h"
 #include "../../core/async_task.h"
+
+#define KSR_RTHREAD_NEED_4PP
 #include "../../core/rthreads.h"
 #include "../../lib/srdb1/db_query.h"
 #include "../../lib/srdb1/db_ut.h"
@@ -67,7 +69,7 @@ static char *mysql_sql_buf;
  * \param _s executed query
  * \return zero on success, negative value on failure
  */
-static int db_mysql_submit_query(const db1_con_t *_h, const str *_s)
+static int db_mysql_submit_query_impl(const db1_con_t *_h, const str *_s)
 {
time_t t;
int i, code;
@@ -128,6 +130,11 @@ static int db_mysql_submit_query(const db1_con_t *_h, 
const str *_s)
 }
 
 
+static int db_mysql_submit_query(const db1_con_t *_h, const str *_s)
+{
+   return run_thread4PP((_thread_proto4PP)db_mysql_submit_query_impl,
+   (void *)_h, (void *)_s);
+}
 /**
  *
  */

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


[sr-dev] git:master:ba921b21: core/rthread.h: add prototype for db queries

2024-02-05 Thread S-P Chan via sr-dev
Module: kamailio
Branch: master
Commit: ba921b2112e87625fba5789d1b049161bb611073
URL: 
https://github.com/kamailio/kamailio/commit/ba921b2112e87625fba5789d1b049161bb611073

Author: S-P Chan 
Committer: S-P Chan 
Date: 2024-02-06T10:17:53+08:00

core/rthread.h: add prototype for db queries

---

Modified: src/core/rthreads.h

---

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

---

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

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


[sr-dev] git:master:475b4da7: Sample etc/kamailio.cfg: tls should be loaded first if used

2024-02-05 Thread S-P Chan via sr-dev
Module: kamailio
Branch: master
Commit: 475b4da798fce232eba6834c3cb05e3c97e12d03
URL: 
https://github.com/kamailio/kamailio/commit/475b4da798fce232eba6834c3cb05e3c97e12d03

Author: S-P Chan 
Committer: S-P Chan 
Date: 2024-02-06T11:09:13+08:00

Sample etc/kamailio.cfg: tls should be loaded first if used

---

Modified: etc/kamailio.cfg

---

Diff:  
https://github.com/kamailio/kamailio/commit/475b4da798fce232eba6834c3cb05e3c97e12d03.diff
Patch: 
https://github.com/kamailio/kamailio/commit/475b4da798fce232eba6834c3cb05e3c97e12d03.patch

---

diff --git a/etc/kamailio.cfg b/etc/kamailio.cfg
old mode 100644
new mode 100755
index 598d12bc23e..cc043fad58b
--- a/etc/kamailio.cfg
+++ b/etc/kamailio.cfg
@@ -257,6 +257,12 @@ voicemail.srv_port = "5060" desc "VoiceMail Port"
 /* set paths to location of modules */
 # mpath="/usr/local/lib/kamailio/modules/"
 
+# when using TLS with OpenSSL it is recommended to load this module
+# first so that OpenSSL is initialized correctly
+#!ifdef WITH_TLS
+loadmodule "tls.so"
+#!endif
+
 #!ifdef WITH_MYSQL
 loadmodule "db_mysql.so"
 #!endif
@@ -319,10 +325,6 @@ loadmodule "rtpproxy.so"
 #!endif
 #!endif
 
-#!ifdef WITH_TLS
-loadmodule "tls.so"
-#!endif
-
 #!ifdef WITH_HTABLE
 loadmodule "htable.so"
 #!endif

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


[sr-dev] git:5.7:63009ee5: db_postgres: handle SSL and submit query

2024-02-05 Thread S-P Chan via sr-dev
Module: kamailio
Branch: 5.7
Commit: 63009ee559bb68a3fde0b7f479d3023b06a6c376
URL: 
https://github.com/kamailio/kamailio/commit/63009ee559bb68a3fde0b7f479d3023b06a6c376

Author: S-P Chan 
Committer: S-P Chan 
Date: 2024-02-06T13:14:12+08:00

db_postgres: handle SSL and submit query

(cherry-pick from d638c774ed816eec800e72ba2546004215cfe097)

---

Modified: src/modules/db_postgres/km_dbase.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/63009ee559bb68a3fde0b7f479d3023b06a6c376.diff
Patch: 
https://github.com/kamailio/kamailio/commit/63009ee559bb68a3fde0b7f479d3023b06a6c376.patch

---

diff --git a/src/modules/db_postgres/km_dbase.c 
b/src/modules/db_postgres/km_dbase.c
index 3d58f1a53e0..7948ff0075f 100644
--- a/src/modules/db_postgres/km_dbase.c
+++ b/src/modules/db_postgres/km_dbase.c
@@ -44,6 +44,7 @@
 #include "../../core/hashes.h"
 #include "../../core/clist.h"
 #define KSR_RTHREAD_NEED_PI
+#define KSR_RTHREAD_NEED_4PP
 #include "../../core/rthreads.h"
 #include "km_dbase.h"
 #include "km_pg_con.h"
@@ -158,7 +159,7 @@ void db_postgres_close(db1_con_t *_h)
  * \param _s query string
  * \return 0 on success, negative on failure
  */
-static int db_postgres_submit_query(const db1_con_t *_con, const str *_s)
+static int db_postgres_submit_query_impl(const db1_con_t *_con, const str *_s)
 {
char *s = NULL;
int i, retries;
@@ -286,6 +287,12 @@ static int db_postgres_submit_query(const db1_con_t *_con, 
const str *_s)
return -1;
 }
 
+static int db_postgres_submit_query(const db1_con_t *_con, const str *_s)
+{
+   return run_thread4PP((_thread_proto4PP)db_postgres_submit_query_impl,
+   (void *)_con, (void *)_s);
+}
+
 void db_postgres_async_exec_task(void *param)
 {
str *p;

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


[sr-dev] git:5.7:6f037a48: core/rthread.h: add prototype for db queries

2024-02-05 Thread S-P Chan via sr-dev
Module: kamailio
Branch: 5.7
Commit: 6f037a48f706e6108a063883f9e9a324bea56da9
URL: 
https://github.com/kamailio/kamailio/commit/6f037a48f706e6108a063883f9e9a324bea56da9

Author: S-P Chan 
Committer: S-P Chan 
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/6f037a48f706e6108a063883f9e9a324bea56da9.diff
Patch: 
https://github.com/kamailio/kamailio/commit/6f037a48f706e6108a063883f9e9a324bea56da9.patch

---

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

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


[sr-dev] git:5.7:103c62ba: db_mysql: handle SSL and submit query

2024-02-05 Thread S-P Chan via sr-dev
Module: kamailio
Branch: 5.7
Commit: 103c62ba675f8d306e1c0fb60ddfd4c4bca1e931
URL: 
https://github.com/kamailio/kamailio/commit/103c62ba675f8d306e1c0fb60ddfd4c4bca1e931

Author: S-P Chan 
Committer: S-P Chan 
Date: 2024-02-06T13:13:59+08:00

db_mysql: handle SSL and submit query

(cherry-pick from 51d9f92eca3ef1044052581c9438af6e643652a1)

---

Modified: src/modules/db_mysql/km_dbase.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/103c62ba675f8d306e1c0fb60ddfd4c4bca1e931.diff
Patch: 
https://github.com/kamailio/kamailio/commit/103c62ba675f8d306e1c0fb60ddfd4c4bca1e931.patch

---

diff --git a/src/modules/db_mysql/km_dbase.c b/src/modules/db_mysql/km_dbase.c
index 9cd238b78ab..e86e4a0391b 100644
--- a/src/modules/db_mysql/km_dbase.c
+++ b/src/modules/db_mysql/km_dbase.c
@@ -38,6 +38,8 @@
 #include "../../core/mem/mem.h"
 #include "../../core/dprint.h"
 #include "../../core/async_task.h"
+
+#define KSR_RTHREAD_NEED_4PP
 #include "../../core/rthreads.h"
 #include "../../lib/srdb1/db_query.h"
 #include "../../lib/srdb1/db_ut.h"
@@ -67,7 +69,7 @@ static char *mysql_sql_buf;
  * \param _s executed query
  * \return zero on success, negative value on failure
  */
-static int db_mysql_submit_query(const db1_con_t *_h, const str *_s)
+static int db_mysql_submit_query_impl(const db1_con_t *_h, const str *_s)
 {
time_t t;
int i, code;
@@ -128,6 +130,11 @@ static int db_mysql_submit_query(const db1_con_t *_h, 
const str *_s)
 }
 
 
+static int db_mysql_submit_query(const db1_con_t *_h, const str *_s)
+{
+   return run_thread4PP((_thread_proto4PP)db_mysql_submit_query_impl,
+   (void *)_h, (void *)_s);
+}
 /**
  *
  */

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


[sr-dev] git:5.7:579d3973: db_unixodbc: handle SSL and submit query

2024-02-05 Thread S-P Chan via sr-dev
Module: kamailio
Branch: 5.7
Commit: 579d39736b8f11d0e5c68715ba3a9aafc07cd7dc
URL: 
https://github.com/kamailio/kamailio/commit/579d39736b8f11d0e5c68715ba3a9aafc07cd7dc

Author: S-P Chan 
Committer: S-P Chan 
Date: 2024-02-06T13:13:42+08:00

db_unixodbc: handle SSL and submit query

(cherry-pick from 7d917e6649be7188bb9ab152ada75bc7199b2980)

---

Modified: src/modules/db_unixodbc/dbase.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/579d39736b8f11d0e5c68715ba3a9aafc07cd7dc.diff
Patch: 
https://github.com/kamailio/kamailio/commit/579d39736b8f11d0e5c68715ba3a9aafc07cd7dc.patch

---

diff --git a/src/modules/db_unixodbc/dbase.c b/src/modules/db_unixodbc/dbase.c
index c4ba64b019c..7a5f2bdb09e 100644
--- a/src/modules/db_unixodbc/dbase.c
+++ b/src/modules/db_unixodbc/dbase.c
@@ -25,6 +25,7 @@
 #include "../../core/mem/mem.h"
 #include "../../core/dprint.h"
 #include "../../core/async_task.h"
+#define KSR_RTHREAD_NEED_4PP
 #include "../../core/rthreads.h"
 #include "../../lib/srdb1/db_query.h"
 #include "val.h"
@@ -81,7 +82,7 @@ static int reconnect(const db1_con_t *_h)
 /*
  * Send an SQL query to the server
  */
-static int db_unixodbc_submit_query(const db1_con_t *_h, const str *_s)
+static int db_unixodbc_submit_query_impl(const db1_con_t *_h, const str *_s)
 {
int ret = 0;
SQLCHAR sqlstate[7];
@@ -155,6 +156,11 @@ static int db_unixodbc_submit_query(const db1_con_t *_h, 
const str *_s)
return ret;
 }
 
+static int db_unixodbc_submit_query(const db1_con_t *_h, const str *_s)
+{
+   return run_thread4PP((_thread_proto4PP)db_unixodbc_submit_query_impl,
+   (void *)_h, (void *)_s);
+}
 /**
  *
  */

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


[sr-dev] Re: git:master:ba921b21: core/rthread.h: add prototype for db queries

2024-02-05 Thread Daniel-Constantin Mierla via sr-dev
Hello,

by latest commits, I notice that more functions need to be executed in
another thread when having to deal libssl3. I wonder if it is not an
alternative to run only the tls module functions in other threads?

If not, maybe we can introduce a global parameter (or per module) that
makes this wrapper functions to execute directly or through another
thread. There are cases when it is no need to run through different threads.

Cheers,
Daniel

On 06.02.24 03:40, S-P Chan via sr-dev wrote:
> Module: kamailio
> Branch: master
> Commit: ba921b2112e87625fba5789d1b049161bb611073
> URL: 
> https://github.com/kamailio/kamailio/commit/ba921b2112e87625fba5789d1b049161bb611073
>
> Author: S-P Chan 
> Committer: S-P Chan 
> Date: 2024-02-06T10:17:53+08:00
>
> core/rthread.h: add prototype for db queries
>
> ---
>
> Modified: src/core/rthreads.h
>
> ---
>
> Diff:  
> https://github.com/kamailio/kamailio/commit/ba921b2112e87625fba5789d1b049161bb611073.diff
> Patch: 
> https://github.com/kamailio/kamailio/commit/ba921b2112e87625fba5789d1b049161bb611073.patch
>
> ---
>
> 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
>
> ___
> Kamailio (SER) - Development Mailing List
> To unsubscribe send an email to sr-dev-le...@lists.kamailio.org

-- 
Daniel-Constantin Mierla (@ asipto.com)
twitter.com/miconda -- linkedin.com/in/miconda
Kamailio Consultancy, Training and Development Services -- asipto.com
Kamailio Advanced Training, February 20-22, 2024 -- asipto.com
Kamailio World Conference, April 18-19, 2024, Berlin -- kamailioworld.com

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


[sr-dev] Re: git:master:ba921b21: core/rthread.h: add prototype for db queries

2024-02-05 Thread Henning Westerholt via sr-dev
Hello,

yes, good idea. It would be also probably a good idea to have a bit more time 
to review these commits in git master before merging them directly to stable 
branch, as done some minutes ago.

Cheers,

Henning

> -Original Message-
> From: Daniel-Constantin Mierla via sr-dev 
> Sent: Dienstag, 6. Februar 2024 08:40
> To: Kamailio (SER) - Development Mailing List 
> Cc: Daniel-Constantin Mierla 
> Subject: [sr-dev] Re: git:master:ba921b21: core/rthread.h: add prototype for
> db queries
> 
> Hello,
> 
> by latest commits, I notice that more functions need to be executed in another
> thread when having to deal libssl3. I wonder if it is not an alternative to 
> run
> only the tls module functions in other threads?
> 
> If not, maybe we can introduce a global parameter (or per module) that makes
> this wrapper functions to execute directly or through another thread. There
> are cases when it is no need to run through different threads.
> 
> Cheers,
> Daniel
> 
> On 06.02.24 03:40, S-P Chan via sr-dev wrote:
> > Module: kamailio
> > Branch: master
> > Commit: ba921b2112e87625fba5789d1b049161bb611073
> > URL:
> >
> https://github.com/kamailio/kamailio/commit/ba921b2112e87625fba5789
> d1b
> > 049161bb611073
> >
> > Author: S-P Chan 
> > Committer: S-P Chan 
> > Date: 2024-02-06T10:17:53+08:00
> >
> > core/rthread.h: add prototype for db queries
> >
> > ---
> >
> > Modified: src/core/rthreads.h
> >
> > ---
> >
> > Diff:
> >
> https://github.com/kamailio/kamailio/commit/ba921b2112e87625fba5789
> d1b
> > 049161bb611073.diff
> > Patch:
> >
> https://github.com/kamailio/kamailio/commit/ba921b2112e87625fba5789
> d1b
> > 049161bb611073.patch
> >
> > ---
> >
> > 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
> >
> > ___
> > Kamailio (SER) - Development Mailing List To unsubscribe send an email
> > to sr-dev-le...@lists.kamailio.org
> 
> --
> Daniel-Constantin Mierla (@ asipto.com)
> twitter.com/miconda -- linkedin.com/in/miconda Kamailio Consultancy,
> Training and Development Services -- asipto.com Kamailio Advanced Training,
> February 20-22, 2024 -- asipto.com Kamailio World Conference, April 18-19,
> 2024, Berlin -- kamailioworld.com
> 
> ___
> Kamailio (SER) - Development Mailing List To unsubscribe send an email to sr-
> dev-le...@lists.kamailio.org
___
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org