<!-- 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 - [x] 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 - [x] 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/2474
-- Commit Summary --
* WIP
-- File Changes --
M src/modules/keepalive/keepalive.h (1) M src/modules/keepalive/keepalive_api.c (23) M src/modules/keepalive/keepalive_core.c (4)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/2474.patch https://github.com/kamailio/kamailio/pull/2474.diff
@linuxmaniac requested changes on this pull request.
- lock_get(target->lock);
+ free_destination(target); // Lock is released and freed in this free function if(!head){ LM_DBG("There isn't any head so maybe it is first \r\n"); ka_destinations_list->first = target->next; - free_destination(target); - ka_unlock_destination_list(); - return 1; + } else { + head->next = target->next; } - head->next = target->next; - free_destination(target); ka_unlock_destination_list();
You can't call free_destination(target) and after that use target
@NGSegovia pushed 1 commit.
7a8641a1e71721f0383dc0eb818f9b851e9923f3 keepalive: prevent race condition when deleting a destination
@NGSegovia commented on this pull request.
- lock_get(target->lock);
+ free_destination(target); // Lock is released and freed in this free function if(!head){ LM_DBG("There isn't any head so maybe it is first \r\n"); ka_destinations_list->first = target->next; - free_destination(target); - ka_unlock_destination_list(); - return 1; + } else { + head->next = target->next; } - head->next = target->next; - free_destination(target); ka_unlock_destination_list();
Opps, thanks for the catch @linuxmaniac
@NGSegovia commented on this pull request.
- lock_get(target->lock);
+ free_destination(target); // Lock is released and freed in this free function if(!head){ LM_DBG("There isn't any head so maybe it is first \r\n"); ka_destinations_list->first = target->next; - free_destination(target); - ka_unlock_destination_list(); - return 1; + } else { + head->next = target->next; } - head->next = target->next; - free_destination(target); ka_unlock_destination_list();
Fixed
@NGSegovia pushed 1 commit.
c94e5416a67615971df051af117081a5a9dcca61 keepalive: prevent race condition when deleting a destination
@NGSegovia pushed 1 commit.
fe5911e233fbef6722c0f262203430987446e8ad keepalive: prevent race condition when deleting a destination
@NGSegovia pushed 1 commit.
fb115679228b19944f886893b47743db44465072 keepalive: prevent race condition when deleting a destination
I am going to merge this PR if no other comments. No deep review done by me, I am not using the module.
@NGSegovia - as a matter of fact, give that you seem to work closely with this module, we can grant you git commit access if you want to take over the maintenance of this module. The original developer of the module is no longer working in VoIP space related to it. Even with git commit access, you should consider using the pull requests process for major changes to the module, other devs may have useful feedback before merging.
On another plan, not being really familiar with the code of the module, but based on what I could figure out so far, as general remarks, the keepalive module seems to be designed for dealing with rather small number of destinations, keeping a single linked list. Moreover, it uses the main core time which can affect performance and impact retransmissions of routing SIP requests if it is overloaded by large number of keepalive tasks or the event callbacks executed by keepalive are slow. If someone plans to use it for large number of addresses, it should seriously consider redesigning some internal parts of this module to be more scalable (e.g., use hash table instead of single list, own timer processes, etc...).
Thanks @miconda , that would be a pleasure. We are using this module so I think I can take it.
About the number of destinations, I had the same impression but I was surprised by some feedback in this comment https://github.com/kamailio/kamailio/issues/2448#issuecomment-689451262. Anyway, I still think this module has limitations in that regard.
@NGSegovia - developer invitation sent, you can merge at your convenience, provided no other comments are done.
Received @miconda! Thanks!
Merged #2474 into master.