bdb_lib.c File Reference

#include <stdio.h>
#include <string.h>
#include <time.h>
#include <sys/types.h>
#include <dirent.h>
#include "../../ut.h"
#include "../../mem/mem.h"
#include "../../dprint.h"
#include "bdb_util.h"
#include "bdb_lib.h"
#include "bdb_val.h"

Include dependency graph for bdb_lib.c:

Go to the source code of this file.

Functions

int bdblib_close (char *_n)
int bdblib_create_dbenv (DB_ENV **_dbenv, char *_home)
int bdblib_create_journal (table_p _tp)
table_p bdblib_create_table (database_p _db, str *_s)
int bdblib_destroy (void)
database_p bdblib_get_db (str *_s)
tbl_cache_p bdblib_get_table (database_p _db, str *_s)
int bdblib_init (db_parms_p _p)
void bdblib_log (int op, table_p _tp, char *_msg, int len)
int bdblib_recover (table_p _tp, int _rc)
int bdblib_reopen (char *_n)
int bdblib_valtochar (table_p _tp, int *_lres, char *_k, int *_klen, db_val_t *_v, int _n, int _ko)
int db_free (database_p _dbp)
int load_metadata_columns (table_p _tp)
int load_metadata_defaults (table_p _tp)
int load_metadata_keys (table_p _tp)
int load_metadata_logflags (table_p _tp)
int load_metadata_readonly (table_p _tp)
int tbl_cache_free (tbl_cache_p _tbc)
int tbl_free (table_p _tp)

Variables

static database_p_cachedb = NULL
static db_parms_p _db_parms = NULL


Function Documentation

int bdblib_close ( char *  _n  ) 

closes the underlying Berkeley DB. assumes the lib data-structures are already initialzed; used to sync and reload the db file.

Definition at line 104 of file bdb_lib.c.

References _table::db, _database::dbenv, _tbl_cache::dtp, _str::len, LM_CRIT, LM_DBG, _table::name, _database::name, _tbl_cache::next, NULL, _str::s, s, _table::sem, and _database::tables.

Referenced by bdb_reload().

int bdblib_create_dbenv ( DB_ENV **  _dbenv,
char *  _home 
)

Definition at line 298 of file bdb_lib.c.

References _db_parms::cache_size, and LM_ERR.

Referenced by bdblib_get_db(), and bdblib_reopen().

int bdblib_create_journal ( table_p  _tp  ) 

table_p bdblib_create_table ( database_p  _db,
str _s 
)

The function is called to create a handle to a db table.

On startup, we do not create any of the db handles. Instead it is done on first-use (lazy-initialized) to only create handles to files (db) that we require.

There is one db file per openser table (eg. acc), and they should exist in your DB_PATH (refer to kamctlrc) directory.

This function does _not_ create the underlying binary db tables. Creating the tables MUST be manually performed before openser startup by 'kamdbctl create'

Function returns NULL on error, which will cause openser to exit.

Definition at line 562 of file bdb_lib.c.

References bdblib_create_journal(), _table::colp, _table::db, _database::dbenv, _table::fp, _table::ino, JLOG_FILE, _str::len, LM_DBG, LM_ERR, LM_INFO, load_metadata_columns(), load_metadata_defaults(), load_metadata_keys(), load_metadata_logflags(), load_metadata_readonly(), _table::logflags, MAX_NUM_COLS, MAX_TABLENAME_SIZE, _table::name, _table::ncols, _table::nkeys, NULL, pkg_free, pkg_malloc, _table::ro, _str::s, _table::sem, and _table::t.

Referenced by bdblib_get_table().

int bdblib_destroy ( void   ) 

close all DBs and then the DBENV; free all memory

Definition at line 92 of file bdb_lib.c.

References db_free(), and pkg_free.

Referenced by bdblib_recover(), and destroy().

database_p bdblib_get_db ( str _s  ) 

tbl_cache_p bdblib_get_table ( database_p  _db,
str _s 
)

look thru a linked list for the table. if dne, create a new one and add to the list

Definition at line 421 of file bdb_lib.c.

References bdblib_create_table(), _database::dbenv, _tbl_cache::dtp, _str::len, LM_DBG, LM_ERR, _table::name, _tbl_cache::next, NULL, pkg_free, pkg_malloc, _str::s, _tbl_cache::sem, and _database::tables.

Referenced by _bdb_delete_cursor(), bdb_check_reload(), bdb_delete(), bdb_insert(), bdb_query(), and bdb_update().

int bdblib_init ( db_parms_p  _p  ) 

void bdblib_log ( int  op,
table_p  _tp,
char *  _msg,
int  len 
)

int bdblib_recover ( table_p  _tp,
int  _rc 
)

Definition at line 1309 of file bdb_lib.c.

References bdblib_destroy(), and LM_ERR.

Referenced by _bdb_delete_cursor(), bdb_delete(), bdb_insert(), bdb_query(), bdb_update(), and bdblib_reopen().

int bdblib_reopen ( char *  _n  ) 

opens the underlying Berkeley DB. assumes the lib data-structures are already initialzed; used to sync and reload the db file.

Definition at line 188 of file bdb_lib.c.

References bdblib_create_dbenv(), bdblib_recover(), _table::db, _database::dbenv, _tbl_cache::dtp, _str::len, LM_CRIT, LM_DBG, _table::name, _database::name, _tbl_cache::next, NULL, _str::s, s, _table::sem, and _database::tables.

Referenced by bdb_reload().

int bdblib_valtochar ( table_p  _tp,
int *  _lres,
char *  _k,
int *  _klen,
db_val_t _v,
int  _n,
int  _ko 
)

int db_free ( database_p  _dbp  ) 

int load_metadata_columns ( table_p  _tp  ) 

int load_metadata_defaults ( table_p  _tp  ) 

int load_metadata_keys ( table_p  _tp  ) 

Definition at line 857 of file bdb_lib.c.

References _table::colp, _table::db, _column::flag, LM_ERR, MAX_ROW_SIZE, METADATA_KEY, _table::nkeys, NULL, and s.

Referenced by bdblib_create_table().

int load_metadata_logflags ( table_p  _tp  ) 

Definition at line 934 of file bdb_lib.c.

References _table::db, _table::logflags, MAX_ROW_SIZE, METADATA_LOGFLAGS, and NULL.

Referenced by bdblib_create_table().

int load_metadata_readonly ( table_p  _tp  ) 

Definition at line 902 of file bdb_lib.c.

References _table::db, MAX_ROW_SIZE, METADATA_READONLY, NULL, and _table::ro.

Referenced by bdblib_create_table().

int tbl_cache_free ( tbl_cache_p  _tbc  ) 

Definition at line 1263 of file bdb_lib.c.

References _tbl_cache::dtp, pkg_free, _tbl_cache::sem, and tbl_free().

Referenced by db_free().

int tbl_free ( table_p  _tp  ) 

close DB (sync data to disk) and free mem

Definition at line 1283 of file bdb_lib.c.

References _table::colp, _table::db, _column::dv, _table::fp, _column::name, _table::name, _table::ncols, pkg_free, and _str::s.

Referenced by tbl_cache_free().


Variable Documentation

database_p* _cachedb = NULL [static]

Definition at line 43 of file bdb_lib.c.

db_parms_p _db_parms = NULL [static]

Definition at line 44 of file bdb_lib.c.


Generated on Thu May 17 12:00:35 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6