core::rt: Just a small fix to TcpStream
This commit is contained in:
parent
a134503d74
commit
ad6719ee0b
@ -171,4 +171,30 @@ mod test {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test] #[ignore]
|
||||
fn multiple_connect_serial() {
|
||||
do run_in_newsched_task {
|
||||
let addr = next_test_ip4();
|
||||
let max = 100;
|
||||
|
||||
do spawntask_immediately {
|
||||
let mut listener = TcpListener::bind(addr);
|
||||
for max.times {
|
||||
let mut stream = listener.accept();
|
||||
let mut buf = [0];
|
||||
stream.read(buf);
|
||||
assert!(buf[0] == 99);
|
||||
}
|
||||
}
|
||||
|
||||
do spawntask_immediately {
|
||||
for max.times {
|
||||
let mut stream = TcpStream::connect(addr);
|
||||
stream.write([99]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -239,9 +239,10 @@ pub impl TcpWatcher {
|
||||
extern fn connection_cb(handle: *uvll::uv_stream_t, status: c_int) {
|
||||
rtdebug!("connection_cb");
|
||||
let mut stream_watcher: StreamWatcher = NativeHandle::from_native_handle(handle);
|
||||
let cb = stream_watcher.get_watcher_data().connect_cb.swap_unwrap();
|
||||
let status = status_to_maybe_uv_error(stream_watcher.native_handle(), status);
|
||||
cb(stream_watcher, status);
|
||||
let data = stream_watcher.get_watcher_data();
|
||||
let cb = data.connect_cb.get_ref();
|
||||
let status = status_to_maybe_uv_error(handle, status);
|
||||
(*cb)(stream_watcher, status);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user