Skip to content

Commit 1b589d0

Browse files
Internally, before a connection is returned from a pool, check for
control packets from the server (which may inform the client that the connection needs to be closed and a new one established).
1 parent 0b7294f commit 1b589d0

File tree

6 files changed

+201
-167
lines changed

6 files changed

+201
-167
lines changed

doc/src/release_notes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ Thin Mode Changes
2323
the database sends a password challenge with a verifier type that is not
2424
recognized, instead of `ORA-01017: invalid username/password`
2525
(`issue 26 <https://github.com/oracle/python-oracledb/issues/26>`__).
26+
#) Internally, before a connection is returned from a pool, check for control
27+
packets from the server (which may inform the client that the connection
28+
needs to be closed and a new one established).
2629
#) Internally make use of the `TCP_NODELAY` socket option to remove delays
2730
in socket reads.
2831

src/oracledb/impl/thin/buffer.pyx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,21 @@ cdef class ReadBuffer:
10811081

10821082
return bytes(output_value).decode()
10831083

1084+
cdef int check_control_packet(self) except -1:
1085+
"""
1086+
Checks for a control packet or final close packet from the server.
1087+
"""
1088+
cdef:
1089+
uint8_t packet_type, packet_flags
1090+
uint16_t data_flags
1091+
self._receive_packet_helper(&packet_type, &packet_flags)
1092+
if packet_type == TNS_PACKET_TYPE_CONTROL:
1093+
self._process_control_packet()
1094+
elif packet_type == TNS_PACKET_TYPE_DATA:
1095+
self.read_uint16(&data_flags)
1096+
if data_flags == TNS_DATA_FLAGS_EOF:
1097+
self._session_needs_to_be_closed = True
1098+
10841099
cdef int receive_packet(self, uint8_t *packet_type,
10851100
uint8_t *packet_flags) except -1:
10861101
"""

src/oracledb/impl/thin/constants.pxi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ DEF TNS_PACKET_TYPE_REDIRECT = 5
4242
# packet flags
4343
DEF TNS_PACKET_FLAG_TLS_RENEG = 0x08
4444

45+
# data flags
46+
DEF TNS_DATA_FLAGS_EOF = 0x0040
47+
4548
# marker types
4649
DEF TNS_MARKER_TYPE_BREAK = 1
4750
DEF TNS_MARKER_TYPE_RESET = 2

0 commit comments

Comments
 (0)