chore: update several dependencies

This commit is contained in:
Ryan Leckey
2020-12-19 00:25:57 -08:00
parent 4cf1f304f9
commit c410f88bcd
9 changed files with 105 additions and 113 deletions

View File

@@ -2,7 +2,6 @@ use crate::database::{Database, HasStatementCache};
use crate::error::Error;
use crate::transaction::Transaction;
use futures_core::future::BoxFuture;
use futures_core::Future;
use log::LevelFilter;
use std::fmt::Debug;
use std::str::FromStr;
@@ -51,9 +50,9 @@ pub trait Connection: Send {
/// })).await
/// # }
/// ```
fn transaction<F, R, E>(&mut self, callback: F) -> BoxFuture<Result<R, E>>
fn transaction<F, R, E>(&mut self, callback: F) -> BoxFuture<'_, Result<R, E>>
where
for<'c> F: FnOnce(&'c mut Transaction<Self::Database>) -> BoxFuture<'c, Result<R, E>>
for<'c> F: FnOnce(&'c mut Transaction<'_, Self::Database>) -> BoxFuture<'c, Result<R, E>>
+ 'static
+ Send
+ Sync,

View File

@@ -1,4 +1,4 @@
use bytes::buf::ext::Chain;
use bytes::buf::Chain;
use bytes::Bytes;
use digest::{Digest, FixedOutput};
use generic_array::GenericArray;

View File

@@ -8,7 +8,7 @@ use crate::mysql::protocol::connect::{
};
use crate::mysql::protocol::Capabilities;
use crate::mysql::{MySqlConnectOptions, MySqlConnection, MySqlSslMode};
use bytes::buf::BufExt;
use bytes::buf::Buf as _;
impl MySqlConnection {
pub(crate) async fn establish(options: &MySqlConnectOptions) -> Result<Self, Error> {

View File

@@ -1,5 +1,4 @@
use bytes::buf::ext::Chain;
use bytes::buf::BufExt as _;
use bytes::buf::Chain;
use bytes::{Buf, Bytes};
use crate::error::Error;

View File

@@ -41,13 +41,13 @@ impl<DB: Database> SharedPool<DB> {
pub(super) async fn close(&self) {
self.is_closed.store(true, Ordering::Release);
while let Ok(waker) = self.waiters.pop() {
while let Some(waker) = self.waiters.pop() {
waker.wake();
}
// ensure we wait until the pool is actually closed
while self.size() > 0 {
if let Ok(idle) = self.idle_conns.pop() {
if let Some(idle) = self.idle_conns.pop() {
if let Err(e) = Floating::from_idle(idle, self).close().await {
log::warn!("error occurred while closing the pool connection: {}", e);
}
@@ -72,7 +72,7 @@ impl<DB: Database> SharedPool<DB> {
return None;
}
Some(Floating::from_idle(self.idle_conns.pop().ok()?, self))
Some(Floating::from_idle(self.idle_conns.pop()?, self))
}
pub(super) fn release(&self, mut floating: Floating<'_, Live<DB>>) {
@@ -83,11 +83,16 @@ impl<DB: Database> SharedPool<DB> {
}
}
self.idle_conns
let is_ok = self
.idle_conns
.push(floating.into_idle().into_leakable())
.expect("BUG: connection queue overflow in release()");
.is_ok();
if let Ok(waker) = self.waiters.pop() {
if !is_ok {
panic!("BUG: connection queue overflow in release()");
}
if let Some(waker) = self.waiters.pop() {
waker.wake();
}
}
@@ -331,9 +336,11 @@ fn spawn_reaper<DB: Database>(pool: &Arc<SharedPool<DB>>) {
for conn in keep {
// return these connections to the pool first
pool.idle_conns
.push(conn.into_leakable())
.expect("BUG: connection queue overflow in spawn_reaper");
let is_ok = pool.idle_conns.push(conn.into_leakable()).is_ok();
if !is_ok {
panic!("BUG: connection queue overflow in spawn_reaper");
}
}
for conn in reap {
@@ -379,7 +386,7 @@ impl Drop for DecrementSizeGuard<'_> {
assert!(!self.dropped, "double-dropped!");
self.dropped = true;
self.size.fetch_sub(1, Ordering::SeqCst);
if let Ok(waker) = self.waiters.pop() {
if let Some(waker) = self.waiters.pop() {
waker.wake();
}
}

View File

@@ -238,9 +238,14 @@ async fn init_min_connections<DB: Database>(pool: &SharedPool<DB>) -> Result<(),
// [connect] will raise an error when past deadline
// [connect] returns None if its okay to retry
if let Some(conn) = pool.connection(deadline, guard).await? {
pool.idle_conns
let is_ok = pool
.idle_conns
.push(conn.into_idle().into_leakable())
.expect("BUG: connection queue overflow in init_min_connections");
.is_ok();
if !is_ok {
panic!("BUG: connection queue overflow in init_min_connections");
}
}
}
}