[OpenSIPS-Devel] [OpenSIPS/opensips] aa93d0: dialog: Fix data reload race conditions on startup

Liviu Chircu noreply at github.com
Tue Jul 30 07:05:57 EDT 2019


  Branch: refs/heads/bugfix/fix-dialog-sync-bugs
  Home:   https://github.com/OpenSIPS/opensips
  Commit: aa93d0fbf369078f1c0e85fc10314fe7799aeca0
      https://github.com/OpenSIPS/opensips/commit/aa93d0fbf369078f1c0e85fc10314fe7799aeca0
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2019-07-30 (Tue, 30 Jul 2019)

  Changed paths:
    M modules/dialog/dlg_db_handler.c
    M modules/dialog/dlg_hash.c
    M modules/dialog/dlg_hash.h
    M modules/dialog/dlg_replication.c

  Log Message:
  -----------
  dialog: Fix data reload race conditions on startup

Since loading the data on child_init(), the load_dialog_info_from_db()
routines and rcv_cluster_event() routines could run in parallel, without
any synchronization on the dialog table, which could lead to duplicate
dialogs in the hash.


  Commit: f88c41064c9d895e52c6a8dac62867246da3b253
      https://github.com/OpenSIPS/opensips/commit/f88c41064c9d895e52c6a8dac62867246da3b253
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2019-07-30 (Tue, 30 Jul 2019)

  Changed paths:
    M modules/dialog/dlg_db_handler.c
    M modules/dialog/dlg_handlers.c
    M modules/dialog/dlg_hash.h
    M modules/dialog/dlg_replication.c
    M modules/dialog/dlg_req_within.h

  Log Message:
  -----------
  dialog: Decrement dialog stats during post-sync cleanup

After a sync completes, it proceeds to clean up all dialogs loaded from
DB which did not match the data received via sync.  However, make sure
to also decrement the 'active' / 'early' dialog stats on each delete!


  Commit: 51b5ec3bac182104781a5e12287a217053170432
      https://github.com/OpenSIPS/opensips/commit/51b5ec3bac182104781a5e12287a217053170432
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2019-07-30 (Tue, 30 Jul 2019)

  Changed paths:
    M modules/dialog/dlg_replication.c

  Log Message:
  -----------
  dialog sync: Fix ref miscount during post-sync cleanup

The hash reference must only be decremented a single time during the
lifetime of a dialog.  Given that multiple pieces of code may attempt
to delete a dialog concurrently (e.g. a BIN "delete" packet and the
post-sync cleanup routine), the only way to guarantee a single decrement
of the hash ref is by using the dialog state machine transition.

Iff we're the ones to transition from ACK -> DELETED, we can (and MUST)
also decrement the hash reference.


Compare: https://github.com/OpenSIPS/opensips/compare/dfa863b9b2a9...51b5ec3bac18



More information about the Devel mailing list