fix fastopen and add a new test
This commit is contained in:
parent
30f4f78557
commit
99c8bbafe7
2 changed files with 9 additions and 6 deletions
|
@ -49,6 +49,10 @@ run_test python tests/test.py --with-coverage -b "-m aes-256-cfb -k testrc4 -s 1
|
||||||
|
|
||||||
if [ -f /proc/sys/net/ipv4/tcp_fastopen ] ; then
|
if [ -f /proc/sys/net/ipv4/tcp_fastopen ] ; then
|
||||||
if [ 3 -eq `cat /proc/sys/net/ipv4/tcp_fastopen` ] ; then
|
if [ 3 -eq `cat /proc/sys/net/ipv4/tcp_fastopen` ] ; then
|
||||||
|
# we have to run it twice:
|
||||||
|
# the first time there's no syn cookie
|
||||||
|
# the second time there is syn cookie
|
||||||
|
run_test python tests/test.py --with-coverage -c tests/fastopen.json
|
||||||
run_test python tests/test.py --with-coverage -c tests/fastopen.json
|
run_test python tests/test.py --with-coverage -c tests/fastopen.json
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -241,19 +241,18 @@ class TCPRelayHandler(object):
|
||||||
self._create_remote_socket(self._chosen_server[0],
|
self._create_remote_socket(self._chosen_server[0],
|
||||||
self._chosen_server[1])
|
self._chosen_server[1])
|
||||||
self._loop.add(remote_sock, eventloop.POLL_ERR)
|
self._loop.add(remote_sock, eventloop.POLL_ERR)
|
||||||
data = b''.join(self._data_to_write_to_local)
|
data = b''.join(self._data_to_write_to_remote)
|
||||||
l = len(data)
|
l = len(data)
|
||||||
s = remote_sock.sendto(data, MSG_FASTOPEN, self._chosen_server)
|
s = remote_sock.sendto(data, MSG_FASTOPEN, self._chosen_server)
|
||||||
if s < l:
|
if s < l:
|
||||||
data = data[s:]
|
data = data[s:]
|
||||||
self._data_to_write_to_local = [data]
|
self._data_to_write_to_remote = [data]
|
||||||
self._update_stream(STREAM_UP, WAIT_STATUS_READWRITING)
|
|
||||||
else:
|
else:
|
||||||
self._data_to_write_to_local = []
|
self._data_to_write_to_remote = []
|
||||||
self._update_stream(STREAM_UP, WAIT_STATUS_READING)
|
self._update_stream(STREAM_UP, WAIT_STATUS_READWRITING)
|
||||||
self._stage = STAGE_STREAM
|
|
||||||
except (OSError, IOError) as e:
|
except (OSError, IOError) as e:
|
||||||
if eventloop.errno_from_exception(e) == errno.EINPROGRESS:
|
if eventloop.errno_from_exception(e) == errno.EINPROGRESS:
|
||||||
|
# in this case data is not sent at all
|
||||||
self._update_stream(STREAM_UP, WAIT_STATUS_READWRITING)
|
self._update_stream(STREAM_UP, WAIT_STATUS_READWRITING)
|
||||||
elif eventloop.errno_from_exception(e) == errno.ENOTCONN:
|
elif eventloop.errno_from_exception(e) == errno.ENOTCONN:
|
||||||
logging.error('fast open not supported on this OS')
|
logging.error('fast open not supported on this OS')
|
||||||
|
|
Loading…
Add table
Reference in a new issue