]> granicus.if.org Git - apache/commitdiff
event, eventopt: follow up to r1638879 and r1639960.
authorYann Ylavic <ylavic@apache.org>
Sun, 16 Nov 2014 21:32:48 +0000 (21:32 +0000)
committerYann Ylavic <ylavic@apache.org>
Sun, 16 Nov 2014 21:32:48 +0000 (21:32 +0000)
Clear the pool in ap_push_pool() before recycling.

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

server/mpm/event/event.c
server/mpm/event/fdqueue.c
server/mpm/eventopt/eventopt.c
server/mpm/eventopt/fdqueue.c

index d3607563dd6eeddff9ee1551832a62da5610dd24..6d5bdbf56630bfb748a3194918a89109a034f2f1 100644 (file)
@@ -867,15 +867,13 @@ static int start_lingering_close_common(event_conn_state_t *cs, int in_worker)
     rv = apr_pollset_add(event_pollset, &cs->pfd);
     apr_thread_mutex_unlock(timeout_mutex);
     if (rv != APR_SUCCESS && !APR_STATUS_IS_EEXIST(rv)) {
-        apr_pool_t *p = cs->p;
         ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf,
                      "start_lingering_close: apr_pollset_add failure");
         apr_thread_mutex_lock(timeout_mutex);
         TO_QUEUE_REMOVE(*q, cs);
         apr_thread_mutex_unlock(timeout_mutex);
         apr_socket_close(cs->pfd.desc.s);
-        apr_pool_clear(cs->p);
-        ap_push_pool(worker_queue_info, p);
+        ap_push_pool(worker_queue_info, cs->p);
         return 0;
     }
     return 1;
@@ -892,9 +890,7 @@ static int start_lingering_close_common(event_conn_state_t *cs, int in_worker)
 static int start_lingering_close_blocking(event_conn_state_t *cs)
 {
     if (ap_start_lingering_close(cs->c)) {
-        apr_pool_t *p = cs->p;
-        apr_pool_clear(cs->p);
-        ap_push_pool(worker_queue_info, p);
+        ap_push_pool(worker_queue_info, cs->p);
         return 0;
     }
     return start_lingering_close_common(cs, 1);
@@ -919,7 +915,6 @@ static int start_lingering_close_nonblocking(event_conn_state_t *cs)
         || ap_shutdown_conn(c, 0) != APR_SUCCESS || c->aborted
         || apr_socket_shutdown(csd, APR_SHUTDOWN_WRITE) != APR_SUCCESS) {
         apr_socket_close(csd);
-        apr_pool_clear(cs->p);
         ap_push_pool(worker_queue_info, cs->p);
         return 0;
     }
@@ -936,7 +931,6 @@ static int stop_lingering_close(event_conn_state_t *cs)
 {
     apr_status_t rv;
     apr_socket_t *csd = ap_get_conn_socket(cs->c);
-    apr_pool_t *p = cs->p;
     ap_log_error(APLOG_MARK, APLOG_TRACE4, 0, ap_server_conf,
                  "socket reached timeout in lingering-close state");
     rv = apr_socket_close(csd);
@@ -944,8 +938,7 @@ static int stop_lingering_close(event_conn_state_t *cs)
         ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf, APLOGNO(00468) "error closing socket");
         AP_DEBUG_ASSERT(0);
     }
-    apr_pool_clear(cs->p);
-    ap_push_pool(worker_queue_info, p);
+    ap_push_pool(worker_queue_info, cs->p);
     return 0;
 }
 
@@ -1010,8 +1003,6 @@ static void process_socket(apr_thread_t *thd, apr_pool_t * p, apr_socket_t * soc
         c = ap_run_create_connection(p, ap_server_conf, sock,
                                      conn_id, sbh, cs->bucket_alloc);
         if (!c) {
-            apr_bucket_alloc_destroy(cs->bucket_alloc);
-            apr_pool_clear(p);
             ap_push_pool(worker_queue_info, p);
             return;
         }
@@ -1355,7 +1346,6 @@ static apr_status_t push2worker(const apr_pollfd_t * pfd,
 
     rc = ap_queue_push(worker_queue, cs->pfd.desc.s, cs, cs->p);
     if (rc != APR_SUCCESS) {
-        apr_pool_t *p = cs->p;
         /* trash the connection; we couldn't queue the connected
          * socket to a worker
          */
@@ -1363,8 +1353,7 @@ static apr_status_t push2worker(const apr_pollfd_t * pfd,
         apr_socket_close(cs->pfd.desc.s);
         ap_log_error(APLOG_MARK, APLOG_CRIT, rc,
                      ap_server_conf, APLOGNO(00471) "push2worker: ap_queue_push failed");
-        apr_pool_clear(cs->p);
-        ap_push_pool(worker_queue_info, p);
+        ap_push_pool(worker_queue_info, cs->p);
     }
 
     return rc;
@@ -1585,7 +1574,6 @@ static void process_lingering_close(event_conn_state_t *cs, const apr_pollfd_t *
     apr_size_t nbytes;
     apr_status_t rv;
     struct timeout_queue *q;
-    apr_pool_t *p = cs->p;
     q = (cs->pub.state == CONN_STATE_LINGER_SHORT) ?  &short_linger_q : &linger_q;
 
     /* socket is already in non-blocking state */
@@ -1609,8 +1597,7 @@ static void process_lingering_close(event_conn_state_t *cs, const apr_pollfd_t *
     apr_thread_mutex_unlock(timeout_mutex);
     TO_QUEUE_ELEM_INIT(cs);
 
-    apr_pool_clear(cs->p);
-    ap_push_pool(worker_queue_info, p);
+    ap_push_pool(worker_queue_info, cs->p);
 }
 
 /* call 'func' for all elements of 'q' with timeout less than 'timeout_time'.
@@ -1942,7 +1929,6 @@ static void * APR_THREAD_FUNC listener_thread(apr_thread_t * thd, void *dummy)
                             ap_log_error(APLOG_MARK, APLOG_CRIT, rc,
                                          ap_server_conf,
                                          "ap_queue_push failed");
-                            apr_pool_clear(ptrans);
                             ap_push_pool(worker_queue_info, ptrans);
                         }
                         else {
@@ -1950,7 +1936,6 @@ static void * APR_THREAD_FUNC listener_thread(apr_thread_t * thd, void *dummy)
                         }
                     }
                     else {
-                        apr_pool_clear(ptrans);
                         ap_push_pool(worker_queue_info, ptrans);
                     }
                 }
index 2fa7e1e52c4272abeb2cc38d6320f138e161362b..485a98dc109ceb27785bba062819d2a1ae45e69c 100644 (file)
@@ -231,6 +231,7 @@ void ap_push_pool(fd_queue_info_t * queue_info,
         apr_atomic_inc32(&queue_info->recycled_pools_count);
     }
 
+    apr_pool_clear(pool_to_recycle);
     new_recycle = (struct recycled_pool *) apr_palloc(pool_to_recycle,
                                                       sizeof (*new_recycle));
     new_recycle->pool = pool_to_recycle;
index b3ac01c310288c36c916f94e4798fa7be7015278..56239a563dabcb38747414aaec20398dc52808cb 100644 (file)
@@ -820,12 +820,10 @@ static int process_pollop(pollset_op_t *op)
     rv = apr_pollset_add(event_pollset, &op->cs->pfd);
 
     if (rv != APR_SUCCESS && !APR_STATUS_IS_EEXIST(rv)) {
-        apr_pool_t *p = cs->p;
         ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf, APLOGNO(00467)
                      "%s: apr_pollset_add failure", op->tag);
         apr_socket_close(cs->pfd.desc.s);
-        apr_pool_clear(cs->p);
-        ap_push_pool(worker_queue_info, p);
+        ap_push_pool(worker_queue_info, cs->p);
         return 0;
     }
     return 1;
@@ -911,9 +909,7 @@ static int start_lingering_close(event_conn_state_t *cs, ap_equeue_t *eq)
 static int start_lingering_close_blocking(event_conn_state_t *cs, ap_equeue_t *eq)
 {
     if (ap_start_lingering_close(cs->c)) {
-        apr_pool_t *p = cs->p;
-        apr_pool_clear(cs->p);
-        ap_push_pool(worker_queue_info, p);
+        ap_push_pool(worker_queue_info, cs->p);
         return 0;
     }
     return start_lingering_close(cs, eq);
@@ -937,10 +933,8 @@ static int start_lingering_close_nonblocking(event_conn_state_t *cs, ap_equeue_t
     if (c->aborted
         || ap_shutdown_conn(c, 0) != APR_SUCCESS || c->aborted
         || apr_socket_shutdown(csd, APR_SHUTDOWN_WRITE) != APR_SUCCESS) {
-        apr_pool_t *p = cs->p;
         apr_socket_close(csd);
-        apr_pool_clear(cs->p);
-        ap_push_pool(worker_queue_info, p);
+        ap_push_pool(worker_queue_info, cs->p);
         return 0;
     }
     return start_lingering_close(cs, eq);
@@ -956,7 +950,6 @@ static int stop_lingering_close(event_conn_state_t *cs, ap_equeue_t *eq)
 {
     apr_status_t rv;
     apr_socket_t *csd = ap_get_conn_socket(cs->c);
-    apr_pool_t *p = cs->p;
     ap_log_error(APLOG_MARK, APLOG_TRACE4, 0, ap_server_conf,
                  "socket reached timeout in lingering-close state");
     rv = apr_socket_close(csd);
@@ -964,8 +957,7 @@ static int stop_lingering_close(event_conn_state_t *cs, ap_equeue_t *eq)
         ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf, APLOGNO(00468) "error closing socket");
         AP_DEBUG_ASSERT(0);
     }
-    apr_pool_clear(cs->p);
-    ap_push_pool(worker_queue_info, p);
+    ap_push_pool(worker_queue_info, cs->p);
     return 0;
 }
 
@@ -992,8 +984,6 @@ static void process_socket(apr_thread_t *thd, apr_pool_t * p, apr_socket_t * soc
         c = ap_run_create_connection(p, ap_server_conf, sock,
                                      conn_id, sbh, cs->bucket_alloc);
         if (!c) {
-            apr_bucket_alloc_destroy(cs->bucket_alloc);
-            apr_pool_clear(p);
             ap_push_pool(worker_queue_info, p);
             return;
         }
@@ -1315,7 +1305,6 @@ static apr_status_t push2worker(const apr_pollfd_t * pfd,
 
     rc = ap_queue_push(worker_queue, cs->pfd.desc.s, cs, cs->p);
     if (rc != APR_SUCCESS) {
-        apr_pool_t *p = cs->p;
         /* trash the connection; we couldn't queue the connected
          * socket to a worker
          */
@@ -1323,8 +1312,7 @@ static apr_status_t push2worker(const apr_pollfd_t * pfd,
         apr_socket_close(cs->pfd.desc.s);
         ap_log_error(APLOG_MARK, APLOG_CRIT, rc,
                      ap_server_conf, APLOGNO(00471) "push2worker: ap_queue_push failed");
-        apr_pool_clear(cs->p);
-        ap_push_pool(worker_queue_info, p);
+        ap_push_pool(worker_queue_info, cs->p);
     }
 
     return rc;
@@ -1436,7 +1424,6 @@ static void process_lingering_close(event_conn_state_t *cs, const apr_pollfd_t *
     apr_size_t nbytes;
     apr_status_t rv;
     struct timeout_queue *q;
-    apr_pool_t *p = cs->p;
     q = (cs->pub.state == CONN_STATE_LINGER_SHORT) ?  &short_linger_q : &linger_q;
 
     /* socket is already in non-blocking state */
@@ -1458,8 +1445,7 @@ static void process_lingering_close(event_conn_state_t *cs, const apr_pollfd_t *
     TO_QUEUE_REMOVE(*q, cs);
     TO_QUEUE_ELEM_INIT(cs);
 
-    apr_pool_clear(cs->p);
-    ap_push_pool(worker_queue_info, p);
+    ap_push_pool(worker_queue_info, cs->p);
 }
 
 /* call 'func' for all elements of 'q' with timeout less than 'timeout_time'.
@@ -1773,7 +1759,6 @@ static void * APR_THREAD_FUNC listener_thread(apr_thread_t * thd, void *dummy)
                             ap_log_error(APLOG_MARK, APLOG_CRIT, rc,
                                          ap_server_conf,
                                          "ap_queue_push failed");
-                            apr_pool_clear(ptrans);
                             ap_push_pool(worker_queue_info, ptrans);
                         }
                         else {
@@ -1781,7 +1766,6 @@ static void * APR_THREAD_FUNC listener_thread(apr_thread_t * thd, void *dummy)
                         }
                     }
                     else {
-                        apr_pool_clear(ptrans);
                         ap_push_pool(worker_queue_info, ptrans);
                     }
                 }
index 9b67c553526e94d320bf51ae511ac6747567d52d..d32a837f709013fece29682cb053e10565c29d1f 100644 (file)
@@ -231,6 +231,7 @@ void ap_push_pool(fd_queue_info_t * queue_info,
         apr_atomic_inc32(&queue_info->recycled_pools_count);
     }
 
+    apr_pool_clear(pool_to_recycle);
     new_recycle = (struct recycled_pool *) apr_palloc(pool_to_recycle,
                                                       sizeof (*new_recycle));
     new_recycle->pool = pool_to_recycle;