summaryrefslogtreecommitdiff
path: root/util-misc
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2018-06-21 22:17:48 +0000
committerYann Ylavic <ylavic@apache.org>2018-06-21 22:17:48 +0000
commit67a609a4cfde8988d37bb34139eaeaabef8976da (patch)
tree1cc7bc79da0eeb5eac36e8432b281aa378d0a438 /util-misc
parent2a935660953233f477351be519aefa269f434526 (diff)
downloadapr-67a609a4cfde8988d37bb34139eaeaabef8976da.tar.gz
apr_reslist: put common code in push_resource().
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1834064 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'util-misc')
-rw-r--r--util-misc/apr_reslist.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/util-misc/apr_reslist.c b/util-misc/apr_reslist.c
index 76e35c349..7e87be828 100644
--- a/util-misc/apr_reslist.c
+++ b/util-misc/apr_reslist.c
@@ -83,13 +83,23 @@ static apr_res_t *pop_resource(apr_reslist_t *reslist, int fifo)
* it was added to the list.
* Assumes: that the reslist is locked.
*/
-static void push_resource(apr_reslist_t *reslist, apr_res_t *resource)
+static apr_status_t push_resource(apr_reslist_t *reslist,
+ apr_res_t *resource, int new)
{
APR_RING_INSERT_HEAD(&reslist->avail_list, resource, apr_res_t, link);
if (reslist->ttl) {
resource->freed = apr_time_now();
}
reslist->nidle++;
+ if (new) {
+ reslist->ntotal++;
+ }
+#if APR_HAS_THREADS
+ /* If someone is waiting on that guy, wake them up. */
+ return apr_thread_cond_signal(reslist->avail);
+#else
+ return APR_SUCCESS;
+#endif
}
/**
@@ -197,16 +207,10 @@ static apr_status_t reslist_maintain(apr_reslist_t *reslist)
return rv;
}
/* Add it to the list */
- push_resource(reslist, res);
- /* Update our counters */
- reslist->ntotal++;
- /* If someone is waiting on that guy, wake them up. */
-#if APR_HAS_THREADS
- rv = apr_thread_cond_signal(reslist->avail);
+ rv = push_resource(reslist, res, 1);
if (rv != APR_SUCCESS) {
return rv;
}
-#endif
created_one++;
}
@@ -453,10 +457,7 @@ APR_DECLARE(apr_status_t) apr_reslist_release(apr_reslist_t *reslist,
#endif
res = get_container(reslist);
res->opaque = resource;
- push_resource(reslist, res);
-#if APR_HAS_THREADS
- apr_thread_cond_signal(reslist->avail);
-#endif
+ push_resource(reslist, res, 0);
rv = reslist_maintain(reslist);
#if APR_HAS_THREADS
apr_thread_mutex_unlock(reslist->listlock);