Module: kamailio
Branch: master
Commit: d613b328b9f99f7cf739c082deede5d4d48b00de
URL:
https://github.com/kamailio/kamailio/commit/d613b328b9f99f7cf739c082deede5d…
Author: jaybeepee <jason.penton(a)gmail.com>
Committer: jaybeepee <jason.penton(a)gmail.com>
Date: 2015-09-11T12:00:30+02:00
modules/cdp: changed load balancing timer from second resolution to millisecond resolution
(reverted from commit 64054ac9506d45171ee8f607fc9bff5763c144dc)
---
Modified: modules/cdp/routing.c
Modified: modules/cdp/session.c
---
Diff:
https://github.com/kamailio/kamailio/commit/d613b328b9f99f7cf739c082deede5d…
Patch:
https://github.com/kamailio/kamailio/commit/d613b328b9f99f7cf739c082deede5d…
---
diff --git a/modules/cdp/routing.c b/modules/cdp/routing.c
index 5bd494d..81db889 100644
--- a/modules/cdp/routing.c
+++ b/modules/cdp/routing.c
@@ -47,7 +47,6 @@
#include "config.h"
#include "peermanager.h"
#include "diameter_api.h"
-#include "math.h"
#define LB_MAX_PEERS 20 /**< maximum peers that can be loadbalanced accross i.e.
same metric */
@@ -83,7 +82,6 @@ peer* get_first_connected_route(cdp_session_t* cdp_session,
routing_entry *r, in
peer *p;
int j;
time_t least_recent_time;
- struct timespec time_spec;
if (cdp_session) {
/*try and find an already used peer for this session - sticky*/
@@ -127,20 +125,13 @@ peer* get_first_connected_route(cdp_session_t* cdp_session,
routing_entry *r, in
}
least_recent_time = peers[0]->last_selected;
- LM_DBG("peer [%.*s] was last used @ %ld\n", peers[0]->fqdn.len,
peers[0]->fqdn.s, peers[0]->last_selected);
p = peers[0];
for (j = 1; j < peer_count; j++) {
- LM_DBG("Peer [%.*s] was last used at [%ld]\n", peers[j]->fqdn.len,
peers[j]->fqdn.s, peers[j]->last_selected);
if (peers[j]->last_selected < least_recent_time) {
least_recent_time = peers[j]->last_selected;
p = peers[j];
}
}
-
- clock_gettime(CLOCK_REALTIME, &time_spec);
-
- p->last_selected = (time_spec.tv_sec*1000000) + round(time_spec.tv_nsec / 1.0e3);
// Convert nanoseconds to microseconds
- LM_DBG("chosen peer [%.*s]\n", p->fqdn.len, p->fqdn.s);
if (cdp_session) {
if (cdp_session->sticky_peer_fqdn_buflen <= p->fqdn.len) {
@@ -159,7 +150,7 @@ peer* get_first_connected_route(cdp_session_t* cdp_session,
routing_entry *r, in
cdp_session->sticky_peer_fqdn.len = p->fqdn.len;
memcpy(cdp_session->sticky_peer_fqdn.s, p->fqdn.s, p->fqdn.len);
}
-
+ p->last_selected = time(NULL);
return p;
}
diff --git a/modules/cdp/session.c b/modules/cdp/session.c
index 716048f..c048a05 100644
--- a/modules/cdp/session.c
+++ b/modules/cdp/session.c
@@ -587,7 +587,6 @@ AAASession* cdp_new_auth_session(str id,int is_client,int
is_statefull)
s->u.auth.lifetime=0;
s->u.auth.grace_period=0;
s->u.auth.class = AUTH_CLASS_UNKNOWN;
- s->u.auth.last_requested_grace = s->u.auth.last_requested_lifetime
= s->u.auth.last_requested_timeout = 0;
cdp_add_session(s);
}
return s;