summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2018-01-19 15:16:01 +0100
committerYann Ylavic <ylavic@apache.org>2018-01-19 15:16:01 +0100
commit5b6172385fc54786b27101df205596229e0667cd (patch)
treee744ee20797a285c81e21c20700c762d9614239d /server
parentmpm_fdqueue: follow up to r1821624. (diff)
downloadapache2-5b6172385fc54786b27101df205596229e0667cd.tar.xz
apache2-5b6172385fc54786b27101df205596229e0667cd.zip
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
Diffstat (limited to 'server')
-rw-r--r--server/mpm/event/event.c5
-rw-r--r--server/mpm/worker/worker.c5
-rw-r--r--server/mpm_fdqueue.c22
-rw-r--r--server/mpm_fdqueue.h2
4 files changed, 12 insertions, 22 deletions
diff --git a/server/mpm/event/event.c b/server/mpm/event/event.c
index 57344780f1..fa36e44db1 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 2c4bdef4e2..340dff94cb 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 8118645551..3c0f064ebc 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 f454e7bd0c..a4910f4243 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);