Skip to content

Commit 00b2497

Browse files
committed
---
yaml --- r: 61287 b: refs/heads/try c: cfd183d h: refs/heads/master i: 61285: e8a503c 61283: 608ca03 61279: 0478fe4 v: v3
1 parent 4878eda commit 00b2497

File tree

4 files changed

+10
-15
lines changed

4 files changed

+10
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2d28d645422c1617be58c8ca7ad9a457264ca850
5-
refs/heads/try: b771c993044d87d80c4ebc740e86b1b744770c57
5+
refs/heads/try: cfd183db15af50f06b5e2803b03f87061adad9f5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libcore/rt/uv/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,6 @@ struct WatcherData {
362362
connect_cb: Option<ConnectionCallback>,
363363
close_cb: Option<NullCallback>,
364364
alloc_cb: Option<AllocCallback>,
365-
buf: Option<Buf>
366365
}
367366
368367
pub fn install_watcher_data<H, W: Watcher + NativeHandle<*H>>(watcher: &mut W) {
@@ -373,7 +372,6 @@ pub fn install_watcher_data<H, W: Watcher + NativeHandle<*H>>(watcher: &mut W) {
373372
connect_cb: None,
374373
close_cb: None,
375374
alloc_cb: None,
376-
buf: None
377375
};
378376
let data = transmute::<~WatcherData, *c_void>(data);
379377
uvll::set_data_for_uv_handle(watcher.native_handle(), data);

branches/try/src/libcore/rt/uv/net.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111
use prelude::*;
1212
use libc::{size_t, ssize_t, c_int, c_void};
1313
use cast::transmute_mut_region;
14+
use util::ignore;
1415
use rt::uv::uvll;
1516
use rt::uv::uvll::*;
1617
use super::{Loop, Watcher, Request, UvError, Buf, Callback, NativeHandle, NullCallback,
1718
loop_from_watcher, status_to_maybe_uv_error,
1819
install_watcher_data, get_watcher_data, drop_watcher_data,
19-
vec_to_uv_buf, vec_from_uv_buf};
20+
vec_to_uv_buf, vec_from_uv_buf, slice_to_uv_buf};
2021
use super::super::io::net::ip::{IpAddr, Ipv4, Ipv6};
2122
use rt::uv::last_uv_error;
2223

@@ -99,17 +100,13 @@ pub impl StreamWatcher {
99100
unsafe { uvll::read_stop(handle); }
100101
}
101102

102-
// XXX: Needs to take &[u8], not ~[u8]
103-
fn write(&mut self, msg: ~[u8], cb: ConnectionCallback) {
103+
fn write(&mut self, buf: Buf, cb: ConnectionCallback) {
104104
// XXX: Borrowck
105105
let data = get_watcher_data(unsafe { transmute_mut_region(self) });
106106
assert!(data.write_cb.is_none());
107107
data.write_cb = Some(cb);
108108

109109
let req = WriteRequest::new();
110-
let buf = vec_to_uv_buf(msg);
111-
assert!(data.buf.is_none());
112-
data.buf = Some(buf);
113110
let bufs = [buf];
114111
unsafe {
115112
assert!(0 == uvll::write(req.native_handle(),
@@ -123,7 +120,6 @@ pub impl StreamWatcher {
123120
write_request.delete();
124121
let cb = {
125122
let data = get_watcher_data(&mut stream_watcher);
126-
let _vec = vec_from_uv_buf(data.buf.swap_unwrap());
127123
let cb = data.write_cb.swap_unwrap();
128124
cb
129125
};
@@ -434,10 +430,13 @@ fn listen() {
434430
assert!(status.is_none());
435431
let mut stream_watcher = stream_watcher;
436432
let msg = ~[0, 1, 2, 3, 4, 5, 6 ,7 ,8, 9];
437-
do stream_watcher.write(msg) |stream_watcher, status| {
433+
let buf = slice_to_uv_buf(msg);
434+
let msg_cell = Cell(msg);
435+
do stream_watcher.write(buf) |stream_watcher, status| {
438436
rtdebug!("writing");
439437
assert!(status.is_none());
440-
stream_watcher.close(||());
438+
let msg_cell = Cell(msg_cell.take());
439+
stream_watcher.close(||ignore(msg_cell.take()));
441440
}
442441
}
443442
loop_.run();

branches/try/src/libcore/rt/uv/uvio.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,7 @@ impl RtioTcpStream for UvTcpStream {
289289
do scheduler.deschedule_running_task_and_then |task| {
290290
let mut watcher = watcher;
291291
let task_cell = Cell(task);
292-
let buf = unsafe { &*buf_ptr };
293-
// XXX: OMGCOPIES
294-
let buf = buf.to_vec();
292+
let buf = unsafe { slice_to_uv_buf(*buf_ptr) };
295293
do watcher.write(buf) |_watcher, status| {
296294
let result = if status.is_none() {
297295
Ok(())

0 commit comments

Comments
 (0)