Skip to content

Commit 281ac3e

Browse files
committed
PYTHON-1024: fix error handling for SSL errors
This also removes a check that depends internal behavior that no longer holds, as `process_io_buffer` is no longer called after `handle_read` gets an error.
1 parent 2fe7084 commit 281ac3e

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
3.15.2
22
======
33

4+
Bug Fixes
5+
---------
6+
* Improve and fix socket error-catching code in nonblocking-socket reactors (PYTHON-1024)
7+
48
Other
59
-----
610
* Fix tests when RF is not maintained if we decomission a node (PYTHON-1017)

cassandra/io/asyncorereactor.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,14 @@ def handle_read(self):
424424
break
425425
except socket.error as err:
426426
if ssl and isinstance(err, ssl.SSLError):
427-
if err.args[0] not in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE):
427+
if err.args[0] in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE):
428+
return
429+
else:
428430
self.defunct(err)
429431
return
430-
elif err.args[0] not in NONBLOCKING:
432+
elif err.args[0] in NONBLOCKING:
433+
return
434+
else:
431435
self.defunct(err)
432436
return
433437

cassandra/io/libevreactor.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,14 @@ def handle_read(self, watcher, revents, errno=None):
344344
break
345345
except socket.error as err:
346346
if ssl and isinstance(err, ssl.SSLError):
347-
if err.args[0] not in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE):
347+
if err.args[0] in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE):
348+
return
349+
else:
348350
self.defunct(err)
349351
return
350-
elif err.args[0] not in NONBLOCKING:
352+
elif err.args[0] in NONBLOCKING:
353+
return
354+
else:
351355
self.defunct(err)
352356
return
353357

tests/unit/io/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@ def side_effect(*args):
284284

285285
self.get_socket(c).recv.side_effect = side_effect
286286
c.handle_read(*self.null_handle_function_args)
287-
self.assertEqual(c._current_frame.end_pos, 20000 + len(header))
288287
# the EAGAIN prevents it from reading the last 100 bytes
289288
c._iobuf.seek(0, os.SEEK_END)
290289
pos = c._iobuf.tell()

0 commit comments

Comments
 (0)