#include <stdio.h>
#include "../../statistics.h"
#include "../../locking.h"
#include "../../str.h"
#include "../../db/db.h"
#include "urecord.h"
#include "hslot.h"


Go to the source code of this file.
Data Structures | |
| struct | udomain |
| The structure represents a usrloc domain. More... | |
Typedefs | |
| typedef int(* | delete_urecord_t )(udomain_t *_d, str *_aor, struct urecord *_r) |
| Delete a urecord from domain. | |
| typedef int(* | get_urecord_t )(udomain_t *_d, str *_aor, struct urecord **_r) |
| Obtain a urecord pointer if the urecord exists in domain. | |
| typedef int(* | insert_urecord_t )(udomain_t *_d, str *_aor, struct urecord **_r) |
| Create and insert a new record. | |
| typedef void(* | lock_udomain_t )(udomain_t *_d, str *_aor) |
| Timer handler for given domain. | |
| typedef struct udomain | udomain_t |
| The structure represents a usrloc domain. | |
| typedef void(* | unlock_udomain_t )(udomain_t *_d, str *_aor) |
| Release lock for a domain. | |
Functions | |
| int | db_timer_udomain (udomain_t *_d) |
| Timer function to cleanup expired contacts, DB_ONLY db_mode. | |
| int | delete_urecord (udomain_t *_d, str *_aor, struct urecord *_r) |
| Delete a urecord from domain. | |
| void | free_udomain (udomain_t *_d) |
| Free all memory allocated for the domain. | |
| int | get_urecord (udomain_t *_d, str *_aor, struct urecord **_r) |
| Obtain a urecord pointer if the urecord exists in domain. | |
| int | insert_urecord (udomain_t *_d, str *_aor, struct urecord **_r) |
| Create and insert a new record. | |
| void | lock_udomain (udomain_t *_d, str *_aor) |
| Get lock for a domain. | |
| void | lock_ulslot (udomain_t *_d, int i) |
| Get lock for a slot. | |
| void | mem_delete_urecord (udomain_t *_d, struct urecord *_r) |
| Remove a record from domain in memory. | |
| int | mem_insert_urecord (udomain_t *_d, str *_aor, struct urecord **_r) |
| Insert a new record into domain in memory. | |
| void | mem_timer_udomain (udomain_t *_d) |
| Run timer handler for given domain. | |
| int | new_udomain (str *_n, int _s, udomain_t **_d) |
| Create a new domain structure. | |
| int | preload_udomain (db_con_t *_c, udomain_t *_d) |
| Load all records from a udomain. | |
| void | print_udomain (FILE *_f, udomain_t *_d) |
| Print udomain, debugging helper function. | |
| int | testdb_udomain (db_con_t *con, udomain_t *d) |
| performs a dummy query just to see if DB is ok | |
| void | unlock_udomain (udomain_t *_d, str *_aor) |
| Release lock for a domain. | |
| void | unlock_ulslot (udomain_t *_d, int i) |
| Release lock for a slot. | |
Definition in file udomain.h.
| typedef int(* delete_urecord_t)(udomain_t *_d, str *_aor, struct urecord *_r) |
| typedef int(* get_urecord_t)(udomain_t *_d, str *_aor, struct urecord **_r) |
| typedef int(* insert_urecord_t)(udomain_t *_d, str *_aor, struct urecord **_r) |
| typedef void(* lock_udomain_t)(udomain_t *_d, str *_aor) |
| typedef void(* unlock_udomain_t)(udomain_t *_d, str *_aor) |
| int db_timer_udomain | ( | udomain_t * | _d | ) |
Timer function to cleanup expired contacts, DB_ONLY db_mode.
| _d | cleaned domain |
Definition at line 612 of file udomain.c.
References act_time, DB_DATETIME, db_func::delete, expires_col, LM_ERR, udomain::name, db_val_t::nul, _str::s, db_val_t::time_val, db_val_t::type, ul_dbf, ul_dbh, db_func::use_table, db_val_t::val, and vals.
Referenced by synchronize_all_udomains().
Delete a urecord from domain.
| _d | domain where the record should be deleted | |
| _aor | address of record | |
| _r | deleted record |
Definition at line 885 of file udomain.c.
References ucontact::c, urecord::contacts, db_delete_urecord(), db_mode, DB_ONLY, delete_ucontact(), free_urecord(), get_static_urecord(), get_urecord(), LM_ERR, ucontact::next, and release_urecord().
Referenced by bind_usrloc(), and mi_usrloc_rm_aor().
| void free_udomain | ( | udomain_t * | _d | ) |
Free all memory allocated for the domain.
| _d | freed domain |
Definition at line 148 of file udomain.c.
References deinit_slot(), lock_ulslot(), shm_free, udomain::size, udomain::table, and unlock_ulslot().
Referenced by free_all_udomains(), and register_udomain().
Obtain a urecord pointer if the urecord exists in domain.
| _d | domain to search the record | |
| _aor | address of record | |
| _r | new created record |
Definition at line 845 of file udomain.c.
References urecord::aorhash, core_hash(), db_load_urecord(), db_mode, DB_ONLY, hslot::first, _str::len, hslot::n, urecord::next, _str::s, udomain::size, udomain::table, and ul_dbh.
Referenced by bind_usrloc(), delete_urecord(), mi_usrloc_add(), mi_usrloc_rm_contact(), mi_usrloc_show_contact(), and preload_udomain().
Create and insert a new record.
| _d | domain to insert the new record | |
| _aor | address of the record | |
| _r | new created record |
Definition at line 824 of file udomain.c.
References db_mode, DB_ONLY, get_static_urecord(), LM_ERR, and mem_insert_urecord().
Referenced by bind_usrloc(), and mi_usrloc_add().
Get lock for a domain.
| _d | domain | |
| _aor | adress of record, used as hash source for the lock slot |
Definition at line 749 of file udomain.c.
References core_hash(), db_mode, DB_ONLY, hslot::lockidx, udomain::size, udomain::table, and ul_lock_idx().
Referenced by bind_usrloc(), mi_usrloc_add(), mi_usrloc_rm_aor(), mi_usrloc_rm_contact(), mi_usrloc_show_contact(), and preload_udomain().
| void lock_ulslot | ( | udomain_t * | _d, | |
| int | i | |||
| ) |
Get lock for a slot.
| _d | domain | |
| i | slot number |
Definition at line 789 of file udomain.c.
References db_mode, DB_ONLY, hslot::lockidx, udomain::table, and ul_lock_idx().
Referenced by free_udomain(), get_all_mem_ucontacts(), mem_timer_udomain(), and mi_usrloc_dump().
Remove a record from domain in memory.
| _d | domain the record belongs to | |
| _r | deleted record |
Definition at line 705 of file udomain.c.
References free_urecord(), urecord::slot, slot_rem(), update_stat, and udomain::users.
Referenced by mem_timer_udomain(), and release_urecord().
Insert a new record into domain in memory.
| _d | domain the record belongs to | |
| _aor | address of record | |
| _r | new created record |
Definition at line 684 of file udomain.c.
References LM_ERR, udomain::name, new_urecord(), udomain::size, slot_add(), udomain::table, update_stat, and udomain::users.
Referenced by insert_urecord(), and preload_udomain().
| void mem_timer_udomain | ( | udomain_t * | _d | ) |
Run timer handler for given domain.
| _d | domain |
Definition at line 717 of file udomain.c.
References urecord::contacts, hslot::first, lock_ulslot(), mem_delete_urecord(), urecord::next, udomain::size, udomain::table, timer_urecord(), and unlock_ulslot().
Referenced by synchronize_all_udomains().
Create a new domain structure.
| _n | is pointer to str representing name of the domain, the string is not copied, it should point to str structure stored in domain list | |
| _s | is hash table size | |
| _d | new created domain |
Definition at line 83 of file udomain.c.
References init_slot(), LM_ERR, register_stat, shm_free, shm_malloc(), STAT_NO_RESET, and STAT_SHM_NAME.
Referenced by new_dlist().
Load all records from a udomain.
Load all records from a udomain, useful to populate the memory cache on startup.
| _c | database connection | |
| _d | loaded domain |
Definition at line 346 of file udomain.c.
References callid_col, cflags_col, columns, contact_col, CS_SYNC, cseq_col, DB_CAP_FETCH, DB_CAPABILITY, dbrow2info(), domain_col, expires_col, db_func::fetch_result, flags_col, db_func::free_result, free_ucontact(), get_urecord(), last_mod_col, _str::len, LM_CRIT, LM_DBG, LM_ERR, LM_NOTICE, lock_udomain(), MAX_URI_SIZE, mem_insert_ucontact(), mem_insert_urecord(), methods_col, udomain::name, NULL, path_col, q_col, db_func::query, received_col, RES_ROW_N, RES_ROWS, ROW_VALUES, _str::s, snprintf, sock_col, ucontact::state, ul_dbf, ul_fetch_rows, unlock_udomain(), use_domain, db_func::use_table, user, user_agent_col, user_col, VAL_NULL, and VAL_STRING.
Referenced by child_init().
| void print_udomain | ( | FILE * | _f, | |
| udomain_t * | _d | |||
| ) |
Print udomain, debugging helper function.
Definition at line 185 of file udomain.c.
References hslot::first, _str::len, max, hslot::n, udomain::name, urecord::next, print_urecord(), _str::s, udomain::size, urecord::slot, table, udomain::table, and ZSW.
Referenced by print_all_udomains().
performs a dummy query just to see if DB is ok
| con | database connection | |
| d | domain |
Definition at line 649 of file udomain.c.
References DB_STRING, db_func::free_result, LM_ERR, udomain::name, NULL, db_func::query, ul_dbf, db_func::use_table, user_col, VAL_NULL, VAL_STRING, and VAL_TYPE.
Referenced by register_udomain().
Release lock for a domain.
| _d | domain | |
| _aor | address of record, uses as hash source for the lock slot |
Definition at line 770 of file udomain.c.
References core_hash(), db_mode, DB_ONLY, hslot::lockidx, udomain::size, udomain::table, and ul_release_idx().
Referenced by bind_usrloc(), mi_usrloc_add(), mi_usrloc_rm_aor(), mi_usrloc_rm_contact(), mi_usrloc_show_contact(), and preload_udomain().
| void unlock_ulslot | ( | udomain_t * | _d, | |
| int | i | |||
| ) |
Release lock for a slot.
| _d | domain | |
| i | slot number |
Definition at line 805 of file udomain.c.
References db_mode, DB_ONLY, hslot::lockidx, udomain::table, and ul_release_idx().
Referenced by free_udomain(), get_all_mem_ucontacts(), mem_timer_udomain(), and mi_usrloc_dump().
1.5.6