mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-10 14:57:14 +00:00
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]) {
|
||||
match (**self).write(buf) {
|
||||
Ok(_) => (),
|
||||
Err(ioerr) => {
|
||||
io_error::cond.raise(ioerr);
|
||||
}
|
||||
Err(ioerr) => io_error::cond.raise(ioerr),
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,9 +127,7 @@ impl TcpListener {
|
||||
impl Listener<TcpStream> for TcpListener {
|
||||
fn accept(&mut self) -> Option<TcpStream> {
|
||||
match (**self).accept() {
|
||||
Ok(s) => {
|
||||
Some(TcpStream::new(s))
|
||||
}
|
||||
Ok(s) => Some(TcpStream::new(s)),
|
||||
Err(ioerr) => {
|
||||
io_error::cond.raise(ioerr);
|
||||
return None;
|
||||
|
@ -190,9 +190,10 @@ impl StreamWatcher {
|
||||
|
||||
extern fn close_cb(handle: *uvll::uv_stream_t) {
|
||||
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();
|
||||
unsafe { free_handle(handle as *c_void) }
|
||||
cb();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -411,9 +412,10 @@ impl UdpWatcher {
|
||||
|
||||
extern fn close_cb(handle: *uvll::uv_udp_t) {
|
||||
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();
|
||||
unsafe { free_handle(handle as *c_void) }
|
||||
cb();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user