From: Joe Orton Date: Thu, 8 Jul 2021 07:04:49 +0000 (+0000) Subject: Merge r1889957 from trunk: [excluding server/mpm/simple changes] X-Git-Tag: candidate-2.4.49~3^2~72 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2cfafb4a3690ecd60c7d955e12429af0c9082af3;p=thirdparty%2Fapache%2Fhttpd.git Merge r1889957 from trunk: [excluding server/mpm/simple changes] * server/mpm/event/event.c, server/mpm/simple/simple_run.c, support/htcacheclean.c: Adjust use of APR_RING macros to ensure the APR_RING_HEAD is always embedded in a containing structure, to avoid warnings with GCC 11. (apr_ring.h also suggests this is best practice) See also: https://bugzilla.redhat.com/show_bug.cgi?id=1957353 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98503 msgid <814cca2a-1992-3fae-bb0e-c84b3d09b73b@gmail.com> Github: closes #186 Reviewed by: jorton, minfrin, jfclere git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1891377 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/mpm/event/event.c b/server/mpm/event/event.c index 6ba01576b05..8977e176dca 100644 --- a/server/mpm/event/event.c +++ b/server/mpm/event/event.c @@ -1338,7 +1338,7 @@ static void get_worker(int *have_idle_worker_p, int blocking, int *all_busy) } /* Structures to reuse */ -static APR_RING_HEAD(timer_free_ring_t, timer_event_t) timer_free_ring; +static timer_event_t timer_free_ring; static apr_skiplist *timer_skiplist; static volatile apr_time_t timers_next_expiry; @@ -1380,8 +1380,8 @@ static apr_status_t event_register_timed_callback(apr_time_t t, /* oh yeah, and make locking smarter/fine grained. */ apr_thread_mutex_lock(g_timer_skiplist_mtx); - if (!APR_RING_EMPTY(&timer_free_ring, timer_event_t, link)) { - te = APR_RING_FIRST(&timer_free_ring); + if (!APR_RING_EMPTY(&timer_free_ring.link, timer_event_t, link)) { + te = APR_RING_FIRST(&timer_free_ring.link); APR_RING_REMOVE(te, link); } else { @@ -1478,7 +1478,7 @@ static void process_timeout_queue(struct timeout_queue *q, { apr_uint32_t total = 0, count; event_conn_state_t *first, *cs, *last; - struct timeout_head_t trash; + struct event_conn_state_t trash; struct timeout_queue *qp; apr_status_t rv; @@ -1486,7 +1486,7 @@ static void process_timeout_queue(struct timeout_queue *q, return; } - APR_RING_INIT(&trash, event_conn_state_t, timeout_list); + APR_RING_INIT(&trash.timeout_list, event_conn_state_t, timeout_list); for (qp = q; qp; qp = qp->next) { count = 0; cs = first = last = APR_RING_FIRST(&qp->head); @@ -1532,7 +1532,7 @@ static void process_timeout_queue(struct timeout_queue *q, continue; APR_RING_UNSPLICE(first, last, timeout_list); - APR_RING_SPLICE_TAIL(&trash, first, last, event_conn_state_t, + APR_RING_SPLICE_TAIL(&trash.timeout_list, first, last, event_conn_state_t, timeout_list); AP_DEBUG_ASSERT(*q->total >= count && qp->count >= count); *q->total -= count; @@ -1543,7 +1543,7 @@ static void process_timeout_queue(struct timeout_queue *q, return; apr_thread_mutex_unlock(timeout_mutex); - first = APR_RING_FIRST(&trash); + first = APR_RING_FIRST(&trash.timeout_list); do { cs = APR_RING_NEXT(first, timeout_list); TO_QUEUE_ELEM_INIT(first); @@ -2059,7 +2059,7 @@ static void *APR_THREAD_FUNC worker_thread(apr_thread_t * thd, void *dummy) { apr_thread_mutex_lock(g_timer_skiplist_mtx); - APR_RING_INSERT_TAIL(&timer_free_ring, te, timer_event_t, link); + APR_RING_INSERT_TAIL(&timer_free_ring.link, te, timer_event_t, link); apr_thread_mutex_unlock(g_timer_skiplist_mtx); } } @@ -2164,7 +2164,7 @@ static void setup_threads_runtime(void) apr_pool_create(&pskip, pconf); apr_pool_tag(pskip, "mpm_skiplist"); apr_thread_mutex_create(&g_timer_skiplist_mtx, APR_THREAD_MUTEX_DEFAULT, pskip); - APR_RING_INIT(&timer_free_ring, timer_event_t, link); + APR_RING_INIT(&timer_free_ring.link, timer_event_t, link); apr_skiplist_init(&timer_skiplist, pskip); apr_skiplist_set_compare(timer_skiplist, timer_comp, timer_comp); diff --git a/support/htcacheclean.c b/support/htcacheclean.c index 609b2e5cc13..b4eabbf3488 100644 --- a/support/htcacheclean.c +++ b/support/htcacheclean.c @@ -110,7 +110,7 @@ static apr_file_t *errfile; /* stderr file handle */ static apr_file_t *outfile; /* stdout file handle */ static apr_off_t unsolicited; /* file size summary for deleted unsolicited files */ -static APR_RING_ENTRY(_entry) root; /* ENTRY ring anchor */ +static ENTRY root; /* ENTRY ring anchor */ /* short program name as called */ static const char *shortname = "htcacheclean"; @@ -605,13 +605,12 @@ static int process_dir(char *path, apr_pool_t *pool, apr_off_t *nodes) apr_size_t len; apr_time_t current, deviation; char *nextpath, *base, *ext; - APR_RING_ENTRY(_direntry) anchor; - DIRENTRY *d, *t, *n; + DIRENTRY *d, *t, *n, anchor; ENTRY *e; int skip, retries; disk_cache_info_t disk_info; - APR_RING_INIT(&anchor, _direntry, link); + APR_RING_INIT(&anchor.link, _direntry, link); apr_pool_create(&p, pool); h = apr_hash_make(p); fd = NULL; @@ -627,7 +626,7 @@ static int process_dir(char *path, apr_pool_t *pool, apr_off_t *nodes) } d = apr_pcalloc(p, sizeof(DIRENTRY)); d->basename = apr_pstrcat(p, path, "/", info.name, NULL); - APR_RING_INSERT_TAIL(&anchor, d, _direntry, link); + APR_RING_INSERT_TAIL(&anchor.link, d, _direntry, link); (*nodes)++; } @@ -639,8 +638,8 @@ static int process_dir(char *path, apr_pool_t *pool, apr_off_t *nodes) skip = baselen + 1; - for (d = APR_RING_FIRST(&anchor); - !interrupted && d != APR_RING_SENTINEL(&anchor, _direntry, link); + for (d = APR_RING_FIRST(&anchor.link); + !interrupted && d != APR_RING_SENTINEL(&anchor.link, _direntry, link); d=n) { n = APR_RING_NEXT(d, link); base = strrchr(d->basename, '/'); @@ -785,7 +784,7 @@ static int process_dir(char *path, apr_pool_t *pool, apr_off_t *nodes) &len) == APR_SUCCESS) { apr_file_close(fd); e = apr_palloc(pool, sizeof(ENTRY)); - APR_RING_INSERT_TAIL(&root, e, _entry, link); + APR_RING_INSERT_TAIL(&root.link, e, _entry, link); e->expire = disk_info.expire; e->response_time = disk_info.response_time; e->htime = d->htime; @@ -901,7 +900,7 @@ static int process_dir(char *path, apr_pool_t *pool, apr_off_t *nodes) &len) == APR_SUCCESS) { apr_file_close(fd); e = apr_palloc(pool, sizeof(ENTRY)); - APR_RING_INSERT_TAIL(&root, e, _entry, link); + APR_RING_INSERT_TAIL(&root.link, e, _entry, link); e->expire = disk_info.expire; e->response_time = disk_info.response_time; e->htime = d->htime; @@ -988,8 +987,8 @@ static void purge(char *path, apr_pool_t *pool, apr_off_t max, s.inodes = inodes; s.ntotal = nodes; - for (e = APR_RING_FIRST(&root); - e != APR_RING_SENTINEL(&root, _entry, link); + for (e = APR_RING_FIRST(&root.link); + e != APR_RING_SENTINEL(&root.link, _entry, link); e = APR_RING_NEXT(e, link)) { s.sum += round_up((apr_size_t)e->hsize, round); s.sum += round_up((apr_size_t)e->dsize, round); @@ -1008,8 +1007,8 @@ static void purge(char *path, apr_pool_t *pool, apr_off_t max, * happen if a wrong system time is corrected */ - for (e = APR_RING_FIRST(&root); - e != APR_RING_SENTINEL(&root, _entry, link) && !interrupted;) { + for (e = APR_RING_FIRST(&root.link); + e != APR_RING_SENTINEL(&root.link, _entry, link) && !interrupted;) { n = APR_RING_NEXT(e, link); if (e->response_time > now || e->htime > now || e->dtime > now) { delete_entry(path, e->basename, &s.nodes, pool); @@ -1033,8 +1032,8 @@ static void purge(char *path, apr_pool_t *pool, apr_off_t max, } /* process all entries which are expired */ - for (e = APR_RING_FIRST(&root); - e != APR_RING_SENTINEL(&root, _entry, link) && !interrupted;) { + for (e = APR_RING_FIRST(&root.link); + e != APR_RING_SENTINEL(&root.link, _entry, link) && !interrupted;) { n = APR_RING_NEXT(e, link); if (e->expire != APR_DATE_BAD && e->expire < now) { delete_entry(path, e->basename, &s.nodes, pool); @@ -1063,11 +1062,11 @@ static void purge(char *path, apr_pool_t *pool, apr_off_t max, * than sorry */ while (!((!s.max || s.sum <= s.max) && (!s.inodes || s.nodes <= s.inodes)) - && !interrupted && !APR_RING_EMPTY(&root, _entry, link)) { - oldest = APR_RING_FIRST(&root); + && !interrupted && !APR_RING_EMPTY(&root.link, _entry, link)) { + oldest = APR_RING_FIRST(&root.link); for (e = APR_RING_NEXT(oldest, link); - e != APR_RING_SENTINEL(&root, _entry, link); + e != APR_RING_SENTINEL(&root.link, _entry, link); e = APR_RING_NEXT(e, link)) { if (e->dtime < oldest->dtime) { oldest = e; @@ -1718,7 +1717,7 @@ int main(int argc, const char * const argv[]) apr_pool_create(&instance, pool); now = apr_time_now(); - APR_RING_INIT(&root, _entry, link); + APR_RING_INIT(&root.link, _entry, link); delcount = 0; unsolicited = 0; dowork = 0;