<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hello,</p>
<p>is this a question because you got some issue testing your
function?</p>
<p>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?</p>
<p>Cheers,<br>
Daniel<br>
</p>
<div class="moz-cite-prefix">On 20.11.18 13:25, Andrey Deykunov
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAEsJsWB5W75pnWB2ovUJ-Z=JPRSVs+VwHD9jLedee=6hObZm9g@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">Hi guys,
<div><br>
</div>
<div>I've implemented an rpc call that closes all WS
connections:</div>
<div><br>
</div>
<div><br>
</div>
<div>
<div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;line-height:19px;white-space:pre"><div><span style="color:rgb(86,156,214)">void</span> <span style="color:rgb(220,220,170)">ws_rpc_close_all</span>(<span style="color:rgb(78,201,176)">rpc_t</span> *rpc, <span style="color:rgb(86,156,214)">void</span> *ctx)</div><div>{</div><div> <span style="color:rgb(78,201,176)">ws_connection_t</span> **list = <span style="color:rgb(86,156,214)">NULL</span>, **list_head = <span style="color:rgb(86,156,214)">NULL</span>;</div><div> <span style="color:rgb(78,201,176)">ws_connection_t</span> *wsc = <span style="color:rgb(86,156,214)">NULL</span>;</div><div> <span style="color:rgb(86,156,214)">int</span> ret;</div>
<div> list_head = <span style="color:rgb(220,220,170)">wsconn_get_list</span>();</div><div> <span style="color:rgb(197,134,192)">if</span>(!list_head)</div><div> <span style="color:rgb(197,134,192)">return</span>;</div>
<div> list = list_head;</div><div> wsc = *list_head;</div><div> <span style="color:rgb(197,134,192)">while</span>(wsc) {</div><div> <span style="color:rgb(220,220,170)">LM_WARN</span>(<span style="color:rgb(206,145,120)">"Closing connection</span><span style="color:rgb(215,186,125)">\n</span><span style="color:rgb(206,145,120)">"</span>);</div><div> ret = <span style="color:rgb(220,220,170)">close_connection</span>(&wsc, LOCAL_CLOSE, <span style="color:rgb(181,206,168)">1000</span>, str_status_normal_closure);</div><div> wsc = *(++list);</div><div> }</div><div> <span style="color:rgb(220,220,170)">wsconn_put_list</span>(list_head); </div><div>}</div></div>
</div>
<div><br>
</div>
<div>Please take a look. Can I call close_connection()
and perform list iterations in this function not using
WSCONN_LOCK?<br>
</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Andrey</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
Kamailio (SER) - Users Mailing List
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a>
<a class="moz-txt-link-freetext" href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
Daniel-Constantin Mierla -- <a class="moz-txt-link-abbreviated" href="http://www.asipto.com">www.asipto.com</a>
<a class="moz-txt-link-abbreviated" href="http://www.twitter.com/miconda">www.twitter.com/miconda</a> -- <a class="moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda">www.linkedin.com/in/miconda</a>
Kamailio World Conference -- <a class="moz-txt-link-abbreviated" href="http://www.kamailioworld.com">www.kamailioworld.com</a>
Kamailio Advanced Training, Nov 12-14, 2018, in Berlin -- <a class="moz-txt-link-abbreviated" href="http://www.asipto.com">www.asipto.com</a></pre>
</body>
</html>