Hi guys,
I've implemented an rpc call that closes all WS connections:
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); }
Please take a look. Can I call close_connection() and perform list iterations in this function not using WSCONN_LOCK?
Thanks, Andrey
Hello,
is this a question because you got some issue testing your function?
I am not that familiar with the internals of websocket connection management, but there is a function for closing a connection, have you looked at it?
Cheers, Daniel
On 20.11.18 13:25, Andrey Deykunov wrote:
Hi guys,
I've implemented an rpc call that closes all WS connections:
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); }
Please take a look. Can I call close_connection() and perform list iterations in this function not using WSCONN_LOCK?
Thanks, Andrey
Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Am Dienstag, 20. November 2018, 13:25:12 CET schrieb Andrey Deykunov:
I've implemented an rpc call that closes all WS connections:
void ws_rpc_close_all(rpc_t *rpc, void *ctx) { [..] wsconn_put_list(list_head); }
Please take a look. Can I call close_connection() and perform list iterations in this function not using WSCONN_LOCK?
Hi Andrey,
can't help you with internals of this module right now, but please direct this question to our developer list. If you don't get a reply in time there, you could also contact the developer of the websocket module (Peter) directly.
Best regards,
Henning