Some random cleanup
This commit is contained in:
parent
b926745f50
commit
adc81a9809
30
src/lib.rs
30
src/lib.rs
@ -87,7 +87,6 @@ use std::from_str::FromStr;
|
||||
use std::io::{BufferedStream, IoResult};
|
||||
use std::io::net::ip::Port;
|
||||
use std::mem;
|
||||
use std::owned::Box;
|
||||
use std::task;
|
||||
use std::fmt;
|
||||
|
||||
@ -107,8 +106,7 @@ use error::{InvalidUrl,
|
||||
UnsupportedAuthentication,
|
||||
PgWrongConnection,
|
||||
PgWrongTransaction};
|
||||
use io::{MaybeSslStream,
|
||||
InternalStream};
|
||||
use io::{MaybeSslStream, InternalStream};
|
||||
use message::{AuthenticationCleartextPassword,
|
||||
AuthenticationGSS,
|
||||
AuthenticationKerberosV5,
|
||||
@ -435,19 +433,6 @@ impl InnerPostgresConnection {
|
||||
let params = try!(params.into_connect_params());
|
||||
let stream = try!(io::initialize_stream(¶ms, ssl));
|
||||
|
||||
let mut conn = InnerPostgresConnection {
|
||||
stream: BufferedStream::new(stream),
|
||||
next_stmt_id: 0,
|
||||
notice_handler: box DefaultNoticeHandler,
|
||||
notifications: RingBuf::new(),
|
||||
cancel_data: PostgresCancelData { process_id: 0, secret_key: 0 },
|
||||
unknown_types: HashMap::new(),
|
||||
desynchronized: false,
|
||||
finished: false,
|
||||
trans_depth: 0,
|
||||
canary: CANARY,
|
||||
};
|
||||
|
||||
let PostgresConnectParams {
|
||||
user,
|
||||
password,
|
||||
@ -461,6 +446,19 @@ impl InnerPostgresConnection {
|
||||
None => return Err(MissingUser),
|
||||
};
|
||||
|
||||
let mut conn = InnerPostgresConnection {
|
||||
stream: BufferedStream::new(stream),
|
||||
next_stmt_id: 0,
|
||||
notice_handler: box DefaultNoticeHandler,
|
||||
notifications: RingBuf::new(),
|
||||
cancel_data: PostgresCancelData { process_id: 0, secret_key: 0 },
|
||||
unknown_types: HashMap::new(),
|
||||
desynchronized: false,
|
||||
finished: false,
|
||||
trans_depth: 0,
|
||||
canary: CANARY,
|
||||
};
|
||||
|
||||
options.push(("client_encoding".to_owned(), "UTF8".to_owned()));
|
||||
// Postgres uses the value of TimeZone as the time zone for TIMESTAMP
|
||||
// WITH TIME ZONE values. Timespec converts to GMT internally.
|
||||
|
17
src/pool.rs
17
src/pool.rs
@ -79,13 +79,16 @@ impl PostgresConnectionPool {
|
||||
pub fn get_connection(&self) -> PooledPostgresConnection {
|
||||
let mut pool = self.pool.lock();
|
||||
|
||||
while pool.pool.is_empty() {
|
||||
pool.cond.wait();
|
||||
}
|
||||
|
||||
PooledPostgresConnection {
|
||||
pool: self.clone(),
|
||||
conn: Some(pool.pool.pop().unwrap())
|
||||
loop {
|
||||
match pool.pool.pop() {
|
||||
Some(conn) => {
|
||||
return PooledPostgresConnection {
|
||||
pool: self.clone(),
|
||||
conn: Some(conn),
|
||||
};
|
||||
}
|
||||
None => pool.cond.wait()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user