提交 da2ac908 编写于 作者: P Patrick Walton

libstd: Remove mutable fields from fileinput and net_tcp

上级 5a65f51d
......@@ -145,7 +145,7 @@ struct FileInput_ {
// "self.fi." -> "self." and renaming FileInput_. Documentation above
// will likely have to be updated to use `let mut in = ...`.
pub struct FileInput {
priv mut fi: FileInput_
priv fi: @mut FileInput_
}
impl FileInput {
......@@ -170,7 +170,7 @@ pub fn from_vec(files: ~[Option<Path>]) -> FileInput {
pub fn from_vec_raw(files: ~[Option<Path>])
-> FileInput {
FileInput{
fi: FileInput_ {
fi: @mut FileInput_ {
files: files,
current_reader: None,
state: FileInputState {
......
......@@ -71,14 +71,14 @@ pub fn TcpSocket(socket_data: @TcpSocketData) -> TcpSocket {
* satisfy both the `io::Reader` and `io::Writer` traits.
*/
pub struct TcpSocketBuf {
data: @TcpBufferedSocketData,
mut end_of_stream: bool
data: @mut TcpBufferedSocketData,
end_of_stream: @mut bool
}
pub fn TcpSocketBuf(data: @TcpBufferedSocketData) -> TcpSocketBuf {
pub fn TcpSocketBuf(data: @mut TcpBufferedSocketData) -> TcpSocketBuf {
TcpSocketBuf {
data: data,
end_of_stream: false
end_of_stream: @mut false
}
}
......@@ -670,7 +670,7 @@ fn listen_common(host_ip: ip::IpAddr,
&ip::Ipv4(_) => { false }
&ip::Ipv6(_) => { true }
},
mut active: true
active: @mut true
};
let server_data_ptr: *TcpListenFcData = &server_data;
......@@ -751,7 +751,7 @@ fn listen_common(host_ip: ip::IpAddr,
debug!(
"tcp::listen post-kill recv hl interact %?",
loop_ptr);
(*server_data_ptr).active = false;
*(*server_data_ptr).active = false;
uv::ll::close(server_stream_ptr, tcp_lfc_close_cb);
}
};
......@@ -782,7 +782,7 @@ fn listen_common(host_ip: ip::IpAddr,
debug!(
"tcp::listen post-kill recv hl interact %?",
loop_ptr);
(*server_data_ptr).active = false;
*(*server_data_ptr).active = false;
uv::ll::close(server_stream_ptr, tcp_lfc_close_cb);
}
};
......@@ -816,8 +816,8 @@ fn listen_common(host_ip: ip::IpAddr,
* A buffered wrapper that you can cast as an `io::Reader` or `io::Writer`
*/
pub fn socket_buf(sock: TcpSocket) -> TcpSocketBuf {
TcpSocketBuf(@TcpBufferedSocketData {
sock: sock, mut buf: ~[], buf_off: 0
TcpSocketBuf(@mut TcpBufferedSocketData {
sock: sock, buf: ~[], buf_off: 0
})
}
......@@ -902,12 +902,13 @@ fn read(&self, buf: &mut [u8], len: uint) -> uint {
// need to read in data from the socket. Note that the internal
// buffer is of no use anymore as we read all bytes from it,
// so we can throw it away.
let read_result = read(&self.data.sock, 0u);
let data = &*self.data;
let read_result = read(&data.sock, 0u);
if read_result.is_err() {
let err_data = read_result.get_err();
if err_data.err_name == ~"EOF" {
self.end_of_stream = true;
*self.end_of_stream = true;
break;
} else {
debug!("ERROR sock_buf as io::reader.read err %? %?",
......@@ -934,12 +935,13 @@ fn read_byte(&self) -> int {
return c as int
}
let read_result = read(&self.data.sock, 0u);
let data = &*self.data;
let read_result = read(&data.sock, 0u);
if read_result.is_err() {
let err_data = read_result.get_err();
if err_data.err_name == ~"EOF" {
self.end_of_stream = true;
*self.end_of_stream = true;
return -1
} else {
debug!("ERROR sock_buf as io::reader.read err %? %?",
......@@ -954,7 +956,7 @@ fn read_byte(&self) -> int {
}
}
fn eof(&self) -> bool {
self.end_of_stream
*self.end_of_stream
}
fn seek(&self, dist: int, seek: io::SeekStyle) {
debug!("tcp_socket_buf seek stub %? %?", dist, seek);
......@@ -1204,7 +1206,7 @@ struct TcpListenFcData {
on_connect_cb: ~fn(*uv::ll::uv_tcp_t),
iotask: IoTask,
ipv6: bool,
mut active: bool,
active: @mut bool,
}
extern fn tcp_lfc_close_cb(handle: *uv::ll::uv_tcp_t) {
......@@ -1222,7 +1224,7 @@ struct TcpListenFcData {
let server_data_ptr = uv::ll::get_data_for_uv_handle(handle)
as *TcpListenFcData;
let kill_ch = (*server_data_ptr).kill_ch.clone();
if (*server_data_ptr).active {
if *(*server_data_ptr).active {
match status {
0i32 => ((*server_data_ptr).on_connect_cb)(handle),
_ => {
......@@ -1230,7 +1232,7 @@ struct TcpListenFcData {
kill_ch.send(
Some(uv::ll::get_last_err_data(loop_ptr)
.to_tcp_err()));
(*server_data_ptr).active = false;
*(*server_data_ptr).active = false;
}
}
}
......@@ -1430,8 +1432,8 @@ struct TcpSocketData {
struct TcpBufferedSocketData {
sock: TcpSocket,
mut buf: ~[u8],
mut buf_off: uint
buf: ~[u8],
buf_off: uint
}
#[cfg(test)]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册