Deadly infinite loop with ring group & follow-me

Status
Not open for further replies.

francois

New Member
Oct 3, 2019
26
9
3
56
One of our customer has configured its ring group as following:

Ring-Group
Destination: 1001
Destination: 1002

And its follow-me extensions as following:

Follow-Me 1001
Destination: 1001
Destination: 1002

Follow-Me 1002
Destination: 1002
Destination: 1001

The above configuration leaded to a fatal infinite loop that caused FreeSWITCH / PostgreSQL / Nginx to slow down at a point where the system was almost crashed.

After investigations, I found that the root cause of the endless loop is in app/ring_groups/index.lua. The lua script creates a destination array (destinations) based on the destinations that are part of the ring group and the follow-me destinations that are parts of every follow-me destinations. The problem comes from the fact that the script loops through the destinations array that grows endlessly.

To avoid this situation (that I do not aim to prevent in the follow-me / ring group forms), I added the below function and I am adding a new destination only when it is not already present in the destination array.

Code:
local function destination_exists(destinations, destination)
        local exist = false;
        for key, row in pairs(destinations) do
            if row.destination_number == destination then
                exist = true;
               break;
            end
        end
   
        return exist;
    end

So, now I add a new destination (destinations[new_key] = {}) only when destination_exists(destinations, field.destination_number) returns false.

Any comment?
 

francois

New Member
Oct 3, 2019
26
9
3
56
Yes, please proceed as you want.

I also found some weird code in this script that causing another issue, should we discuss it here or in private?
 
Status
Not open for further replies.