Skip to content

Commit

Permalink
cgrates: fix infinite re-connect issue
Browse files Browse the repository at this point in the history
When a non-default connection would have reconnected, due to a
mishandling of the return code of the `cgrc_reconn` function, a new
connection would have been created every time, resulting in infinite
re-connections. And in time, this would acquire all the available ports
(65k) and would no longer accept new connections.

Many thanks go to Vasilios Tzanoudakis (@vtzan on GitHub) for reporting
and providing a solid testbed for this.
Close #2850
  • Loading branch information
razvancrainea committed Nov 14, 2022
1 parent 7a82baa commit 27cd5d7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions modules/cgrates/cgrates_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ static void cgrc_reconn_rpc(int sender, void *p);

static int cgrc_reconn(struct cgr_conn *c)
{
if (cgrc_conn(c) >= 0 && c == c->engine->default_con)
int ret = cgrc_conn(c);
if (ret >= 0 && c == c->engine->default_con)
return cgrc_start_listen(c);
return -1;
return ret;
}

#ifdef HAVE_TIMER_FD
Expand Down

0 comments on commit 27cd5d7

Please sign in to comment.