You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by yl...@apache.org on 2018/01/19 14:16:02 UTC

svn commit: r1821660 - in /httpd/httpd/trunk/server: mpm/event/event.c mpm/worker/worker.c mpm_fdqueue.c mpm_fdqueue.h

Author: ylavic
Date: Fri Jan 19 14:16:01 2018
New Revision: 1821660

URL: http://svn.apache.org/viewvc?rev=1821660&view=rev
Log:
mpm_fdqueue: follow up to r1821624.

Make the allocation and zero-ing in ap_queue_init() => ap_queue_create().


Modified:
    httpd/httpd/trunk/server/mpm/event/event.c
    httpd/httpd/trunk/server/mpm/worker/worker.c
    httpd/httpd/trunk/server/mpm_fdqueue.c
    httpd/httpd/trunk/server/mpm_fdqueue.h

Modified: httpd/httpd/trunk/server/mpm/event/event.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/event/event.c?rev=1821660&r1=1821659&r2=1821660&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/event/event.c (original)
+++ httpd/httpd/trunk/server/mpm/event/event.c Fri Jan 19 14:16:01 2018
@@ -2454,11 +2454,10 @@ static void *APR_THREAD_FUNC start_threa
 
     /* 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);
     }
 

Modified: httpd/httpd/trunk/server/mpm/worker/worker.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/worker/worker.c?rev=1821660&r1=1821659&r2=1821660&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/worker/worker.c (original)
+++ httpd/httpd/trunk/server/mpm/worker/worker.c Fri Jan 19 14:16:01 2018
@@ -908,11 +908,10 @@ static void * APR_THREAD_FUNC start_thre
 
     /* 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);
     }
 

Modified: httpd/httpd/trunk/server/mpm_fdqueue.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm_fdqueue.c?rev=1821660&r1=1821659&r2=1821660&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm_fdqueue.c (original)
+++ httpd/httpd/trunk/server/mpm_fdqueue.c Fri Jan 19 14:16:01 2018
@@ -343,10 +343,12 @@ static apr_status_t ap_queue_destroy(voi
 /**
  * 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 *q
 
     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_queu
 
     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);
 }
 
 /**

Modified: httpd/httpd/trunk/server/mpm_fdqueue.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm_fdqueue.h?rev=1821660&r1=1821659&r2=1821660&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm_fdqueue.h (original)
+++ httpd/httpd/trunk/server/mpm_fdqueue.h Fri Jan 19 14:16:01 2018
@@ -86,7 +86,7 @@ void ap_pop_pool(apr_pool_t **recycled_p
 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);