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

Liviu Chircu liviu at opensips.org
Mon Jul 3 10:55:55 EDT 2017


  Branch: refs/heads/2.3
  Home:   https://github.com/OpenSIPS/opensips
  Commit: 1bf414226d0a7616d8a7b3dbd730fe45a42f9084
      https://github.com/OpenSIPS/opensips/commit/1bf414226d0a7616d8a7b3dbd730fe45a42f9084
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2017-07-03 (Mon, 03 Jul 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.

(cherry picked from commit 04e2d6e5f46b98c481b2e810ea0aa73c7be36b40)


  Commit: 0fd713369378c6c4c0682b5f503346bb80d6c41e
      https://github.com/OpenSIPS/opensips/commit/0fd713369378c6c4c0682b5f503346bb80d6c41e
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2017-07-03 (Mon, 03 Jul 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

(cherry picked from commit 99181710c3f52b4ca97186623af0a7760191a276)


  Commit: b33c84392e4bd2383c28ffc170efd4cea50fae1c
      https://github.com/OpenSIPS/opensips/commit/b33c84392e4bd2383c28ffc170efd4cea50fae1c
  Author: Razvan Crainea <razvan at opensips.org>
  Date:   2017-07-03 (Mon, 03 Jul 2017)

  Changed paths:
    M net/net_tcp_proc.c

  Log Message:
  -----------
  net/tcp: do not reset conn proc_no as a writer

when releasing a conn as a writer, do not reset the process owner of the
conn, otherwise a reader will have to re-take it back.

(cherry picked from commit d5fca4482ab1746351157ee0353474a24b084f60)


  Commit: 6a5fd0e6451eb9614c14669bd8c0f94d5f00c0a1
      https://github.com/OpenSIPS/opensips/commit/6a5fd0e6451eb9614c14669bd8c0f94d5f00c0a1
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2017-07-03 (Mon, 03 Jul 2017)

  Changed paths:
    M net/net_tcp.c

  Log Message:
  -----------
  TCP engine: Fix misleading logs

(cherry picked from commit a7249f03d7a16221e21b8f57eb73540f0b8c4888)


  Commit: 4f06fd6e5c3e8cac3d1c5ccc2d332948e10a5152
      https://github.com/OpenSIPS/opensips/commit/4f06fd6e5c3e8cac3d1c5ccc2d332948e10a5152
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2017-07-03 (Mon, 03 Jul 2017)

  Changed paths:
    M net/net_tcp_proc.c
    M net/tcp_conn.h

  Log Message:
  -----------
  TCP engine: Fix the TCP worker duplicate connection check

(cherry picked from commit 8845fd7950ec90fad7498b323745c86cac4070f6)


Compare: https://github.com/OpenSIPS/opensips/compare/e1497271f029...4f06fd6e5c3e


More information about the Devel mailing list