udomain.h File Reference

USRLOC - Usrloc domain structure. More...

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

Include dependency graph for udomain.h:

This graph shows which files directly or indirectly include this file:

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.


Detailed Description

USRLOC - Usrloc domain structure.

Definition in file udomain.h.


Typedef Documentation

typedef int(* delete_urecord_t)(udomain_t *_d, str *_aor, struct urecord *_r)

Delete a urecord from domain.

Parameters:
_d domain where the record should be deleted
_aor address of record
_r deleted record
Returns:
0 on success, -1 if the record could not be deleted

Definition at line 204 of file udomain.h.

typedef int(* get_urecord_t)(udomain_t *_d, str *_aor, struct urecord **_r)

Obtain a urecord pointer if the urecord exists in domain.

Parameters:
_d domain to search the record
_aor address of record
_r new created record
Returns:
0 if a record was found, 1 if nothing could be found

Definition at line 193 of file udomain.h.

typedef int(* insert_urecord_t)(udomain_t *_d, str *_aor, struct urecord **_r)

Create and insert a new record.

Parameters:
_d domain to insert the new record
_aor address of the record
_r new created record
Returns:
return 0 on success, -1 on failure

Definition at line 182 of file udomain.h.

typedef void(* lock_udomain_t)(udomain_t *_d, str *_aor)

Timer handler for given domain.

Definition at line 145 of file udomain.h.

typedef struct udomain udomain_t

The structure represents a usrloc domain.

Usrloc record

typedef void(* unlock_udomain_t)(udomain_t *_d, str *_aor)

Release lock for a domain.

Parameters:
_d domain
_aor address of record, uses as hash source for the lock slot

Definition at line 154 of file udomain.h.


Function Documentation

int db_timer_udomain ( udomain_t _d  ) 

Timer function to cleanup expired contacts, DB_ONLY db_mode.

Parameters:
_d cleaned domain
Returns:
0 on success, -1 on failure

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().

int delete_urecord ( udomain_t _d,
str _aor,
struct urecord _r 
)

Delete a urecord from domain.

Parameters:
_d domain where the record should be deleted
_aor address of record
_r deleted record
Returns:
0 on success, -1 if the record could not be deleted

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.

Parameters:
_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().

int get_urecord ( udomain_t _d,
str _aor,
struct urecord **  _r 
)

Obtain a urecord pointer if the urecord exists in domain.

Parameters:
_d domain to search the record
_aor address of record
_r new created record
Returns:
0 if a record was found, 1 if nothing could be found

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().

int insert_urecord ( udomain_t _d,
str _aor,
struct urecord **  _r 
)

Create and insert a new record.

Parameters:
_d domain to insert the new record
_aor address of the record
_r new created record
Returns:
return 0 on success, -1 on failure

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().

void lock_udomain ( udomain_t _d,
str _aor 
)

Get lock for a domain.

Parameters:
_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.

Parameters:
_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().

void mem_delete_urecord ( udomain_t _d,
struct urecord _r 
)

Remove a record from domain in memory.

Parameters:
_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().

int mem_insert_urecord ( udomain_t _d,
str _aor,
struct urecord **  _r 
)

Insert a new record into domain in memory.

Parameters:
_d domain the record belongs to
_aor address of record
_r new created record
Returns:
0 on success, -1 on failure

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.

Parameters:
_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().

int new_udomain ( str _n,
int  _s,
udomain_t **  _d 
)

Create a new domain structure.

Parameters:
_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
Returns:
0 on success, -1 on failure

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().

int preload_udomain ( db_con_t _c,
udomain_t _d 
)

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().

int testdb_udomain ( db_con_t con,
udomain_t d 
)

performs a dummy query just to see if DB is ok

Parameters:
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().

void unlock_udomain ( udomain_t _d,
str _aor 
)

Release lock for a domain.

Parameters:
_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.

Parameters:
_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().


Generated on Thu May 24 22:00:45 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6