Hi Andrey,

as you know, there is an RPC command ws.close() and also a script function to 
close sessions remotely. So, it should be certainly possible to close the 
sessions over RPC.

Not being the author of this particular module, it is hard to say why it 
crashes. Try the usual debugging techniques, e.g. gdb to find more clues.

If you have a working version, please open a pull request. In case of more 
questions, just ask on this list again.

Cheers,

Henning

--
Henning Westerholt – https://skalatan.de/blog/
Kamailio services – https://gilawa.com<https://gilawa.com/>

From: sr-dev <sr-dev-boun...@lists.kamailio.org> On Behalf Of Andrey Deykunov
Sent: Monday, May 18, 2020 1:02 PM
To: Kamailio (SER) - Development Mailing List <sr-dev@lists.kamailio.org>
Subject: [sr-dev] Fwd: RPC command to close all WS connections.


---------- Forwarded message ---------
От: Andrey Deykunov <deyku...@gmail.com<mailto:deyku...@gmail.com>>
Date: пн, 18 мая 2020 г. в 12:24
Subject: RPC command to close all WS connections.
To: Daniel-Constantin Mierla <mico...@gmail.com<mailto:mico...@gmail.com>>

Hi Daniel,

We're using two nodes (active and passive) of our PBX server in production. 
When an active node becomes passive, we should forcibly close all WS 
connections, established by clients on this node. So, I've added 'ws.close_all' 
command to websocket module to let our failover service be able closing WS 
connections remotely.

I've added the following code to ws_frame.c:

void ws_rpc_close_all(rpc_t *rpc, void *ctx)
{
    ws_connection_t **list = NULL, **list_head = NULL;
    ws_connection_t *wsc = NULL;
    int ret;

    list_head = wsconn_get_list();
    if(!list_head)
        return;

    list = list_head;
    wsc = *list_head;
    while(wsc) {
        LM_WARN("Closing connection\n");
        ret = close_connection(&wsc, LOCAL_CLOSE, 1000, 
str_status_normal_closure);
        wsc = *(++list);
    }
    wsconn_put_list(list_head);
}

but I think this code may be unsafe and could corrupt shared memory, because 
I've got some segfaults during failovers after adding this command.

What do you think? Is it possible to close connections properly and safety for 
shared memory?

Thanks,
Andrey






_______________________________________________
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to