citadel
About: Citadel is an advanced messaging and collaboration system for groupware and BBS applications (preferred OS: Linux).
  Fossies Dox: citadel.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

database.c File Reference
#include "sysdep.h"
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <stdio.h>
#include <dirent.h>
#include <zlib.h>
#include <db.h>
#include <libcitadel.h>
#include "ctdl_module.h"
#include "control.h"
#include "citserver.h"
#include "config.h"
Include dependency graph for database.c:

Go to the source code of this file.

Macros

#define MAX_CHECKPOINT_KBYTES   256
 
#define MAX_CHECKPOINT_MINUTES   15
 

Functions

void cdb_abort (void)
 
void cdb_verbose_log (const DB_ENV *dbenv, const char *msg)
 
void cdb_verbose_err (const DB_ENV *dbenv, const char *errpfx, const char *msg)
 
static void txabort (DB_TXN *tid)
 
static void txcommit (DB_TXN *tid)
 
static void txbegin (DB_TXN **tid)
 
static void dbpanic (DB_ENV *env, int errval)
 
static void cclose (DBC *cursor)
 
static void bailIfCursor (DBC **cursors, const char *msg)
 
void cdb_check_handles (void)
 
void cdb_checkpoint (void)
 
void open_databases (void)
 
void cdb_chmod_data (void)
 
void close_databases (void)
 
void cdb_decompress_if_necessary (struct cdbdata *cdb)
 
int cdb_store (int cdb, const void *ckey, int ckeylen, void *cdata, int cdatalen)
 
int cdb_delete (int cdb, void *key, int keylen)
 
static DBC * localcursor (int cdb)
 
struct cdbdatacdb_fetch (int cdb, const void *key, int keylen)
 
void cdb_free (struct cdbdata *cdb)
 
void cdb_close_cursor (int cdb)
 
void cdb_rewind (int cdb)
 
struct cdbdatacdb_next_item (int cdb)
 
void cdb_begin_transaction (void)
 
void cdb_end_transaction (void)
 
void cdb_trunc (int cdb)
 
void cdb_compact (void)
 
int CheckIfAlreadySeen (StrBuf *guid)
 
char * ctdl_module_database_init (int threading)
 

Variables

static DB * dbp [MAXCDB]
 
static DB_ENV * dbenv
 

Macro Definition Documentation

◆ MAX_CHECKPOINT_KBYTES

#define MAX_CHECKPOINT_KBYTES   256

Tunable configuration parameters for the Berkeley DB back end

Definition at line 21 of file database.c.

◆ MAX_CHECKPOINT_MINUTES

#define MAX_CHECKPOINT_MINUTES   15

Definition at line 22 of file database.c.

Function Documentation

◆ bailIfCursor()

static void bailIfCursor ( DBC **  cursors,
const char *  msg 
)
static

Definition at line 126 of file database.c.

References cdb_abort(), and MAXCDB.

Referenced by cdb_begin_transaction(), cdb_check_handles(), cdb_delete(), cdb_store(), and cdb_trunc().

◆ cclose()

static void cclose ( DBC *  cursor)
static

Definition at line 116 of file database.c.

References cdb_abort().

Referenced by cdb_close_cursor(), cdb_end_transaction(), and cdb_fetch().

◆ cdb_abort()

◆ cdb_begin_transaction()

void cdb_begin_transaction ( void  )

Definition at line 688 of file database.c.

References bailIfCursor(), cdb_abort(), TSD, and txbegin().

Referenced by check_ref_counts().

◆ cdb_check_handles()

void cdb_check_handles ( void  )

◆ cdb_checkpoint()

void cdb_checkpoint ( void  )

◆ cdb_chmod_data()

void cdb_chmod_data ( void  )

Definition at line 285 of file database.c.

References ctdl_db_dir, CTDLUID, and snprintf().

Referenced by main().

◆ cdb_close_cursor()

void cdb_close_cursor ( int  cdb)

Definition at line 617 of file database.c.

References cclose(), and TSD.

Referenced by cdb_next_item(), and cmd_gnur().

◆ cdb_compact()

void cdb_compact ( void  )

Definition at line 764 of file database.c.

References dbp, and MAXCDB.

Referenced by purge_databases().

◆ cdb_decompress_if_necessary()

void cdb_decompress_if_necessary ( struct cdbdata cdb)

◆ cdb_delete()

◆ cdb_end_transaction()

void cdb_end_transaction ( void  )

Definition at line 700 of file database.c.

References cclose(), cdb_abort(), MAXCDB, TSD, and txcommit().

Referenced by check_ref_counts().

◆ cdb_fetch()

◆ cdb_free()

◆ cdb_next_item()

◆ cdb_rewind()

◆ cdb_store()

◆ cdb_trunc()

void cdb_trunc ( int  cdb)

◆ cdb_verbose_err()

void cdb_verbose_err ( const DB_ENV *  dbenv,
const char *  errpfx,
const char *  msg 
)

Definition at line 66 of file database.c.

Referenced by open_databases().

◆ cdb_verbose_log()

void cdb_verbose_log ( const DB_ENV *  dbenv,
const char *  msg 
)

Definition at line 58 of file database.c.

Referenced by open_databases().

◆ CheckIfAlreadySeen()

int CheckIfAlreadySeen ( StrBuf *  guid)

◆ close_databases()

void close_databases ( void  )

Definition at line 310 of file database.c.

References dbenv, dbp, and MAXCDB.

Referenced by master_cleanup().

◆ ctdl_module_database_init()

char * ctdl_module_database_init ( int  threading)

Definition at line 804 of file database.c.

◆ dbpanic()

static void dbpanic ( DB_ENV *  env,
int  errval 
)
static

Definition at line 111 of file database.c.

Referenced by open_databases().

◆ localcursor()

static DBC * localcursor ( int  cdb)
static

Definition at line 521 of file database.c.

References cdb_abort(), dbp, and TSD.

Referenced by cdb_fetch().

◆ open_databases()

void open_databases ( void  )

◆ txabort()

static void txabort ( DB_TXN *  tid)
static

Definition at line 72 of file database.c.

References cdb_abort().

Referenced by cdb_delete(), and cdb_store().

◆ txbegin()

static void txbegin ( DB_TXN **  tid)
static

Definition at line 98 of file database.c.

References cdb_abort(), and dbenv.

Referenced by cdb_begin_transaction(), cdb_delete(), and cdb_store().

◆ txcommit()

static void txcommit ( DB_TXN *  tid)
static

Definition at line 85 of file database.c.

References cdb_abort().

Referenced by cdb_delete(), cdb_end_transaction(), and cdb_store().

Variable Documentation

◆ dbenv

DB_ENV* dbenv
static

Definition at line 46 of file database.c.

Referenced by cdb_checkpoint(), close_databases(), open_databases(), and txbegin().

◆ dbp