From c8bfc84832f2b46b9b4b27d78ee5b3f51ccd4f5d Mon Sep 17 00:00:00 2001 From: Yann Ylavic Date: Fri, 13 Mar 2015 14:47:50 +0000 Subject: [PATCH] mpm_event: Allow for timer events duplicates. Meanwhile ap[r]_skiplist_add()... git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1666468 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 2 ++ server/mpm/event/event.c | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 0222887db0..416240ad5a 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,8 @@ Changes with Apache 2.5.0 to a local URL-path with the INCLUDES filter active, introduced in 2.4.11. PR 57531. [Yann Ylavic] + *) mpm_event: Allow for timer events duplicates. [Jim Jagielski, Yann Ylavic] + *) mod_dav: Avoid a potential integer underflow in the lock timeout value sent back to a client. The answer to a LOCK request could be an extremly large integer if the time needed to lock the resource was longer that the diff --git a/server/mpm/event/event.c b/server/mpm/event/event.c index be464a8772..595105c510 100644 --- a/server/mpm/event/event.c +++ b/server/mpm/event/event.c @@ -1460,7 +1460,7 @@ static int indexing_comp(void *a, void *b) apr_time_t t2 = (apr_time_t) (((timer_event_t *) b)->when); AP_DEBUG_ASSERT(t1); AP_DEBUG_ASSERT(t2); - return ((t1 < t2) ? -1 : ((t1 > t2) ? 1 : 0)); + return ((t1 < t2) ? -1 : (t1 > t2)); } static int indexing_compk(void *ac, void *b) @@ -1468,7 +1468,16 @@ static int indexing_compk(void *ac, void *b) apr_time_t *t1 = (apr_time_t *) ac; apr_time_t t2 = (apr_time_t) (((timer_event_t *) b)->when); AP_DEBUG_ASSERT(t2); - return ((*t1 < t2) ? -1 : ((*t1 > t2) ? 1 : 0)); + return ((*t1 < t2) ? -1 : (*t1 > t2)); +} + +static int indexing_add_comp(void *a, void *b) +{ + apr_time_t t1 = (apr_time_t) (((timer_event_t *) a)->when); + apr_time_t t2 = (apr_time_t) (((timer_event_t *) b)->when); + AP_DEBUG_ASSERT(t1); + AP_DEBUG_ASSERT(t2); + return ((t1 < t2) ? -1 : 1); } static apr_thread_mutex_t *g_timer_skiplist_mtx; @@ -1500,8 +1509,8 @@ static timer_event_t * event_get_timer_event(apr_time_t t, te->remove = remove; if (insert) { - /* Okay, insert sorted by when.. */ - apr_skiplist_insert(timer_skiplist, (void *)te); + /* Okay, add sorted by when.. */ + apr_skiplist_insert_compare(timer_skiplist, te, indexing_add_comp); } apr_thread_mutex_unlock(g_timer_skiplist_mtx); -- 2.40.0