mirror of https://github.com/sipwise/kamailio.git
- remove already applied patches Change-Id: I7d04dedfc7888006faf65b7a08fd05992efd8293mr12.4
parent
fddc5a9eca
commit
6feb745e4d
@ -1,207 +0,0 @@
|
||||
From: Victor Seva <vseva@sipwise.com>
|
||||
Date: Wed, 29 Mar 2023 12:12:54 +0200
|
||||
Subject: cfgt: route log
|
||||
|
||||
---
|
||||
src/modules/cfgt/cfgt_int.c | 39 ++++++++++++++++++++++++++++++++++++-
|
||||
src/modules/cfgt/cfgt_int.h | 3 ++-
|
||||
src/modules/cfgt/cfgt_mod.c | 4 +++-
|
||||
src/modules/cfgt/doc/cfgt_admin.xml | 19 ++++++++++++++++++
|
||||
4 files changed, 62 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/modules/cfgt/cfgt_int.c b/src/modules/cfgt/cfgt_int.c
|
||||
index 15f0606..56e3376 100644
|
||||
--- a/src/modules/cfgt/cfgt_int.c
|
||||
+++ b/src/modules/cfgt/cfgt_int.c
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
*
|
||||
- * Copyright (C) 2015 Victor Seva (sipwise.com)
|
||||
+ * Copyright (C) 2015-2023 Victor Seva (sipwise.com)
|
||||
*
|
||||
* This file is part of Kamailio, a free SIP server.
|
||||
*
|
||||
@@ -22,6 +22,7 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
+#include <sys/time.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
@@ -45,6 +46,7 @@ str cfgt_hdr_prefix = {"NGCP%", 5};
|
||||
str cfgt_basedir = {"/tmp", 4};
|
||||
int cfgt_mask = CFGT_DP_ALL;
|
||||
int cfgt_skip_unknown = 0;
|
||||
+int cfgt_route_log = 0;
|
||||
int not_sip = 0;
|
||||
|
||||
int _cfgt_get_filename(int msgid, str uuid, str *dest, int *dir);
|
||||
@@ -463,6 +465,7 @@ int _cfgt_set_dump(struct sip_msg *msg, cfgt_node_p node, str *flow)
|
||||
{
|
||||
int len;
|
||||
char v;
|
||||
+ unsigned long int tdiff;
|
||||
srjson_t *f, *vars;
|
||||
|
||||
if(node == NULL || flow == NULL)
|
||||
@@ -494,6 +497,17 @@ int _cfgt_set_dump(struct sip_msg *msg, cfgt_node_p node, str *flow)
|
||||
return -1;
|
||||
}
|
||||
|
||||
+ if(node->route->duration.tv_usec > 0) {
|
||||
+ tdiff = (node->route->duration.tv_sec) * 1000000
|
||||
+ + (node->route->duration.tv_usec);
|
||||
+ f = srjson_CreateNumber(&node->jdoc, tdiff);
|
||||
+ if(f == NULL) {
|
||||
+ LM_ERR("cannot create json object\n");
|
||||
+ return -1;
|
||||
+ }
|
||||
+ srjson_AddItemToObject(&node->jdoc, vars, "execution_usec", f);
|
||||
+ }
|
||||
+
|
||||
f = srjson_CreateObject(&node->jdoc);
|
||||
if(f == NULL) {
|
||||
LM_ERR("cannot create json object\n");
|
||||
@@ -506,6 +520,21 @@ int _cfgt_set_dump(struct sip_msg *msg, cfgt_node_p node, str *flow)
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static void _cfgt_log_route(cfgt_str_list_p route)
|
||||
+{
|
||||
+ unsigned long int tdiff;
|
||||
+ if(!route) {
|
||||
+ LM_BUG("empty route\n");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if(route->duration.tv_usec > 0) {
|
||||
+ tdiff = (route->duration.tv_sec) * 1000000 + (route->duration.tv_usec);
|
||||
+ LM_WARN("[%.*s] exectime=%lu usec\n", route->s.len, route->s.s,
|
||||
+ tdiff);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void _cfgt_set_type(cfgt_str_list_p route, struct action *a)
|
||||
{
|
||||
switch(a->type) {
|
||||
@@ -521,6 +550,8 @@ void _cfgt_set_type(cfgt_str_list_p route, struct action *a)
|
||||
route->type = CFGT_DROP_E;
|
||||
LM_DBG("set[%.*s]->CFGT_DROP_E\n", route->s.len, route->s.s);
|
||||
}
|
||||
+ gettimeofday(&route->end, NULL);
|
||||
+ timersub(&route->end, &route->start, &route->duration);
|
||||
break;
|
||||
case ROUTE_T:
|
||||
route->type = CFGT_ROUTE;
|
||||
@@ -535,6 +566,8 @@ void _cfgt_set_type(cfgt_str_list_p route, struct action *a)
|
||||
LM_DBG("[%.*s] already set to CFGT_DROP_E[%d]\n", route->s.len,
|
||||
route->s.s, a->type);
|
||||
}
|
||||
+ gettimeofday(&route->end, NULL);
|
||||
+ timersub(&route->end, &route->start, &route->duration);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -554,6 +587,7 @@ int _cfgt_add_routename(cfgt_node_p node, struct action *a, str *routename)
|
||||
memset(node->route, 0, sizeof(cfgt_str_list_t));
|
||||
node->flow_head = node->route;
|
||||
node->route->type = CFGT_ROUTE;
|
||||
+ gettimeofday(&node->route->start, NULL);
|
||||
ret = 1;
|
||||
} else {
|
||||
LM_DBG("actual routename:[%.*s][%d]\n", node->route->s.len,
|
||||
@@ -601,6 +635,7 @@ int _cfgt_add_routename(cfgt_node_p node, struct action *a, str *routename)
|
||||
route->prev = node->route;
|
||||
node->route->next = route;
|
||||
node->route = route;
|
||||
+ gettimeofday(&node->route->start, NULL);
|
||||
_cfgt_set_type(node->route, a);
|
||||
}
|
||||
node->route->s.s = routename->s;
|
||||
@@ -618,6 +653,8 @@ void _cfgt_del_routename(cfgt_node_p node)
|
||||
}
|
||||
LM_DBG("del route[%.*s]\n", node->route->s.len, node->route->s.s);
|
||||
node->route = node->route->prev;
|
||||
+ if(cfgt_route_log)
|
||||
+ _cfgt_log_route(node->route->next);
|
||||
pkg_free(node->route->next);
|
||||
node->route->next = NULL;
|
||||
}
|
||||
diff --git a/src/modules/cfgt/cfgt_int.h b/src/modules/cfgt/cfgt_int.h
|
||||
index 197e4bb..1564daa 100644
|
||||
--- a/src/modules/cfgt/cfgt_int.h
|
||||
+++ b/src/modules/cfgt/cfgt_int.h
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
*
|
||||
- * Copyright (C) 2015 Victor Seva (sipwise.com)
|
||||
+ * Copyright (C) 2015-2023 Victor Seva (sipwise.com)
|
||||
*
|
||||
* This file is part of Kamailio, a free SIP server.
|
||||
*
|
||||
@@ -48,6 +48,7 @@ typedef struct _cfgt_str_list
|
||||
{
|
||||
str s;
|
||||
enum _cfgt_action_type type;
|
||||
+ struct timeval start, end, duration;
|
||||
struct _cfgt_str_list *next, *prev;
|
||||
} cfgt_str_list_t, *cfgt_str_list_p;
|
||||
|
||||
diff --git a/src/modules/cfgt/cfgt_mod.c b/src/modules/cfgt/cfgt_mod.c
|
||||
index 7dec36a..4809426 100644
|
||||
--- a/src/modules/cfgt/cfgt_mod.c
|
||||
+++ b/src/modules/cfgt/cfgt_mod.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
- * Copyright (C) 2015 Victor Seva (sipwise.com)
|
||||
+ * Copyright (C) 2015-2023 Victor Seva (sipwise.com)
|
||||
*
|
||||
* This file is part of Kamailio, a free SIP server.
|
||||
*
|
||||
@@ -43,6 +43,7 @@ extern int cfgt_mask;
|
||||
extern str cfgt_basedir;
|
||||
extern str cfgt_hdr_prefix;
|
||||
extern int cfgt_skip_unknown;
|
||||
+extern int cfgt_route_log;
|
||||
/* clang-format off */
|
||||
/*! \brief
|
||||
* Exported functions
|
||||
@@ -60,6 +61,7 @@ static param_export_t params[] = {
|
||||
{"mask", INT_PARAM, &cfgt_mask},
|
||||
{"callid_prefix", PARAM_STR, &cfgt_hdr_prefix},
|
||||
{"skip_unknown", INT_PARAM, &cfgt_skip_unknown},
|
||||
+ {"route_log", INT_PARAM, &cfgt_route_log},
|
||||
{0, 0, 0}
|
||||
};
|
||||
|
||||
diff --git a/src/modules/cfgt/doc/cfgt_admin.xml b/src/modules/cfgt/doc/cfgt_admin.xml
|
||||
index b3af2de..4975a5c 100644
|
||||
--- a/src/modules/cfgt/doc/cfgt_admin.xml
|
||||
+++ b/src/modules/cfgt/doc/cfgt_admin.xml
|
||||
@@ -163,6 +163,25 @@ modparam("cfgt", "callid_prefix", "TEST-ID%")
|
||||
...
|
||||
modparam("cfgt", "skip_unknown", "1")
|
||||
...
|
||||
+</programlisting>
|
||||
+ </example>
|
||||
+ </section>
|
||||
+ <section id="cfg.p.route_log">
|
||||
+ <title><varname>route_log</varname> (int)</title>
|
||||
+ <para>
|
||||
+ If enabled, value different from 0, cfgt will log (WARN) the execution time of routes.
|
||||
+ </para>
|
||||
+ <para>
|
||||
+ <emphasis>
|
||||
+ Default value is <quote>0</quote>, false.
|
||||
+ </emphasis>
|
||||
+ </para>
|
||||
+ <example>
|
||||
+ <title>Set <varname>route_log</varname> parameter</title>
|
||||
+ <programlisting format="linespecific">
|
||||
+...
|
||||
+modparam("cfgt", "route_log", "1")
|
||||
+...
|
||||
</programlisting>
|
||||
</example>
|
||||
</section>
|
@ -1,91 +0,0 @@
|
||||
From: Victor Seva <vseva@sipwise.com>
|
||||
Date: Fri, 17 Mar 2023 16:08:00 +0100
|
||||
Subject: cfgt: don't dump same node
|
||||
|
||||
---
|
||||
src/modules/cfgt/cfgt_int.c | 41 ++++++++++++++++++++++++++++++++++++++++-
|
||||
1 file changed, 40 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/modules/cfgt/cfgt_int.c b/src/modules/cfgt/cfgt_int.c
|
||||
index ed2204b..15f0606 100644
|
||||
--- a/src/modules/cfgt/cfgt_int.c
|
||||
+++ b/src/modules/cfgt/cfgt_int.c
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "../../core/rpc.h"
|
||||
#include "../../core/rpc_lookup.h"
|
||||
#include "../../core/parser/msg_parser.h"
|
||||
+#include "../../core/script_cb.h"
|
||||
|
||||
#include "cfgt_int.h"
|
||||
#include "cfgt_json.h"
|
||||
@@ -460,11 +461,25 @@ void _cfgt_print_node(cfgt_node_p node, int json)
|
||||
|
||||
int _cfgt_set_dump(struct sip_msg *msg, cfgt_node_p node, str *flow)
|
||||
{
|
||||
+ int len;
|
||||
+ char v;
|
||||
srjson_t *f, *vars;
|
||||
|
||||
if(node == NULL || flow == NULL)
|
||||
return -1;
|
||||
|
||||
+ /* don't generate two same nodes */
|
||||
+ if((len = srjson_GetArraySize(&node->jdoc, node->flow)) >= 1) {
|
||||
+ f = srjson_GetArrayItem(&node->jdoc, node->flow, len - 1);
|
||||
+ STR_VTOZ(flow->s[flow->len], v);
|
||||
+ f = srjson_GetObjectItem(&node->jdoc, f, flow->s);
|
||||
+ STR_ZTOV(flow->s[flow->len], v);
|
||||
+ if(f != NULL) {
|
||||
+ LM_DBG("node[%.*s] flow already there\n", flow->len, flow->s);
|
||||
+ return 0;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
vars = srjson_CreateObject(&node->jdoc);
|
||||
if(vars == NULL) {
|
||||
LM_ERR("cannot create json object\n");
|
||||
@@ -763,11 +778,35 @@ int cfgt_msgin(sr_event_param_t *evp)
|
||||
return -1;
|
||||
}
|
||||
|
||||
+static inline void print_cb_flags(unsigned int flags)
|
||||
+{
|
||||
+ LM_DBG("flags:");
|
||||
+ if(flags & REQUEST_CB)
|
||||
+ LM_DBG("REQUEST_CB");
|
||||
+ if(flags & FAILURE_CB)
|
||||
+ LM_DBG("FAILURE_CB");
|
||||
+ if(flags & ONREPLY_CB)
|
||||
+ LM_DBG("ONREPLY_CB");
|
||||
+ if(flags & BRANCH_CB)
|
||||
+ LM_DBG("BRANCH_CB");
|
||||
+ if(flags & ONSEND_CB)
|
||||
+ LM_DBG("ONSEND_CB");
|
||||
+ if(flags & ERROR_CB)
|
||||
+ LM_DBG("ERROR_CB");
|
||||
+ if(flags & LOCAL_CB)
|
||||
+ LM_DBG("LOCAL_CB");
|
||||
+ if(flags & EVENT_CB)
|
||||
+ LM_DBG("EVENT_CB");
|
||||
+ if(flags & BRANCH_FAILURE_CB)
|
||||
+ LM_DBG("BRANCH_FAILURE_CB");
|
||||
+}
|
||||
+
|
||||
int cfgt_pre(struct sip_msg *msg, unsigned int flags, void *bar)
|
||||
{
|
||||
str unknown = {"unknown", 7};
|
||||
int get_hdr_result = 0, res;
|
||||
|
||||
+ print_cb_flags(flags);
|
||||
if(_cfgt_node) {
|
||||
if(_cfgt_node->msgid == 0) {
|
||||
LM_DBG("new node\n");
|
||||
@@ -812,7 +851,7 @@ int cfgt_pre(struct sip_msg *msg, unsigned int flags, void *bar)
|
||||
int cfgt_post(struct sip_msg *msg, unsigned int flags, void *bar)
|
||||
{
|
||||
str flowname = STR_NULL;
|
||||
-
|
||||
+ print_cb_flags(flags);
|
||||
if(_cfgt_node) {
|
||||
if(cfgt_skip_unknown && strncmp(_cfgt_node->uuid.s, "unknown", 7) == 0) {
|
||||
return 1;
|
@ -1,114 +0,0 @@
|
||||
From: Victor Seva <vseva@sipwise.com>
|
||||
Date: Wed, 27 Apr 2022 15:49:30 +0200
|
||||
Subject: cfgt: skip_unknown
|
||||
|
||||
---
|
||||
src/modules/cfgt/cfgt_int.c | 14 ++++++++++++++
|
||||
src/modules/cfgt/cfgt_mod.c | 2 ++
|
||||
src/modules/cfgt/doc/cfgt_admin.xml | 20 ++++++++++++++++++++
|
||||
3 files changed, 36 insertions(+)
|
||||
|
||||
diff --git a/src/modules/cfgt/cfgt_int.c b/src/modules/cfgt/cfgt_int.c
|
||||
index 2509b3e..ed2204b 100644
|
||||
--- a/src/modules/cfgt/cfgt_int.c
|
||||
+++ b/src/modules/cfgt/cfgt_int.c
|
||||
@@ -43,6 +43,7 @@ cfgt_hash_p _cfgt_uuid = NULL;
|
||||
str cfgt_hdr_prefix = {"NGCP%", 5};
|
||||
str cfgt_basedir = {"/tmp", 4};
|
||||
int cfgt_mask = CFGT_DP_ALL;
|
||||
+int cfgt_skip_unknown = 0;
|
||||
int not_sip = 0;
|
||||
|
||||
int _cfgt_get_filename(int msgid, str uuid, str *dest, int *dir);
|
||||
@@ -385,6 +386,10 @@ void cfgt_save_node(cfgt_node_p node)
|
||||
str dest = STR_NULL;
|
||||
int dir = 0;
|
||||
struct stat sb;
|
||||
+ if(cfgt_skip_unknown && strncmp(_cfgt_node->uuid.s, "unknown", 7) == 0) {
|
||||
+ LM_DBG("skip unknown\n");
|
||||
+ return;
|
||||
+ }
|
||||
if(_cfgt_get_filename(node->msgid, node->uuid, &dest, &dir) < 0) {
|
||||
LM_ERR("can't build filename\n");
|
||||
return;
|
||||
@@ -658,6 +663,9 @@ int cfgt_process_route(struct sip_msg *msg, struct action *a)
|
||||
LM_ERR("node empty\n");
|
||||
return -1;
|
||||
}
|
||||
+ if(cfgt_skip_unknown && strncmp(_cfgt_node->uuid.s, "unknown", 7) == 0) {
|
||||
+ return 0;
|
||||
+ }
|
||||
if(a->rname == NULL) {
|
||||
LM_DBG("no routename. type:%d\n", a->type);
|
||||
return 0;
|
||||
@@ -806,6 +814,9 @@ int cfgt_post(struct sip_msg *msg, unsigned int flags, void *bar)
|
||||
str flowname = STR_NULL;
|
||||
|
||||
if(_cfgt_node) {
|
||||
+ if(cfgt_skip_unknown && strncmp(_cfgt_node->uuid.s, "unknown", 7) == 0) {
|
||||
+ return 1;
|
||||
+ }
|
||||
LM_DBG("dump last flow\n");
|
||||
if(_cfgt_node->route == NULL
|
||||
&& strncmp(_cfgt_node->uuid.s, "unknown", 7) == 0)
|
||||
@@ -844,6 +855,9 @@ int cfgt_msgout(sr_event_param_t *evp)
|
||||
}
|
||||
|
||||
if(_cfgt_node) {
|
||||
+ if(cfgt_skip_unknown && strncmp(_cfgt_node->uuid.s, "unknown", 7) == 0) {
|
||||
+ return 0;
|
||||
+ }
|
||||
jobj = srjson_CreateStr(&_cfgt_node->jdoc, buf->s, buf->len);
|
||||
if(jobj == NULL) {
|
||||
LM_ERR("cannot create json object\n");
|
||||
diff --git a/src/modules/cfgt/cfgt_mod.c b/src/modules/cfgt/cfgt_mod.c
|
||||
index 728d228..7dec36a 100644
|
||||
--- a/src/modules/cfgt/cfgt_mod.c
|
||||
+++ b/src/modules/cfgt/cfgt_mod.c
|
||||
@@ -42,6 +42,7 @@ unsigned int init_flag = 0;
|
||||
extern int cfgt_mask;
|
||||
extern str cfgt_basedir;
|
||||
extern str cfgt_hdr_prefix;
|
||||
+extern int cfgt_skip_unknown;
|
||||
/* clang-format off */
|
||||
/*! \brief
|
||||
* Exported functions
|
||||
@@ -58,6 +59,7 @@ static param_export_t params[] = {
|
||||
{"basedir", PARAM_STR, &cfgt_basedir},
|
||||
{"mask", INT_PARAM, &cfgt_mask},
|
||||
{"callid_prefix", PARAM_STR, &cfgt_hdr_prefix},
|
||||
+ {"skip_unknown", INT_PARAM, &cfgt_skip_unknown},
|
||||
{0, 0, 0}
|
||||
};
|
||||
|
||||
diff --git a/src/modules/cfgt/doc/cfgt_admin.xml b/src/modules/cfgt/doc/cfgt_admin.xml
|
||||
index 920b1bf..b3af2de 100644
|
||||
--- a/src/modules/cfgt/doc/cfgt_admin.xml
|
||||
+++ b/src/modules/cfgt/doc/cfgt_admin.xml
|
||||
@@ -143,6 +143,26 @@ modparam("cfgt", "mask", 12)
|
||||
# using '%' as delimiter
|
||||
modparam("cfgt", "callid_prefix", "TEST-ID%")
|
||||
...
|
||||
+</programlisting>
|
||||
+ </example>
|
||||
+ </section>
|
||||
+ <section id="cfg.p.skip_unknown">
|
||||
+ <title><varname>skip_unknown</varname> (int)</title>
|
||||
+ <para>
|
||||
+ If enabled, value different from 0, cfgt will not generate the report
|
||||
+ of any message that doesn't match the callid_prefix.
|
||||
+ </para>
|
||||
+ <para>
|
||||
+ <emphasis>
|
||||
+ Default value is <quote>0</quote>, false.
|
||||
+ </emphasis>
|
||||
+ </para>
|
||||
+ <example>
|
||||
+ <title>Set <varname>skip_unknown</varname> parameter</title>
|
||||
+ <programlisting format="linespecific">
|
||||
+...
|
||||
+modparam("cfgt", "skip_unknown", "1")
|
||||
+...
|
||||
</programlisting>
|
||||
</example>
|
||||
</section>
|
@ -1,63 +0,0 @@
|
||||
From: Sipwise Development Team <support@sipwise.com>
|
||||
Date: Wed, 12 May 2021 11:53:43 +0200
|
||||
Subject: db_redis_graceful_scan
|
||||
|
||||
---
|
||||
src/modules/db_redis/redis_dbase.c | 20 ++++++++++++++++----
|
||||
1 file changed, 16 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/modules/db_redis/redis_dbase.c b/src/modules/db_redis/redis_dbase.c
|
||||
index 0cf2791..1d8721d 100644
|
||||
--- a/src/modules/db_redis/redis_dbase.c
|
||||
+++ b/src/modules/db_redis/redis_dbase.c
|
||||
@@ -824,7 +824,7 @@ static int db_redis_scan_query_keys_pattern(km_redis_con_t *con,
|
||||
int l;
|
||||
|
||||
|
||||
-#undef USE_SCAN
|
||||
+#define USE_SCAN
|
||||
|
||||
#ifdef USE_SCAN
|
||||
|
||||
@@ -832,6 +832,8 @@ static int db_redis_scan_query_keys_pattern(km_redis_con_t *con,
|
||||
unsigned long cursor = 0;
|
||||
unsigned int match_count = match_count_start_val;
|
||||
char match_count_str[16];
|
||||
+ struct timeval start_tv, end_tv;
|
||||
+ long tv_diff;
|
||||
|
||||
do {
|
||||
snprintf(cursor_str, sizeof(cursor_str), "%lu", cursor);
|
||||
@@ -870,7 +872,13 @@ static int db_redis_scan_query_keys_pattern(km_redis_con_t *con,
|
||||
goto err;
|
||||
}
|
||||
|
||||
+ gettimeofday(&start_tv, NULL);
|
||||
reply = db_redis_command_argv(con, query_v);
|
||||
+ gettimeofday(&end_tv, NULL);
|
||||
+ tv_diff = ((long long)end_tv.tv_sec * 1000LL + end_tv.tv_usec / 1000L)
|
||||
+ - ((long long)start_tv.tv_sec * 1000LL
|
||||
+ + start_tv.tv_usec / 1000L);
|
||||
+
|
||||
db_redis_key_free(&query_v);
|
||||
db_redis_check_reply(con, reply, err);
|
||||
if(reply->type != REDIS_REPLY_ARRAY) {
|
||||
@@ -966,11 +974,15 @@ static int db_redis_scan_query_keys_pattern(km_redis_con_t *con,
|
||||
}
|
||||
|
||||
#ifdef USE_SCAN
|
||||
- // exponential increase and falloff, hovering around 1000 results
|
||||
- if(keys_list->elements > 1300 && match_count > 500)
|
||||
+ // exponential increase and falloff, not to exceed ~100 ms query run time
|
||||
+ if(tv_diff > 50 && match_count > 10)
|
||||
match_count /= 2;
|
||||
- else if(keys_list->elements < 700 && match_count < 500000)
|
||||
+ else if(tv_diff < 25 && match_count < 1000000)
|
||||
match_count *= 2;
|
||||
+ if(cursor > 0) {
|
||||
+ // give other queries some time to run
|
||||
+ usleep(100000);
|
||||
+ }
|
||||
#endif
|
||||
|
||||
db_redis_free_reply(&reply);
|
@ -1,22 +0,0 @@
|
||||
From: Sipwise Development Team <support@sipwise.com>
|
||||
Date: Wed, 12 May 2021 11:53:43 +0200
|
||||
Subject: db_redis_skip_empty_keys
|
||||
|
||||
---
|
||||
src/modules/db_redis/redis_dbase.c | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
diff --git a/src/modules/db_redis/redis_dbase.c b/src/modules/db_redis/redis_dbase.c
|
||||
index ce65628..0cf2791 100644
|
||||
--- a/src/modules/db_redis/redis_dbase.c
|
||||
+++ b/src/modules/db_redis/redis_dbase.c
|
||||
@@ -700,6 +700,9 @@ static int db_redis_build_query_keys(km_redis_con_t *con, const str *table_name,
|
||||
LM_DBG("no direct entry key found, checking type keys\n");
|
||||
for(type = table->types; type; type = type->next) {
|
||||
key = type->keys;
|
||||
+ /* skip value-less master keys */
|
||||
+ if(!key)
|
||||
+ continue;
|
||||
LM_DBG("checking type '%.*s'\n", type->type.len, type->type.s);
|
||||
if(db_redis_find_query_key(key, table_name, table, &type->type, _k,
|
||||
_v, _op, _n, &keyname, &key_found, ts_scan_start)
|
@ -1,338 +0,0 @@
|
||||
From: Sipwise Development Team <support@sipwise.com>
|
||||
Date: Wed, 12 May 2021 11:53:43 +0200
|
||||
Subject: db_redis_sscan
|
||||
|
||||
---
|
||||
src/modules/db_redis/redis_dbase.c | 116 +++++++++++++++++++++++++++----------
|
||||
1 file changed, 84 insertions(+), 32 deletions(-)
|
||||
|
||||
diff --git a/src/modules/db_redis/redis_dbase.c b/src/modules/db_redis/redis_dbase.c
|
||||
index 1d8721d..b98e0f3 100644
|
||||
--- a/src/modules/db_redis/redis_dbase.c
|
||||
+++ b/src/modules/db_redis/redis_dbase.c
|
||||
@@ -646,7 +646,7 @@ static int db_redis_build_query_keys(km_redis_con_t *con, const str *table_name,
|
||||
const db_key_t *_k, const db_val_t *_v, const db_op_t *_op,
|
||||
const int _n, redis_key_t **query_keys, int *query_keys_count,
|
||||
int **manual_keys, int *manual_keys_count, int *do_table_scan,
|
||||
- uint64_t *ts_scan_start, str *ts_scan_key)
|
||||
+ uint64_t *ts_scan_start, str *ts_scan_key, str *ts_scan_table)
|
||||
{
|
||||
|
||||
struct str_hash_entry *table_e;
|
||||
@@ -775,6 +775,22 @@ static int db_redis_build_query_keys(km_redis_con_t *con, const str *table_name,
|
||||
keyname.len, keyname.s,
|
||||
(unsigned long long)*ts_scan_start);
|
||||
*ts_scan_key = keyname;
|
||||
+ if(ts_scan_table) {
|
||||
+ if(ts_scan_table->s)
|
||||
+ pkg_free(ts_scan_table->s);
|
||||
+ // <version>:<table>::index::<type>
|
||||
+ ts_scan_table->len = table->version_code.len
|
||||
+ + table_name->len + 9 + type->type.len;
|
||||
+ ts_scan_table->s = pkg_malloc(ts_scan_table->len + 1);
|
||||
+ if(!ts_scan_table->s) {
|
||||
+ LM_ERR("Failed to allocate memory for ts_scan_table\n");
|
||||
+ goto err;
|
||||
+ }
|
||||
+ sprintf(ts_scan_table->s, "%.*s%.*s::index::%.*s",
|
||||
+ table->version_code.len, table->version_code.s,
|
||||
+ table_name->len, table_name->s, type->type.len,
|
||||
+ type->type.s);
|
||||
+ }
|
||||
keyname.s = NULL;
|
||||
} else if(keyname.s) {
|
||||
pkg_free(keyname.s);
|
||||
@@ -811,9 +827,9 @@ err:
|
||||
}
|
||||
|
||||
static int db_redis_scan_query_keys_pattern(km_redis_con_t *con,
|
||||
- const str *match_pattern, const int _n, redis_key_t **query_keys,
|
||||
- int *query_keys_count, int **manual_keys, int *manual_keys_count,
|
||||
- unsigned int match_count_start_val)
|
||||
+ const str *match_pattern, const str *index_key, const int _n,
|
||||
+ redis_key_t **query_keys, int *query_keys_count, int **manual_keys,
|
||||
+ int *manual_keys_count, unsigned int match_count_start_val)
|
||||
{
|
||||
|
||||
size_t i = 0;
|
||||
@@ -838,9 +854,21 @@ static int db_redis_scan_query_keys_pattern(km_redis_con_t *con,
|
||||
do {
|
||||
snprintf(cursor_str, sizeof(cursor_str), "%lu", cursor);
|
||||
|
||||
- if(db_redis_key_add_string(&query_v, "SCAN", 4) != 0) {
|
||||
- LM_ERR("Failed to add scan command to scan query\n");
|
||||
- goto err;
|
||||
+ if(!index_key) {
|
||||
+ if(db_redis_key_add_string(&query_v, "SCAN", 4) != 0) {
|
||||
+ LM_ERR("Failed to add scan command to scan query\n");
|
||||
+ goto err;
|
||||
+ }
|
||||
+ } else {
|
||||
+ if(db_redis_key_add_string(&query_v, "SSCAN", 5) != 0) {
|
||||
+ LM_ERR("Failed to add scan command to scan query\n");
|
||||
+ goto err;
|
||||
+ }
|
||||
+ if(db_redis_key_add_string(&query_v, index_key->s, index_key->len)
|
||||
+ != 0) {
|
||||
+ LM_ERR("Failed to add scan command to scan query\n");
|
||||
+ goto err;
|
||||
+ }
|
||||
}
|
||||
if(db_redis_key_add_string(&query_v, cursor_str, strlen(cursor_str))
|
||||
!= 0) {
|
||||
@@ -1033,7 +1061,7 @@ return -1;
|
||||
static int db_redis_scan_query_keys(km_redis_con_t *con, const str *table_name,
|
||||
const int _n, redis_key_t **query_keys, int *query_keys_count,
|
||||
int **manual_keys, int *manual_keys_count, uint64_t ts_scan_start,
|
||||
- const str *ts_scan_key)
|
||||
+ const str *ts_scan_key, const str *ts_scan_table)
|
||||
{
|
||||
|
||||
struct str_hash_entry *table_e;
|
||||
@@ -1070,9 +1098,9 @@ static int db_redis_scan_query_keys(km_redis_con_t *con, const str *table_name,
|
||||
int len = sprintf(match, "%.*s%.*s:entry::*", table->version_code.len,
|
||||
table->version_code.s, table_name->len, table_name->s);
|
||||
str match_pattern = {match, len};
|
||||
- ret = db_redis_scan_query_keys_pattern(con, &match_pattern, _n,
|
||||
- query_keys, query_keys_count, manual_keys, manual_keys_count,
|
||||
- 1000);
|
||||
+ ret = db_redis_scan_query_keys_pattern(con, &match_pattern,
|
||||
+ ts_scan_table, _n, query_keys, query_keys_count, manual_keys,
|
||||
+ manual_keys_count, 1000);
|
||||
pkg_free(match);
|
||||
return ret;
|
||||
}
|
||||
@@ -1136,9 +1164,9 @@ static int db_redis_scan_query_keys(km_redis_con_t *con, const str *table_name,
|
||||
"'%.*s'\n",
|
||||
len, match);
|
||||
|
||||
- ret = db_redis_scan_query_keys_pattern(con, &match_pattern, _n,
|
||||
- &set_keys, &set_keys_count, manual_keys, manual_keys_count,
|
||||
- 5000);
|
||||
+ ret = db_redis_scan_query_keys_pattern(con, &match_pattern,
|
||||
+ ts_scan_table, _n, &set_keys, &set_keys_count, manual_keys,
|
||||
+ manual_keys_count, 5000);
|
||||
if(ret)
|
||||
goto out;
|
||||
}
|
||||
@@ -1183,9 +1211,9 @@ static int db_redis_scan_query_keys(km_redis_con_t *con, const str *table_name,
|
||||
LM_DBG("running timestamp/int range matching using pattern '%.*s'\n",
|
||||
len, match);
|
||||
|
||||
- ret = db_redis_scan_query_keys_pattern(con, &match_pattern, _n,
|
||||
- &set_keys, &set_keys_count, manual_keys, manual_keys_count,
|
||||
- 5000);
|
||||
+ ret = db_redis_scan_query_keys_pattern(con, &match_pattern,
|
||||
+ ts_scan_table, _n, &set_keys, &set_keys_count, manual_keys,
|
||||
+ manual_keys_count, 5000);
|
||||
if(ret)
|
||||
goto out;
|
||||
}
|
||||
@@ -1199,9 +1227,9 @@ static int db_redis_scan_query_keys(km_redis_con_t *con, const str *table_name,
|
||||
LM_DBG("running timestamp/int range matching using pattern '%.*s'\n",
|
||||
len, match);
|
||||
|
||||
- ret = db_redis_scan_query_keys_pattern(con, &match_pattern, _n,
|
||||
- &set_keys, &set_keys_count, manual_keys, manual_keys_count,
|
||||
- 5000);
|
||||
+ ret = db_redis_scan_query_keys_pattern(con, &match_pattern,
|
||||
+ ts_scan_table, _n, &set_keys, &set_keys_count, manual_keys,
|
||||
+ manual_keys_count, 5000);
|
||||
if(ret)
|
||||
goto out;
|
||||
}
|
||||
@@ -1579,7 +1607,7 @@ static int db_redis_perform_query(const db1_con_t *_h, km_redis_con_t *con,
|
||||
const db_key_t *_c, const int _n, const int _nc, db1_res_t **_r,
|
||||
redis_key_t **keys, int *keys_count, int **manual_keys,
|
||||
int *manual_keys_count, int do_table_scan, uint64_t ts_scan_start,
|
||||
- const str *ts_scan_key)
|
||||
+ const str *ts_scan_key, const str *ts_scan_table)
|
||||
{
|
||||
|
||||
redisReply *reply = NULL;
|
||||
@@ -1614,7 +1642,8 @@ static int db_redis_perform_query(const db1_con_t *_h, km_redis_con_t *con,
|
||||
CON_TABLE(_h)->s);
|
||||
}
|
||||
if(db_redis_scan_query_keys(con, CON_TABLE(_h), _n, keys, keys_count,
|
||||
- manual_keys, manual_keys_count, ts_scan_start, ts_scan_key)
|
||||
+ manual_keys, manual_keys_count, ts_scan_start, ts_scan_key,
|
||||
+ ts_scan_table)
|
||||
!= 0) {
|
||||
LM_ERR("failed to scan query keys\n");
|
||||
goto error;
|
||||
@@ -1769,7 +1798,7 @@ static int db_redis_perform_delete(const db1_con_t *_h, km_redis_con_t *con,
|
||||
const db_key_t *_k, const db_val_t *_v, const db_op_t *_op,
|
||||
const int _n, redis_key_t **keys, int *keys_count, int **manual_keys,
|
||||
int *manual_keys_count, int do_table_scan, uint64_t ts_scan_start,
|
||||
- const str *ts_scan_key)
|
||||
+ const str *ts_scan_key, const str *ts_scan_table)
|
||||
{
|
||||
|
||||
int i = 0, j = 0;
|
||||
@@ -1807,7 +1836,8 @@ static int db_redis_perform_delete(const db1_con_t *_h, km_redis_con_t *con,
|
||||
LM_WARN(" scan key %d is '%.*s'\n", i, _k[i]->len, _k[i]->s);
|
||||
}
|
||||
if(db_redis_scan_query_keys(con, CON_TABLE(_h), _n, keys, keys_count,
|
||||
- manual_keys, manual_keys_count, ts_scan_start, ts_scan_key)
|
||||
+ manual_keys, manual_keys_count, ts_scan_start, ts_scan_key,
|
||||
+ ts_scan_table)
|
||||
!= 0) {
|
||||
LM_ERR("failed to scan query keys\n");
|
||||
goto error;
|
||||
@@ -2083,7 +2113,7 @@ static int db_redis_perform_update(const db1_con_t *_h, km_redis_con_t *con,
|
||||
const db_key_t *_uk, const db_val_t *_uv, const int _n, const int _nu,
|
||||
redis_key_t **keys, int *keys_count, int **manual_keys,
|
||||
int *manual_keys_count, int do_table_scan, uint64_t ts_scan_start,
|
||||
- const str *ts_scan_key)
|
||||
+ const str *ts_scan_key, const str *ts_scan_table)
|
||||
{
|
||||
|
||||
redisReply *reply = NULL;
|
||||
@@ -2115,7 +2145,8 @@ static int db_redis_perform_update(const db1_con_t *_h, km_redis_con_t *con,
|
||||
LM_WARN(" scan key %d is '%.*s'\n", i, _k[i]->len, _k[i]->s);
|
||||
}
|
||||
if(db_redis_scan_query_keys(con, CON_TABLE(_h), _n, keys, keys_count,
|
||||
- manual_keys, manual_keys_count, ts_scan_start, ts_scan_key)
|
||||
+ manual_keys, manual_keys_count, ts_scan_start, ts_scan_key,
|
||||
+ ts_scan_table)
|
||||
!= 0) {
|
||||
LM_ERR("failed to scan query keys\n");
|
||||
goto error;
|
||||
@@ -2589,6 +2620,9 @@ int db_redis_query(const db1_con_t *_h, const db_key_t *_k, const db_op_t *_op,
|
||||
str ts_scan_key = {
|
||||
0,
|
||||
};
|
||||
+ str ts_scan_table = {
|
||||
+ 0,
|
||||
+ };
|
||||
|
||||
redis_key_t *keys = NULL;
|
||||
int keys_count = 0;
|
||||
@@ -2663,7 +2697,7 @@ int db_redis_query(const db1_con_t *_h, const db_key_t *_k, const db_op_t *_op,
|
||||
if(_n > 0) {
|
||||
if(db_redis_build_query_keys(con, CON_TABLE(_h), _k, _v, query_ops, _n,
|
||||
&keys, &keys_count, &manual_keys, &manual_keys_count,
|
||||
- &do_table_scan, &ts_scan_start, &ts_scan_key)
|
||||
+ &do_table_scan, &ts_scan_start, &ts_scan_key, &ts_scan_table)
|
||||
!= 0) {
|
||||
LM_ERR("failed to build query keys\n");
|
||||
goto error;
|
||||
@@ -2686,7 +2720,7 @@ int db_redis_query(const db1_con_t *_h, const db_key_t *_k, const db_op_t *_op,
|
||||
|
||||
if(db_redis_perform_query(_h, con, _k, _v, query_ops, _c, _n, _nc, _r,
|
||||
&keys, &keys_count, &manual_keys, &manual_keys_count,
|
||||
- do_table_scan, ts_scan_start, &ts_scan_key)
|
||||
+ do_table_scan, ts_scan_start, &ts_scan_key, &ts_scan_table)
|
||||
!= 0) {
|
||||
goto error;
|
||||
}
|
||||
@@ -2703,6 +2737,8 @@ int db_redis_query(const db1_con_t *_h, const db_key_t *_k, const db_op_t *_op,
|
||||
}
|
||||
if(ts_scan_key.s)
|
||||
pkg_free(ts_scan_key.s);
|
||||
+ if(ts_scan_table.s)
|
||||
+ pkg_free(ts_scan_table.s);
|
||||
|
||||
db_redis_consume_replies(con);
|
||||
return 0;
|
||||
@@ -2718,6 +2754,8 @@ error:
|
||||
}
|
||||
if(ts_scan_key.s)
|
||||
pkg_free(ts_scan_key.s);
|
||||
+ if(ts_scan_table.s)
|
||||
+ pkg_free(ts_scan_table.s);
|
||||
db_redis_consume_replies(con);
|
||||
|
||||
|
||||
@@ -2909,6 +2947,9 @@ int db_redis_delete(const db1_con_t *_h, const db_key_t *_k, const db_op_t *_op,
|
||||
str ts_scan_key = {
|
||||
0,
|
||||
};
|
||||
+ str ts_scan_table = {
|
||||
+ 0,
|
||||
+ };
|
||||
db_op_t *query_ops = NULL;
|
||||
int i;
|
||||
|
||||
@@ -2954,7 +2995,7 @@ int db_redis_delete(const db1_con_t *_h, const db_key_t *_k, const db_op_t *_op,
|
||||
if(_n > 0) {
|
||||
if(db_redis_build_query_keys(con, CON_TABLE(_h), _k, _v, query_ops, _n,
|
||||
&keys, &keys_count, &manual_keys, &manual_keys_count,
|
||||
- &do_table_scan, &ts_scan_start, &ts_scan_key)
|
||||
+ &do_table_scan, &ts_scan_start, &ts_scan_key, &ts_scan_table)
|
||||
!= 0) {
|
||||
LM_ERR("failed to build query keys\n");
|
||||
goto error;
|
||||
@@ -2977,7 +3018,7 @@ int db_redis_delete(const db1_con_t *_h, const db_key_t *_k, const db_op_t *_op,
|
||||
|
||||
if(db_redis_perform_delete(_h, con, _k, _v, query_ops, _n, &keys,
|
||||
&keys_count, &manual_keys, &manual_keys_count, do_table_scan,
|
||||
- ts_scan_start, &ts_scan_key)
|
||||
+ ts_scan_start, &ts_scan_key, &ts_scan_table)
|
||||
!= 0) {
|
||||
goto error;
|
||||
}
|
||||
@@ -2992,6 +3033,8 @@ int db_redis_delete(const db1_con_t *_h, const db_key_t *_k, const db_op_t *_op,
|
||||
pkg_free(manual_keys);
|
||||
if(ts_scan_key.s)
|
||||
pkg_free(ts_scan_key.s);
|
||||
+ if(ts_scan_table.s)
|
||||
+ pkg_free(ts_scan_table.s);
|
||||
db_redis_consume_replies(con);
|
||||
|
||||
return 0;
|
||||
@@ -3006,6 +3049,8 @@ error:
|
||||
pkg_free(manual_keys);
|
||||
if(ts_scan_key.s)
|
||||
pkg_free(ts_scan_key.s);
|
||||
+ if(ts_scan_table.s)
|
||||
+ pkg_free(ts_scan_table.s);
|
||||
db_redis_consume_replies(con);
|
||||
return -1;
|
||||
}
|
||||
@@ -3032,6 +3077,9 @@ int db_redis_update(const db1_con_t *_h, const db_key_t *_k, const db_op_t *_op,
|
||||
str ts_scan_key = {
|
||||
0,
|
||||
};
|
||||
+ str ts_scan_table = {
|
||||
+ 0,
|
||||
+ };
|
||||
|
||||
redis_key_t *keys = NULL;
|
||||
int keys_count = 0;
|
||||
@@ -3082,7 +3130,7 @@ int db_redis_update(const db1_con_t *_h, const db_key_t *_k, const db_op_t *_op,
|
||||
if(_n > 0) {
|
||||
if(db_redis_build_query_keys(con, CON_TABLE(_h), _k, _v, query_ops, _n,
|
||||
&keys, &keys_count, &manual_keys, &manual_keys_count,
|
||||
- &do_table_scan, &ts_scan_start, &ts_scan_key)
|
||||
+ &do_table_scan, &ts_scan_start, &ts_scan_key, &ts_scan_table)
|
||||
!= 0) {
|
||||
LM_ERR("failed to build query keys\n");
|
||||
goto error;
|
||||
@@ -3104,7 +3152,7 @@ int db_redis_update(const db1_con_t *_h, const db_key_t *_k, const db_op_t *_op,
|
||||
|
||||
if(db_redis_perform_update(_h, con, _k, _v, query_ops, _uk, _uv, _n, _nu,
|
||||
&keys, &keys_count, &manual_keys, &manual_keys_count,
|
||||
- do_table_scan, ts_scan_start, &ts_scan_key)
|
||||
+ do_table_scan, ts_scan_start, &ts_scan_key, &ts_scan_table)
|
||||
!= 0) {
|
||||
goto error;
|
||||
}
|
||||
@@ -3121,6 +3169,8 @@ int db_redis_update(const db1_con_t *_h, const db_key_t *_k, const db_op_t *_op,
|
||||
}
|
||||
if(ts_scan_key.s)
|
||||
pkg_free(ts_scan_key.s);
|
||||
+ if(ts_scan_table.s)
|
||||
+ pkg_free(ts_scan_table.s);
|
||||
db_redis_consume_replies(con);
|
||||
return 0;
|
||||
|
||||
@@ -3135,6 +3185,8 @@ error:
|
||||
}
|
||||
if(ts_scan_key.s)
|
||||
pkg_free(ts_scan_key.s);
|
||||
+ if(ts_scan_table.s)
|
||||
+ pkg_free(ts_scan_table.s);
|
||||
db_redis_consume_replies(con);
|
||||
return -1;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
From: Sipwise Development Team <support@sipwise.com>
|
||||
Date: Wed, 12 May 2021 11:53:43 +0200
|
||||
Subject: db_redis_sscan_fix_empty_key
|
||||
|
||||
---
|
||||
src/modules/db_redis/redis_dbase.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/modules/db_redis/redis_dbase.c b/src/modules/db_redis/redis_dbase.c
|
||||
index b98e0f3..c0b9416 100644
|
||||
--- a/src/modules/db_redis/redis_dbase.c
|
||||
+++ b/src/modules/db_redis/redis_dbase.c
|
||||
@@ -854,7 +854,7 @@ static int db_redis_scan_query_keys_pattern(km_redis_con_t *con,
|
||||
do {
|
||||
snprintf(cursor_str, sizeof(cursor_str), "%lu", cursor);
|
||||
|
||||
- if(!index_key) {
|
||||
+ if(!index_key || !index_key->len) {
|
||||
if(db_redis_key_add_string(&query_v, "SCAN", 4) != 0) {
|
||||
LM_ERR("Failed to add scan command to scan query\n");
|
||||
goto err;
|
@ -1,298 +0,0 @@
|
||||
From: Victor Seva <vseva@sipwise.com>
|
||||
Date: Fri, 9 Jun 2023 13:56:33 +0200
|
||||
Subject: pua_dialoginfo: fix dlg_var store and retrieval
|
||||
|
||||
* dlg_var can have more than one value
|
||||
* store values as comma separate strings
|
||||
* alloc string values always for str_list
|
||||
---
|
||||
src/modules/pua_dialoginfo/pua_dialoginfo.c | 203 +++++++++++++++++++---------
|
||||
1 file changed, 137 insertions(+), 66 deletions(-)
|
||||
|
||||
diff --git a/src/modules/pua_dialoginfo/pua_dialoginfo.c b/src/modules/pua_dialoginfo/pua_dialoginfo.c
|
||||
index 6efcdc0..089586d 100644
|
||||
--- a/src/modules/pua_dialoginfo/pua_dialoginfo.c
|
||||
+++ b/src/modules/pua_dialoginfo/pua_dialoginfo.c
|
||||
@@ -83,6 +83,7 @@ unsigned short pubruri_callee_avp_type;
|
||||
int_str pubruri_callee_avp_name;
|
||||
sruid_t _puadi_sruid;
|
||||
|
||||
+static char *DLG_VAR_SEP = ",";
|
||||
static str caller_dlg_var = {0, 0}; /* pubruri_caller */
|
||||
static str callee_dlg_var = {0, 0}; /* pubruri_callee */
|
||||
static str caller_entity_when_publish_disabled = {0, 0}; /* pubruri_caller */
|
||||
@@ -596,7 +597,6 @@ struct str_list *get_str_list(unsigned short avp_flags, int_str avp_name)
|
||||
{
|
||||
|
||||
int_str avp_value;
|
||||
- unsigned int len;
|
||||
struct str_list *list_first = 0;
|
||||
struct str_list *list_current = 0;
|
||||
struct search_state st;
|
||||
@@ -606,33 +606,122 @@ struct str_list *get_str_list(unsigned short avp_flags, int_str avp_name)
|
||||
}
|
||||
|
||||
do {
|
||||
-
|
||||
LM_DBG("AVP found '%.*s'\n", avp_value.s.len, avp_value.s.s);
|
||||
-
|
||||
- len = sizeof(struct str_list) + avp_value.s.len;
|
||||
-
|
||||
if(list_current) {
|
||||
- list_current->next = (struct str_list *)shm_malloc(len);
|
||||
+ list_current->next =
|
||||
+ (struct str_list *)shm_malloc(sizeof(struct str_list));
|
||||
list_current = list_current->next;
|
||||
} else {
|
||||
- list_current = list_first = (struct str_list *)shm_malloc(len);
|
||||
+ list_current = list_first =
|
||||
+ (struct str_list *)shm_malloc(sizeof(struct str_list));
|
||||
}
|
||||
-
|
||||
- if(list_current == 0) {
|
||||
+ if(!list_current) {
|
||||
SHM_MEM_ERROR;
|
||||
- return 0;
|
||||
+ free_str_list_all(list_first);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ memset(list_current, 0, sizeof(struct str_list));
|
||||
+ list_current->s.s = shm_str2char_dup(&avp_value.s);
|
||||
+ if(!list_current->s.s) {
|
||||
+ free_str_list_all(list_first);
|
||||
+ return NULL;
|
||||
}
|
||||
+ list_current->s.len = avp_value.s.len;
|
||||
+ } while(search_next_avp(&st, &avp_value));
|
||||
|
||||
- memset(list_current, 0, len);
|
||||
+ return list_first;
|
||||
+}
|
||||
|
||||
- list_current->s.s = (char *)list_current + sizeof(struct str_list);
|
||||
- list_current->s.len = avp_value.s.len;
|
||||
- memcpy(list_current->s.s, avp_value.s.s, avp_value.s.len);
|
||||
+/**
|
||||
+ * @brief set dlg_var value from str_list as comma separated values
|
||||
+ *
|
||||
+ * @param dlg dialog
|
||||
+ * @param key dlg_var keyname
|
||||
+ * @param lst list of str values
|
||||
+ * @return int
|
||||
+ */
|
||||
+static int set_dlg_var(struct dlg_cell *dlg, str *key, struct str_list *lst)
|
||||
+{
|
||||
+ str buf = STR_NULL;
|
||||
+ struct str_list *it = lst;
|
||||
+ int num = -1;
|
||||
+ int res;
|
||||
|
||||
+ if(!lst)
|
||||
+ return -1;
|
||||
|
||||
- } while(search_next_avp(&st, &avp_value));
|
||||
+ while(it) {
|
||||
+ buf.len += it->s.len + ++num;
|
||||
+ it = it->next;
|
||||
+ }
|
||||
+ buf.s = (char *)pkg_malloc(sizeof(char) * buf.len);
|
||||
+
|
||||
+ it = lst;
|
||||
+ num = 0;
|
||||
+ while(it) {
|
||||
+ memcpy(buf.s + num, it->s.s, it->s.len);
|
||||
+ if(it->next) {
|
||||
+ num += it->s.len;
|
||||
+ buf.s[num++] = *DLG_VAR_SEP;
|
||||
+ }
|
||||
+ it = it->next;
|
||||
+ }
|
||||
+ res = dlg_api.set_dlg_var(dlg, key, &buf);
|
||||
+ pkg_free(buf.s);
|
||||
|
||||
- return list_first;
|
||||
+ return res;
|
||||
+}
|
||||
+
|
||||
+static int get_dlg_var(struct dlg_cell *dlg, str *key, struct str_list **lst)
|
||||
+{
|
||||
+ str dval = STR_NULL;
|
||||
+ str val = STR_NULL;
|
||||
+ struct str_list *it, *prev;
|
||||
+ char *sep, *ini, *end;
|
||||
+
|
||||
+ if(dlg_api.get_dlg_varval(dlg, &caller_dlg_var, &dval) != 0
|
||||
+ || dval.s == NULL)
|
||||
+ return 0;
|
||||
+
|
||||
+ if(*lst) {
|
||||
+ free_str_list_all(*lst);
|
||||
+ }
|
||||
+ *lst = prev = NULL;
|
||||
+ ini = dval.s;
|
||||
+ end = dval.s + dval.len - 1;
|
||||
+ sep = stre_search_strz(ini, end, DLG_VAR_SEP);
|
||||
+ if(!sep)
|
||||
+ sep = end;
|
||||
+ do {
|
||||
+ val.s = ini;
|
||||
+ val.len = sep - ini + 1;
|
||||
+ ini = sep + 1;
|
||||
+ it = (struct str_list *)shm_malloc(sizeof(struct str_list));
|
||||
+ if(!it) {
|
||||
+ SHM_MEM_ERROR;
|
||||
+ return -1;
|
||||
+ }
|
||||
+ memset(it, 0, sizeof(struct str_list));
|
||||
+ it->s.s = shm_str2char_dup(&val);
|
||||
+ if(!it->s.s) {
|
||||
+ free_str_list_all(*lst);
|
||||
+ return -1;
|
||||
+ }
|
||||
+ it->s.len = val.len;
|
||||
+ LM_DBG("Found uri '%.*s' in dlg_var:'%.*s'\n", val.len, val.s, key->len,
|
||||
+ key->s);
|
||||
+ if(!*lst) {
|
||||
+ *lst = prev = it;
|
||||
+ } else {
|
||||
+ prev->next = it;
|
||||
+ }
|
||||
+ if(ini < end)
|
||||
+ sep = stre_search_strz(ini, end, DLG_VAR_SEP);
|
||||
+ else
|
||||
+ sep = NULL;
|
||||
+ } while(sep);
|
||||
+
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
struct dlginfo_cell *get_dialog_data(struct dlg_cell *dlg, int type,
|
||||
@@ -640,7 +729,6 @@ struct dlginfo_cell *get_dialog_data(struct dlg_cell *dlg, int type,
|
||||
{
|
||||
struct dlginfo_cell *dlginfo;
|
||||
int len;
|
||||
- str dval = {0};
|
||||
|
||||
// generate new random uuid
|
||||
if(sruid_next_safe(&_puadi_sruid) < 0) {
|
||||
@@ -701,59 +789,35 @@ struct dlginfo_cell *get_dialog_data(struct dlg_cell *dlg, int type,
|
||||
dlginfo->pubruris_callee = get_str_list(
|
||||
pubruri_callee_avp_type, pubruri_callee_avp_name);
|
||||
|
||||
- if(dlginfo->pubruris_callee != NULL && callee_dlg_var.len > 0)
|
||||
- dlg_api.set_dlg_var(
|
||||
- dlg, &callee_dlg_var, &dlginfo->pubruris_callee->s);
|
||||
-
|
||||
- if(dlginfo->pubruris_caller != NULL && caller_dlg_var.len > 0)
|
||||
- dlg_api.set_dlg_var(
|
||||
- dlg, &caller_dlg_var, &dlginfo->pubruris_caller->s);
|
||||
-
|
||||
+ if(dlginfo->pubruris_callee != NULL && callee_dlg_var.len > 0) {
|
||||
+ if(set_dlg_var(dlg, &callee_dlg_var, dlginfo->pubruris_callee)
|
||||
+ < 0) {
|
||||
+ free_str_list_all(dlginfo->pubruris_callee);
|
||||
+ dlginfo->pubruris_callee = NULL;
|
||||
+ }
|
||||
+ }
|
||||
+ if(dlginfo->pubruris_caller != NULL && caller_dlg_var.len > 0) {
|
||||
+ if(set_dlg_var(dlg, &caller_dlg_var, dlginfo->pubruris_caller)
|
||||
+ < 0) {
|
||||
+ free_str_list_all(dlginfo->pubruris_caller);
|
||||
+ dlginfo->pubruris_caller = NULL;
|
||||
+ }
|
||||
+ }
|
||||
} else {
|
||||
- if(caller_dlg_var.len > 0
|
||||
- && (dlg_api.get_dlg_varval(dlg, &caller_dlg_var, &dval)
|
||||
- == 0)
|
||||
- && dval.s != NULL) {
|
||||
- dlginfo->pubruris_caller = (struct str_list *)shm_malloc(
|
||||
- sizeof(struct str_list) + dval.len + 1);
|
||||
- if(dlginfo->pubruris_caller == 0) {
|
||||
- SHM_MEM_ERROR;
|
||||
+ if(caller_dlg_var.len > 0) {
|
||||
+ if(get_dlg_var(dlg, &caller_dlg_var, &dlginfo->pubruris_caller)
|
||||
+ < 0) {
|
||||
free_dlginfo_cell(dlginfo);
|
||||
return NULL;
|
||||
}
|
||||
- memset(dlginfo->pubruris_caller, 0, sizeof(struct str_list));
|
||||
- dlginfo->pubruris_caller->s.s =
|
||||
- (char *)dlginfo->pubruris_caller
|
||||
- + sizeof(sizeof(struct str_list));
|
||||
- memcpy(dlginfo->pubruris_caller->s.s, dval.s, dval.len);
|
||||
- dlginfo->pubruris_caller->s.s[dval.len] = '\0';
|
||||
- dlginfo->pubruris_caller->s.len = dval.len;
|
||||
- LM_DBG("Found pubruris_caller in dialog '%.*s'\n",
|
||||
- dlginfo->pubruris_caller->s.len,
|
||||
- dlginfo->pubruris_caller->s.s);
|
||||
}
|
||||
|
||||
- if(callee_dlg_var.len > 0
|
||||
- && (dlg_api.get_dlg_varval(dlg, &callee_dlg_var, &dval)
|
||||
- == 0)
|
||||
- && dval.s != NULL) {
|
||||
- dlginfo->pubruris_callee = (struct str_list *)shm_malloc(
|
||||
- sizeof(struct str_list) + dval.len + 1);
|
||||
- if(dlginfo->pubruris_callee == 0) {
|
||||
- SHM_MEM_ERROR;
|
||||
+ if(callee_dlg_var.len > 0) {
|
||||
+ if(get_dlg_var(dlg, &callee_dlg_var, &dlginfo->pubruris_callee)
|
||||
+ < 0) {
|
||||
free_dlginfo_cell(dlginfo);
|
||||
return NULL;
|
||||
}
|
||||
- memset(dlginfo->pubruris_callee, 0, sizeof(struct str_list));
|
||||
- dlginfo->pubruris_callee->s.s =
|
||||
- (char *)dlginfo->pubruris_callee
|
||||
- + sizeof(sizeof(struct str_list));
|
||||
- memcpy(dlginfo->pubruris_callee->s.s, dval.s, dval.len);
|
||||
- dlginfo->pubruris_callee->s.s[dval.len] = '\0';
|
||||
- dlginfo->pubruris_callee->s.len = dval.len;
|
||||
- LM_DBG("Found pubruris_callee in dialog '%.*s'\n",
|
||||
- dlginfo->pubruris_callee->s.len,
|
||||
- dlginfo->pubruris_callee->s.s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -772,7 +836,12 @@ struct dlginfo_cell *get_dialog_data(struct dlg_cell *dlg, int type,
|
||||
return NULL;
|
||||
}
|
||||
memset(dlginfo->pubruris_caller, 0, sizeof(struct str_list));
|
||||
- dlginfo->pubruris_caller->s = dlginfo->from_uri;
|
||||
+ dlginfo->pubruris_caller->s.s = shm_str2char_dup(&dlginfo->from_uri);
|
||||
+ if(!dlginfo->pubruris_caller->s.s) {
|
||||
+ free_dlginfo_cell(dlginfo);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ dlginfo->pubruris_caller->s.len = dlginfo->from_uri.len;
|
||||
|
||||
dlginfo->pubruris_callee =
|
||||
(struct str_list *)shm_malloc(sizeof(struct str_list));
|
||||
@@ -784,9 +853,11 @@ struct dlginfo_cell *get_dialog_data(struct dlg_cell *dlg, int type,
|
||||
memset(dlginfo->pubruris_callee, 0, sizeof(struct str_list));
|
||||
|
||||
if(include_req_uri) {
|
||||
- dlginfo->pubruris_callee->s = dlginfo->req_uri;
|
||||
+ dlginfo->pubruris_callee->s.s = shm_str2char_dup(&dlginfo->req_uri);
|
||||
+ dlginfo->pubruris_callee->s.len = dlginfo->req_uri.len;
|
||||
} else {
|
||||
- dlginfo->pubruris_callee->s = dlginfo->to_uri;
|
||||
+ dlginfo->pubruris_callee->s.s = shm_str2char_dup(&dlginfo->to_uri);
|
||||
+ dlginfo->pubruris_callee->s.len = dlginfo->to_uri.len;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1105,10 +1176,10 @@ void free_str_list_all(struct str_list *del_current)
|
||||
struct str_list *del_next;
|
||||
|
||||
while(del_current) {
|
||||
-
|
||||
del_next = del_current->next;
|
||||
+ if(del_current->s.s)
|
||||
+ shm_free(del_current->s.s);
|
||||
shm_free(del_current);
|
||||
-
|
||||
del_current = del_next;
|
||||
}
|
||||
}
|
@ -1,245 +0,0 @@
|
||||
From: Victor Seva <vseva@sipwise.com>
|
||||
Date: Mon, 29 Aug 2022 13:59:38 +0200
|
||||
Subject: pv_headers: rework pvh_remove_header_param, take two
|
||||
|
||||
* pvh_set_xavi changes/removes xavi, so we need the new value
|
||||
* after pvh_remove_header, search for the header again
|
||||
---
|
||||
src/modules/pv_headers/pv_headers.c | 22 ++++++++++++++++------
|
||||
src/modules/pv_headers/pvh_func.c | 12 ++++++++----
|
||||
src/modules/pv_headers/pvh_xavp.c | 34 +++++++++++++++-------------------
|
||||
src/modules/pv_headers/pvh_xavp.h | 2 +-
|
||||
4 files changed, 40 insertions(+), 30 deletions(-)
|
||||
|
||||
diff --git a/src/modules/pv_headers/pv_headers.c b/src/modules/pv_headers/pv_headers.c
|
||||
index a833b96..fdb6f2e 100644
|
||||
--- a/src/modules/pv_headers/pv_headers.c
|
||||
+++ b/src/modules/pv_headers/pv_headers.c
|
||||
@@ -224,12 +224,15 @@ static int w_pvh_header_param_exists(struct sip_msg *msg, char *p1, char *p2)
|
||||
static int ki_pvh_remove_header_param(
|
||||
struct sip_msg *msg, str *hname, str *toRemove)
|
||||
{
|
||||
- int idx;
|
||||
+ int next;
|
||||
+ int idx = 0;
|
||||
int new_size;
|
||||
str dst = STR_NULL;
|
||||
sr_xavp_t *avi = pvh_xavi_get_child(msg, &xavi_name, hname);
|
||||
|
||||
- for(idx = 0; avi != NULL; avi = xavi_get_next(avi)) {
|
||||
+ while(avi) {
|
||||
+ next = 1;
|
||||
+ LM_DBG("hname:%.*s[%d]\n", STR_FMT(hname), idx);
|
||||
if(avi->val.type == SR_XTYPE_STR && avi->val.v.s.s != NULL) {
|
||||
if(str_casesearch(&avi->val.v.s, toRemove) != NULL) {
|
||||
new_size = pvh_remove_header_param_helper(
|
||||
@@ -239,15 +242,19 @@ static int ki_pvh_remove_header_param(
|
||||
STR_FMT(hname), idx);
|
||||
if(pvh_remove_header(msg, hname, idx) < 0)
|
||||
return -1;
|
||||
+ avi = pvh_xavi_get_child(msg, &xavi_name, hname);
|
||||
+ if(idx > 0)
|
||||
+ idx = 0;
|
||||
+ next = 0;
|
||||
} else if(dst.len < 0 || new_size == avi->val.v.s.len) {
|
||||
LM_DBG("'%.*s' not found at '%.*s'\n", STR_FMT(toRemove),
|
||||
STR_FMT(&avi->val.v.s));
|
||||
} else {
|
||||
LM_DBG("old_value:'%.*s' new_value:'%.*s'\n",
|
||||
STR_FMT(&avi->val.v.s), STR_FMT(&dst));
|
||||
- if(pvh_set_xavi(msg, &xavi_name, hname, &dst, SR_XTYPE_STR,
|
||||
- idx, 0)
|
||||
- < 0) {
|
||||
+ avi = pvh_set_xavi(
|
||||
+ msg, &xavi_name, hname, &dst, SR_XTYPE_STR, idx, 0);
|
||||
+ if(avi == NULL) {
|
||||
LM_ERR("can't set new value\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -257,7 +264,10 @@ static int ki_pvh_remove_header_param(
|
||||
STR_FMT(&avi->val.v.s));
|
||||
}
|
||||
}
|
||||
- idx++;
|
||||
+ if(next) {
|
||||
+ avi = xavi_get_next(avi);
|
||||
+ idx++;
|
||||
+ }
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
diff --git a/src/modules/pv_headers/pvh_func.c b/src/modules/pv_headers/pvh_func.c
|
||||
index 7b1c6f9..b0e7a82 100644
|
||||
--- a/src/modules/pv_headers/pvh_func.c
|
||||
+++ b/src/modules/pv_headers/pvh_func.c
|
||||
@@ -325,12 +325,16 @@ int pvh_check_header(struct sip_msg *msg, str *hname)
|
||||
|
||||
int pvh_append_header(struct sip_msg *msg, str *hname, str *hvalue)
|
||||
{
|
||||
- return pvh_set_xavi(msg, &xavi_name, hname, hvalue, SR_XTYPE_STR, 0, 1);
|
||||
+ if(pvh_set_xavi(msg, &xavi_name, hname, hvalue, SR_XTYPE_STR, 0, 1) == NULL)
|
||||
+ return -1;
|
||||
+ return 1;
|
||||
}
|
||||
|
||||
int pvh_modify_header(struct sip_msg *msg, str *hname, str *hvalue, int indx)
|
||||
{
|
||||
- return pvh_set_xavi(msg, &xavi_name, hname, hvalue, SR_XTYPE_STR, indx, 0);
|
||||
+ if(pvh_set_xavi(msg, &xavi_name, hname, hvalue, SR_XTYPE_STR, indx, 0) == NULL)
|
||||
+ return -1;
|
||||
+ return 1;
|
||||
}
|
||||
|
||||
int pvh_remove_header(struct sip_msg *msg, str *hname, int indx)
|
||||
@@ -346,12 +350,12 @@ int pvh_remove_header(struct sip_msg *msg, str *hname, int indx)
|
||||
do {
|
||||
if(pvh_set_xavi(
|
||||
msg, &xavi_name, hname, NULL, SR_XTYPE_STR, indx++, 0)
|
||||
- < 1)
|
||||
+ == NULL)
|
||||
return -1;
|
||||
} while(indx < count);
|
||||
} else {
|
||||
if(pvh_set_xavi(msg, &xavi_name, hname, NULL, SR_XTYPE_STR, indx, 0)
|
||||
- < 1)
|
||||
+ == NULL)
|
||||
return -1;
|
||||
}
|
||||
|
||||
diff --git a/src/modules/pv_headers/pvh_xavp.c b/src/modules/pv_headers/pvh_xavp.c
|
||||
index e52f9da..fb9a714 100644
|
||||
--- a/src/modules/pv_headers/pvh_xavp.c
|
||||
+++ b/src/modules/pv_headers/pvh_xavp.c
|
||||
@@ -131,18 +131,18 @@ static sr_xavp_t *pvh_xavi_new_value(str *name, sr_xval_t *val)
|
||||
return avp;
|
||||
}
|
||||
|
||||
-int pvh_xavi_append_value(str *name, sr_xval_t *val, sr_xavp_t **start)
|
||||
+static sr_xavp_t * pvh_xavi_append_value(str *name, sr_xval_t *val, sr_xavp_t **start)
|
||||
{
|
||||
sr_xavp_t *last = NULL;
|
||||
sr_xavp_t *xavi = NULL;
|
||||
|
||||
if((xavi = pvh_xavi_new_value(name, val)) == NULL)
|
||||
- return -1;
|
||||
+ return xavi;
|
||||
|
||||
if(*start == NULL) {
|
||||
xavi->next = *start;
|
||||
*start = xavi;
|
||||
- return 1;
|
||||
+ return xavi;
|
||||
}
|
||||
|
||||
last = *start;
|
||||
@@ -150,13 +150,13 @@ int pvh_xavi_append_value(str *name, sr_xval_t *val, sr_xavp_t **start)
|
||||
last = last->next;
|
||||
last->next = xavi;
|
||||
|
||||
- return 1;
|
||||
+ return xavi;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
-static int pvh_xavi_set_value(
|
||||
+static sr_xavp_t * pvh_xavi_set_value(
|
||||
str *name, sr_xval_t *val, int idx, sr_xavp_t **start)
|
||||
{
|
||||
int cnt = 0;
|
||||
@@ -166,14 +166,11 @@ static int pvh_xavi_set_value(
|
||||
idx = idx + cnt;
|
||||
if(idx < 0) {
|
||||
LM_ERR("wrong calculated idx:%d\n", idx);
|
||||
- return -1;
|
||||
+ return NULL;
|
||||
}
|
||||
}
|
||||
LM_DBG("xavi name: %.*s\n", name->len, name->s);
|
||||
- if(xavi_set_value(name, idx, val, start) == NULL)
|
||||
- return -1;
|
||||
-
|
||||
- return 1;
|
||||
+ return xavi_set_value(name, idx, val, start);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -356,11 +353,12 @@ int pvh_xavi_keys_count(sr_xavp_t **start)
|
||||
/**
|
||||
*
|
||||
*/
|
||||
-int pvh_set_xavi(struct sip_msg *msg, str *xname, str *name, void *data,
|
||||
+sr_xavp_t * pvh_set_xavi(struct sip_msg *msg, str *xname, str *name, void *data,
|
||||
sr_xtype_t type, int idx, int append)
|
||||
{
|
||||
sr_xavp_t **xavi = NULL;
|
||||
sr_xavp_t *root = NULL;
|
||||
+ sr_xavp_t *result = NULL;
|
||||
sr_xval_t root_xval;
|
||||
sr_xval_t xval;
|
||||
char t[header_name_size];
|
||||
@@ -368,7 +366,7 @@ int pvh_set_xavi(struct sip_msg *msg, str *xname, str *name, void *data,
|
||||
|
||||
if(xname == NULL || name == NULL) {
|
||||
LM_ERR("missing xavi/pv name\n");
|
||||
- return -1;
|
||||
+ return result;
|
||||
}
|
||||
|
||||
pvh_get_branch_xname(msg, xname, &br_xname);
|
||||
@@ -385,7 +383,7 @@ int pvh_set_xavi(struct sip_msg *msg, str *xname, str *name, void *data,
|
||||
xval.v.data = (sr_data_t *)shm_malloc(sizeof(sr_data_t));
|
||||
if(xval.v.data == NULL) {
|
||||
SHM_MEM_ERROR;
|
||||
- return -1;
|
||||
+ return result;
|
||||
}
|
||||
memset(xval.v.data, 0, sizeof(sr_data_t));
|
||||
xval.v.data->p = data;
|
||||
@@ -409,7 +407,7 @@ int pvh_set_xavi(struct sip_msg *msg, str *xname, str *name, void *data,
|
||||
|
||||
if((root = xavi_add_value(&br_xname, &root_xval, NULL)) == NULL) {
|
||||
LM_ERR("error create xavi %.*s\n", br_xname.len, br_xname.s);
|
||||
- return -1;
|
||||
+ return NULL;
|
||||
}
|
||||
xavi = &root->val.v.xavp;
|
||||
} else if(xavi_get_child(&br_xname, name) == NULL) {
|
||||
@@ -417,20 +415,18 @@ int pvh_set_xavi(struct sip_msg *msg, str *xname, str *name, void *data,
|
||||
}
|
||||
|
||||
if(append) {
|
||||
- if(pvh_xavi_append_value(name, &xval, xavi) < 0) {
|
||||
+ if((result = pvh_xavi_append_value(name, &xval, xavi)) == NULL) {
|
||||
LM_ERR("error append xavi=>name %.*s=>%.*s\n", br_xname.len,
|
||||
br_xname.s, name->len, name->s);
|
||||
- return -1;
|
||||
}
|
||||
} else {
|
||||
- if(pvh_xavi_set_value(name, &xval, idx, xavi) < 0) {
|
||||
+ if((result = pvh_xavi_set_value(name, &xval, idx, xavi)) == NULL) {
|
||||
LM_ERR("error modify xavi=>name %.*s=>%.*s idx=%d\n", br_xname.len,
|
||||
br_xname.s, name->len, name->s, idx);
|
||||
- return -1;
|
||||
}
|
||||
}
|
||||
|
||||
- return 1;
|
||||
+ return result;
|
||||
}
|
||||
|
||||
|
||||
diff --git a/src/modules/pv_headers/pvh_xavp.h b/src/modules/pv_headers/pvh_xavp.h
|
||||
index 646ebd7..2ced2eb 100644
|
||||
--- a/src/modules/pv_headers/pvh_xavp.h
|
||||
+++ b/src/modules/pv_headers/pvh_xavp.h
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
int pvh_reply_append(sr_xavp_t **start);
|
||||
|
||||
-int pvh_set_xavi(struct sip_msg *msg, str *xname, str *name, void *data,
|
||||
+sr_xavp_t * pvh_set_xavi(struct sip_msg *msg, str *xname, str *name, void *data,
|
||||
sr_xtype_t type, int idx, int append);
|
||||
int pvh_xavi_keys_count(sr_xavp_t **start);
|
||||
sr_xavp_t *pvh_xavi_get_child(struct sip_msg *msg, str *xname, str *name);
|
@ -1,193 +0,0 @@
|
||||
From: Sipwise Development Team <support@sipwise.com>
|
||||
Date: Fri, 18 Aug 2023 12:49:37 +0200
|
||||
Subject: rtpengine-set-mime-content-length
|
||||
|
||||
---
|
||||
src/modules/rtpengine/rtpengine.c | 43 ++++++++++++++++++++++++---------
|
||||
src/modules/rtpengine/rtpengine_funcs.c | 9 ++++---
|
||||
src/modules/rtpengine/rtpengine_funcs.h | 3 +--
|
||||
3 files changed, 38 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/src/modules/rtpengine/rtpengine.c b/src/modules/rtpengine/rtpengine.c
|
||||
index 442df8d..1c7da31 100644
|
||||
--- a/src/modules/rtpengine/rtpengine.c
|
||||
+++ b/src/modules/rtpengine/rtpengine.c
|
||||
@@ -2550,7 +2550,7 @@ error:
|
||||
|
||||
static bencode_item_t *rtpp_function_call(bencode_buffer_t *bencbuf,
|
||||
struct sip_msg *msg, enum rtpe_operation op, const char *flags_str,
|
||||
- str *body_out)
|
||||
+ str *body_out, str *cl_field)
|
||||
{
|
||||
struct ng_flags_parse ng_flags;
|
||||
bencode_item_t *item, *resp;
|
||||
@@ -2616,7 +2616,7 @@ static bencode_item_t *rtpp_function_call(bencode_buffer_t *bencbuf,
|
||||
body = pv_val.rs;
|
||||
}
|
||||
|
||||
- } else if((cont_type = extract_body(msg, &body)) == -1) {
|
||||
+ } else if((cont_type = extract_body(msg, &body, cl_field)) == -1) {
|
||||
LM_ERR("can't extract body from the message\n");
|
||||
goto error;
|
||||
}
|
||||
@@ -2953,7 +2953,7 @@ static int rtpp_function_call_simple(
|
||||
bencode_buffer_t bencbuf;
|
||||
bencode_item_t *ret;
|
||||
|
||||
- ret = rtpp_function_call(&bencbuf, msg, op, flags_str, NULL);
|
||||
+ ret = rtpp_function_call(&bencbuf, msg, op, flags_str, NULL, NULL);
|
||||
if(!ret)
|
||||
return -1;
|
||||
|
||||
@@ -2976,11 +2976,11 @@ static int rtpengine_simple_wrap(
|
||||
|
||||
static bencode_item_t *rtpp_function_call_ok(bencode_buffer_t *bencbuf,
|
||||
struct sip_msg *msg, enum rtpe_operation op, const char *flags_str,
|
||||
- str *body)
|
||||
+ str *body, str *cl_field)
|
||||
{
|
||||
bencode_item_t *ret;
|
||||
|
||||
- ret = rtpp_function_call(bencbuf, msg, op, flags_str, body);
|
||||
+ ret = rtpp_function_call(bencbuf, msg, op, flags_str, body, cl_field);
|
||||
if(!ret)
|
||||
return NULL;
|
||||
|
||||
@@ -3804,7 +3804,7 @@ static int rtpengine_delete(struct sip_msg *msg, const char *flags)
|
||||
{
|
||||
bencode_buffer_t bencbuf;
|
||||
bencode_item_t *ret =
|
||||
- rtpp_function_call_ok(&bencbuf, msg, OP_DELETE, flags, NULL);
|
||||
+ rtpp_function_call_ok(&bencbuf, msg, OP_DELETE, flags, NULL, NULL);
|
||||
if(!ret)
|
||||
return -1;
|
||||
parse_call_stats(ret, msg);
|
||||
@@ -3816,7 +3816,7 @@ static int rtpengine_query(struct sip_msg *msg, const char *flags)
|
||||
{
|
||||
bencode_buffer_t bencbuf;
|
||||
bencode_item_t *ret =
|
||||
- rtpp_function_call_ok(&bencbuf, msg, OP_QUERY, flags, NULL);
|
||||
+ rtpp_function_call_ok(&bencbuf, msg, OP_QUERY, flags, NULL, NULL);
|
||||
if(!ret)
|
||||
return -1;
|
||||
parse_call_stats(ret, msg);
|
||||
@@ -4097,9 +4097,11 @@ static int rtpengine_offer_answer(struct sip_msg *msg, const char *flags,
|
||||
str body, newbody;
|
||||
struct lump *anchor;
|
||||
pv_value_t pv_val;
|
||||
- str cur_body = {0, 0};
|
||||
+ str cur_body = STR_NULL;
|
||||
+ str cl_field = STR_NULL;
|
||||
+ str cl_repl = STR_NULL;
|
||||
|
||||
- dict = rtpp_function_call_ok(&bencbuf, msg, op, flags, &body);
|
||||
+ dict = rtpp_function_call_ok(&bencbuf, msg, op, flags, &body, &cl_field);
|
||||
if(!dict)
|
||||
return -1;
|
||||
|
||||
@@ -4129,6 +4131,21 @@ static int rtpengine_offer_answer(struct sip_msg *msg, const char *flags,
|
||||
pkg_free(newbody.s);
|
||||
|
||||
} else {
|
||||
+ if(cl_field.len) {
|
||||
+ anchor = del_lump(msg, cl_field.s - msg->buf, cl_field.len, 0);
|
||||
+ cl_repl.s = pkg_malloc(10);
|
||||
+ if(!cl_repl.s) {
|
||||
+ LM_ERR("pkg_malloc for Content-Length failed\n");
|
||||
+ goto error_free;
|
||||
+ }
|
||||
+ cl_repl.len = snprintf(cl_repl.s, 10, "%i", (int)newbody.len);
|
||||
+ if(!insert_new_lump_after(anchor, cl_repl.s, cl_repl.len, 0)) {
|
||||
+ LM_ERR("insert_new_lump_after failed\n");
|
||||
+ goto error_free;
|
||||
+ }
|
||||
+ cl_repl.s = NULL;
|
||||
+ }
|
||||
+
|
||||
if(read_sdp_pvar_str.len > 0) {
|
||||
/* get the body from the message as body ptr may have changed
|
||||
* when using read_sdp_pv */
|
||||
@@ -4156,6 +4173,8 @@ static int rtpengine_offer_answer(struct sip_msg *msg, const char *flags,
|
||||
|
||||
error_free:
|
||||
pkg_free(newbody.s);
|
||||
+ if(cl_repl.s)
|
||||
+ pkg_free(cl_repl.s);
|
||||
error:
|
||||
bencode_buffer_free(&bencbuf);
|
||||
return -1;
|
||||
@@ -4219,7 +4238,7 @@ static int rtpengine_play_media(
|
||||
pv_value_t val;
|
||||
int retval = 1;
|
||||
|
||||
- ret = rtpp_function_call_ok(&bencbuf, msg, OP_PLAY_MEDIA, d, NULL);
|
||||
+ ret = rtpp_function_call_ok(&bencbuf, msg, OP_PLAY_MEDIA, d, NULL, NULL);
|
||||
if(!ret)
|
||||
return -1;
|
||||
if(media_duration_pvar) {
|
||||
@@ -4283,7 +4302,7 @@ static int rtpengine_rtpstat_wrap(
|
||||
param = parms[0];
|
||||
res = parms[1];
|
||||
|
||||
- dict = rtpp_function_call_ok(&bencbuf, msg, OP_QUERY, NULL, NULL);
|
||||
+ dict = rtpp_function_call_ok(&bencbuf, msg, OP_QUERY, NULL, NULL, NULL);
|
||||
if(!dict)
|
||||
return -1;
|
||||
|
||||
@@ -4452,7 +4471,7 @@ static int rtpengine_query_v_wrap(
|
||||
fmt = parms[0];
|
||||
dst = parms[1];
|
||||
|
||||
- dict = rtpp_function_call_ok(&bencbuf, msg, OP_QUERY, NULL, NULL);
|
||||
+ dict = rtpp_function_call_ok(&bencbuf, msg, OP_QUERY, NULL, NULL, NULL);
|
||||
if(!dict) {
|
||||
return -1;
|
||||
}
|
||||
diff --git a/src/modules/rtpengine/rtpengine_funcs.c b/src/modules/rtpengine/rtpengine_funcs.c
|
||||
index 7ef7c8b..dde9cf5 100644
|
||||
--- a/src/modules/rtpengine/rtpengine_funcs.c
|
||||
+++ b/src/modules/rtpengine/rtpengine_funcs.c
|
||||
@@ -66,7 +66,7 @@
|
||||
* 2: multipart
|
||||
* 3: trickle ice sdp fragment
|
||||
*/
|
||||
-int check_content_type(struct sip_msg *msg)
|
||||
+static int check_content_type(struct sip_msg *msg)
|
||||
{
|
||||
static unsigned int appl[16] = {0x6c707061 /*appl*/, 0x6c707041 /*Appl*/,
|
||||
0x6c705061 /*aPpl*/, 0x6c705041 /*APpl*/, 0x6c507061 /*apPl*/,
|
||||
@@ -156,7 +156,7 @@ other:
|
||||
/*
|
||||
* Get message body and check Content-Type header field
|
||||
*/
|
||||
-int extract_body(struct sip_msg *msg, str *body)
|
||||
+int extract_body(struct sip_msg *msg, str *body, str *cl_field)
|
||||
{
|
||||
char c;
|
||||
int ret;
|
||||
@@ -234,7 +234,10 @@ int extract_body(struct sip_msg *msg, str *body)
|
||||
break;
|
||||
if(hf.type == HDR_ERROR_T)
|
||||
return -1;
|
||||
- if(hf.type == HDR_CONTENTTYPE_T) {
|
||||
+ if(hf.type == HDR_CONTENTLENGTH_T) {
|
||||
+ if(cl_field)
|
||||
+ *cl_field = hf.body;
|
||||
+ } else if(hf.type == HDR_CONTENTTYPE_T) {
|
||||
if(decode_mime_type(hf.body.s, hf.body.s + hf.body.len, &mime)
|
||||
== NULL)
|
||||
return -1;
|
||||
diff --git a/src/modules/rtpengine/rtpengine_funcs.h b/src/modules/rtpengine/rtpengine_funcs.h
|
||||
index a1221bd..ea0a720 100644
|
||||
--- a/src/modules/rtpengine/rtpengine_funcs.h
|
||||
+++ b/src/modules/rtpengine/rtpengine_funcs.h
|
||||
@@ -27,8 +27,7 @@
|
||||
#include "../../core/parser/msg_parser.h"
|
||||
#include "../../core/parser/contact/contact.h"
|
||||
|
||||
-int extract_body(struct sip_msg *, str *);
|
||||
-int check_content_type(struct sip_msg *);
|
||||
+int extract_body(struct sip_msg *, str *, str *);
|
||||
int get_callid(struct sip_msg *, str *);
|
||||
int get_to_tag(struct sip_msg *, str *);
|
||||
int get_from_tag(struct sip_msg *, str *);
|
@ -1,80 +0,0 @@
|
||||
From: Victor Seva <linuxmaniac@torreviejawireless.org>
|
||||
Date: Tue, 21 Nov 2023 15:30:03 +0100
|
||||
Subject: core: timer_proc don't execute timers on shutdown phase
|
||||
|
||||
---
|
||||
src/core/timer_proc.c | 19 +++++++++++++++++++
|
||||
1 file changed, 19 insertions(+)
|
||||
|
||||
diff --git a/src/core/timer_proc.c b/src/core/timer_proc.c
|
||||
index 0b04cf6..55bd98d 100644
|
||||
--- a/src/core/timer_proc.c
|
||||
+++ b/src/core/timer_proc.c
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "pt.h"
|
||||
#include "ut.h"
|
||||
#include "mem/shm_mem.h"
|
||||
+#include "sr_module.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -76,6 +77,9 @@ int fork_basic_timer(int child_id, char *desc, int make_sock, timer_function *f,
|
||||
if(cfg_child_init())
|
||||
return -1;
|
||||
for(;;) {
|
||||
+ if(unlikely(ksr_shutdown_phase() != 0)) {
|
||||
+ return 0;
|
||||
+ }
|
||||
sleep(interval);
|
||||
cfg_update();
|
||||
f(get_ticks(), param); /* ticks in s for compatibility with old
|
||||
@@ -99,6 +103,9 @@ int fork_basic_timer_w(int child_id, char *desc, int make_sock,
|
||||
if(cfg_child_init())
|
||||
return -1;
|
||||
for(;;) {
|
||||
+ if(unlikely(ksr_shutdown_phase() != 0)) {
|
||||
+ return 0;
|
||||
+ }
|
||||
sleep(interval);
|
||||
cfg_update();
|
||||
f(get_ticks(), worker,
|
||||
@@ -141,6 +148,9 @@ int fork_basic_utimer(int child_id, char *desc, int make_sock,
|
||||
if(cfg_child_init())
|
||||
return -1;
|
||||
for(;;) {
|
||||
+ if(unlikely(ksr_shutdown_phase() != 0)) {
|
||||
+ return 0;
|
||||
+ }
|
||||
sleep_us(uinterval);
|
||||
cfg_update();
|
||||
ts = get_ticks_raw();
|
||||
@@ -165,6 +175,9 @@ int fork_basic_utimer_w(int child_id, char *desc, int make_sock,
|
||||
if(cfg_child_init())
|
||||
return -1;
|
||||
for(;;) {
|
||||
+ if(unlikely(ksr_shutdown_phase() != 0)) {
|
||||
+ return 0;
|
||||
+ }
|
||||
sleep_us(uinterval);
|
||||
cfg_update();
|
||||
ts = get_ticks_raw();
|
||||
@@ -273,6 +286,9 @@ int fork_sync_timer(int child_id, char *desc, int make_sock, timer_function *f,
|
||||
if(cfg_child_init())
|
||||
return -1;
|
||||
for(;;) {
|
||||
+ if(unlikely(ksr_shutdown_phase() != 0)) {
|
||||
+ return 0;
|
||||
+ }
|
||||
if(ts2 > interval)
|
||||
sleep_us(1000); /* 1 millisecond sleep to catch up */
|
||||
else
|
||||
@@ -324,6 +340,9 @@ int fork_sync_utimer(int child_id, char *desc, int make_sock,
|
||||
if(cfg_child_init())
|
||||
return -1;
|
||||
for(;;) {
|
||||
+ if(unlikely(ksr_shutdown_phase() != 0)) {
|
||||
+ return 0;
|
||||
+ }
|
||||
if(ts2 > uinterval)
|
||||
sleep_us(1);
|
||||
else
|
@ -1,183 +0,0 @@
|
||||
From: Nicolas C <nchaigne@capgemini.fr>
|
||||
Date: Tue, 24 Oct 2023 17:10:09 +0200
|
||||
Subject: http_client: Add parameter timeout_mode (timeout in seconds or
|
||||
milliseconds)
|
||||
|
||||
A new parameter timeout_mode is added.
|
||||
This parameter defines if timeouts are enabled, and in which unit timeout values are expressed.
|
||||
- 0 - Timeouts are disabled.
|
||||
- 1 - Timeout values are in seconds (default).
|
||||
- 2 - Timeout values are in milliseconds.
|
||||
|
||||
Implementation detail:
|
||||
|
||||
default global timeout = 0 (unconfigured).
|
||||
|
||||
Parse connections as usual. If they have a timeout configured, use it.
|
||||
|
||||
In mod_init:
|
||||
if global timeout == 0 (unconfigured), and timeout_mode is 1 or 2:
|
||||
if timeout_mode == 1 -> global timeout = 4 (seconds)
|
||||
if timeout_mode == 2 -> global timeout = 4000 (milliseconds)
|
||||
|
||||
for each connection "conn" (fixup):
|
||||
if timeout_mode is not 1 or 2 -> conn.timeout = 0 (to reflect the fact that no timeout will be handled)
|
||||
else if conn.timeout is not configured -> conn.timeout = global timeout (in seconds or milliseconds, depending on timeout_mode).
|
||||
|
||||
When doing Curl requests (curL_request_url):
|
||||
if timeout_mode == 1: set CURLOPT_TIMEOUT
|
||||
if timeout_mode == 2: set CURLOPT_TIMEOUT_MS
|
||||
---
|
||||
src/modules/http_client/curlcon.c | 28 +++++++++++++++++++++++++++-
|
||||
src/modules/http_client/curlcon.h | 4 ++++
|
||||
src/modules/http_client/functions.c | 13 ++++++++++++-
|
||||
src/modules/http_client/http_client.c | 27 +++++++++++++++++++++++----
|
||||
src/modules/http_client/http_client.h | 1 +
|
||||
5 files changed, 67 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/modules/http_client/curlcon.c b/src/modules/http_client/curlcon.c
|
||||
index bffd26c..35735b7 100644
|
||||
--- a/src/modules/http_client/curlcon.c
|
||||
+++ b/src/modules/http_client/curlcon.c
|
||||
@@ -403,7 +403,7 @@ int curl_parse_param(char *val)
|
||||
} else if(pit->name.len == 7
|
||||
&& strncmp(pit->name.s, "timeout", 7) == 0) {
|
||||
if(str2int(&tok, &timeout) != 0) {
|
||||
- /* Bad timeout */
|
||||
+ /* Bad value */
|
||||
LM_WARN("curl connection [%.*s]: timeout bad value. Using "
|
||||
"default\n",
|
||||
name.len, name.s);
|
||||
@@ -854,3 +854,29 @@ curl_con_t *curl_init_con(str *name)
|
||||
LM_DBG("CURL: Added connection [%.*s]\n", name->len, name->s);
|
||||
return cc;
|
||||
}
|
||||
+
|
||||
+/*! Fixup CURL connections - if timeout is not configured, Use as default global connection_timeout.
|
||||
+ */
|
||||
+void curl_conn_list_fixup(void)
|
||||
+{
|
||||
+ curl_con_t *cc;
|
||||
+ cc = _curl_con_root;
|
||||
+ while (cc) {
|
||||
+ if (!(timeout_mode == 1 || timeout_mode == 2)) {
|
||||
+ /* Timeout is disabled globally. Set timeout to 0 for all connections to reflect this. */
|
||||
+ if (cc->timeout > 0) {
|
||||
+ LM_WARN("curl connection [%.*s]: configured timeout is ignored "
|
||||
+ "because timeouts are disabled (timeout_mode)\n",
|
||||
+ cc->name.len, cc->name.s);
|
||||
+ cc->timeout = 0;
|
||||
+ }
|
||||
+ }
|
||||
+ else if (cc->timeout == 0) {
|
||||
+ /* Timeout is not configured for that connection.
|
||||
+ * Use as default global connection_timeout (which can be seconds or milliseconds).
|
||||
+ */
|
||||
+ cc->timeout = default_connection_timeout;
|
||||
+ }
|
||||
+ cc = cc->next;
|
||||
+ }
|
||||
+}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/modules/http_client/curlcon.h b/src/modules/http_client/curlcon.h
|
||||
index ff5ebe1..3f77476 100644
|
||||
--- a/src/modules/http_client/curlcon.h
|
||||
+++ b/src/modules/http_client/curlcon.h
|
||||
@@ -52,4 +52,8 @@ int curl_parse_param(char *val);
|
||||
curl_con_t *curl_get_connection(str *name);
|
||||
curl_con_pkg_t *curl_get_pkg_connection(curl_con_t *con);
|
||||
|
||||
+/*! Fixup CURL connections - if timeout is not configured, Use as default global connection_timeout.
|
||||
+ */
|
||||
+void curl_conn_list_fixup(void);
|
||||
+
|
||||
#endif
|
||||
diff --git a/src/modules/http_client/functions.c b/src/modules/http_client/functions.c
|
||||
index 1472da7..dda4721 100644
|
||||
--- a/src/modules/http_client/functions.c
|
||||
+++ b/src/modules/http_client/functions.c
|
||||
@@ -262,7 +262,18 @@ static int curL_request_url(struct sip_msg *_m, const char *_met,
|
||||
curl, CURLOPT_SSL_VERIFYHOST, (long)params->verify_host ? 2 : 0);
|
||||
|
||||
res |= curl_easy_setopt(curl, CURLOPT_NOSIGNAL, (long)1);
|
||||
- res |= curl_easy_setopt(curl, CURLOPT_TIMEOUT, (long)params->timeout);
|
||||
+
|
||||
+ /* timeout_mode parameter:
|
||||
+ * - 0 : timeout is disabled.
|
||||
+ * - 1 (default) : timeout value is in seconds.
|
||||
+ * - 2 : timeout value is in milliseconds.
|
||||
+ */
|
||||
+ if (timeout_mode == 1) { /* timeout is in seconds (default) */
|
||||
+ res |= curl_easy_setopt(curl, CURLOPT_TIMEOUT, (long)params->timeout);
|
||||
+ } else if (timeout_mode == 2) { /* timeout is in milliseconds */
|
||||
+ res |= curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, (long)params->timeout);
|
||||
+ }
|
||||
+
|
||||
res |= curl_easy_setopt(
|
||||
curl, CURLOPT_FOLLOWLOCATION, (long)params->http_follow_redirect);
|
||||
if(params->http_follow_redirect) {
|
||||
diff --git a/src/modules/http_client/http_client.c b/src/modules/http_client/http_client.c
|
||||
index 430933e..4884424 100644
|
||||
--- a/src/modules/http_client/http_client.c
|
||||
+++ b/src/modules/http_client/http_client.c
|
||||
@@ -76,7 +76,8 @@ MODULE_VERSION
|
||||
#define CURL_USER_AGENT_LEN (sizeof(CURL_USER_AGENT) - 1)
|
||||
|
||||
/* Module parameter variables */
|
||||
-unsigned int default_connection_timeout = 4;
|
||||
+unsigned int default_connection_timeout = 0; /*!< 0 = not user configured - the default (4 seconds) will be used */
|
||||
+unsigned int timeout_mode = 1; /*!< 0 = timeout disabled, 1 (default) = timeout in seconds, 2 = timeout in ms */
|
||||
char *default_tls_cacert =
|
||||
NULL; /*!< File name: Default CA cert to use for curl TLS connection */
|
||||
str default_tls_clientcert =
|
||||
@@ -195,6 +196,7 @@ static cmd_export_t cmds[] = {
|
||||
/* Exported parameters */
|
||||
static param_export_t params[] = {
|
||||
{"connection_timeout", PARAM_INT, &default_connection_timeout},
|
||||
+ {"timeout_mode", PARAM_INT, &timeout_mode},
|
||||
{"cacert", PARAM_STRING, &default_tls_cacert },
|
||||
{"client_cert", PARAM_STR, &default_tls_clientcert },
|
||||
{"client_key", PARAM_STR, &default_tls_clientkey },
|
||||
@@ -310,10 +312,27 @@ static int mod_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
- if(default_connection_timeout == 0) {
|
||||
- LM_ERR("CURL connection timeout set to zero. Using default 4 secs\n");
|
||||
- default_connection_timeout = 4;
|
||||
+ /* timeout_mode parameter:
|
||||
+ * - 0 : timeout is disabled.
|
||||
+ * - 1 (default) : timeout value is in seconds.
|
||||
+ * - 2 : timeout value is in milliseconds.
|
||||
+ */
|
||||
+ if (!(timeout_mode == 1 || timeout_mode == 2)) {
|
||||
+ if (default_connection_timeout > 0) {
|
||||
+ LM_WARN("configured connection_timeout is ignored "
|
||||
+ "because timeouts are disabled (timeout_mode)\n");
|
||||
+ }
|
||||
+ } else if (default_connection_timeout == 0) {
|
||||
+ LM_INFO("curl connection timeout set to zero. Using default 4 secs\n");
|
||||
+ if (timeout_mode == 1) { /* timeout is in seconds (default) */
|
||||
+ default_connection_timeout = 4;
|
||||
+ } else if (timeout_mode == 2) { /* timeout is in milliseconds */
|
||||
+ default_connection_timeout = 4000;
|
||||
+ }
|
||||
}
|
||||
+ /* Fixup named connections for which no specific timeout is configured. */
|
||||
+ curl_conn_list_fixup();
|
||||
+
|
||||
if(default_http_proxy_port == 0) {
|
||||
LM_INFO("HTTP proxy port set to 0. Disabling HTTP proxy\n");
|
||||
}
|
||||
diff --git a/src/modules/http_client/http_client.h b/src/modules/http_client/http_client.h
|
||||
index 0f659f9..c56f411 100644
|
||||
--- a/src/modules/http_client/http_client.h
|
||||
+++ b/src/modules/http_client/http_client.h
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "../../lib/srdb1/db.h"
|
||||
|
||||
extern unsigned int default_connection_timeout;
|
||||
+extern unsigned int timeout_mode;
|
||||
extern char *
|
||||
default_tls_cacert; /*!< File name: Default CA cert to use for curl TLS connection */
|
||||
extern str
|
@ -1,84 +0,0 @@
|
||||
From: Daniel-Constantin Mierla <miconda@gmail.com>
|
||||
Date: Wed, 23 Aug 2023 10:55:35 +0200
|
||||
Subject: pv_headers: compare result of pvh_set_xavi() with NULL for error
|
||||
cases
|
||||
|
||||
- the function returns a pointer
|
||||
---
|
||||
src/modules/pv_headers/pvh_xavp.c | 18 +++++++++---------
|
||||
1 file changed, 9 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/src/modules/pv_headers/pvh_xavp.c b/src/modules/pv_headers/pvh_xavp.c
|
||||
index fb9a714..b715baa 100644
|
||||
--- a/src/modules/pv_headers/pvh_xavp.c
|
||||
+++ b/src/modules/pv_headers/pvh_xavp.c
|
||||
@@ -618,11 +618,11 @@ int pvh_set_header(
|
||||
xavi->name.len, xavi->name.s, hname->len, hname->s);
|
||||
}
|
||||
if(pvh_set_xavi(msg, &xavi_name, hname, NULL, SR_XTYPE_NULL, 0, 0)
|
||||
- < 0)
|
||||
+ == NULL)
|
||||
goto err;
|
||||
} else {
|
||||
if(pvh_set_xavi(msg, &xavi_name, hname, NULL, SR_XTYPE_NULL, idx, 0)
|
||||
- < 0)
|
||||
+ == NULL)
|
||||
goto err;
|
||||
}
|
||||
} else if(val->flags & (PV_VAL_STR | PV_TYPE_INT | PV_VAL_INT)) {
|
||||
@@ -641,7 +641,7 @@ int pvh_set_header(
|
||||
}
|
||||
if(idx == 0 && idxf == PV_IDX_NONE) {
|
||||
if(pvh_set_xavi(msg, &xavi_name, hname, &fval, SR_XTYPE_STR, 0, 1)
|
||||
- < 0)
|
||||
+ == NULL)
|
||||
goto err;
|
||||
} else if(idxf == PV_IDX_ALL) {
|
||||
if(hname_cnt > 1) {
|
||||
@@ -651,11 +651,11 @@ int pvh_set_header(
|
||||
}
|
||||
if(pvh_set_xavi(msg, &xavi_name, hname, &fval, SR_XTYPE_STR, 0,
|
||||
hname_cnt ? 0 : 1)
|
||||
- < 0)
|
||||
+ == NULL)
|
||||
goto err;
|
||||
} else {
|
||||
if(pvh_set_xavi(msg, &xavi_name, hname, &fval, SR_XTYPE_STR, idx, 0)
|
||||
- < 0)
|
||||
+ == NULL)
|
||||
goto err;
|
||||
}
|
||||
if(pv_format)
|
||||
@@ -693,7 +693,7 @@ xavp_c_data_t *pvh_set_parsed(
|
||||
if(pvh_merge_uri(msg, SET_URI_T, cur, val, c_data) < 0)
|
||||
goto err;
|
||||
if(pvh_set_xavi(msg, &xavi_parsed_xname, hname, c_data, SR_XTYPE_DATA, 0, 0)
|
||||
- < 0)
|
||||
+ == NULL)
|
||||
goto err;
|
||||
LM_DBG("c_data from pvh_merge_uri hname:%.*s\n", hname->len, hname->s);
|
||||
|
||||
@@ -856,12 +856,12 @@ int pvh_set_uri(struct sip_msg *msg, pv_param_t *param, int op, pv_value_t *val)
|
||||
/* LM_DBG("xavi:%.*s hname:%.*s value:%.*s\n", xavi_name.len, xavi_name.s,
|
||||
hname.len, hname.s, c_data->value.len, c_data->value.s); */
|
||||
if(pvh_set_xavi(msg, &xavi_name, &hname, &c_data->value, SR_XTYPE_STR, 0, 0)
|
||||
- < 0)
|
||||
+ == NULL)
|
||||
goto err;
|
||||
|
||||
if(pvh_set_xavi(
|
||||
msg, &xavi_parsed_xname, &hname, c_data, SR_XTYPE_DATA, 0, 0)
|
||||
- < 0)
|
||||
+ == NULL)
|
||||
goto err;
|
||||
|
||||
if(pv_format)
|
||||
@@ -1126,7 +1126,7 @@ int pvh_set_reply_sr(
|
||||
case 2: // reason
|
||||
if(pvh_set_xavi(msg, &xavi_name, &_hdr_reply_reason, &fval,
|
||||
SR_XTYPE_STR, 0, 0)
|
||||
- < 0) {
|
||||
+ == NULL) {
|
||||
LM_ERR("set reply: cannot set reply reason\n");
|
||||
goto err;
|
||||
}
|
Loading…
Reference in new issue