Remove canary
Destructors are sound now, so this is no longer necessary
This commit is contained in:
parent
4f5183898c
commit
f0cfaedb01
12
src/lib.rs
12
src/lib.rs
@ -100,7 +100,6 @@ mod url;
|
|||||||
mod util;
|
mod util;
|
||||||
pub mod types;
|
pub mod types;
|
||||||
|
|
||||||
const CANARY: u32 = 0xdeadbeef;
|
|
||||||
const TYPEINFO_QUERY: &'static str = "t";
|
const TYPEINFO_QUERY: &'static str = "t";
|
||||||
|
|
||||||
/// A type alias of the result returned by many methods.
|
/// A type alias of the result returned by many methods.
|
||||||
@ -398,7 +397,6 @@ struct InnerConnection {
|
|||||||
parameters: HashMap<String, String>,
|
parameters: HashMap<String, String>,
|
||||||
next_stmt_id: u32,
|
next_stmt_id: u32,
|
||||||
trans_depth: u32,
|
trans_depth: u32,
|
||||||
canary: u32,
|
|
||||||
desynchronized: bool,
|
desynchronized: bool,
|
||||||
finished: bool,
|
finished: bool,
|
||||||
}
|
}
|
||||||
@ -433,7 +431,6 @@ impl InnerConnection {
|
|||||||
desynchronized: false,
|
desynchronized: false,
|
||||||
finished: false,
|
finished: false,
|
||||||
trans_depth: 0,
|
trans_depth: 0,
|
||||||
canary: CANARY,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
options.push(("client_encoding".to_owned(), "UTF8".to_owned()));
|
options.push(("client_encoding".to_owned(), "UTF8".to_owned()));
|
||||||
@ -797,10 +794,6 @@ impl InnerConnection {
|
|||||||
self.desynchronized
|
self.desynchronized
|
||||||
}
|
}
|
||||||
|
|
||||||
fn canary(&self) -> u32 {
|
|
||||||
self.canary
|
|
||||||
}
|
|
||||||
|
|
||||||
fn wait_for_ready(&mut self) -> Result<()> {
|
fn wait_for_ready(&mut self) -> Result<()> {
|
||||||
match try!(self.read_message()) {
|
match try!(self.read_message()) {
|
||||||
ReadyForQuery { .. } => Ok(()),
|
ReadyForQuery { .. } => Ok(()),
|
||||||
@ -840,7 +833,6 @@ impl InnerConnection {
|
|||||||
|
|
||||||
fn finish_inner(&mut self) -> Result<()> {
|
fn finish_inner(&mut self) -> Result<()> {
|
||||||
check_desync!(self);
|
check_desync!(self);
|
||||||
self.canary = 0;
|
|
||||||
try!(self.write_messages(&[Terminate]));
|
try!(self.write_messages(&[Terminate]));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -1142,10 +1134,6 @@ impl Connection {
|
|||||||
conn.finish_inner()
|
conn.finish_inner()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn canary(&self) -> u32 {
|
|
||||||
self.conn.borrow().canary()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn write_messages(&self, messages: &[FrontendMessage]) -> IoResult<()> {
|
fn write_messages(&self, messages: &[FrontendMessage]) -> IoResult<()> {
|
||||||
self.conn.borrow_mut().write_messages(messages)
|
self.conn.borrow_mut().write_messages(messages)
|
||||||
}
|
}
|
||||||
|
@ -12,9 +12,6 @@ macro_rules! try_desync {
|
|||||||
|
|
||||||
macro_rules! check_desync {
|
macro_rules! check_desync {
|
||||||
($e:expr) => ({
|
($e:expr) => ({
|
||||||
if $e.canary() != CANARY {
|
|
||||||
panic!("Connection use after free. See mozilla/rust#13246.");
|
|
||||||
}
|
|
||||||
if $e.is_desynchronized() {
|
if $e.is_desynchronized() {
|
||||||
return Err(::Error::StreamDesynchronized);
|
return Err(::Error::StreamDesynchronized);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user