apr_status_t jxr_conn_setup(jaxer_worker* aw) { apr_status_t rv = APR_SUCCESS; ap_log_perror(APLOG_MARK, APLOG_ZDEBUG, 0, aw->pool, "mod_jaxer: jxr_conn_setup: creating connection pool (min=%d keep=%d max=%d) for worker %s", aw->nmin, aw->nkeep, aw->nmax, aw->name); rv = apr_reslist_create(&aw->ac_cache, aw->nmin, aw->nkeep, aw->nmax, apr_time_from_sec(aw->exptime), jxr_conn_construct, jxr_conn_destruct, aw, aw->res_pool); if (rv == APR_SUCCESS) { apr_reslist_timeout_set(aw->ac_cache, apr_time_from_sec(aw->acquire_timeout)); apr_pool_cleanup_register(aw->res_pool, aw->ac_cache, (void*)apr_reslist_destroy, apr_pool_cleanup_null); ap_log_perror(APLOG_MARK, APLOG_NOTICE, 0, aw->res_pool, "mod_jaxer: connection pool (min=%d keep=%d max=%d) created for worker %s", aw->nmin, aw->nkeep, aw->nmax, aw->name); }else { ap_log_perror(APLOG_MARK, APLOG_CRIT, rv, aw->res_pool, "mod_jaxer: failed to initialize connection reslist for worker %s", aw->name); // apr_pool_destroy(aw->pool); // aw->pool = 0; } return rv; }
static void test_timeout(abts_case *tc, apr_reslist_t *rl) { apr_status_t rv; my_resource_t *resources[RESLIST_HMAX]; my_resource_t *res; void *vp; int i; apr_reslist_timeout_set(rl, 1000); /* deplete all possible resources from the resource list * so that the next call will block until timeout is reached * (since there are no other threads to make a resource * available) */ for (i = 0; i < RESLIST_HMAX; i++) { rv = apr_reslist_acquire(rl, (void**)&resources[i]); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); } /* next call will block until timeout is reached */ rv = apr_reslist_acquire(rl, &vp); ABTS_TRUE(tc, APR_STATUS_IS_TIMEUP(rv)); res = vp; /* release the resources; otherwise the destroy operation * will blow */ for (i = 0; i < RESLIST_HMAX; i++) { rv = apr_reslist_release(rl, resources[i]); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); } }