[OpenSIPS-Devel] [OpenSIPS/opensips] 87f241: Change CON_SET_CURR_PS pattern to always call it _...

Bogdan Andrei IANCU noreply at github.com
Tue Jul 6 12:54:38 EST 2021


  Branch: refs/heads/master
  Home:   https://github.com/OpenSIPS/opensips
  Commit: 87f2416517e128fe139c1888fa74beeaa96287dd
      https://github.com/OpenSIPS/opensips/commit/87f2416517e128fe139c1888fa74beeaa96287dd
  Author: Walter Doekes <walter+github at wjd.nu>
  Date:   2021-05-26 (Wed, 26 May 2021)

  Changed paths:
    M db/db_insertq.c
    M modules/acc/acc.c
    M modules/alias_db/alookup.c
    M modules/auth_db/checks.c
    M modules/call_center/cc_db.c
    M modules/db_mysql/dbase.c
    M modules/dialog/dlg_db_handler.c
    M modules/emergency/report_emergency.c
    M modules/group/group.c
    M modules/presence/notify.c
    M modules/presence/presence.c
    M modules/presence/subscribe.c
    M modules/sipcapture/sipcapture.c
    M modules/speeddial/sdlookup.c
    M modules/tracer/tracer.c
    M modules/usrloc/ucontact.c
    M modules/usrloc/udomain.c
    M modules/usrloc/ul_mi.c
    M modules/usrloc/urecord.c

  Log Message:
  -----------
  Change CON_SET_CURR_PS pattern to always call it _directly_ before db call

Because CON_SET_CURR_PS is always followed by an immediate call to
CON_RESET_CURR_PS inside the DB function, it makes sense to call
CON_SET_CURR_PS just before the DB call.

Otherwise you could get this:

   CON_SET_CURR_PS(...);

   for (i = 0; i < n; ++i) {
       // first insert uses prepared statement
       db.insert(...);
       // but second time in the loop, we use "plain" text queries
   }

The updated pattern would look like this:

   for (i = 0; i < n; ++i) {
       // the ps handle is always reset, so we reinit it every time
       CON_SET_CURR_PS(...);
       db.insert(...);
   }

Note that we don't need any explicit CON_RESET_CURR_PS() at odd points
anymore (like was added in 57caa6c03). A SET is immediately followed by
an implicit RESET.


  Commit: f54e5f95ac7869d983e41ee2a880a8e450a8eb4b
      https://github.com/OpenSIPS/opensips/commit/f54e5f95ac7869d983e41ee2a880a8e450a8eb4b
  Author: Bogdan Andrei IANCU <bogdan at opensips.org>
  Date:   2021-07-06 (Tue, 06 Jul 2021)

  Changed paths:
    M db/db_insertq.c
    M modules/acc/acc.c
    M modules/alias_db/alookup.c
    M modules/auth_db/checks.c
    M modules/call_center/cc_db.c
    M modules/db_mysql/dbase.c
    M modules/dialog/dlg_db_handler.c
    M modules/emergency/report_emergency.c
    M modules/group/group.c
    M modules/presence/notify.c
    M modules/presence/presence.c
    M modules/presence/subscribe.c
    M modules/sipcapture/sipcapture.c
    M modules/speeddial/sdlookup.c
    M modules/tracer/tracer.c
    M modules/usrloc/ucontact.c
    M modules/usrloc/udomain.c
    M modules/usrloc/ul_mi.c
    M modules/usrloc/urecord.c

  Log Message:
  -----------
  Merge pull request #2470 from wdoekes/con-ps-reference-cleanup-2

Change CON_SET_CURR_PS pattern to always call it _directly_ before db call


Compare: https://github.com/OpenSIPS/opensips/compare/2b0dde30258d...f54e5f95ac78



More information about the Devel mailing list