Skip to content

Commit

Permalink
TCP server: Do not enable socket linger with null timeout if SSL is used
Browse files Browse the repository at this point in the history
  • Loading branch information
francis-clairicia committed Jun 27, 2024
1 parent de4e921 commit dab8dbf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/easynetwork/servers/async_tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
ISocket,
SocketAddress,
SocketProxy,
TLSAttribute,
enable_socket_linger,
new_socket_address,
set_tcp_keepalive,
Expand Down Expand Up @@ -405,7 +406,12 @@ async def __client_initializer(
client_exit_stack.enter_context(self.__suppress_and_log_remaining_exception(client_address=client_address))
# If the socket was not closed gracefully, (i.e. client.aclose() failed )
# tell the OS to immediately abort the connection when calling socket.socket.close()
client_exit_stack.callback(self.__set_socket_linger_if_not_closed, lowlevel_client.extra(INETSocketAttribute.socket))
# NOTE: Do not set this option if SSL/TLS is enabled
if lowlevel_client.extra(TLSAttribute.sslcontext, None) is None:
client_exit_stack.callback(
self.__set_socket_linger_if_not_closed,
lowlevel_client.extra(INETSocketAttribute.socket),
)

logger: logging.Logger = self.__logger
client = _ConnectedClientAPI(client_address, lowlevel_client)
Expand Down

0 comments on commit dab8dbf

Please sign in to comment.