|
libcmdbm 0.2.0
MyBatis-like SQL mapping library for C99
|
How a datasource pools its connections. More...
#include <libcmdbm.h>
Data Fields | |
| uint32_t | pingterm |
| Seconds between two rounds of the idle connection check. | |
| CMBool | pingtest |
Whether idle connections are checked every pingterm seconds. | |
| CMBool | testonborrow |
| Whether a connection is validated when it is borrowed. | |
| uint32_t | initcnt |
| Connections opened when the datasource starts up. | |
| uint32_t | maxcnt |
| Upper limit of open connections. A session which asks for one beyond it waits, and gives up after five seconds. | |
| char * | testsql |
| The statement which validates a connection. | |
How a datasource pools its connections.
The struct is copied by CMDBM_DatabaseCreate, so a caller may fill one in on the stack, and testsql is copied too.
| uint32_t CMDBM_PoolConfig::pingterm |
Seconds between two rounds of the idle connection check.
0 is taken as the default of 30 - the check is a repeating task and cannot run with no period at all.
| CMBool CMDBM_PoolConfig::pingtest |
Whether idle connections are checked every pingterm seconds.
The check runs testsql on each connection currently sitting in the pool, and replaces the ones which do not answer - which is what keeps a pool usable across a database restart or an idle timeout on the server.
| CMBool CMDBM_PoolConfig::testonborrow |
Whether a connection is validated when it is borrowed.
The safe setting, and the default: a session never gets a connection the database has dropped meanwhile. It costs one round trip per checkout, which is what pingtest alone avoids.
With this and pingtest both off, connections are handed out without ever being tested.
| char* CMDBM_PoolConfig::testsql |
The statement which validates a connection.
NULL takes the one of the module, CMDBM_ModuleInterface::GetTestQuery - which is how an Oracle datasource ends up validating with "select 1 from dual" without anything having to say so.