Skip to content

Commit

Permalink
🐛 syntax errors
Browse files Browse the repository at this point in the history
  • Loading branch information
spacetourist committed Mar 28, 2024
1 parent 44068d7 commit fccf7ec
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
9 changes: 4 additions & 5 deletions modules/load_balancer/lb_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ static int get_dst_load(struct lb_resource **res, unsigned int res_no,
} else if( flags & LB_FLAGS_PERCENT_WITH_CPU ) {
/* generate score based on the percentage of channels occupied, reduced by CPU idle factor */
if( dst->rmap[l].current_sessions && dst->rmap[l].max_sessions && dst->rmap[l].cpu_idle ) {
av = ( 100 - ( 100 * ( dst->rmap[l].current_sessions + dst->rmap[l].sessions_since_last_heartbeat ) / dst->rmap[l].max_sessions ) ) * dst->rmap[l].cpu_idle
av = ( 100 - ( 100 * ( dst->rmap[l].current_sessions + dst->rmap[l].sessions_since_last_heartbeat ) / dst->rmap[l].max_sessions ) ) * dst->rmap[l].cpu_idle;
}
} else {
av = dst->rmap[l].max_load - lb_dlg_binds.get_profile_size(res[k]->profile, &dst->profile_id);
Expand Down Expand Up @@ -499,7 +499,7 @@ int lb_route(struct sip_msg *req, int group, struct lb_res_str_list *rl,
struct lb_resource *it_r;
int load, it_l;
int i, j, cond, cnt_aval_dst;

unsigned int k, l;

/* init control vars state */
res_cur = NULL;
Expand Down Expand Up @@ -842,9 +842,8 @@ int lb_route(struct sip_msg *req, int group, struct lb_res_str_list *rl,
if( res_cur[k] == dst->rmap[l].resource ) {
dst->rmap[l].sessions_since_last_heartbeat++;

LM_DBG("Incrementing sess since last HB for winning destination %d <%.*s> "
"(sessions_since_last_heartbeat=%d)\n",
dst->id, dst->uri.len, dst->uri.s, dst->sessions_since_last_heartbeat );
LM_DBG("Incrementing sess since last HB for winning destination %d <%.*s> (sessions_since_last_heartbeat=%d)\n",
dst->id, dst->uri.len, dst->uri.s, dst->rmap[l].sessions_since_last_heartbeat );

break; // exit the loop
}
Expand Down
27 changes: 14 additions & 13 deletions modules/load_balancer/load_balancer.c
Original file line number Diff line number Diff line change
Expand Up @@ -810,19 +810,20 @@ static void lb_update_max_loads(unsigned int ticks, void *param)
dst->rmap[ri].resource->profile, &dst->profile_id);
old = dst->rmap[ri].max_load;

if ( flags & LB_FLAGS_PERCENT_WITH_CPU ) {
/*
* In this mode we capture the raw values and use these in each LB calculation. This
* means we do not use profile counting in the load calculation. This is suitable for
* architectures where many unreplicated OpenSIPs instances feed calls into the same pool
* of FreeSWITCH instances.
*/
dst->rmap[ri].max_sessions = dst->fs_sock->stats.max_sess;
dst->rmap[ri].current_sessions = dst->fs_sock->stats.sess;
dst->rmap[ri].cpu_idle = dst->fs_sock->stats.id_cpu / (float)100;
/* reset sessions since last heartbeat counter */
dst->rmap[ri].sessions_since_last_heartbeat = 0;
} else if (psz < dst->fs_sock->stats.max_sess) {
// if ( flags & LB_FLAGS_PERCENT_WITH_CPU ) { todo flags not avavilable here
/*
* In LB_FLAGS_PERCENT_WITH_CPU mode we capture the raw values and use these in each LB calculation. This
* means we do not use profile counting in the load calculation. This is suitable for
* architectures where many unreplicated OpenSIPs instances feed calls into the same pool
* of FreeSWITCH instances.
*/
dst->rmap[ri].max_sessions = dst->fs_sock->stats.max_sess;
dst->rmap[ri].current_sessions = dst->fs_sock->stats.sess;
dst->rmap[ri].cpu_idle = dst->fs_sock->stats.id_cpu / (float)100;
/* reset sessions since last heartbeat counter */
dst->rmap[ri].sessions_since_last_heartbeat = 0;

if (psz < dst->fs_sock->stats.max_sess) {
/*
* The normal case. OpenSIPS sees, at _most_, the same number
* of sessions as FreeSWITCH does. Any differences must be
Expand Down

0 comments on commit fccf7ec

Please sign in to comment.