[OpenSIPS-Devel] [OpenSIPS/opensips] 04e2d6: TCP engine: Fix ref counting bug in async writes

Liviu Chircu liviu at opensips.org
Wed Jun 21 03:41:16 EDT 2017


  Branch: refs/heads/master
  Home:   https://github.com/OpenSIPS/opensips
  Commit: 04e2d6e5f46b98c481b2e810ea0aa73c7be36b40
      https://github.com/OpenSIPS/opensips/commit/04e2d6e5f46b98c481b2e810ea0aa73c7be36b40
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2017-06-21 (Wed, 21 Jun 2017)

  Changed paths:
    M net/net_tcp.c
    M net/net_tcp_proc.c

  Log Message:
  -----------
  TCP engine: Fix ref counting bug in async writes

TCP writes done by TCP workers were subject to an extra
dereferencing operation, potentially leading to memory corruption
due to SHM overwriting on freed tcp_connection structs.

This patch eliminates the extra dereferening operation, while also
taking care not to break the code for non-TCP worker writers, which
will now have their passed connections dereferenced by TCP main.


  Commit: 99181710c3f52b4ca97186623af0a7760191a276
      https://github.com/OpenSIPS/opensips/commit/99181710c3f52b4ca97186623af0a7760191a276
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2017-06-21 (Wed, 21 Jun 2017)

  Changed paths:
    M net/net_tcp_proc.c

  Log Message:
  -----------
  TCP engine: Fix a race condition related to con lifetime management

Connections which received a read event concurrently with their
expiration time could trigger an indefinitely long, CPU wasteful, rapid
succession of back-forth passing of the connection object between TCP Main
and a TCP worker process.

The fix involves adding a TCP connection lifetime update in the TCP worker
just after receiving the connection object from TCP Main (this is correct
- there is some pending data, the connection is non-idle), before the
expiration check is done.

Thanks to Bogdan for helping with troubleshooting


  Commit: f30a658c46837a1396098c2028c7d02cf5fd5c3e
      https://github.com/OpenSIPS/opensips/commit/f30a658c46837a1396098c2028c7d02cf5fd5c3e
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2017-06-21 (Wed, 21 Jun 2017)

  Changed paths:
    M Makefile
    M Makefile.conf.template
    M Makefile.sources
    A lib/dbg/struct_hist.c
    A lib/dbg/struct_hist.h

  Log Message:
  -----------
  Add support for generic struct troubleshooting

Optionally includible via the -DDBG_STRUCT_HIST compile flag


  Commit: 3da3e800847f7f903d01ac5c87ce6a8f20f985ad
      https://github.com/OpenSIPS/opensips/commit/3da3e800847f7f903d01ac5c87ce6a8f20f985ad
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2017-06-21 (Wed, 21 Jun 2017)

  Changed paths:
    M modules/tm/h_table.h

  Log Message:
  -----------
  tm: Remove unused/redundant tm_list_entry() macro


  Commit: 8ba454be756b583082ce98ce293968518ac95235
      https://github.com/OpenSIPS/opensips/commit/8ba454be756b583082ce98ce293968518ac95235
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2017-06-21 (Wed, 21 Jun 2017)

  Changed paths:
    M Makefile.conf.template
    M net/net_tcp.c
    M net/net_tcp.h
    A net/net_tcp_dbg.h
    M net/net_tcp_proc.c
    M net/proto_tcp/proto_tcp.c
    M net/tcp_conn_defs.h

  Log Message:
  -----------
  Add optional TCP connection debugging code

To include this code, both -DDBG_STRUCT_HIST and -DDBG_TCPCON compile
flags must be defined under Makefile.conf


Compare: https://github.com/OpenSIPS/opensips/compare/8b52f1331ef2...8ba454be756b


More information about the Devel mailing list