fix daemon and add fastopen tests
This commit is contained in:
parent
072afd68f2
commit
5ea8403e56
4 changed files with 14 additions and 9 deletions
|
@ -46,6 +46,13 @@ run_test python tests/test.py --with-coverage -c tests/workers.json
|
|||
run_test python tests/test.py --with-coverage -s tests/ipv6.json -c tests/ipv6-client-side.json
|
||||
run_test python tests/test.py --with-coverage -b "-m rc4-md5 -k testrc4 -s 127.0.0.1 -p 8388" -a "-m rc4-md5 -k testrc4 -s 127.0.0.1 -p 8388 -l 1081"
|
||||
run_test python tests/test.py --with-coverage -b "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388" -a "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 -l 1081"
|
||||
|
||||
if [ -f /proc/sys/net/ipv4/tcp_fastopen ] ; then
|
||||
if [ 3 -eq `cat /proc/sys/net/ipv4/tcp_fastopen` ] ; then
|
||||
run_test python tests/test.py --with-coverage -c tests/fastopen.json
|
||||
fi
|
||||
fi
|
||||
|
||||
coverage combine && coverage report --include=shadowsocks/*
|
||||
rm -rf htmlcov
|
||||
rm -rf tmp
|
||||
|
|
|
@ -100,19 +100,21 @@ def freopen(f, mode, stream):
|
|||
|
||||
|
||||
def daemon_start(pid_file, log_file):
|
||||
# fork only once because we are sure parent will exit
|
||||
pid = os.fork()
|
||||
assert pid != -1
|
||||
|
||||
def handle_exit(signum, _):
|
||||
if signum == signal.SIGTERM:
|
||||
sys.exit(0)
|
||||
sys.exit(1)
|
||||
|
||||
signal.signal(signal.SIGINT, handle_exit)
|
||||
signal.signal(signal.SIGTERM, handle_exit)
|
||||
|
||||
# fork only once because we are sure parent will exit
|
||||
pid = os.fork()
|
||||
assert pid != -1
|
||||
|
||||
if pid > 0:
|
||||
# parent waits for its child
|
||||
signal.signal(signal.SIGINT, handle_exit)
|
||||
signal.signal(signal.SIGTERM, handle_exit)
|
||||
time.sleep(5)
|
||||
sys.exit(0)
|
||||
|
||||
|
@ -135,7 +137,6 @@ def daemon_start(pid_file, log_file):
|
|||
freopen(log_file, 'a', sys.stderr)
|
||||
except IOError as e:
|
||||
logging.error(e)
|
||||
os.kill(ppid, signal.SIGINT)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
|
|
@ -138,9 +138,7 @@ try:
|
|||
finally:
|
||||
for p in [p1, p2]:
|
||||
try:
|
||||
print('kill', file=sys.stderr)
|
||||
os.kill(p.pid, signal.SIGINT)
|
||||
print('waitpid', file=sys.stderr)
|
||||
os.waitpid(p.pid, 0)
|
||||
except OSError:
|
||||
pass
|
||||
|
|
|
@ -39,6 +39,5 @@ run_test 0 -c tests/aes.json -d restart --pid-file tmp/shadowsocks.pid --log-fil
|
|||
run_test 0 -c tests/aes.json -d stop --pid-file tmp/shadowsocks.pid --log-file tmp/shadowsocks.log
|
||||
|
||||
run_test 1 -c tests/aes.json -d start --pid-file tmp/not_exist/shadowsocks.pid --log-file tmp/shadowsocks.log
|
||||
run_test 1 -c tests/aes.json -d start --pid-file tmp/shadowsocks.pid --log-file tmp/not_exist/shadowsocks.log
|
||||
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue