Skip to content

Commit 421a0c3

Browse files
Adjust handling of break/reset to avoid potential hangs in some
configurations.
1 parent 5cb9fd1 commit 421a0c3

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

doc/src/release_notes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Thin Mode Changes
2020
#) Fixed bug in statement cache when the maximum number of cursors is unknown
2121
due to the database not being open.
2222
#) Fixed bug in handling redirect data with small SDU sizes.
23+
#) Internal change: adjust handling of break/reset to avoid potential hangs in
24+
some configurations.
2325

2426
Thick Mode Changes
2527
++++++++++++++++++

src/oracledb/impl/thin/protocol.pyx

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,10 @@ cdef class Protocol(BaseProtocol):
466466
cdef int _reset(self, Message message) except -1:
467467
cdef uint8_t marker_type, packet_type
468468

469-
# read and discard all packets until a marker packet is received
469+
# send reset marker
470+
self._send_marker(self._write_buf, TNS_MARKER_TYPE_RESET)
471+
472+
# read and discard all packets until a reset marker is received
470473
while True:
471474
packet_type = self._read_buf._current_packet.packet_type
472475
if packet_type == TNS_PACKET_TYPE_MARKER:
@@ -476,12 +479,11 @@ cdef class Protocol(BaseProtocol):
476479
break
477480
self._read_buf.wait_for_packets_sync()
478481

479-
# send reset marker and then read error packet; first skip as many
480-
# marker packets as may be sent by the server; if the server doesn't
481-
# handle out-of-band breaks properly, some quit immediately and others
482-
# send multiple reset markers (this addresses both situations without
483-
# resulting in strange errors)
484-
self._send_marker(self._write_buf, TNS_MARKER_TYPE_RESET)
482+
# read error packet; first skip as many marker packets as may be sent
483+
# by the server; if the server doesn't handle out-of-band breaks
484+
# properly, some quit immediately and others send multiple reset
485+
# markers (this addresses both situations without resulting in strange
486+
# errors)
485487
while packet_type == TNS_PACKET_TYPE_MARKER:
486488
self._read_buf.wait_for_packets_sync()
487489
packet_type = self._read_buf._current_packet.packet_type
@@ -842,7 +844,10 @@ cdef class BaseAsyncProtocol(BaseProtocol):
842844
async def _reset(self):
843845
cdef uint8_t marker_type, packet_type
844846

845-
# read and discard all packets until a marker packet is received
847+
# send reset marker
848+
self._send_marker(self._write_buf, TNS_MARKER_TYPE_RESET)
849+
850+
# read and discard all packets until a reset marker is received
846851
while True:
847852
packet_type = self._read_buf._current_packet.packet_type
848853
if packet_type == TNS_PACKET_TYPE_MARKER:
@@ -852,12 +857,11 @@ cdef class BaseAsyncProtocol(BaseProtocol):
852857
break
853858
await self._read_buf.wait_for_packets_async()
854859

855-
# send reset marker and then read error packet; first skip as many
856-
# marker packets as may be sent by the server; if the server doesn't
857-
# handle out-of-band breaks properly, some quit immediately and others
858-
# send multiple reset markers (this addresses both situations without
859-
# resulting in strange errors)
860-
self._send_marker(self._write_buf, TNS_MARKER_TYPE_RESET)
860+
# read error packet; first skip as many marker packets as may be sent
861+
# by the server; if the server doesn't handle out-of-band breaks
862+
# properly, some quit immediately and others send multiple reset
863+
# markers (this addresses both situations without resulting in strange
864+
# errors)
861865
while packet_type == TNS_PACKET_TYPE_MARKER:
862866
await self._read_buf.wait_for_packets_async()
863867
packet_type = self._read_buf._current_packet.packet_type

0 commit comments

Comments
 (0)