Allow non-empty connection pools to be dropped (#583)
This breaks a reference cycle between PoolReturner and Agent that was causing Agents (and their contained ConnectionPool) to never be dropped so long as there was any stream in the ConnectionPool. This cause sockets to leak over time, particularly when the convenience functions ureq::get(), ureq::post(), etc were used, since those functions create a new Agent each time.
This commit is contained in:
committed by
GitHub
parent
33fb553a28
commit
498e19943f
@@ -238,6 +238,10 @@ impl Agent {
|
||||
pub fn cookie_store(&self) -> CookieStoreGuard<'_> {
|
||||
self.state.cookie_tin.read_lock()
|
||||
}
|
||||
|
||||
pub(crate) fn weak_state(&self) -> std::sync::Weak<AgentState> {
|
||||
Arc::downgrade(&self.state)
|
||||
}
|
||||
}
|
||||
|
||||
const DEFAULT_MAX_IDLE_CONNECTIONS: usize = 100;
|
||||
|
||||
Reference in New Issue
Block a user