Module: kamailio Branch: master Commit: 1c0242fecb1a5ea9a3fde54b8ce331886e564d39 URL: https://github.com/kamailio/kamailio/commit/1c0242fecb1a5ea9a3fde54b8ce331886e564d39
Author: Phil Lavin <phil.la...@synety.com> Committer: Phil Lavin <phil.la...@synety.com> Date: 2016-02-19T12:07:41Z presence: Fully implement table locking for updating the presentity table - Implement table locking for all routes through update_presentity in order to avoid a number of different race conditions which resulted in extraneous data being put into the presentity table. --- Modified: modules/presence/presentity.c --- Diff: https://github.com/kamailio/kamailio/commit/1c0242fecb1a5ea9a3fde54b8ce331886e564d39.diff Patch: https://github.com/kamailio/kamailio/commit/1c0242fecb1a5ea9a3fde54b8ce331886e564d39.patch --- diff --git a/modules/presence/presentity.c b/modules/presence/presentity.c index 0f3c3e5..1c385b5 100644 --- a/modules/presence/presentity.c +++ b/modules/presence/presentity.c @@ -426,6 +426,15 @@ int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body, goto error; } + if (pa_dbf.start_transaction) + { + if (pa_dbf.start_transaction(pa_db, db_table_lock) < 0) + { + LM_ERR("in start_transaction\n"); + goto error; + } + } + LM_DBG("inserting %d cols into table\n",n_query_cols); if (pa_dbf.insert(pa_db, query_cols, query_vals, n_query_cols) < 0) @@ -468,22 +477,8 @@ int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body, if (pa_dbf.replace(pa_db, query_cols, query_vals, n_query_cols, 4, 0) < 0) { LM_ERR("replacing record in database\n"); - if (pa_dbf.abort_transaction) - { - if (pa_dbf.abort_transaction(pa_db) < 0) - LM_ERR("in abort_transaction\n"); - } goto error; } - - if (pa_dbf.end_transaction) - { - if (pa_dbf.end_transaction(pa_db) < 0) - { - LM_ERR("in end_transaction\n"); - goto error; - } - } } if( publ_send200ok(msg, presentity->expires, presentity->etag)< 0) @@ -503,6 +498,15 @@ int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body, goto error; } + if (pa_dbf.start_transaction) + { + if (pa_dbf.start_transaction(pa_db, db_table_lock) < 0) + { + LM_ERR("in start_transaction\n"); + goto error; + } + } + if(EVENT_DIALOG_SLA(presentity->event->evp)) { @@ -837,6 +841,15 @@ int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body, if(pres_uri.s) pkg_free(pres_uri.s); + if (pa_dbf.end_transaction) + { + if (pa_dbf.end_transaction(pa_db) < 0) + { + LM_ERR("in end_transaction\n"); + goto error; + } + } + return 0; send_412: @@ -867,6 +880,15 @@ int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body, if(pres_uri.s) pkg_free(pres_uri.s); + if (pa_dbf.abort_transaction) + { + if (pa_dbf.abort_transaction(pa_db) < 0) + { + LM_ERR("in abort_transaction\n"); + goto error; + } + } + return ret; } _______________________________________________ sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev