| 1576 | } |
| 1577 | |
| 1578 | static void init_conn_pool(apr_pool_t *p, proxy_worker *worker, server_rec *s) |
| 1579 | { |
| 1580 | proxy_conn_pool *cp; |
| 1581 | |
| 1582 | /* |
| 1583 | * Alloc from the same pool as worker. |
| 1584 | * proxy_conn_pool is permanently attached to the worker. |
| 1585 | */ |
| 1586 | cp = (proxy_conn_pool *)apr_pcalloc(p, sizeof(proxy_conn_pool)); |
| 1587 | worker->cp = cp; |
| 1588 | |
| 1589 | /* |
| 1590 | * We need a first pool (cp->pool) to maintain the connections attached to |
| 1591 | * the worker and a second one (cp->dns_pool) to maintain the DNS addresses |
| 1592 | * in use (TTL'ed, refcounted). New connections are created as/on a subpool |
| 1593 | * of cp->pool and new addresses as/on a subpool of cp->dns_pool, such that |
| 1594 | * both leaks (the subpools can be destroyed when the connections and/or |
| 1595 | * addresses are over) and race conditions (the creation/destruction of |
| 1596 | * subpools is protected by the parent pool's mutex) can be avoided. |
| 1597 | * |
| 1598 | * cp->dns_pool is created before cp->pool because when a connection on the |
| 1599 | * latter is destroyed it might destroy an address on the former, so when |
| 1600 | * the base pools are destroyed (e.g. child exit) we thusly make sure that |
| 1601 | * cp->dns_pool and its subpools are still alive when cp->pool gets killed. |
| 1602 | * |
| 1603 | * Both cp->dns_pool and cp->pool have their own allocator/mutex too since |
| 1604 | * acquiring connections and addresses don't need to contend. |
| 1605 | */ |
| 1606 | cp->dns_pool = make_conn_subpool(p, "proxy_worker_dns", s); |
| 1607 | cp->pool = make_conn_subpool(p, "proxy_worker_cp", s); |
| 1608 | |
| 1609 | /* When p is cleaning up the child is exiting, signal that to e.g. avoid |
| 1610 | * destroying the subpools explicitely in connection_destructor() when |
| 1611 | * they have been destroyed already by the reslist cleanup. |
| 1612 | */ |
| 1613 | apr_pool_pre_cleanup_register(p, worker, conn_pool_cleanup); |
| 1614 | } |
| 1615 | |
| 1616 | PROXY_DECLARE(int) ap_proxy_connection_reusable(proxy_conn_rec *conn) |
| 1617 | { |
no test coverage detected