<p>Hi Bogdan,</p>

<p>Almost a month ago, I have raised the issue regarding the opensips log file filling up with the following message </p>

<p>ERROR:core:io_watch_del: BUG - trying to del fd 38 with flags 2 1</p>

<p>Now I can reproduce it every time with the following scenario:</p>

<p>1)      UAC and UAS are connected to opensips proxy with TCP transport<br>
2)      Connections looks good<br>
3)      Netstat shows the connection to UAC in ESTABLISHED state and the tcp_conn_lists of opensips also looks fine for that UAC<br>
4)      Now unplug the Ethernet cable on UAC<br>
5)      After tcp connection timeout (set to 5 mins in opensips.cfg), the tcp connection goes away from netstat as well as from tcp_conn_lists<br>
6)      UAS tries another tcp call to the UAC which is still unplugged<br>
7)      tcp_conn_lists shows the tcp connection to the UAC and netstat shows the connection in SYN_SENT state<br>
8)      After the tcp connection timeout (set to 5 mins in opensips.cfg), the connection goes away from netstat however it remains there in tcp_conn_lists and at that moment the “BUG - trying to del fd 38 with flags 2 1” starts printing in infinite loop.</p>

<p>I looked at the source code and observed the following</p>

<p>1)      When the network cable is plugged in <br>
The io_watch_add happens with flag IO_WATCH_READ in tcp_main.c  when the command is CONN_NEW<br>
2)      When the network cable is unplugged<br>
The io_watch_add happens with flag IO_WATCH_WRITE in tcp_main.c  when the command is ASYNC_CONNECT</p>

<p>3)      While doing io_watch_del after timeout, from handle_tcpconn_ev method, io_watch_del always uses IO_WATCH_READ to delete the fd, which gives this error in case of unplugged cable.</p>

<p>Please look into this and suggest how can I fix this issue ?</p>

<p>Thanks<br>
Rahul Gupta</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br>Reply to this email directly or <a href="https://github.com/OpenSIPS/opensips/issues/591">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AFOcia4frZ3nRd7q-FZnxXtn1K9ebDsLks5ok7XVgaJpZM4FnHG4.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
  <div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
    <link itemprop="url" href="https://github.com/OpenSIPS/opensips/issues/591"></link>
    <meta itemprop="name" content="View Issue"></meta>
  </div>
  <meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>