From 177c639b191f87767505eb4322a1f6f3a976d11e Mon Sep 17 00:00:00 2001 From: clowwindy Date: Sun, 2 Aug 2015 15:12:41 +0800 Subject: [PATCH] fix graceful restart test --- shadowsocks/udprelay.py | 2 +- tests/graceful.json | 2 +- tests/test_graceful_restart.sh | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/shadowsocks/udprelay.py b/shadowsocks/udprelay.py index 856fe08..e3fe77c 100644 --- a/shadowsocks/udprelay.py +++ b/shadowsocks/udprelay.py @@ -274,11 +274,11 @@ class UDPRelay(object): def handle_periodic(self): if self._closed: if self._server_socket: - logging.info('closed UDP port %d', self._listen_port) self._server_socket.close() self._server_socket = None for sock in self._sockets: sock.close() + logging.info('closed UDP port %d', self._listen_port) self._cache.sweep() self._client_fd_to_server_addr.sweep() diff --git a/tests/graceful.json b/tests/graceful.json index 4b95434..7d94ea5 100644 --- a/tests/graceful.json +++ b/tests/graceful.json @@ -1,6 +1,6 @@ { "server":"127.0.0.1", - "server_port":8387, + "server_port":8388, "local_port":1081, "password":"aes_password", "timeout":15, diff --git a/tests/test_graceful_restart.sh b/tests/test_graceful_restart.sh index cec984a..d91ba92 100755 --- a/tests/test_graceful_restart.sh +++ b/tests/test_graceful_restart.sh @@ -23,6 +23,7 @@ sleep 1 # graceful restart server: send SIGQUIT to old process and start a new one kill -s SIGQUIT $SERVER +sleep 0.5 $PYTHON shadowsocks/server.py -c tests/graceful.json --forbidden-ip "" & NEWSERVER=$! @@ -37,7 +38,7 @@ echo old server running: $OLD_SERVER_RUNNING1 sleep 1 # close connections on old server -kill -s SIGINT $GCLI +kill -s SIGKILL $GCLI kill -s SIGKILL $GSERVER kill -s SIGINT $LOCAL @@ -49,6 +50,7 @@ OLD_SERVER_RUNNING2=$? # old server should quit at this moment echo old server running: $OLD_SERVER_RUNNING2 +kill -s SIGINT $SERVER # new server is expected running kill -s SIGINT $NEWSERVER || exit 1 @@ -57,7 +59,6 @@ if [ $OLD_SERVER_RUNNING1 -ne 0 ]; then fi if [ $OLD_SERVER_RUNNING2 -ne 1 ]; then - kill -s SIGINT $SERVER sleep 1 exit 1 fi