[sr-dev] git:master:501c41dd: db_mongodb: re-init iterator and search again if fails to find from crt position

2017-03-06 Thread Daniel-Constantin Mierla
Module: kamailio
Branch: master
Commit: 501c41dd35fb9f15fdf96f4f3778860395e37a84
URL: 
https://github.com/kamailio/kamailio/commit/501c41dd35fb9f15fdf96f4f3778860395e37a84

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2017-03-07T08:56:37+01:00

db_mongodb: re-init iterator and search again if fails to find from crt position

---

Modified: src/modules/db_mongodb/mongodb_dbase.c

---

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

---

diff --git a/src/modules/db_mongodb/mongodb_dbase.c 
b/src/modules/db_mongodb/mongodb_dbase.c
index f4316ae..759b1c6 100644
--- a/src/modules/db_mongodb/mongodb_dbase.c
+++ b/src/modules/db_mongodb/mongodb_dbase.c
@@ -377,9 +377,16 @@ int db_mongodb_get_columns(const db1_con_t* _h, db1_res_t* 
_r)
LM_DBG("Found a field[%d] named: %s\n", col, colname);
if(mgres->colsdoc) {
if(!bson_iter_find(, colname)) {
-   LM_ERR("field [%s] not found in result 
iterator\n",
-   colname);
-   return -4;
+   /* re-init the iterator */
+   if (!bson_iter_init (, mgres->rdoc)) {
+   LM_ERR("failed to initialize result 
iterator\n");
+   return -3;
+   }
+   if(!bson_iter_find(, colname)) {
+   LM_ERR("field [%s] not found in result 
iterator\n",
+   colname);
+   return -4;
+   }
}
coltype = bson_iter_type();
} else {


___
sr-dev mailing list
sr-dev@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] [kamailio/kamailio] Misdirected packets with NAT and topos loaded (#1005)

2017-03-06 Thread dryvoip
As an added datapoint I did update to 5.0.0 and grabbed the lastest topos from 
github and there was no improvement.

I am happy to put up a small bounty if you or anyone else is able to dedicate 
some time to resolve these two use cases in a timely manner.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/1005#issuecomment-284530711___
sr-dev mailing list
sr-dev@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] [kamailio/kamailio] app_perl.so: undefined symbol: sv2int_str (#1012)

2017-03-06 Thread James Cloos
It turns out this inline difference is not a bug but rather a C89 vs C11
difference, and gcc5 switched from -std=gnu89 to -std=gnu11 by default.

So removing the inline is not a bad idea.

Or better yet adding static.

I'll send a pull request for adding static to that declaration.

A quick test shows that adding static works.

-JimC
-- 
James Cloos  OpenPGP: 0x997A9F17ED7DAEA6


-- 
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/1012#issuecomment-284457010___
sr-dev mailing list
sr-dev@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] [kamailio/kamailio] Make app_perl’s sv2int_str() static (#1020)

2017-03-06 Thread James Cloos
The function is only called from the xs file, and C11’s inline
semantics mean that gcc-5 and later miscompile this file when
no optimization is specified.

Signed-off-by: James Cloos 
You can view, comment on, or merge this pull request online at:

  https://github.com/kamailio/kamailio/pull/1020

-- Commit Summary --

  * Make app_perl’s sv2int_str() static

-- File Changes --

M src/modules/app_perl/kamailioxs.xs (2)

-- Patch Links --

https://github.com/kamailio/kamailio/pull/1020.patch
https://github.com/kamailio/kamailio/pull/1020.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/1020
___
sr-dev mailing list
sr-dev@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] [kamailio/kamailio] app_perl.so: undefined symbol: sv2int_str (#1012)

2017-03-06 Thread James Cloos
> "DM" == Daniel-Constantin Mierla  writes:

DM> If the function is not used in the same object (source file) only,
DM> then inline should be removed,

It is only used in the .xs file where it is defined.

Without optimization gcc (at least gcc 5) leaves it in the .o file as an
undefined symbol.

I just duplicated what kamailio master does to make(1) kamailioxs.s, but
with -S instead of -c.  The four places where sv2int_str() is called
show up as:

callsv2int_str@PLT

With -O2 or -O1 it gets inlined.

So it seems that w/o optimization gcc5 fails to inline the function at
its call sites, but also leaves it out because it was defined as inline.

Gcc-4.8, OTOH, compiles it as a non-inlined function called run w/o
optimization.

So this is a gcc bug which kamailio can work around by optimizing.

I see in Makefile.defs that CC_OPT defaults to -O3 when using clang.
And before that it is ?='ed to -O9.  But that -O9 didn't make it into
the gcc calls when I tried compiling with Q=0.


To test, make kama however you normally do, then:

   cd src/modules/app_perl
   rm kamailioxs.o
   make kamailioxs.o Q=0

copy the resulting cc line, replacing -c with -S and kamailioxs.o with
kamailioxs.s and search for sv2int_str in that kamailioxs.s.

-JimC
-- 
James Cloos  OpenPGP: 0x997A9F17ED7DAEA6


-- 
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/1012#issuecomment-284442048___
sr-dev mailing list
sr-dev@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] [kamailio/kamailio] Anyone thinking about adding JWT (JSON Web Token) support to Kamailio (#29)

2017-03-06 Thread bwiles-vysk
I am writing a JWT module now.  I'll create a pull request when it's ready.

-- 
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/29#issuecomment-284425599___
sr-dev mailing list
sr-dev@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:f1f0dbbb: kazoo : add consistent worker binding option

2017-03-06 Thread Luis Azedo
Module: kamailio
Branch: master
Commit: f1f0dbbbde0bfbe1162deca4f70c3c3969bf99d0
URL: 
https://github.com/kamailio/kamailio/commit/f1f0dbbbde0bfbe1162deca4f70c3c3969bf99d0

Author: Luis Azedo 
Committer: Luis Azedo 
Date: 2017-03-06T12:06:48Z

kazoo : add consistent worker binding option

---

Modified: src/modules/kazoo/kz_amqp.c
Modified: src/modules/kazoo/kz_amqp.h

---

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

---

diff --git a/src/modules/kazoo/kz_amqp.c b/src/modules/kazoo/kz_amqp.c
index a962d99..05e8407 100644
--- a/src/modules/kazoo/kz_amqp.c
+++ b/src/modules/kazoo/kz_amqp.c
@@ -1551,6 +1551,7 @@ int kz_amqp_subscribe(struct sip_msg* msg, char* payload)
int no_ack = 1;
int federate = 0;
int wait_for_consumer_ack = 1;
+int consistent_worker = 0;
 
 json_obj_ptr json_obj = NULL;
struct json_object* tmpObj = NULL;
@@ -1607,6 +1608,11 @@ int kz_amqp_subscribe(struct sip_msg* msg, char* payload)
federate = json_object_get_int(tmpObj);
 }
 
+tmpObj = kz_json_get_object(json_obj, "consistent-worker");
+if(tmpObj != NULL) {
+consistent_worker = json_object_get_int(tmpObj);
+}
+
kz_amqp_bind_ptr bind = kz_amqp_bind_alloc(_s, 
_type_s, _s, _key_s);
if(bind == NULL) {
LM_ERR("Could not allocate bind struct\n");
@@ -1620,6 +1626,7 @@ int kz_amqp_subscribe(struct sip_msg* msg, char* payload)
bind->no_ack = no_ack;
bind->wait_for_consumer_ack = wait_for_consumer_ack;
bind->federate = federate;
+bind->consistent_worker = consistent_worker;
 
 
kz_amqp_binding_ptr binding = shm_malloc(sizeof(kz_amqp_binding));
@@ -2571,6 +2578,7 @@ void kz_amqp_send_worker_event(int _kz_server_id, 
amqp_envelope_t* envelope, kz_
 kz_amqp_consumer_delivery_ptr ptr = NULL;
 str* message_id = NULL;
 int idx = envelope->channel-1;
+int worker = 0;
 
 json_obj_ptr json_obj = kz_json_parse((char*)envelope->message.body.bytes);
 if (json_obj == NULL) {
@@ -2617,12 +2625,21 @@ void kz_amqp_send_worker_event(int _kz_server_id, 
amqp_envelope_t* envelope, kz_
ptr->event_subkey = kz_amqp_bytes_dup(bind->event_subkey);
}
 
-   consumer++;
-   if(consumer >= dbk_consumer_workers) {
-   consumer = 0;
-   }
+if(bind && bind->consistent_worker) {
+str rk;
+rk.s = (char*)envelope->routing_key.bytes;
+rk.len = (int)envelope->routing_key.len;
+worker = core_hash(, NULL, dbk_consumer_workers);
+LM_DBG("computed worker for %.*s is %d\n", rk.len, rk.s, worker);
+} else {
+consumer++;
+if(consumer >= dbk_consumer_workers) {
+consumer = 0;
+}
+worker = consumer;
+}
 
-   if (write(kz_worker_pipes[consumer], , sizeof(ptr)) != sizeof(ptr)) 
{
+   if (write(kz_worker_pipes[worker], , sizeof(ptr)) != sizeof(ptr)) {
LM_ERR("failed to send payload to consumer %d : %s\nPayload 
%s\n", consumer, strerror(errno), ptr->payload);
goto error;
}
diff --git a/src/modules/kazoo/kz_amqp.h b/src/modules/kazoo/kz_amqp.h
index 6aa36b8..7c5e6e8 100644
--- a/src/modules/kazoo/kz_amqp.h
+++ b/src/modules/kazoo/kz_amqp.h
@@ -183,6 +183,7 @@ typedef struct {
amqp_boolean_t no_ack;
amqp_boolean_t wait_for_consumer_ack;
amqp_boolean_t federate;
+amqp_boolean_t consistent_worker;
 } kz_amqp_bind, *kz_amqp_bind_ptr;
 
 typedef struct {


___
sr-dev mailing list
sr-dev@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] [kamailio/kamailio] siputils: added is_alphanumex(tval, eset) function (76c5da5)

2017-03-06 Thread Daniel-Constantin Mierla
The functions was removed accidentally. I reintroduced it. Thanks!

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/commit/76c5da5ec048cd62c0f3cab6bf38aef5f3c19248#commitcomment-21162281___
sr-dev mailing list
sr-dev@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:2d0a0d8d: siputils: reintroduced the c function for is_alphanum()

2017-03-06 Thread Daniel-Constantin Mierla
Module: kamailio
Branch: master
Commit: 2d0a0d8decbad9cea3d603a5067b6656d659cbf6
URL: 
https://github.com/kamailio/kamailio/commit/2d0a0d8decbad9cea3d603a5067b6656d659cbf6

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2017-03-06T09:16:12+01:00

siputils: reintroduced the c function for is_alphanum()

- accidentaly stripped when adding is_alphanumex()
- reported by Carsten Bock

---

Modified: src/modules/siputils/checks.c
Modified: src/modules/siputils/checks.h
Modified: src/modules/siputils/siputils.c

---

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

---

diff --git a/src/modules/siputils/checks.c b/src/modules/siputils/checks.c
index cfddfda..ca6991f 100644
--- a/src/modules/siputils/checks.c
+++ b/src/modules/siputils/checks.c
@@ -807,11 +807,38 @@ int is_numeric(sip_msg_t *msg, char *_sp, char* _s2)
return 1;
 }
 
+
+/*
+ * Check if the parameter contains alphanumeric characters
+ */
+int ksr_is_alphanum(sip_msg_t *msg, char *_sp, char* _s2)
+{
+   str tval = {0, 0};
+   int i;
+
+   if(fixup_get_svalue(msg, (gparam_t*)_sp, )!=0) {
+   LM_ERR("cannot get parameter value\n");
+   return -1;
+   }
+   if(tval.len<=0)
+   return -2;
+
+   i = 0;
+   for(; i='0' && tval.s[i]<='9')
+   || (tval.s[i]>='A' && tval.s[i]<='Z')
+   || (tval.s[i]>='z' && tval.s[i]<='z')) )
+   return -3;
+   }
+
+   return 1;
+}
+
 /*
  * Check if the parameter contains alphanumeric characters or are part of
  * the second parameter
  */
-int is_alphanumex(sip_msg_t *msg, char *_sp, char* _se)
+int ksr_is_alphanumex(sip_msg_t *msg, char *_sp, char* _se)
 {
str tval = {0, 0};
str eset = {0, 0};
diff --git a/src/modules/siputils/checks.h b/src/modules/siputils/checks.h
index f071e24..39a575d 100644
--- a/src/modules/siputils/checks.h
+++ b/src/modules/siputils/checks.h
@@ -127,12 +127,12 @@ int is_numeric(sip_msg_t *msg, char *_sp, char* _s2);
 /*
  * Check if the parameter contains alphanumeric characters
  */
-int is_alphanum(sip_msg_t *msg, char *_sp, char* _s2);
+int ksr_is_alphanum(sip_msg_t *msg, char *_sp, char* _s2);
 
 /*
  * Check if the parameter contains alphanumeric characters or are part of
  * the second parameter
  */
-int is_alphanumex(sip_msg_t *msg, char *_sp, char* _se);
+int ksr_is_alphanumex(sip_msg_t *msg, char *_sp, char* _se);
 
 #endif /* CHECKS_H */
diff --git a/src/modules/siputils/siputils.c b/src/modules/siputils/siputils.c
index f01bf6f..519e82b 100644
--- a/src/modules/siputils/siputils.c
+++ b/src/modules/siputils/siputils.c
@@ -179,9 +179,9 @@ static cmd_export_t cmds[]={
0, ANY_ROUTE},
{"is_numeric", (cmd_function)is_numeric, 1, 
fixup_spve_null,
0, ANY_ROUTE},
-   {"is_alphanum", (cmd_function)is_alphanum,   1, 
fixup_spve_null,
+   {"is_alphanum", (cmd_function)ksr_is_alphanum,   1, 
fixup_spve_null,
0, ANY_ROUTE},
-   {"is_alphanumex", (cmd_function)is_alphanumex,   2, 
fixup_spve_spve,
+   {"is_alphanumex", (cmd_function)ksr_is_alphanumex,   2, 
fixup_spve_spve,
0, ANY_ROUTE},
{"sip_p_charging_vector", (cmd_function)sip_handle_pcv,  1, 
fixup_spve_null,
fixup_free_spve_null, ANY_ROUTE},


___
sr-dev mailing list
sr-dev@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev