- Execute db_redis_consume_replies on failed update same as in db_redis_insert:
if db_redis_perform_update encounters an error it was leaving unconsumed data
thus causing unexpected reply later on when reading from the same connection.
<!-- Kamailio Pull Request Template -->
<!--
IMPORTANT:
- for detailed contributing guidelines, read:
https://github.com/kamailio/kamailio/blob/master/.github/CONTRIBUTING.md
- pull requests must be done to master branch, unless they are backports
of fixes from master branch to a stable branch
- backports to stable branches must be done with 'git cherry-pick -x ...'
- code is contributed under BSD for core and main components (tm, sl, auth, tls)
- code is contributed GPLv2 or a compatible license for the other components
- GPL code is contributed with OpenSSL licensing exception
-->
#### Pre-Submission Checklist
<!-- Go over all points below, and after creating the PR, tick all the checkboxes that apply -->
<!-- All points should be verified, otherwise, read the CONTRIBUTING guidelines from above-->
<!-- If you're unsure about any of these, don't hesitate to ask on sr-dev mailing list -->
- [x] Commit message has the format required by CONTRIBUTING guide
- [x] Commits are split per component (core, individual modules, libs, utils, ...)
- [x] Each component has a single commit (if not, squash them into one commit)
- [ ] No commits to README files for modules (changes must be done to docbook files
in `doc/` subfolder, the README file is autogenerated)
#### Type Of Change
- [ ] Small bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds new functionality)
- [ ] Breaking change (fix or feature that would change existing functionality)
#### Checklist:
<!-- Go over all points below, and after creating the PR, tick the checkboxes that apply -->
- [ ] PR should be backported to stable branches
- [ ] Tested changes locally
- [ ] Related to issue #XXXX (replace XXXX with an open issue number)
#### Description
<!-- Describe your changes in detail -->
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/2960
-- Commit Summary --
* db_redis: don't leave unconsumed redis replies in case of error on update
-- File Changes --
M src/modules/db_redis/redis_dbase.c (2)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/2960.patchhttps://github.com/kamailio/kamailio/pull/2960.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/2960
Module: kamailio
Branch: master
Commit: bbd7b2ed5827252680e9d8949c193699da0a76b2
URL: https://github.com/kamailio/kamailio/commit/bbd7b2ed5827252680e9d8949c19369…
Author: Andrii Pogrebennyk <andrii(a)ng-voice.com>
Committer: Andrii Pogrebennyk <andrii(a)ng-voice.com>
Date: 2021-11-28T08:34:36+01:00
db_redis: don't leave unconsumed redis replies in case of error on update
Execute db_redis_consume_replies on failed update same as in db_redis_insert:
if db_redis_perform_update encounters an error it was leaving unconsumed data
thus causing unexpected reply later on when reading from the same connection.
---
Modified: src/modules/db_redis/redis_dbase.c
---
Diff: https://github.com/kamailio/kamailio/commit/bbd7b2ed5827252680e9d8949c19369…
Patch: https://github.com/kamailio/kamailio/commit/bbd7b2ed5827252680e9d8949c19369…
---
diff --git a/src/modules/db_redis/redis_dbase.c b/src/modules/db_redis/redis_dbase.c
index f7e26e693e..a53d1a3443 100644
--- a/src/modules/db_redis/redis_dbase.c
+++ b/src/modules/db_redis/redis_dbase.c
@@ -2249,6 +2249,7 @@ static int db_redis_perform_update(const db1_con_t* _h, km_redis_con_t *con, con
db_redis_key_free(&all_type_keys);
db_redis_key_free(&new_type_keys);
+ db_redis_consume_replies(con);
return 0;
error:
@@ -2260,6 +2261,7 @@ static int db_redis_perform_update(const db1_con_t* _h, km_redis_con_t *con, con
db_redis_key_free(&type_keys);
db_redis_key_free(&set_keys);
db_redis_key_free(&new_type_keys);
+ db_redis_consume_replies(con);
return -1;
}
As suggested in previous PR (#2936).
This is much more flexible as it can also handle sub XAVPs, and indexes.
This ended up being more complicated than I anticipated, but I wanted to handle all possible cases.
The tests I performed are detailled after, they should cover every possible use case.
#### Type Of Change
- [x] New feature (non-breaking change which adds new functionality)
#### Checklist:
- [x] Tested changes locally
#### Description
Allows counting XAVPs with `$cnt($xavp(...))`
In addition to the `$cnt($avp(...))` - which is not modified.
/* Usage:
*
* $cnt($xavp(key[*])) : number of XAVPs "key".
* $cnt($xavp(key[n]=>sub[*])) : number of children "sub" in XAVP "key[n]".
* $cnt($xavp(key[*]=>sub[*])) : total number of children "sub" in all XAVPs "key".
*
* $cnt($xavp(key[n])) : 1 or 0 (if this index exists or not).
* $cnt($xavp(key[-n])) : same but with reverse indexing (-1 is the last index).
*
* $cnt($xavp(key[*]=>sub[n])) : number of children "sub[n]" that exist in all XAPVs "key".
*
* $cnt($xavp(key)) is the same as $cnt($xavp(key[*])).
* $cnt($xavp(key=>sub)) is the same as $cnt($xavp(key[*]=>sub[*])).
*
* Note: Usually for a XAVP no index means "index 0", not all.
* But this would be less intuitive in our case for counting.
*/
#### Tests
I tried to be exhaustive. All the test cases below do work as expected.
```
$xavp(case1) = "case1.value1";
$xavp(case1) = "case1.value2";
$xavp(case1) = "case1.value3";
$xavp(case2=>sub1) = "case2.value1 sub1.value1";
$xavp(case2[0]=>sub1) = "case2.value1 sub1.value2";
$xavp(case2[0]=>sub1) = "case2.value1 sub1.value3";
$xavp(case2[0]=>sub2) = "case2.value1 sub2.value1";
$xavp(case2[0]=>sub2) = "case2.value1 sub2.value2";
# => will become case2[1] after adding the next entry
$xavp(case2=>sub1) = "case2.value2 sub1.value1";
$xavp(case2[0]=>sub1) = "case2.value2 sub1.value2";
xlog("L_INFO", "----------- TESTS $$cnt($$xavp...) - root XAVPs with no sub XAVPs\n");
xlog("L_INFO", "xavp(case1[0]) : value = $xavp(case1[0]) : cnt (expect: 1) = $cnt($xavp(case1[0]))\n");
xlog("L_INFO", "xavp(case1[1]) : value = $xavp(case1[1]) : cnt (expect: 1) = $cnt($xavp(case1[1]))\n");
xlog("L_INFO", "xavp(case1[-1]) : value = $xavp(case1[-1]) : cnt (expect: 1) = $cnt($xavp(case1[-1]))\n");
xlog("L_INFO", "xavp(case1[-2]) : value = $xavp(case1[-2]) : cnt (expect: 1) = $cnt($xavp(case1[-2]))\n");
xlog("L_INFO", "xavp(case1[-66]) : value = $xavp(case1[-66]) : cnt (expect: 0) = $cnt($xavp(case1[-66]))\n");
xlog("L_INFO", "xavp(case1[66]) : value = $xavp(case1[66]) : cnt (expect: 0) = $cnt($xavp(case1[66]))\n");
xlog("L_INFO", "xavp(case1[*]) : cnt (expect: 3) = $cnt($xavp(case1[*]))\n");
xlog("L_INFO", "xavp(case1) : cnt (expect: 3) = $cnt($xavp(case1))\n");
xlog("L_INFO", "xavp(case1=>sub) : cnt (expect: 0) = $cnt($xavp(case1=>sub))\n");
xlog("L_INFO", "xavp(case1[0]=>sub) : cnt (expect: 0) = $cnt($xavp(case1[0]=>sub))\n");
xlog("L_INFO", "xavp(case1[0]=>sub[0]) : value = $xavp(case1[0]=>sub[0]) : cnt (expect: 0) = $cnt($xavp(case1[0]=>sub[0]))\n");
xlog("L_INFO", "----------- TESTS $$cnt($$xavp...) - root XAVPs using single index\n");
xlog("L_INFO", "xavp(case2[1]=>sub1[0]) : value = $xavp(case2[1]=>sub1[0]) : cnt (expect: 1) = $cnt($xavp(case2[1]=>sub1[0]))\n");
xlog("L_INFO", "xavp(case2[1]=>sub1[-1]) : value = $xavp(case2[1]=>sub1[-1]) : cnt (expect: 1) = $cnt($xavp(case2[1]=>sub1[-1]))\n");
xlog("L_INFO", "xavp(case2[1]=>sub1[3]) : value = $xavp(case2[1]=>sub1[3]) : cnt (expect: 0) = $cnt($xavp(case2[1]=>sub1[3]))\n");
xlog("L_INFO", "xavp(case2[1]=>sub1[*]) : cnt (expect: 3) = $cnt($xavp(case2[1]=>sub1[*]))\n");
xlog("L_INFO", "xavp(case2[1]=>sub1) : cnt (expect: 3) = $cnt($xavp(case2[1]=>sub1))\n");
xlog("L_INFO", "xavp(case2[1]=>sub2[*]) : cnt (expect: 2) = $cnt($xavp(case2[1]=>sub2[*]))\n");
xlog("L_INFO", "xavp(case2[1]=>sub2) : cnt (expect: 2) = $cnt($xavp(case2[1]=>sub2))\n");
xlog("L_INFO", "xavp(case2[66]=>sub1) : cnt (expect: 0) = $cnt($xavp(case2[66]=>sub1))\n");
xlog("L_INFO", "xavp(case2[66]=>sub1[0]) : cnt (expect: 0) = $cnt($xavp(case2[66]=>sub1[0]))\n");
xlog("L_INFO", "----------- TESTS $$cnt($$xavp...) - root XAVPs using all index\n");
xlog("L_INFO", "xavp(case2=>sub1) : cnt (expect: 5) = $cnt($xavp(case2=>sub1))\n");
xlog("L_INFO", "xavp(case2=>sub1[*]) : cnt (expect: 5) = $cnt($xavp(case2=>sub1[*]))\n");
xlog("L_INFO", "xavp(case2[*]=>sub1) : cnt (expect: 5) = $cnt($xavp(case2[*]=>sub1))\n");
xlog("L_INFO", "xavp(case2[*]=>sub1[*]) : cnt (expect: 5) = $cnt($xavp(case2[*]=>sub1[*]))\n");
xlog("L_INFO", "xavp(case2[*]=>sub1) : cnt (expect: 5) = $cnt($xavp(case2[*]=>sub1))\n");
xlog("L_INFO", "xavp(case2[*]=>sub1[0]) : cnt (expect: 2) = $cnt($xavp(case2[*]=>sub1[0]))\n");
xlog("L_INFO", "xavp(case2[*]=>sub1[2]) : cnt (expect: 1) = $cnt($xavp(case2[*]=>sub1[2]))\n");
xlog("L_INFO", "xavp(case2[*]=>sub1[-1]) : cnt (expect: 2) = $cnt($xavp(case2[*]=>sub1[-1]))\n");
xlog("L_INFO", "xavp(case2[*]=>sub2) : cnt (expect: 2) = $cnt($xavp(case2[*]=>sub2))\n");
xlog("L_INFO", "xavp(case2[*]=>sub2[*]) : cnt (expect: 2) = $cnt($xavp(case2[*]=>sub2[*]))\n");
#xlog("L_INFO", "----------- TESTS $$cnt(...) - parsing errors\n");
# parsing error => server fails to start
#xlog("L_INFO", "PARSE ERROR: $cnt($xavu(test))\n");
#xlog("L_INFO", "PARSE ERROR: $cnt($var(test))\n");
#xlog("L_INFO", "PARSE ERROR: $cnt($unknown(test))\n");
```
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/2940
-- Commit Summary --
* pv: extend $cnt to work with $xavp
-- File Changes --
M src/modules/pv/pv_core.c (156)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/2940.patchhttps://github.com/kamailio/kamailio/pull/2940.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/2940
Module: kamailio
Branch: master
Commit: 557952f00bff4e9e70a41cad0be22c2f545f3c22
URL: https://github.com/kamailio/kamailio/commit/557952f00bff4e9e70a41cad0be22c2…
Author: Kamailio Dev <kamailio.dev(a)kamailio.org>
Committer: Kamailio Dev <kamailio.dev(a)kamailio.org>
Date: 2021-11-30T08:46:13+01:00
modules: readme files regenerated - presence ... [skip ci]
---
Modified: src/modules/presence/README
---
Diff: https://github.com/kamailio/kamailio/commit/557952f00bff4e9e70a41cad0be22c2…
Patch: https://github.com/kamailio/kamailio/commit/557952f00bff4e9e70a41cad0be22c2…
---
diff --git a/src/modules/presence/README b/src/modules/presence/README
index eb59dec135..c06ccdd6ec 100644
--- a/src/modules/presence/README
+++ b/src/modules/presence/README
@@ -899,8 +899,9 @@ modparam("presence", "timer_mode", 0)
3.38. subs_respond_200 (integer)
Specify the response code for accepted SUBSCRIBE requests. If set to 0,
- 202 Accepted will be returned. If set to 1, 200 OK will be returned
- instead, in conformance to RFC6665 which prohibits 202 responses.
+ "202 Accepted" will be returned (default behaviour till version 5.5).
+ If set to 1, "200 OK" will be returned instead, in conformance to
+ RFC6665, which prohibits 202 responses.
Default value is 1.
Module: kamailio
Branch: master
Commit: 1ef340457d0bddd8b15be2195c0a9d5d79f88d12
URL: https://github.com/kamailio/kamailio/commit/1ef340457d0bddd8b15be2195c0a9d5…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-11-30T08:33:34+01:00
presence: docs - note the version for default behaviour change on 202 reply
---
Modified: src/modules/presence/doc/presence_admin.xml
---
Diff: https://github.com/kamailio/kamailio/commit/1ef340457d0bddd8b15be2195c0a9d5…
Patch: https://github.com/kamailio/kamailio/commit/1ef340457d0bddd8b15be2195c0a9d5…
---
diff --git a/src/modules/presence/doc/presence_admin.xml b/src/modules/presence/doc/presence_admin.xml
index 764aa26a56..25e43ef0b6 100644
--- a/src/modules/presence/doc/presence_admin.xml
+++ b/src/modules/presence/doc/presence_admin.xml
@@ -983,10 +983,10 @@ modparam("presence", "timer_mode", 0)
<section id="presence.p.subs_respond_200">
<title><varname>subs_respond_200</varname> (integer)</title>
<para>
- Specify the response code for accepted SUBSCRIBE requests.
- If set to 0, 202 Accepted will be returned.
- If set to 1, 200 OK will be returned instead, in conformance to RFC6665
- which prohibits 202 responses.
+ Specify the response code for accepted SUBSCRIBE requests. If set to 0,
+ "202 Accepted" will be returned (default behaviour till version 5.5). If set
+ to 1, "200 OK" will be returned instead, in conformance to RFC6665, which
+ prohibits 202 responses.
</para>
<para>
<emphasis>
Module: kamailio
Branch: master
Commit: 7a01a991b9012918130b131336a988a5f9fc4285
URL: https://github.com/kamailio/kamailio/commit/7a01a991b9012918130b131336a988a…
Author: Kamailio Dev <kamailio.dev(a)kamailio.org>
Committer: Kamailio Dev <kamailio.dev(a)kamailio.org>
Date: 2021-11-30T08:31:19+01:00
modules: readme files regenerated - presence ... [skip ci]
---
Modified: src/modules/presence/README
---
Diff: https://github.com/kamailio/kamailio/commit/7a01a991b9012918130b131336a988a…
Patch: https://github.com/kamailio/kamailio/commit/7a01a991b9012918130b131336a988a…
---
diff --git a/src/modules/presence/README b/src/modules/presence/README
index 94dd0adcd6..eb59dec135 100644
--- a/src/modules/presence/README
+++ b/src/modules/presence/README
@@ -902,11 +902,11 @@ modparam("presence", "timer_mode", 0)
202 Accepted will be returned. If set to 1, 200 OK will be returned
instead, in conformance to RFC6665 which prohibits 202 responses.
- Default value is 0.
+ Default value is 1.
Example 1.38. Set subs_respond_200 parameter
...
-modparam("presence", "subs_respond_200", 1)
+modparam("presence", "subs_respond_200", 0)
...
4. Functions
<!-- Kamailio Pull Request Template -->
<!--
IMPORTANT:
- for detailed contributing guidelines, read:
https://github.com/kamailio/kamailio/blob/master/.github/CONTRIBUTING.md
- pull requests must be done to master branch, unless they are backports
of fixes from master branch to a stable branch
- backports to stable branches must be done with 'git cherry-pick -x ...'
- code is contributed under BSD for core and main components (tm, sl, auth, tls)
- code is contributed GPLv2 or a compatible license for the other components
- GPL code is contributed with OpenSSL licensing exception
-->
#### Pre-Submission Checklist
<!-- Go over all points below, and after creating the PR, tick all the checkboxes that apply -->
<!-- All points should be verified, otherwise, read the CONTRIBUTING guidelines from above-->
<!-- If you're unsure about any of these, don't hesitate to ask on sr-dev mailing list -->
- [x] Commit message has the format required by CONTRIBUTING guide
- [x] Commits are split per component (core, individual modules, libs, utils, ...)
- [x] Each component has a single commit (if not, squash them into one commit)
- [x] No commits to README files for modules (changes must be done to docbook files
in `doc/` subfolder, the README file is autogenerated)
#### Type Of Change
- [ ] Small bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds new functionality)
- [x] Breaking change (fix or feature that would change existing functionality)
#### Checklist:
<!-- Go over all points below, and after creating the PR, tick the checkboxes that apply -->
- [ ] PR should be backported to stable branches
- [ ] Tested changes locally
- [x] Related to issue #2930
#### Description
See https://github.com/kamailio/kamailio/pull/2930#issuecomment-971748854.
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/2949
-- Commit Summary --
* presence: return 200 instead of 202 by default
-- File Changes --
M src/modules/presence/doc/presence_admin.xml (4)
M src/modules/presence/presence.c (2)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/2949.patchhttps://github.com/kamailio/kamailio/pull/2949.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/2949