use lru-cache in crates.io

This commit is contained in:
Y. T. Chung
2015-12-14 22:57:16 +08:00
parent 8340b57dc0
commit 7bdae15ebf
4 changed files with 6 additions and 9 deletions

View File

@@ -59,10 +59,7 @@ env_logger = "^0.3.2"
rust-crypto = "^0.2.34"
ip = "1.0.0"
openssl = "^0.7.1"
[dependencies.lru-cache]
git = "https://github.com/zonyitoo/lru-cache.git"
ver = "7688eae5a4ce8e6f9beb075e11d1abb3d2b2f635"
lru-cache = "^0.0.5"
[dependencies.coio]
git = "https://github.com/zonyitoo/coio-rs.git"

View File

@@ -53,7 +53,7 @@ impl CachedDns {
pub fn resolve(&self, addr_str: &str) -> Option<Vec<SocketAddr>> {
{
let mut cache = self.lru_cache.lock().unwrap();
match cache.cache.get(addr_str).map(|x| x.clone()) {
match cache.cache.get_mut(addr_str).map(|x| x.clone()) {
Some(addrs) => {
cache.totally_matched += 1;
debug!("DNS cache matched!: {}", addr_str);

View File

@@ -303,7 +303,7 @@ fn handle_response(socket: UdpSocket,
let client_addr = {
let mut cmap = client_map.lock().unwrap();
match cmap.get(&addr) {
match cmap.get_mut(&addr) {
Some(a) => a.clone(),
None => return,
}

View File

@@ -86,9 +86,9 @@ impl UdpRelayServer {
let forbidden_ip = forbidden_ip.clone();
Builder::new().stack_size(COROUTINE_STACK_SIZE).spawn(move || {
match remote_map.lock().unwrap().get(&src) {
match remote_map.lock().unwrap().get_mut(&src) {
Some(remote_addr) => {
match client_map.lock().unwrap().get(remote_addr) {
match client_map.lock().unwrap().get_mut(remote_addr) {
Some(client_addr) => {
debug!("UDP response {} -> {}", remote_addr, client_addr);
@@ -119,7 +119,7 @@ impl UdpRelayServer {
return;
}
if let Err(err) = captured_socket.send_to(&iv[..], &client_addr) {
if let Err(err) = captured_socket.send_to(&iv[..], &*client_addr) {
error!("Error occurs while sending data: {:?}", err);
return;
}