Do not execute the callback before cleaning up resources.
This commit is contained in:
parent
97555e865c
commit
f68514c128
@ -88,9 +88,7 @@ impl Writer for TcpStream {
|
|||||||
fn write(&mut self, buf: &[u8]) {
|
fn write(&mut self, buf: &[u8]) {
|
||||||
match (**self).write(buf) {
|
match (**self).write(buf) {
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(ioerr) => {
|
Err(ioerr) => io_error::cond.raise(ioerr),
|
||||||
io_error::cond.raise(ioerr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,9 +127,7 @@ impl TcpListener {
|
|||||||
impl Listener<TcpStream> for TcpListener {
|
impl Listener<TcpStream> for TcpListener {
|
||||||
fn accept(&mut self) -> Option<TcpStream> {
|
fn accept(&mut self) -> Option<TcpStream> {
|
||||||
match (**self).accept() {
|
match (**self).accept() {
|
||||||
Ok(s) => {
|
Ok(s) => Some(TcpStream::new(s)),
|
||||||
Some(TcpStream::new(s))
|
|
||||||
}
|
|
||||||
Err(ioerr) => {
|
Err(ioerr) => {
|
||||||
io_error::cond.raise(ioerr);
|
io_error::cond.raise(ioerr);
|
||||||
return None;
|
return None;
|
||||||
|
@ -190,9 +190,10 @@ impl StreamWatcher {
|
|||||||
|
|
||||||
extern fn close_cb(handle: *uvll::uv_stream_t) {
|
extern fn close_cb(handle: *uvll::uv_stream_t) {
|
||||||
let mut stream_watcher: StreamWatcher = NativeHandle::from_native_handle(handle);
|
let mut stream_watcher: StreamWatcher = NativeHandle::from_native_handle(handle);
|
||||||
stream_watcher.get_watcher_data().close_cb.take_unwrap()();
|
let cb = stream_watcher.get_watcher_data().close_cb.take_unwrap();
|
||||||
stream_watcher.drop_watcher_data();
|
stream_watcher.drop_watcher_data();
|
||||||
unsafe { free_handle(handle as *c_void) }
|
unsafe { free_handle(handle as *c_void) }
|
||||||
|
cb();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -411,9 +412,10 @@ impl UdpWatcher {
|
|||||||
|
|
||||||
extern fn close_cb(handle: *uvll::uv_udp_t) {
|
extern fn close_cb(handle: *uvll::uv_udp_t) {
|
||||||
let mut udp_watcher: UdpWatcher = NativeHandle::from_native_handle(handle);
|
let mut udp_watcher: UdpWatcher = NativeHandle::from_native_handle(handle);
|
||||||
udp_watcher.get_watcher_data().close_cb.take_unwrap()();
|
let cb = udp_watcher.get_watcher_data().close_cb.take_unwrap();
|
||||||
udp_watcher.drop_watcher_data();
|
udp_watcher.drop_watcher_data();
|
||||||
unsafe { free_handle(handle as *c_void) }
|
unsafe { free_handle(handle as *c_void) }
|
||||||
|
cb();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user