Skip to content

Commit 99c8bba

Browse files
author
clowwindy
committed
fix fastopen and add a new test
1 parent 30f4f78 commit 99c8bba

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

.jenkins.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ run_test python tests/test.py --with-coverage -b "-m aes-256-cfb -k testrc4 -s 1
4949

5050
if [ -f /proc/sys/net/ipv4/tcp_fastopen ] ; then
5151
if [ 3 -eq `cat /proc/sys/net/ipv4/tcp_fastopen` ] ; then
52+
# we have to run it twice:
53+
# the first time there's no syn cookie
54+
# the second time there is syn cookie
55+
run_test python tests/test.py --with-coverage -c tests/fastopen.json
5256
run_test python tests/test.py --with-coverage -c tests/fastopen.json
5357
fi
5458
fi

shadowsocks/tcprelay.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,19 +241,18 @@ def _handle_stage_connecting(self, data):
241241
self._create_remote_socket(self._chosen_server[0],
242242
self._chosen_server[1])
243243
self._loop.add(remote_sock, eventloop.POLL_ERR)
244-
data = b''.join(self._data_to_write_to_local)
244+
data = b''.join(self._data_to_write_to_remote)
245245
l = len(data)
246246
s = remote_sock.sendto(data, MSG_FASTOPEN, self._chosen_server)
247247
if s < l:
248248
data = data[s:]
249-
self._data_to_write_to_local = [data]
250-
self._update_stream(STREAM_UP, WAIT_STATUS_READWRITING)
249+
self._data_to_write_to_remote = [data]
251250
else:
252-
self._data_to_write_to_local = []
253-
self._update_stream(STREAM_UP, WAIT_STATUS_READING)
254-
self._stage = STAGE_STREAM
251+
self._data_to_write_to_remote = []
252+
self._update_stream(STREAM_UP, WAIT_STATUS_READWRITING)
255253
except (OSError, IOError) as e:
256254
if eventloop.errno_from_exception(e) == errno.EINPROGRESS:
255+
# in this case data is not sent at all
257256
self._update_stream(STREAM_UP, WAIT_STATUS_READWRITING)
258257
elif eventloop.errno_from_exception(e) == errno.ENOTCONN:
259258
logging.error('fast open not supported on this OS')

0 commit comments

Comments
 (0)