From 6ee803573538a79f73ede3adfca3a1c752bb1aa3 Mon Sep 17 00:00:00 2001 From: BreakWa11 Date: Mon, 26 Oct 2015 14:48:54 +0800 Subject: [PATCH] merge pr from mengskysama --- shadowsocks/lru_cache.py | 2 +- shadowsocks/udprelay.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/shadowsocks/lru_cache.py b/shadowsocks/lru_cache.py index 401f19b..e67fdff 100644 --- a/shadowsocks/lru_cache.py +++ b/shadowsocks/lru_cache.py @@ -88,12 +88,12 @@ class LRUCache(collections.MutableMapping): self.close_callback(value) self._closed_values.add(value) for key in self._time_to_keys[least]: - self._last_visits.popleft() if key in self._store: if now - self._keys_to_last_time[key] > self.timeout: del self._store[key] del self._keys_to_last_time[key] c += 1 + self._last_visits.popleft() del self._time_to_keys[least] if c: self._closed_values.clear() diff --git a/shadowsocks/udprelay.py b/shadowsocks/udprelay.py index d3696d9..b4fcae3 100644 --- a/shadowsocks/udprelay.py +++ b/shadowsocks/udprelay.py @@ -1293,6 +1293,7 @@ class UDPRelay(object): logging.info('closed UDP port %d', self._listen_port) before_sweep_size = len(self._sockets) self._cache.sweep() + self._dns_cache.sweep() if before_sweep_size != len(self._sockets): logging.debug('UDP port %5d sockets %d' % (self._listen_port, len(self._sockets))) self._client_fd_to_server_addr.sweep()