]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mpm_fdqueue: follow up to r1821624.
authorYann Ylavic <ylavic@apache.org>
Fri, 19 Jan 2018 14:16:01 +0000 (14:16 +0000)
committerYann Ylavic <ylavic@apache.org>
Fri, 19 Jan 2018 14:16:01 +0000 (14:16 +0000)
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

server/mpm/event/event.c
server/mpm/worker/worker.c
server/mpm_fdqueue.c
server/mpm_fdqueue.h

index 57344780f1cb1bf29e2aa5e04c74b1a2ccff6145..fa36e44db1dd85ba868963edbf2075de614260fb 100644 (file)
@@ -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);
     }
 
index 2c4bdef4e2a4c1a266667402f3ba4b6a389a1c26..340dff94cb8b1c0ab0b339c7a4661a163d639c4d 100644 (file)
@@ -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);
     }
 
index 811864555159383978dd90d7b24ed3ccee2606f8..3c0f064ebc9e6817b101956a37006f4e914fd672 100644 (file)
@@ -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);
 }
 
 /**
index f454e7bd0ce20a6d80e39b4887784f5305287d3b..a4910f42434384ac098d7a925290bf2047e347a7 100644 (file)
@@ -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);