Connection functions

Functions

void * rxv_spin_conn_get (rxv_spin_ctx_t *ctx, const char *conninfo)
void * rxv_spin_conn_set (rxv_spin_ctx_t *ctx, const char *conninfo, void *conn, apr_status_t(*cleanup)(void *data))

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:
 rxv_spin_conn_get(ctx,"openldap:ldap://ldap.example.com/dc=example,dc=com");
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);
Remarks:
This function will register the connection even if the connection with the same key already exists. This may lead to multiple cleanup functions being registered for the same connection and eventually segfaults. Use rxv_spin_conn_get() function to verify if the connection was registered before.
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.
 All Files Functions Typedefs Enumerations Enumerator Defines

Generated on 29 Dec 2009 for mod_spin by  doxygen 1.6.1