/* * 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; }