Beispiel #1
0
/*!
 * \brief Delete a impurecord from domain
 * \param _d domain where the record should be deleted
 * \param _aor address of record
 * \param _r deleted record
 * \return 0 on success, -1 if the record could not be deleted
 */
int delete_impurecord(udomain_t* _d, str* _aor, struct impurecord* _r) {
    //    struct ucontact* c;//, *t;

    LM_DBG("Deleting IMPURECORD [%.*s]\n", _r->public_identity.len, _r->public_identity.s);

    if (_r == 0) {
	if (get_impurecord(_d, _aor, &_r) > 0) {
	    return 0;
	}
    }

    //TODO: need to unref the contacts in the contact list (not delete them), the timer should delete all contacts that are unreffed
    //    c = _r->contacts;
    //    while (c) {
    //	t = c;
    //	c = c->next;
    //	if (delete_ucontact(_r, t) < 0) {
    //	    LM_ERR("deleting contact failed [%.*s]\n", c->aor.len, c->aor.s);
    //	    return -1;
    //	}
    //    }

    if (exists_ulcb_type(_r->cbs, UL_IMPU_DELETE)) {
	run_ul_callbacks(_r->cbs, UL_IMPU_DELETE, _r, 0);
    }

    /*DB?*/
    if (db_mode == WRITE_THROUGH
	    && db_delete_impurecord(_d, _r) != 0) {
	LM_ERR("error deleting IMPU record from db");
	return 0;
    }

    mem_delete_impurecord(_d, _r);
    return 0;
}
Beispiel #2
0
/*!
 * \brief Delete a impurecord from domain
 * \param _d domain where the record should be deleted
 * \param _aor address of record - used only if _r in next param is null
 * \param _r deleted record to delete - if null will use the aor to search (assumed that domain is locked).
 * \return 0 on success, -1 if the record could not be deleted
 */
int delete_impurecord(udomain_t* _d, str* _aor, struct impurecord* _r) {
    LM_DBG("Deleting IMPURECORD [%.*s]\n", _r->public_identity.len, _r->public_identity.s);

    if (_r == 0) {
        LM_DBG("no impurecord passed in - let's search\n");
        if (get_impurecord(_d, _aor, &_r) != 0) {
            return 0;
        }
    }

    if (exists_ulcb_type(_r->cbs, UL_IMPU_DELETE)) {
        run_ul_callbacks(_r->cbs, UL_IMPU_DELETE, _r, 0);
    }

    /*DB?*/
    if (db_mode == WRITE_THROUGH
            && db_delete_impurecord(_d, _r) != 0) {
        LM_ERR("error deleting IMPU record from db...continuing to remove from memory\n");
    }

    mem_delete_impurecord(_d, _r);

    return 0;
}