db_pool.c File Reference

Functions for managing a pool of database connections. More...

#include "../dprint.h"
#include "db_pool.h"

Include dependency graph for db_pool.c:

Go to the source code of this file.

Functions

struct pool_conpool_get (const struct db_id *id)
void pool_insert (struct pool_con *con)
int pool_remove (struct pool_con *con)

Variables

static struct pool_condb_pool = 0


Detailed Description

Functions for managing a pool of database connections.

Definition in file db_pool.c.


Function Documentation

struct pool_con* pool_get ( const struct db_id id  )  [read]

Search the pool for a connection with the identifier equal to the id.

Parameters:
id searched id
Returns:
the connection if it could be found, NULL otherwise

Definition at line 43 of file db_pool.c.

References cmp_db_id(), pool_con::id, LM_ERR, pool_con::next, and pool_con::ref.

Referenced by db_do_init().

void pool_insert ( struct pool_con con  ) 

Insert a new connection into the pool.

Parameters:
con the inserted connection

Definition at line 68 of file db_pool.c.

References pool_con::next.

Referenced by db_do_init().

int pool_remove ( struct pool_con con  ) 

Release a connection from the pool, the function would return 1 when if the connection is not referenced anymore and thus can be closed and deleted by the backend. The function returns 0 if the connection should still be kept open because some other module is still using it. The function returns -1 if the connection is not in the pool.

Parameters:
con connection that should be removed
Returns:
1 if the connection can be freed, 0 if it can't be freed, -1 if not found

Definition at line 87 of file db_pool.c.

References LM_DBG, LM_ERR, pool_con::next, and pool_con::ref.

Referenced by db_do_close().


Variable Documentation

struct pool_con* db_pool = 0 [static]

Definition at line 35 of file db_pool.c.


Generated on Tue May 22 14:00:35 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6