#### Pre-Submission Checklist - [ ] Commit message has the format required by CONTRIBUTING guide - [ ] Commits are split per component (core, individual modules, libs, utils, ...) - [ ] 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: - [ ] PR should be backported to stable branches - [ ] Tested changes locally - [ ] Related to issue #2167
#### Description Extended t_load_contacts function with the parameter 'mode'. It can be used to define the algorithm to use for ordering the contacts. If 0, or missing, the standard algorithm with be used. If 1, the new weight-based algorithm will be used.
The new algorithm uses the q value as the weight of the branch. Higher is the q value, higher is the probability to be tried as first. Equals q values means equals probability to be tried. Branches with q values equals to 0 or lower are not considered by the ordering algorithm, but just added at the end of the list as backup option if all other branches fail.
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/2178
-- Commit Summary --
* tm: new weight-based call-termination distribution
-- File Changes --
M src/modules/tm/doc/functions.xml (33) M src/modules/tm/t_serial.c (266) M src/modules/tm/t_serial.h (7) M src/modules/tm/tm.c (9)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/2178.patch https://github.com/kamailio/kamailio/pull/2178.diff
I looked quickly trying to see how the existing code was changed, which seems to be mainly moved in a dedicated function. I didn't dig in the new algorithm (mode), being specific for the feature wanted with this PR.
Maybe @juha-h wants to check a bit and see if the old mode (now STANDARD) is not affected somehow.
Otherwise, if nobody else has comments, I am fine to merge.
henningw commented on this pull request.
Thanks for the pull request - I found two things that should be improved before integrating the code.
- return 0;
+} + +/* + * Loads contacts in destination set into contacts_avp in reverse + * proportional order. Each contact is associated with Q_FLAG beacuse + * only one contact at a time has to ring. + */ +int t_load_contacts_proportional(struct contact *contacts, char *sock_buf, int n, unsigned short q_total) +{ + int q_remove, n_rand, idx; + struct contact *curr; + sr_xavp_t *lxavp = NULL; + + /* Initialize the random generator */ + kam_srand(time(NULL));
This is not necessary (and will also overwrite the state for the global one). The random generator is initialized during startup.
@@ -28,14 +28,19 @@
#ifndef _T_SERIAL_H_ #define _T_SERIAL_H_
+#define STANDARD 0
Makes probably sense to qualify the defines, e.g. with T_LOAD_ prefix or similar. Also consider to move them into the respective .c file, if they are not necessary in the .h
@marcocapetta pushed 1 commit.
342db5aface5fe8b5d044517f563a12320c521f4 tm: new weight-based call-termination distribution
Thank you for the change. @juha-h - comments from your side as well?
Merged #2178 into master.
Merged - eventual further changes could be done directly in git master.