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

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


  Branch: refs/heads/2.2
  Home:   https://github.com/OpenSIPS/opensips
  Commit: 7d30b9c234b4ba858299d0915113c67cef0b84e6
      https://github.com/OpenSIPS/opensips/commit/7d30b9c234b4ba858299d0915113c67cef0b84e6
  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: 9ede5894afe4b1f5877e51c36b21308d0d968ff9
      https://github.com/OpenSIPS/opensips/commit/9ede5894afe4b1f5877e51c36b21308d0d968ff9
  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: 2ae866fabd2575cec02305e888a2f049dabb8a21
      https://github.com/OpenSIPS/opensips/commit/2ae866fabd2575cec02305e888a2f049dabb8a21
  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: ad06f0ffd2fd734c5413161fa62a7f3080b1fc38
      https://github.com/OpenSIPS/opensips/commit/ad06f0ffd2fd734c5413161fa62a7f3080b1fc38
  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: 09a7533ed1a910762fcc8f9d13d013bee5921477
      https://github.com/OpenSIPS/opensips/commit/09a7533ed1a910762fcc8f9d13d013bee5921477
  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)


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

  Changed paths:
    M modules/tm/sip_msg.c

  Log Message:
  -----------
  Revert "Set proper UPDATED flag upon cloning."

This reverts commit 7723cd3f6d08d95c3a1d56801e2f234f8e521c23.


Compare: https://github.com/OpenSIPS/opensips/compare/36db1302dc80...8c35fc4e203d


More information about the Devel mailing list