Remove TLS connection slot
use std::borrow::Borrow;
-use std::cell::UnsafeCell;
use std::collections::VecDeque;
use std::fmt;
use std::sync::{Arc, Mutex, Condvar};
@@ -19,10 +18,6 @@ use super::{Conn, Opts, Stmt, QueryResult};
use super::super::error::Result as MyResult;
use super::LocalInfileHandler;
-thread_local! {
- static TLS_CONN: UnsafeCell<Option<Conn>> = UnsafeCell::new(None)
-}
-
#[derive(Debug)]
struct InnerPool {
opts: Opts,
@@ -137,19 +132,7 @@ impl Pool {
let &(ref inner_pool, ref condvar) = &*self.inner;
- let conn = if self.use_tls {
- TLS_CONN.with(|tls_conn| {
- unsafe { &mut *tls_conn.get() }.take()
- })
- } else {
- None
- };
-
- let conn = if let Some(conn) = conn {
- self.count.fetch_add(1, Ordering::SeqCst);
- Some(conn)
- } else {
- if self.use_cache {
+ let conn = if self.use_cache {
if let Some(query) = stmt {
let mut id = None;
let mut pool = inner_pool.lock()?;
@@ -165,7 +148,6 @@ impl Pool {
}
} else {
None
- }
};
let mut conn = if let Some(conn) = conn {
@@ -395,23 +377,6 @@ pub struct PooledConn {
impl Drop for PooledConn {
fn drop(&mut self) {
- let out = if self.pool.use_tls {
- TLS_CONN.with(|tls_conn| {
- let mut val = unsafe { &mut *tls_conn.get() };
- if val.is_none() {
- *val = self.conn.take();
- val.is_some()
- } else {
- false
- }
- })
- } else {
- false
- };
- if out {
- self.pool.count.fetch_sub(1, Ordering::SeqCst);
- return;
- }
if self.pool.count.load(Ordering::Relaxed) > self.pool.max.load(Ordering::Relaxed) || self.conn.is_none() {
self.pool.count.fetch_sub(1, Ordering::SeqCst);
} else {
