Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
da2ac908
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
da2ac908
编写于
5月 02, 2013
作者:
P
Patrick Walton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
libstd: Remove mutable fields from fileinput and net_tcp
上级
5a65f51d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
21 deletion
+23
-21
src/libstd/fileinput.rs
src/libstd/fileinput.rs
+2
-2
src/libstd/net_tcp.rs
src/libstd/net_tcp.rs
+21
-19
未找到文件。
src/libstd/fileinput.rs
浏览文件 @
da2ac908
...
@@ -145,7 +145,7 @@ struct FileInput_ {
...
@@ -145,7 +145,7 @@ struct FileInput_ {
// "self.fi." -> "self." and renaming FileInput_. Documentation above
// "self.fi." -> "self." and renaming FileInput_. Documentation above
// will likely have to be updated to use `let mut in = ...`.
// will likely have to be updated to use `let mut in = ...`.
pub
struct
FileInput
{
pub
struct
FileInput
{
priv
mut
fi
:
FileInput_
priv
fi
:
@
mut
FileInput_
}
}
impl
FileInput
{
impl
FileInput
{
...
@@ -170,7 +170,7 @@ pub fn from_vec(files: ~[Option<Path>]) -> FileInput {
...
@@ -170,7 +170,7 @@ pub fn from_vec(files: ~[Option<Path>]) -> FileInput {
pub
fn
from_vec_raw
(
files
:
~
[
Option
<
Path
>
])
pub
fn
from_vec_raw
(
files
:
~
[
Option
<
Path
>
])
->
FileInput
{
->
FileInput
{
FileInput
{
FileInput
{
fi
:
FileInput_
{
fi
:
@
mut
FileInput_
{
files
:
files
,
files
:
files
,
current_reader
:
None
,
current_reader
:
None
,
state
:
FileInputState
{
state
:
FileInputState
{
...
...
src/libstd/net_tcp.rs
浏览文件 @
da2ac908
...
@@ -71,14 +71,14 @@ pub fn TcpSocket(socket_data: @TcpSocketData) -> TcpSocket {
...
@@ -71,14 +71,14 @@ pub fn TcpSocket(socket_data: @TcpSocketData) -> TcpSocket {
* satisfy both the `io::Reader` and `io::Writer` traits.
* satisfy both the `io::Reader` and `io::Writer` traits.
*/
*/
pub
struct
TcpSocketBuf
{
pub
struct
TcpSocketBuf
{
data
:
@
TcpBufferedSocketData
,
data
:
@
mut
TcpBufferedSocketData
,
mut
end_of_stream
:
bool
end_of_stream
:
@
mut
bool
}
}
pub
fn
TcpSocketBuf
(
data
:
@
TcpBufferedSocketData
)
->
TcpSocketBuf
{
pub
fn
TcpSocketBuf
(
data
:
@
mut
TcpBufferedSocketData
)
->
TcpSocketBuf
{
TcpSocketBuf
{
TcpSocketBuf
{
data
:
data
,
data
:
data
,
end_of_stream
:
false
end_of_stream
:
@
mut
false
}
}
}
}
...
@@ -670,7 +670,7 @@ fn listen_common(host_ip: ip::IpAddr,
...
@@ -670,7 +670,7 @@ fn listen_common(host_ip: ip::IpAddr,
&
ip
::
Ipv4
(
_
)
=>
{
false
}
&
ip
::
Ipv4
(
_
)
=>
{
false
}
&
ip
::
Ipv6
(
_
)
=>
{
true
}
&
ip
::
Ipv6
(
_
)
=>
{
true
}
},
},
mut
active
:
true
active
:
@
mut
true
};
};
let
server_data_ptr
:
*
TcpListenFcData
=
&
server_data
;
let
server_data_ptr
:
*
TcpListenFcData
=
&
server_data
;
...
@@ -751,7 +751,7 @@ fn listen_common(host_ip: ip::IpAddr,
...
@@ -751,7 +751,7 @@ fn listen_common(host_ip: ip::IpAddr,
debug!
(
debug!
(
"tcp::listen post-kill recv hl interact %?"
,
"tcp::listen post-kill recv hl interact %?"
,
loop_ptr
);
loop_ptr
);
(
*
server_data_ptr
)
.active
=
false
;
*
(
*
server_data_ptr
)
.active
=
false
;
uv
::
ll
::
close
(
server_stream_ptr
,
tcp_lfc_close_cb
);
uv
::
ll
::
close
(
server_stream_ptr
,
tcp_lfc_close_cb
);
}
}
};
};
...
@@ -782,7 +782,7 @@ fn listen_common(host_ip: ip::IpAddr,
...
@@ -782,7 +782,7 @@ fn listen_common(host_ip: ip::IpAddr,
debug!
(
debug!
(
"tcp::listen post-kill recv hl interact %?"
,
"tcp::listen post-kill recv hl interact %?"
,
loop_ptr
);
loop_ptr
);
(
*
server_data_ptr
)
.active
=
false
;
*
(
*
server_data_ptr
)
.active
=
false
;
uv
::
ll
::
close
(
server_stream_ptr
,
tcp_lfc_close_cb
);
uv
::
ll
::
close
(
server_stream_ptr
,
tcp_lfc_close_cb
);
}
}
};
};
...
@@ -816,8 +816,8 @@ fn listen_common(host_ip: ip::IpAddr,
...
@@ -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`
* A buffered wrapper that you can cast as an `io::Reader` or `io::Writer`
*/
*/
pub
fn
socket_buf
(
sock
:
TcpSocket
)
->
TcpSocketBuf
{
pub
fn
socket_buf
(
sock
:
TcpSocket
)
->
TcpSocketBuf
{
TcpSocketBuf
(
@
TcpBufferedSocketData
{
TcpSocketBuf
(
@
mut
TcpBufferedSocketData
{
sock
:
sock
,
mut
buf
:
~
[],
buf_off
:
0
sock
:
sock
,
buf
:
~
[],
buf_off
:
0
})
})
}
}
...
@@ -902,12 +902,13 @@ fn read(&self, buf: &mut [u8], len: uint) -> uint {
...
@@ -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
// 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,
// buffer is of no use anymore as we read all bytes from it,
// so we can throw it away.
// 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
()
{
if
read_result
.is_err
()
{
let
err_data
=
read_result
.get_err
();
let
err_data
=
read_result
.get_err
();
if
err_data
.err_name
==
~
"EOF"
{
if
err_data
.err_name
==
~
"EOF"
{
self
.end_of_stream
=
true
;
*
self
.end_of_stream
=
true
;
break
;
break
;
}
else
{
}
else
{
debug!
(
"ERROR sock_buf as io::reader.read err %? %?"
,
debug!
(
"ERROR sock_buf as io::reader.read err %? %?"
,
...
@@ -934,12 +935,13 @@ fn read_byte(&self) -> int {
...
@@ -934,12 +935,13 @@ fn read_byte(&self) -> int {
return
c
as
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
()
{
if
read_result
.is_err
()
{
let
err_data
=
read_result
.get_err
();
let
err_data
=
read_result
.get_err
();
if
err_data
.err_name
==
~
"EOF"
{
if
err_data
.err_name
==
~
"EOF"
{
self
.end_of_stream
=
true
;
*
self
.end_of_stream
=
true
;
return
-
1
return
-
1
}
else
{
}
else
{
debug!
(
"ERROR sock_buf as io::reader.read err %? %?"
,
debug!
(
"ERROR sock_buf as io::reader.read err %? %?"
,
...
@@ -954,7 +956,7 @@ fn read_byte(&self) -> int {
...
@@ -954,7 +956,7 @@ fn read_byte(&self) -> int {
}
}
}
}
fn
eof
(
&
self
)
->
bool
{
fn
eof
(
&
self
)
->
bool
{
self
.end_of_stream
*
self
.end_of_stream
}
}
fn
seek
(
&
self
,
dist
:
int
,
seek
:
io
::
SeekStyle
)
{
fn
seek
(
&
self
,
dist
:
int
,
seek
:
io
::
SeekStyle
)
{
debug!
(
"tcp_socket_buf seek stub %? %?"
,
dist
,
seek
);
debug!
(
"tcp_socket_buf seek stub %? %?"
,
dist
,
seek
);
...
@@ -1204,7 +1206,7 @@ struct TcpListenFcData {
...
@@ -1204,7 +1206,7 @@ struct TcpListenFcData {
on_connect_cb
:
~
fn
(
*
uv
::
ll
::
uv_tcp_t
),
on_connect_cb
:
~
fn
(
*
uv
::
ll
::
uv_tcp_t
),
iotask
:
IoTask
,
iotask
:
IoTask
,
ipv6
:
bool
,
ipv6
:
bool
,
mut
active
:
bool
,
active
:
@
mut
bool
,
}
}
extern
fn
tcp_lfc_close_cb
(
handle
:
*
uv
::
ll
::
uv_tcp_t
)
{
extern
fn
tcp_lfc_close_cb
(
handle
:
*
uv
::
ll
::
uv_tcp_t
)
{
...
@@ -1222,7 +1224,7 @@ struct TcpListenFcData {
...
@@ -1222,7 +1224,7 @@ struct TcpListenFcData {
let
server_data_ptr
=
uv
::
ll
::
get_data_for_uv_handle
(
handle
)
let
server_data_ptr
=
uv
::
ll
::
get_data_for_uv_handle
(
handle
)
as
*
TcpListenFcData
;
as
*
TcpListenFcData
;
let
kill_ch
=
(
*
server_data_ptr
)
.kill_ch
.clone
();
let
kill_ch
=
(
*
server_data_ptr
)
.kill_ch
.clone
();
if
(
*
server_data_ptr
)
.active
{
if
*
(
*
server_data_ptr
)
.active
{
match
status
{
match
status
{
0i32
=>
((
*
server_data_ptr
)
.on_connect_cb
)(
handle
),
0i32
=>
((
*
server_data_ptr
)
.on_connect_cb
)(
handle
),
_
=>
{
_
=>
{
...
@@ -1230,7 +1232,7 @@ struct TcpListenFcData {
...
@@ -1230,7 +1232,7 @@ struct TcpListenFcData {
kill_ch
.send
(
kill_ch
.send
(
Some
(
uv
::
ll
::
get_last_err_data
(
loop_ptr
)
Some
(
uv
::
ll
::
get_last_err_data
(
loop_ptr
)
.to_tcp_err
()));
.to_tcp_err
()));
(
*
server_data_ptr
)
.active
=
false
;
*
(
*
server_data_ptr
)
.active
=
false
;
}
}
}
}
}
}
...
@@ -1430,8 +1432,8 @@ struct TcpSocketData {
...
@@ -1430,8 +1432,8 @@ struct TcpSocketData {
struct
TcpBufferedSocketData
{
struct
TcpBufferedSocketData
{
sock
:
TcpSocket
,
sock
:
TcpSocket
,
mut
buf
:
~
[
u8
],
buf
:
~
[
u8
],
mut
buf_off
:
uint
buf_off
:
uint
}
}
#[cfg(test)]
#[cfg(test)]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录