Skip to content

Commit 8809409

Browse files
committed
---
yaml --- r: 67323 b: refs/heads/master c: a5c6b85 h: refs/heads/master i: 67321: adf9af2 67319: 3fee578 v: v3
1 parent 4af311c commit 8809409

File tree

3 files changed

+73
-16
lines changed

3 files changed

+73
-16
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 005ea3b17375584f823c51d141248e3bcbc04115
2+
refs/heads/master: a5c6b85091e171c9ec85bad68774aece81af74fa
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 18e3db7392d2d0697b7e27d6d986139960144d85
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9

trunk/src/libstd/rt/rtio.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,18 @@ pub trait IoFactory {
5252

5353
pub trait RtioTcpListener : RtioSocket {
5454
fn accept(&mut self) -> Result<~RtioTcpStreamObject, IoError>;
55-
fn accept_simultaneously(&mut self);
56-
fn dont_accept_simultaneously(&mut self);
55+
fn accept_simultaneously(&mut self) -> Result<(), IoError>;
56+
fn dont_accept_simultaneously(&mut self) -> Result<(), IoError>;
5757
}
5858

5959
pub trait RtioTcpStream : RtioSocket {
6060
fn read(&mut self, buf: &mut [u8]) -> Result<uint, IoError>;
6161
fn write(&mut self, buf: &[u8]) -> Result<(), IoError>;
6262
fn peer_name(&mut self) -> Result<IpAddr, IoError>;
63-
fn control_congestion(&mut self);
64-
fn nodelay(&mut self);
65-
fn keepalive(&mut self, delay_in_seconds: uint);
66-
fn letdie(&mut self);
63+
fn control_congestion(&mut self) -> Result<(), IoError>;
64+
fn nodelay(&mut self) -> Result<(), IoError>;
65+
fn keepalive(&mut self, delay_in_seconds: uint) -> Result<(), IoError>;
66+
fn letdie(&mut self) -> Result<(), IoError>;
6767
}
6868

6969
pub trait RtioSocket {

trunk/src/libstd/rt/uv/uvio.rs

Lines changed: 66 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use cell::Cell;
1515
use cast;
1616
use cast::transmute;
1717
use clone::Clone;
18-
use libc::c_void;
18+
use libc::{c_int, c_uint, c_void};
1919
use rt::io::IoError;
2020
use rt::io::net::ip::IpAddr;
2121
use rt::uv::*;
@@ -404,9 +404,27 @@ impl RtioTcpListener for UvTcpListener {
404404
return self.incoming_streams.recv();
405405
}
406406

407-
// XXX implement
408-
fn accept_simultaneously(&mut self) { fail!(); }
409-
fn dont_accept_simultaneously(&mut self) { fail!(); }
407+
fn accept_simultaneously(&mut self) -> Result<(), IoError> {
408+
let r = unsafe {
409+
uvll::rust_uv_tcp_simultaneous_accepts(self.watcher.native_handle(), 1 as c_int)
410+
};
411+
412+
match status_to_maybe_uv_error(self.watcher, r) {
413+
Some(err) => Err(uv_error_to_io_error(err)),
414+
None => Ok(())
415+
}
416+
}
417+
418+
fn dont_accept_simultaneously(&mut self) -> Result<(), IoError> {
419+
let r = unsafe {
420+
uvll::rust_uv_tcp_simultaneous_accepts(self.watcher.native_handle(), 0 as c_int)
421+
};
422+
423+
match status_to_maybe_uv_error(self.watcher, r) {
424+
Some(err) => Err(uv_error_to_io_error(err)),
425+
None => Ok(())
426+
}
427+
}
410428
}
411429

412430
pub struct UvTcpStream(TcpWatcher);
@@ -507,11 +525,50 @@ impl RtioTcpStream for UvTcpStream {
507525
socket_name(TcpPeer, **self)
508526
}
509527

510-
// XXX implement
511-
fn control_congestion(&mut self) { fail!(); }
512-
fn nodelay(&mut self) { fail!(); }
513-
fn keepalive(&mut self, _delay_in_seconds: uint) { fail!(); }
514-
fn letdie(&mut self) { fail!(); }
528+
fn control_congestion(&mut self) -> Result<(), IoError> {
529+
let r = unsafe {
530+
uvll::rust_uv_tcp_nodelay(self.native_handle(), 0 as c_int)
531+
};
532+
533+
match status_to_maybe_uv_error(**self, r) {
534+
Some(err) => Err(uv_error_to_io_error(err)),
535+
None => Ok(())
536+
}
537+
}
538+
539+
fn nodelay(&mut self) -> Result<(), IoError> {
540+
let r = unsafe {
541+
uvll::rust_uv_tcp_nodelay(self.native_handle(), 1 as c_int)
542+
};
543+
544+
match status_to_maybe_uv_error(**self, r) {
545+
Some(err) => Err(uv_error_to_io_error(err)),
546+
None => Ok(())
547+
}
548+
}
549+
550+
fn keepalive(&mut self, delay_in_seconds: uint) -> Result<(), IoError> {
551+
let r = unsafe {
552+
uvll::rust_uv_tcp_keepalive(self.native_handle(), 1 as c_int,
553+
delay_in_seconds as c_uint)
554+
};
555+
556+
match status_to_maybe_uv_error(**self, r) {
557+
Some(err) => Err(uv_error_to_io_error(err)),
558+
None => Ok(())
559+
}
560+
}
561+
562+
fn letdie(&mut self) -> Result<(), IoError> {
563+
let r = unsafe {
564+
uvll::rust_uv_tcp_keepalive(self.native_handle(), 0 as c_int, 0 as c_uint)
565+
};
566+
567+
match status_to_maybe_uv_error(**self, r) {
568+
Some(err) => Err(uv_error_to_io_error(err)),
569+
None => Ok(())
570+
}
571+
}
515572
}
516573

517574
pub struct UvUdpSocket(UdpWatcher);

0 commit comments

Comments
 (0)