From: Yann Ylavic Date: Fri, 19 Jan 2018 14:16:01 +0000 (+0000) Subject: mpm_fdqueue: follow up to r1821624. X-Git-Tag: 2.5.0-alpha2-ci-test-only~2931 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b6172385fc54786b27101df205596229e0667cd;p=thirdparty%2Fapache%2Fhttpd.git mpm_fdqueue: follow up to r1821624. Make the allocation and zero-ing in ap_queue_init() => ap_queue_create(). git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1821660 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/mpm/event/event.c b/server/mpm/event/event.c index 57344780f1c..fa36e44db1d 100644 --- a/server/mpm/event/event.c +++ b/server/mpm/event/event.c @@ -2454,11 +2454,10 @@ static void *APR_THREAD_FUNC start_threads(apr_thread_t * thd, void *dummy) /* We must create the fd queues before we start up the listener * and worker threads. */ - worker_queue = apr_pcalloc(pchild, sizeof(*worker_queue)); - rv = ap_queue_init(worker_queue, threads_per_child, pchild); + rv = ap_queue_create(&worker_queue, threads_per_child, pchild); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ALERT, rv, ap_server_conf, APLOGNO(03100) - "ap_queue_init() failed"); + "ap_queue_create() failed"); clean_child_exit(APEXIT_CHILDFATAL); } diff --git a/server/mpm/worker/worker.c b/server/mpm/worker/worker.c index 2c4bdef4e2a..340dff94cb8 100644 --- a/server/mpm/worker/worker.c +++ b/server/mpm/worker/worker.c @@ -908,11 +908,10 @@ static void * APR_THREAD_FUNC start_threads(apr_thread_t *thd, void *dummy) /* We must create the fd queues before we start up the listener * and worker threads. */ - worker_queue = apr_pcalloc(pchild, sizeof(*worker_queue)); - rv = ap_queue_init(worker_queue, threads_per_child, pchild); + rv = ap_queue_create(&worker_queue, threads_per_child, pchild); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ALERT, rv, ap_server_conf, APLOGNO(03140) - "ap_queue_init() failed"); + "ap_queue_create() failed"); clean_child_exit(APEXIT_CHILDFATAL); } diff --git a/server/mpm_fdqueue.c b/server/mpm_fdqueue.c index 81186455515..3c0f064ebc9 100644 --- a/server/mpm_fdqueue.c +++ b/server/mpm_fdqueue.c @@ -343,10 +343,12 @@ static apr_status_t ap_queue_destroy(void *data) /** * Initialize the fd_queue_t. */ -apr_status_t ap_queue_init(fd_queue_t *queue, int capacity, apr_pool_t *p) +apr_status_t ap_queue_create(fd_queue_t **pqueue, int capacity, apr_pool_t *p) { - int i; apr_status_t rv; + fd_queue_t *queue; + + queue = apr_pcalloc(p, sizeof *queue); if ((rv = apr_thread_mutex_create(&queue->one_big_mutex, APR_THREAD_MUTEX_DEFAULT, @@ -359,18 +361,12 @@ apr_status_t ap_queue_init(fd_queue_t *queue, int capacity, apr_pool_t *p) APR_RING_INIT(&queue->timers, timer_event_t, link); - queue->data = apr_palloc(p, capacity * sizeof(fd_queue_elem_t)); + queue->data = apr_pcalloc(p, capacity * sizeof(fd_queue_elem_t)); queue->bounds = capacity; - queue->nelts = 0; - queue->in = 0; - queue->out = 0; - - /* Set all the sockets in the queue to NULL */ - for (i = 0; i < capacity; ++i) - queue->data[i].sd = NULL; apr_pool_cleanup_register(p, queue, ap_queue_destroy, apr_pool_cleanup_null); + *pqueue = queue; return APR_SUCCESS; } @@ -422,11 +418,7 @@ apr_status_t ap_queue_push_timer(fd_queue_t *queue, timer_event_t *te) apr_thread_cond_signal(queue->not_empty); - if ((rv = apr_thread_mutex_unlock(queue->one_big_mutex)) != APR_SUCCESS) { - return rv; - } - - return APR_SUCCESS; + return apr_thread_mutex_unlock(queue->one_big_mutex); } /** diff --git a/server/mpm_fdqueue.h b/server/mpm_fdqueue.h index f454e7bd0ce..a4910f42434 100644 --- a/server/mpm_fdqueue.h +++ b/server/mpm_fdqueue.h @@ -86,7 +86,7 @@ void ap_pop_pool(apr_pool_t **recycled_pool, fd_queue_info_t *queue_info); void ap_push_pool(fd_queue_info_t *queue_info, apr_pool_t *pool_to_recycle); void ap_free_idle_pools(fd_queue_info_t *queue_info); -apr_status_t ap_queue_init(fd_queue_t *queue, int capacity, apr_pool_t *p); +apr_status_t ap_queue_create(fd_queue_t **pqueue, int capacity, apr_pool_t *p); apr_status_t ap_queue_push_socket(fd_queue_t *queue, apr_socket_t *sd, void *sd_baton, apr_pool_t *p);