Connection functions
Detailed Description
Connection functions (mod_spin API)
Function Documentation
void* rxv_spin_conn_get |
( |
rxv_spin_ctx_t * |
ctx, |
|
|
const char * |
conninfo | |
|
) |
| | |
Get a registered connection from the connection pool.
- Parameters:
-
| ctx | Context |
| conninfo | Connection string for this connection |
- Returns:
- Pointer to the connection or NULL if not found
- Example:
-
void* rxv_spin_conn_set |
( |
rxv_spin_ctx_t * |
ctx, |
|
|
const char * |
conninfo, |
|
|
void * |
conn, |
|
|
apr_status_t(*)(void *data) |
cleanup | |
|
) |
| | |
Register a connection with the connection pool.
- Parameters:
-
| ctx | Context |
| conninfo | Connection string for this connection |
| conn | Connection pointer |
| cleanup | Cleanup function to call on pool destruction |
- Returns:
- Pointer to the connection, NULL on error
- Example:
rxv_spin_conn_set(ctx,"openldap:ldap://host.domain/dc=example,dc=com",
ldapconn,ldap_cleanup);
- Warning:
- If you decide to close the connection by hand, you must remove the cleanup function from the thread specific pool (you can find out what that is by calling rxv_spin_tpool()).
-
The lifetime of the connection and all other variables passed into this function has to be at least the lifetime of the connection pool you are registering the connection with. Normally, connection pools have thread lifetime, so if you have shorter lifetime for your connection (e.g. request, connection) or the connect string, you are setting yourself up for segfaults. Also, if the lifetime of the connection is longer than the one of the connection pool, for instance, if it has the lifetime of the process and you are registering it with the regular thread based connection pool, you may experience segfaults if you rely on that connection once the thread exited.