Hi All!
I had a need to know how many outstanding resources there were in a reslist.
Comments?
-Ryan
Index: include/apr_reslist.h
===================================================================
--- include/apr_reslist.h (revision 10420)
+++ include/apr_reslist.h (working copy)
@@ -125,6 +125,12 @@
apr_interval_time_t timeout);
/**
+ * Return the number of outstanding resources
+ * @param reslist The resource list.
+ */
+APU_DECLARE(apr_uint32_t) apr_reslist_acquired_count(apr_reslist_t *reslist);
+
+/**
* Invalidate a resource in the pool - e.g. a database connection
* that returns a "lost connection" error and can't be restored.
* Use this instead of apr_reslist_release if the resource is bad.
Index: misc/apr_reslist.c
===================================================================
--- misc/apr_reslist.c (revision 10420)
+++ misc/apr_reslist.c (working copy)
@@ -362,6 +362,17 @@
reslist->timeout = timeout;
}
+APU_DECLARE(apr_uint32_t) apr_reslist_acquired_count(apr_reslist_t *reslist)
+{
+ apr_uint32_t count;
+
+ apr_thread_mutex_lock(reslist->listlock);
+ count = reslist->ntotal - reslist->nidle;
+ apr_thread_mutex_unlock(reslist->listlock);
+
+ return count;
+}
+
APU_DECLARE(apr_status_t) apr_reslist_invalidate(apr_reslist_t *reslist,
void *resource)
{