mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 09:14:20 +00:00
std: several minor cleanups wrt codereview.. see extended comments
* there are a few places where I was experimenting w/ using `alt` in places where `if`/`else` would've sufficed. don't drink the koolaid! * I had an unneeded `else` structure (the `if` branch that preceeded concluded with a `fail` statement.. I added the `fail` later in the dev cycle for this branch, so I forgot to remove the `else` after doing so) * consistent wrt `prop_name: value` vs. `prop_name : value` in record decl and initialization * change an `alt` exp on an `ip_addr` to actually be exhaustive, instead of using a catch-all clause
This commit is contained in:
parent
7de1a68217
commit
9b10359041
@ -523,14 +523,15 @@ net::tcp::listen(remote_ip, remote_port, backlog) {|new_conn, kill_ch|
|
|||||||
let cont_ch = comm::chan(cont_po);
|
let cont_ch = comm::chan(cont_po);
|
||||||
task::spawn {||
|
task::spawn {||
|
||||||
let accept_result = net::tcp::accept(new_conn);
|
let accept_result = net::tcp::accept(new_conn);
|
||||||
alt accept_result.is_failure() {
|
if accept_result.is_failure() {
|
||||||
false { comm::send(cont_ch, result::get_err(accept_result)); }
|
comm::send(cont_ch, result::get_err(accept_result));
|
||||||
true {
|
// fail?
|
||||||
|
}
|
||||||
|
else {
|
||||||
let sock = result::get(accept_result);
|
let sock = result::get(accept_result);
|
||||||
comm::send(cont_ch, true);
|
comm::send(cont_ch, true);
|
||||||
// do work here
|
// do work here
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
alt comm::recv(cont_po) {
|
alt comm::recv(cont_po) {
|
||||||
// shut down listen()
|
// shut down listen()
|
||||||
@ -841,8 +842,7 @@ crust fn tcp_lfc_on_connection_cb(handle: *uv::ll::uv_tcp_t,
|
|||||||
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 *tcp_listen_fc_data;
|
as *tcp_listen_fc_data;
|
||||||
let kill_ch = (*server_data_ptr).kill_ch;
|
let kill_ch = (*server_data_ptr).kill_ch;
|
||||||
alt (*server_data_ptr).active {
|
if (*server_data_ptr).active {
|
||||||
true {
|
|
||||||
alt status {
|
alt status {
|
||||||
0i32 {
|
0i32 {
|
||||||
let new_conn = new_tcp_conn(handle);
|
let new_conn = new_tcp_conn(handle);
|
||||||
@ -857,9 +857,6 @@ crust fn tcp_lfc_on_connection_cb(handle: *uv::ll::uv_tcp_t,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
crust fn tcp_nl_close_cb(handle: *uv::ll::uv_tcp_t) unsafe {
|
crust fn tcp_nl_close_cb(handle: *uv::ll::uv_tcp_t) unsafe {
|
||||||
@ -1101,7 +1098,7 @@ fn ipv4_ip_addr_to_sockaddr_in(input_ip: ip::ip_addr,
|
|||||||
ip::ipv4(_,_,_,_) {
|
ip::ipv4(_,_,_,_) {
|
||||||
uv::ll::ip4_addr(ip::format_addr(input_ip), port as int)
|
uv::ll::ip4_addr(ip::format_addr(input_ip), port as int)
|
||||||
}
|
}
|
||||||
_ {
|
ip::ipv6(_,_,_,_,_,_,_,_) {
|
||||||
fail "FIXME ipv6 not yet supported";
|
fail "FIXME ipv6 not yet supported";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1324,7 +1321,6 @@ mod test {
|
|||||||
err_data.err_name, err_data.err_msg));
|
err_data.err_name, err_data.err_msg));
|
||||||
fail "couldn't recv new conn";
|
fail "couldn't recv new conn";
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
let sock = result::unwrap(new_conn_result);
|
let sock = result::unwrap(new_conn_result);
|
||||||
log(debug, "SERVER: successfully accepted"+
|
log(debug, "SERVER: successfully accepted"+
|
||||||
"connection!");
|
"connection!");
|
||||||
@ -1342,7 +1338,6 @@ mod test {
|
|||||||
server_ch.send("");
|
server_ch.send("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
let ret_val = server_ch.recv();
|
let ret_val = server_ch.recv();
|
||||||
log(debug, #fmt("SERVER: exited and got ret val: '%s'", ret_val));
|
log(debug, #fmt("SERVER: exited and got ret val: '%s'", ret_val));
|
||||||
|
Loading…
Reference in New Issue
Block a user