/*! * \brief Update ucontact with new values * \param _r record the contact belongs to * \param _c updated contact * \param _ci new contact informations * \return 0 on success, -1 on failure */ int update_ucontact(struct impurecord* _r, ucontact_t* _c, ucontact_info_t* _ci) { /* we have to update memory in any case, but database directly * only in db_mode 1 */ LM_DBG("Updating contact aor: [%.*s] and contact uri: [%.*s]\n", _c->aor.len, _c->aor.s, _c->c.len, _c->c.s); if (mem_update_ucontact(_c, _ci) < 0) { LM_ERR("failed to update memory\n"); return -1; } if (db_mode == WRITE_THROUGH && (db_insert_ucontact(_r, _c) != 0)) { /* this is an insert/update */ LM_ERR("failed to update contact in DB [%.*s]\n", _c->aor.len, _c->aor.s); return -1; } //make sure IMPU is linked to this contact link_contact_to_impu(_r, _c, 1); /* run callbacks for UPDATE event */ if (exists_ulcb_type(_c->cbs, UL_CONTACT_UPDATE)) { LM_DBG("exists callback for type= UL_CONTACT_UPDATE\n"); run_ul_callbacks(_c->cbs, UL_CONTACT_UPDATE, _r, _c); } if (exists_ulcb_type(_r->cbs, UL_IMPU_UPDATE_CONTACT)) { run_ul_callbacks(_r->cbs, UL_IMPU_UPDATE_CONTACT, _r, _c); } // update_contact_pos(_r, _c); return 0; }
/* * Update ucontact with new values */ int update_ucontact(ucontact_t* _c, time_t _e, float _q, str* _cid, int _cs, unsigned int _set, unsigned int _res) { /* we have to update memory in any case, but database directly * only in db_mode 1 */ if (mem_update_ucontact(_c, _e, _q, _cid, _cs, _set, _res) < 0) { LOG(L_ERR, "update_ucontact(): Error while updating\n"); return -1; } st_update_ucontact(_c); if (db_mode == WRITE_THROUGH) { if (db_update_ucontact(_c) < 0) { LOG(L_ERR, "update_ucontact(): Error while updating database\n"); } } return 0; }
/*! * \brief Update ucontact with new values * \param _r record the contact belongs to * \param _c updated contact * \param _ci new contact informations * \return 0 on success, -1 on failure */ int update_ucontact(struct urecord* _r, ucontact_t* _c, ucontact_info_t* _ci) { int res; /* we have to update memory in any case, but database directly * only in db_mode 1 */ if (mem_update_ucontact( _c, _ci) < 0) { LM_ERR("failed to update memory\n"); return -1; } /* run callbacks for UPDATE event */ if (exists_ulcb_type(UL_CONTACT_UPDATE)) { LM_DBG("exists callback for type= UL_CONTACT_UPDATE\n"); run_ul_callbacks( UL_CONTACT_UPDATE, _c); } if (_r && db_mode!=DB_ONLY) update_contact_pos( _r, _c); st_update_ucontact(_c); if (db_mode == WRITE_THROUGH || db_mode==DB_ONLY) { /* * prevent problems when we're in a failover situation: the first DB contains * the complete location entries, the other misses some of them. Before the * update it checks for a entry in the first DB, this is ok. But the update * in the second DB will not work. Thus the expire mechanism don't work, it * takes too long until both DBs have the same number of entries again. */ if (ul_db_update_as_insert) res = db_insert_ucontact(_c); else res = db_update_ucontact(_c); if (res < 0 ) { LM_ERR("failed to update database\n"); return -1; } else { _c->state = CS_SYNC; } } return 0; }
/* * Wrapper around update_ucontact which overwrites * the replication mark. * FIXME: i'm not sure if we need this... */ int update_ucontact_rep(ucontact_t* _c, time_t _e, float _q, str* _cid, int _cs, int _rep, unsigned int _set, unsigned int _res) { _c->replicate = _rep; return mem_update_ucontact(_c, _e, _q, _cid, _cs, _set, _res); }