/** * conn.c * * Copyright (C) 2003 - 2008 Bojan Smojver, Rexursive * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 2.1 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * */ #include "private.h" void *rxv_spin_conn_get(rxv_spin_ctx_t *ctx,const char *conninfo){ void *v; if(!(ctx && ctx->conf->connpool && conninfo)) return NULL; rxv_spin_lock(ctx->priv); v=apr_hash_get(ctx->priv->conns,conninfo,APR_HASH_KEY_STRING); rxv_spin_unlock(ctx->priv); return v; } void *rxv_spin_conn_set(rxv_spin_ctx_t *ctx, const char *conninfo,void *conn, apr_status_t (*cleanup)(void *data)){ if(!(ctx && ctx->conf->connpool && conninfo && conn && cleanup)) return NULL; rxv_spin_lock(ctx->priv); apr_hash_set(ctx->priv->conns,conninfo,APR_HASH_KEY_STRING,conn); apr_pool_cleanup_register(ctx->priv->pool,conn,cleanup,apr_pool_cleanup_null); rxv_spin_unlock(ctx->priv); return conn; }