fixed bug when closing

This commit is contained in:
Y. T. Chung
2015-06-18 01:43:25 +08:00
parent b74ff12a75
commit 8c44bce231
3 changed files with 19 additions and 9 deletions
+2 -1
View File
@@ -110,6 +110,7 @@ impl Relay for RelayLocal {
info!("Enabled UDP relay");
}
Scheduler::run(num_cpus::get());
// Scheduler::run(num_cpus::get());
Scheduler::run(1);
}
}
+11 -4
View File
@@ -212,10 +212,13 @@ impl TcpRelayLocal {
error!("{} relay from local to remote stream: {}", addr_cloned, err)
}
}
let _ = encrypt_stream.get_ref().shutdown(Shutdown::Both);
let _ = local_reader.get_ref().shutdown(Shutdown::Both);
}
}
let _ = encrypt_stream.get_ref().shutdown(Shutdown::Both);
let _ = local_reader.get_ref().shutdown(Shutdown::Both);
debug!("Local to remote closed");
});
Scheduler::spawn(move|| {
@@ -254,6 +257,7 @@ impl TcpRelayLocal {
return;
}
};
match io::copy(&mut decrypt_stream, &mut local_writer) {
Err(err) => {
match err.kind() {
@@ -264,11 +268,14 @@ impl TcpRelayLocal {
error!("{} relay from local to remote stream: {}", addr, err)
}
}
let _ = decrypt_stream.get_mut().shutdown(Shutdown::Both);
let _ = local_writer.shutdown(Shutdown::Both);
},
Ok(..) => {},
}
let _ = decrypt_stream.get_mut().shutdown(Shutdown::Both);
let _ = local_writer.shutdown(Shutdown::Both);
debug!("Remote to local closed");
});
},
socks5::Command::TcpBind => {
+6 -4
View File
@@ -162,10 +162,11 @@ impl TcpRelayServer {
error!("{} relay from local to remote stream: {}", addr_cloned, err)
}
}
let _ = remote_stream_cloned.shutdown(Shutdown::Both);
let _ = decrypt_stream.get_mut().get_mut().shutdown(Shutdown::Both);
}
}
let _ = remote_stream_cloned.shutdown(Shutdown::Both);
let _ = decrypt_stream.get_mut().get_mut().shutdown(Shutdown::Both);
});
Scheduler::spawn(move|| {
@@ -201,10 +202,11 @@ impl TcpRelayServer {
error!("{} relay from remote to local stream: {}", addr, err)
}
}
let _ = encrypt_stream.get_mut().shutdown(Shutdown::Both);
let _ = buffered_remote_stream.get_mut().shutdown(Shutdown::Both);
}
}
let _ = encrypt_stream.get_mut().shutdown(Shutdown::Both);
let _ = buffered_remote_stream.get_mut().shutdown(Shutdown::Both);
});
});
}