@@ -456,9 +456,6 @@ cdef class Protocol(BaseProtocol):
456456 cdef int _reset(self , Message message) except - 1 :
457457 cdef uint8_t marker_type, packet_type
458458
459- # send reset marker
460- self ._send_marker(self ._write_buf, TNS_MARKER_TYPE_RESET)
461-
462459 # read and discard all packets until a marker packet is received
463460 while True :
464461 packet_type = self ._read_buf._current_packet.packet_type
@@ -469,11 +466,12 @@ cdef class Protocol(BaseProtocol):
469466 break
470467 self ._read_buf.wait_for_packets_sync()
471468
472- # read error packet; first skip as many marker packets as may be sent
473- # by the server; if the server doesn't handle out-of-band breaks
474- # properly, some quit immediately and others send multiple reset
475- # markers (this addresses both situations without resulting in strange
476- # errors)
469+ # send reset marker and then read error packet; first skip as many
470+ # marker packets as may be sent by the server; if the server doesn't
471+ # handle out-of-band breaks properly, some quit immediately and others
472+ # send multiple reset markers (this addresses both situations without
473+ # resulting in strange errors)
474+ self ._send_marker(self ._write_buf, TNS_MARKER_TYPE_RESET)
477475 while packet_type == TNS_PACKET_TYPE_MARKER:
478476 self ._read_buf.wait_for_packets_sync()
479477 packet_type = self ._read_buf._current_packet.packet_type
@@ -851,9 +849,6 @@ cdef class BaseAsyncProtocol(BaseProtocol):
851849 async def _reset(self ):
852850 cdef uint8_t marker_type, packet_type
853851
854- # send reset marker
855- self ._send_marker(self ._write_buf, TNS_MARKER_TYPE_RESET)
856-
857852 # read and discard all packets until a marker packet is received
858853 while True :
859854 packet_type = self ._read_buf._current_packet.packet_type
@@ -864,11 +859,13 @@ cdef class BaseAsyncProtocol(BaseProtocol):
864859 break
865860 await self ._read_buf.wait_for_packets_async()
866861
867- # read error packet; first skip as many marker packets as may be sent
868- # by the server; if the server doesn't handle out-of-band breaks
869- # properly, some quit immediately and others send multiple reset
870- # markers (this addresses both situations without resulting in strange
871- # errors)
862+
863+ # send reset marker and then read error packet; first skip as many
864+ # marker packets as may be sent by the server; if the server doesn't
865+ # handle out-of-band breaks properly, some quit immediately and others
866+ # send multiple reset markers (this addresses both situations without
867+ # resulting in strange errors)
868+ self ._send_marker(self ._write_buf, TNS_MARKER_TYPE_RESET)
872869 while packet_type == TNS_PACKET_TYPE_MARKER:
873870 await self ._read_buf.wait_for_packets_async()
874871 packet_type = self ._read_buf._current_packet.packet_type
0 commit comments