[OpenSIPS-Devel] [OpenSIPS/opensips] 318716: net_tcp: remove the fd from the reactor before tcp...

Bogdan Andrei IANCU noreply at github.com
Fri Oct 2 15:01:37 UTC 2026


  Branch: refs/heads/master
  Home:   https://github.com/OpenSIPS/opensips
  Commit: 318716685ac04e9fc00e521358271bbde88c4fea
      https://github.com/OpenSIPS/opensips/commit/318716685ac04e9fc00e521358271bbde88c4fea
  Author: Yury Kirsanov <yury at kfi.net.au>
  Date:   2026-10-02 (Fri, 02 Oct 2026)

  Changed paths:
    M net/net_tcp.c

  Log Message:
  -----------
  net_tcp: remove the fd from the reactor before tcp_close_connection() closes it

tcp_close_connection() (MI "tcp:close", script tcp_close_conn()) destroys
the connection from TCP main via tcp_conn_destroy().  For an idle
connection the refcount drops to zero and the fd is closed, but it was
never removed from the TCP main reactor, unlike every other TCP main
destroy path (tcp_fail_conn() and friends).  The stale reactor entry then
captures the next connection that reuses the fd number: it is never read
- silently, or with "BUG trying to overwrite entry N in the hash".

Do what tcp_fail_conn() does: reactor_del_all() and F_CONN_REMOVED before
destroying.  A connection that is busy when the close arrives is
unaffected: tcpconn_destroy() only marks it bad, and its job completion
goes through tcp_fail_conn(), which skips the already-done removal.


  Commit: 3fa895c88ed0186fc11e8ab73c12314a4aff335d
      https://github.com/OpenSIPS/opensips/commit/3fa895c88ed0186fc11e8ab73c12314a4aff335d
  Author: Bogdan Andrei IANCU <bogdan at opensips.org>
  Date:   2026-10-02 (Fri, 02 Oct 2026)

  Changed paths:
    M net/net_tcp.c

  Log Message:
  -----------
  Merge pull request #4289 from Lt-Flash/fix/tcp-close-conn-reactor

net_tcp: remove the fd from the reactor before tcp_close_connection() closes it


Compare: https://github.com/OpenSIPS/opensips/compare/0eabc68c3825...3fa895c88ed0

To unsubscribe from these emails, change your notification settings at https://github.com/OpenSIPS/opensips/settings/notifications



More information about the Devel mailing list