]> granicus.if.org Git - apache/commitdiff
mpm_fdqueue: follow up to r1821624.
authorYann Ylavic <ylavic@apache.org>
Fri, 19 Jan 2018 13:46:28 +0000 (13:46 +0000)
committerYann Ylavic <ylavic@apache.org>
Fri, 19 Jan 2018 13:46:28 +0000 (13:46 +0000)
Be explicit in the naming about what's push/pop-ed.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1821651 13f79535-47bb-0310-9956-ffa450edef68

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

index 871b1583acc4fb71b4dfc5cec2e1bf19b6d44346..57344780f1cb1bf29e2aa5e04c74b1a2ccff6145 100644 (file)
@@ -1417,10 +1417,10 @@ static apr_status_t push2worker(event_conn_state_t *cs, apr_socket_t *csd,
         csd = cs->pfd.desc.s;
         ptrans = cs->p;
     }
-    rc = ap_queue_push(worker_queue, csd, cs, ptrans);
+    rc = ap_queue_push_socket(worker_queue, csd, cs, ptrans);
     if (rc != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_CRIT, rc, ap_server_conf, APLOGNO(00471)
-                     "push2worker: ap_queue_push failed");
+                     "push2worker: ap_queue_push_socket failed");
         /* trash the connection; we couldn't queue the connected
          * socket to a worker
          */
@@ -2319,9 +2319,9 @@ static void *APR_THREAD_FUNC worker_thread(apr_thread_t * thd, void *dummy)
             if (APR_STATUS_IS_EOF(rv)) {
                 break;
             }
-            /* We get APR_EINTR whenever ap_queue_pop() has been interrupted
+            /* We get APR_EINTR whenever ap_queue_pop_*() has been interrupted
              * from an explicit call to ap_queue_interrupt_all(). This allows
-             * us to unblock threads stuck in ap_queue_pop() when a shutdown
+             * us to unblock threads stuck in ap_queue_pop_*() when a shutdown
              * is pending.
              *
              * If workers_may_exit is set and this is ungraceful termination/
@@ -2336,7 +2336,7 @@ static void *APR_THREAD_FUNC worker_thread(apr_thread_t * thd, void *dummy)
             /* We got some other error. */
             else if (!workers_may_exit) {
                 ap_log_error(APLOG_MARK, APLOG_CRIT, rv, ap_server_conf,
-                             APLOGNO(03099) "ap_queue_pop failed");
+                             APLOGNO(03099) "ap_queue_pop_socket failed");
             }
             continue;
         }
index 3cf5460e42ffd6eaacd959a54484c02506e4af2e..2c4bdef4e2a4c1a266667402f3ba4b6a389a1c26 100644 (file)
@@ -710,14 +710,14 @@ static void * APR_THREAD_FUNC listener_thread(apr_thread_t *thd, void * dummy)
                 accept_mutex_error("unlock", rv, process_slot);
             }
             if (csd != NULL) {
-                rv = ap_queue_push(worker_queue, csd, NULL, ptrans);
+                rv = ap_queue_push_socket(worker_queue, csd, NULL, ptrans);
                 if (rv) {
                     /* trash the connection; we couldn't queue the connected
                      * socket to a worker
                      */
                     apr_socket_close(csd);
                     ap_log_error(APLOG_MARK, APLOG_CRIT, rv, ap_server_conf, APLOGNO(03138)
-                                 "ap_queue_push failed");
+                                 "ap_queue_push_socket failed");
                 }
                 else {
                     have_idle_worker = 0;
@@ -807,7 +807,7 @@ worker_pop:
         if (workers_may_exit) {
             break;
         }
-        rv = ap_queue_pop(worker_queue, &csd, &ptrans);
+        rv = ap_queue_pop_socket(worker_queue, &csd, &ptrans);
 
         if (rv != APR_SUCCESS) {
             /* We get APR_EOF during a graceful shutdown once all the connections
@@ -816,9 +816,9 @@ worker_pop:
             if (APR_STATUS_IS_EOF(rv)) {
                 break;
             }
-            /* We get APR_EINTR whenever ap_queue_pop() has been interrupted
+            /* We get APR_EINTR whenever ap_queue_pop_*() has been interrupted
              * from an explicit call to ap_queue_interrupt_all(). This allows
-             * us to unblock threads stuck in ap_queue_pop() when a shutdown
+             * us to unblock threads stuck in ap_queue_pop_*() when a shutdown
              * is pending.
              *
              * If workers_may_exit is set and this is ungraceful termination/
@@ -833,7 +833,7 @@ worker_pop:
             /* We got some other error. */
             else if (!workers_may_exit) {
                 ap_log_error(APLOG_MARK, APLOG_CRIT, rv, ap_server_conf, APLOGNO(03139)
-                             "ap_queue_pop failed");
+                             "ap_queue_pop_socket failed");
             }
             continue;
         }
index b8720f47ef7ce55e9560f03637ba44575d409bca..47496398eafeef5142d61a0b6fa3d7aaedd01a0a 100644 (file)
@@ -215,9 +215,7 @@ apr_uint32_t ap_queue_info_num_idlers(fd_queue_info_t *queue_info)
 {
     apr_uint32_t val;
     val = apr_atomic_read32(&queue_info->idlers);
-    if (val <= zero_pt)
-        return 0;
-    return val - zero_pt;
+    return (val > zero_pt) ? val - zero_pt : 0;
 }
 
 void ap_push_pool(fd_queue_info_t *queue_info, apr_pool_t *pool_to_recycle)
@@ -349,34 +347,33 @@ 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 queue_capacity,
-                           apr_pool_t *a)
+apr_status_t ap_queue_init(fd_queue_t *queue, int capacity, apr_pool_t *p)
 {
     int i;
     apr_status_t rv;
 
     if ((rv = apr_thread_mutex_create(&queue->one_big_mutex,
                                       APR_THREAD_MUTEX_DEFAULT,
-                                      a)) != APR_SUCCESS) {
+                                      p)) != APR_SUCCESS) {
         return rv;
     }
-    if ((rv = apr_thread_cond_create(&queue->not_empty, a)) != APR_SUCCESS) {
+    if ((rv = apr_thread_cond_create(&queue->not_empty, p)) != APR_SUCCESS) {
         return rv;
     }
 
     APR_RING_INIT(&queue->timers, timer_event_t, link);
 
-    queue->data = apr_palloc(a, queue_capacity * sizeof(fd_queue_elem_t));
-    queue->bounds = queue_capacity;
+    queue->data = apr_palloc(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 < queue_capacity; ++i)
+    for (i = 0; i < capacity; ++i)
         queue->data[i].sd = NULL;
 
-    apr_pool_cleanup_register(a, queue, ap_queue_destroy,
+    apr_pool_cleanup_register(p, queue, ap_queue_destroy,
                               apr_pool_cleanup_null);
 
     return APR_SUCCESS;
@@ -388,8 +385,9 @@ apr_status_t ap_queue_init(fd_queue_t *queue, int queue_capacity,
  * precondition: ap_queue_info_wait_for_idler has already been called
  *               to reserve an idle worker thread
  */
-apr_status_t ap_queue_push(fd_queue_t *queue, apr_socket_t *sd,
-                           void *sd_baton, 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)
 {
     fd_queue_elem_t *elem;
     apr_status_t rv;
index 2544bba044becb6484ff3df7d6a566e8f56a216a..f454e7bd0ce20a6d80e39b4887784f5305287d3b 100644 (file)
@@ -86,15 +86,15 @@ 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 queue_capacity,
-                           apr_pool_t *a);
-apr_status_t ap_queue_push(fd_queue_t *queue, apr_socket_t *sd,
-                           void *baton, apr_pool_t *p);
+apr_status_t ap_queue_init(fd_queue_t *queue, 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);
 apr_status_t ap_queue_push_timer(fd_queue_t *queue, timer_event_t *te);
-apr_status_t ap_queue_pop_something(fd_queue_t *queue, apr_socket_t **sd,
-                                    void **baton, apr_pool_t **p,
-                                    timer_event_t **te);
-#define      ap_queue_pop(q_, s_, p_) \
+apr_status_t ap_queue_pop_something(fd_queue_t *queue,
+                                    apr_socket_t **sd, void **sd_baton,
+                                    apr_pool_t **p, timer_event_t **te);
+#define      ap_queue_pop_socket(q_, s_, p_) \
                 ap_queue_pop_something((q_), (s_), NULL, (p_), NULL)
 apr_status_t ap_queue_interrupt_all(fd_queue_t *queue);
 apr_status_t ap_queue_interrupt_one(fd_queue_t *queue);