Piotr Kliczewski has uploaded a new change for review. Change subject: stomp: Drain pending bytes from ssl socket ......................................................................
stomp: Drain pending bytes from ssl socket Since commit b2da4effe01f (asyncore: use default handing of read event), we are not handling pending bytes in ssl socket internal buffer. Stomp reactor was reading only 4096 bytes from the ssl socket buffer, and polling again the socket file descriptor. Until the next packet arrived, we did not try to read the pending bytes from the ssl socket buffer. This broke migration when using jsonrpc. The destination host returned a big response, and the source host got stuck after the reading the first 4096 bytes, until the migration timed out. Now all available bytes in are read and processed in handle_read. Change-Id: I4ea37c35c871ae286863c5d4403bcf71ac803da5 Bug-Url: https://bugzilla.redhat.com/1274670 Signed-off-by: Nir Soffer <nsof...@redhat.com> --- M lib/yajsonrpc/stomp.py M tests/stompTests.py 2 files changed, 22 insertions(+), 10 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/65/50265/1 diff --git a/lib/yajsonrpc/stomp.py b/lib/yajsonrpc/stomp.py index 633f307..8717b5f 100644 --- a/lib/yajsonrpc/stomp.py +++ b/lib/yajsonrpc/stomp.py @@ -346,16 +346,20 @@ self._frame_handler.handle_connect(self) def handle_read(self, dispatcher): - try: - data = dispatcher.recv(self._bufferSize) - except socket.error: - dispatcher.handle_error() - return - parser = self._parser + pending = getattr(dispatcher, 'pending', lambda: 0) + todo = self._bufferSize - if data is not None: + while todo: + try: + data = dispatcher.recv(todo) + except socket.error: + dispatcher.handle_error() + return + if data is None: + return parser.parse(data) + todo = pending() while parser.pending > 0: self._frame_handler.handle_frame(self, parser.popFrame()) diff --git a/tests/stompTests.py b/tests/stompTests.py index aead3a7..74ee6db 100644 --- a/tests/stompTests.py +++ b/tests/stompTests.py @@ -59,9 +59,17 @@ @expandPermutations class StompTests(TestCaseBase): - @permutations(_USE_SSL) - def test_echo(self, use_ssl): - data = dummyTextGenerator(1024) + @permutations([ + # size, use_ssl + (1024, True), + (1024, False), + (4096, True), + (4096, False), + (16384, True), + (16384, False), + ]) + def test_echo(self, size, use_ssl): + data = dummyTextGenerator(size) with constructAcceptor(self.log, use_ssl, _SampleBridge()) as acceptor: sslctx = DEAFAULT_SSL_CONTEXT if use_ssl else None -- To view, visit https://gerrit.ovirt.org/50265 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4ea37c35c871ae286863c5d4403bcf71ac803da5 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: ovirt-3.6 Gerrit-Owner: Piotr Kliczewski <piotr.kliczew...@gmail.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches