15
0

- Update to 8.5.2:

* :issue:`358` via :pr:`359`: Fixed a regression from
    :pr:`199` that made the worker threads exit on invalid
    connection attempts and could make the whole server
    unresponsive once there was no workers left.
    *- by :user:`cameronbrunner`.
  * :cp-issue:`1873` via :pr:`340`: Resurrected an
    unintentionally removed feature of interrupting a server
    main thread by externally assigning an exception to the
    :py:meth:`HTTPServer.interrupt <cheroot.server.\
    HTTPServer.interrupt>` property *- by :user:`liamstask`.
  * :pr:`350`: Fixed the incarnation of an earlier regression
    of not resetting the serving state
    on :py:data:``SIGINT`` originally fixed by :pr:`322` and
    :pr:`331` but reintroduced by the changes in :pr:`311`
    *- by :user:`liamstask`.
  * :issue:`305` via :pr:`311`: In
    :py:class:`~cheroot.connections.ConnectionManager`,
    process connections as they become active rather than
    waiting for a ``tick`` event, addressing performance
    degradation introduced in v8.1.0 *- by :user:`liamstask`.
  * :issue:`341` via :pr:`342`: Suppress legitimate OS errors
    expected on shutdown *- by :user:`webknjaz`.
  * :issue:`317` via :pr:`337`: Fixed a regression in
    8.4.5 where the connections dictionary would change
    size during iteration, leading to a :py:exc:`RuntimeError`
    raised in the logs *- by :user:`liamstask`.
  * :issue:`328` via :pr:`322` and :pr:`331`: Fixed a
    regression introduced in the earlier refactoring in v8.4.4
    via :pr:`309` that caused the :py:meth:`~cheroot.server.\
    HTTPServer.serve` method to skip setting
    ``serving=False`` on :py:data:``SIGINT`` and
    :py:data:``SIGTERM`` *- by :user:`marc1n` and
    :user:`cristicbz`.
  * :issue:`312` via :pr:`313`: Fixed a regression introduced
    in the earlier refactoring in v8.4.4 via :pr:`309` that
    caused the connection manager to modify the selector map
    while looping over it *- by :user:`liamstask`.
  * :issue:`312` via :pr:`316`: Added a regression test for
    the error handling in :py:meth:`~cheroot.connections.\
    ConnectionManager.get_conn` to ensure more stability
    *- by :user:`cyraxjoe`.
  * :issue:`304` via :pr:`309`: Refactored :py:class:`~\
    cheroot.connections.ConnectionManager` to use :py:meth:`~\
    selectors.BaseSelector.get_map` and reorganized the
    readable connection tracking *- by :user:`liamstask`.
  * :issue:`304` via :pr:`309`: Fixed the server shutdown
    sequence to avoid race condition resulting in accepting
    new connections while it is being terminated
    *- by :user:`liamstask`.
  * :pr:`282`: Fixed a race condition happening when an HTTP
    client attempts to reuse a persistent HTTP connection after
    it's been discarded on the server in :py:class:`~cheroot.\
    server.HTTPRequest` but no TCP FIN packet has been received
    yet over the wire *- by :user:`meaksh`.
  * Fixed a significant performance regression introduced in
    v8.1.0 (:issue:`305` via :pr:`308`) * by :user:`mar10`.
  * Fixed TLS socket related unclosed resource warnings
    (:pr:`291` and :pr:`298`).
  * Made terminating keep-alive connections more graceful
    (:issue:`263` via :pr:`277`).
- Dropped patches 0001-Avoid-race-condition-on-persistent-HTTP-connections.patch
  and python383.patch, they are included upstream.

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-cheroot?expand=0&rev=32
This commit is contained in:
2021-03-19 05:51:10 +00:00
committed by Git OBS Bridge
parent 007c0b2045
commit caf21991cc
6 changed files with 78 additions and 109 deletions

View File

@@ -1,41 +0,0 @@
From 49a8934d726574f7ff85356e6acbfdc06ca7fbdb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
<psuarezhernandez@suse.com>
Date: Wed, 6 May 2020 14:04:48 +0100
Subject: [PATCH] Avoid race condition on persistent HTTP connections
Add a HTTP "Keep-Alive" header with "timeout" on the HTTP response
to avoid a race condition on persistent HTTP connections when the
HTTP client reuses a connection after the "socket.timeout" exception
triggered on the HTTPServer but before the FIN packet is produced.
When this happens, the client gets a "connection reset by peer" after
writting the request.
This commit makes a HTTP client to know about this "Keep-Alive" idle
timeout by exposing it on the HTTP "Keep-Alive" response header, so
the connection won't be reused if it was "idle" for that "timeout"
after the last request response.
---
cheroot/server.py | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/cheroot/server.py b/cheroot/server.py
index 223bed86..f29559b4 100644
--- a/cheroot/server.py
+++ b/cheroot/server.py
@@ -1167,6 +1167,11 @@ class HTTPRequest:
if not self.close_connection:
self.outheaders.append((b'Connection', b'Keep-Alive'))
+ self.outheaders.append((
+ b'Keep-Alive',
+ "timeout={}".format(self.server.timeout).encode('ISO-8859-1'),
+ ))
+
if (not self.close_connection) and (not self.chunked_read):
# Read any remaining request body data on the socket.
# "If an origin server receives a request that does not include an
--
2.23.0

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a0577e1f28661727d472671a7cc4e0c12ea0cbc5220265e70f00a8b8cb628931
size 100557

3
cheroot-8.5.2.tar.gz Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f137d03fd5155b1364bea557a7c98168665c239f6c8cedd8f80e81cdfac01567
size 113183

View File

@@ -1,3 +1,70 @@
-------------------------------------------------------------------
Fri Mar 19 05:46:04 UTC 2021 - Steve Kowalik <steven.kowalik@suse.com>
- Update to 8.5.2:
* :issue:`358` via :pr:`359`: Fixed a regression from
:pr:`199` that made the worker threads exit on invalid
connection attempts and could make the whole server
unresponsive once there was no workers left.
*- by :user:`cameronbrunner`.
* :cp-issue:`1873` via :pr:`340`: Resurrected an
unintentionally removed feature of interrupting a server
main thread by externally assigning an exception to the
:py:meth:`HTTPServer.interrupt <cheroot.server.\
HTTPServer.interrupt>` property *- by :user:`liamstask`.
* :pr:`350`: Fixed the incarnation of an earlier regression
of not resetting the serving state
on :py:data:``SIGINT`` originally fixed by :pr:`322` and
:pr:`331` but reintroduced by the changes in :pr:`311`
*- by :user:`liamstask`.
* :issue:`305` via :pr:`311`: In
:py:class:`~cheroot.connections.ConnectionManager`,
process connections as they become active rather than
waiting for a ``tick`` event, addressing performance
degradation introduced in v8.1.0 *- by :user:`liamstask`.
* :issue:`341` via :pr:`342`: Suppress legitimate OS errors
expected on shutdown *- by :user:`webknjaz`.
* :issue:`317` via :pr:`337`: Fixed a regression in
8.4.5 where the connections dictionary would change
size during iteration, leading to a :py:exc:`RuntimeError`
raised in the logs *- by :user:`liamstask`.
* :issue:`328` via :pr:`322` and :pr:`331`: Fixed a
regression introduced in the earlier refactoring in v8.4.4
via :pr:`309` that caused the :py:meth:`~cheroot.server.\
HTTPServer.serve` method to skip setting
``serving=False`` on :py:data:``SIGINT`` and
:py:data:``SIGTERM`` *- by :user:`marc1n` and
:user:`cristicbz`.
* :issue:`312` via :pr:`313`: Fixed a regression introduced
in the earlier refactoring in v8.4.4 via :pr:`309` that
caused the connection manager to modify the selector map
while looping over it *- by :user:`liamstask`.
* :issue:`312` via :pr:`316`: Added a regression test for
the error handling in :py:meth:`~cheroot.connections.\
ConnectionManager.get_conn` to ensure more stability
*- by :user:`cyraxjoe`.
* :issue:`304` via :pr:`309`: Refactored :py:class:`~\
cheroot.connections.ConnectionManager` to use :py:meth:`~\
selectors.BaseSelector.get_map` and reorganized the
readable connection tracking *- by :user:`liamstask`.
* :issue:`304` via :pr:`309`: Fixed the server shutdown
sequence to avoid race condition resulting in accepting
new connections while it is being terminated
*- by :user:`liamstask`.
* :pr:`282`: Fixed a race condition happening when an HTTP
client attempts to reuse a persistent HTTP connection after
it's been discarded on the server in :py:class:`~cheroot.\
server.HTTPRequest` but no TCP FIN packet has been received
yet over the wire *- by :user:`meaksh`.
* Fixed a significant performance regression introduced in
v8.1.0 (:issue:`305` via :pr:`308`) * by :user:`mar10`.
* Fixed TLS socket related unclosed resource warnings
(:pr:`291` and :pr:`298`).
* Made terminating keep-alive connections more graceful
(:issue:`263` via :pr:`277`).
- Dropped patches 0001-Avoid-race-condition-on-persistent-HTTP-connections.patch
and python383.patch, they are included upstream.
-------------------------------------------------------------------
Mon May 25 10:59:14 UTC 2020 - Petr Gajdos <pgajdos@suse.com>

View File

@@ -1,7 +1,7 @@
#
# spec file for package python-cheroot
#
# Copyright (c) 2020 SUSE LLC
# Copyright (c) 2021 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -20,22 +20,22 @@
%define pypi_name cheroot
%bcond_without python2
Name: python-%{pypi_name}
Version: 8.3.0
Version: 8.5.2
Release: 0
Summary: Pure-python HTTP server
License: BSD-3-Clause
URL: https://github.com/cherrypy/cheroot
Source: https://files.pythonhosted.org/packages/source/c/%{pypi_name}/%{pypi_name}-%{version}.tar.gz
# PATCH-FIX_UPSTREAM //github.com/cherrypy/cheroot/pull/282
Patch1: 0001-Avoid-race-condition-on-persistent-HTTP-connections.patch
# PATCH-FIX-UPSTREAM pr#280
Patch2: python383.patch
BuildRequires: %{python_module jaraco.context}
BuildRequires: %{python_module jaraco.functools}
BuildRequires: %{python_module jaraco.text >= 3.1}
BuildRequires: %{python_module more-itertools >= 2.6}
BuildRequires: %{python_module portend}
BuildRequires: %{python_module pyOpenSSL}
BuildRequires: %{python_module pytest >= 4.6}
BuildRequires: %{python_module pytest-forked}
BuildRequires: %{python_module pytest-mock >= 1.11.0}
BuildRequires: %{python_module requests-toolbelt}
BuildRequires: %{python_module requests-unixsocket}
BuildRequires: %{python_module requests}
BuildRequires: %{python_module setuptools >= 34.4}
@@ -49,7 +49,7 @@ Requires: python-jaraco.functools
Requires: python-more-itertools >= 2.6
Requires: python-six >= 1.11.0
Requires(post): update-alternatives
Requires(postun): update-alternatives
Requires(postun):update-alternatives
# the package and distribution name is lowercase-cheroot,
# but PyPI claims the name is capital-Cheroot
# *smacks head against desk*
@@ -84,7 +84,7 @@ rm pytest.ini
%check
# Exclusions because of gh#cherrypy/cheroot#200
%pytest -k 'not test_tls_client_auth'
%pytest -k 'not (test_tls_client_auth or test_connection_keepalive)'
%post
%python_install_alternative cheroot

View File

@@ -1,57 +0,0 @@
From 554972e7c3142c4e82e2ac38a019ef403f8f4e3d Mon Sep 17 00:00:00 2001
From: "Jason R. Coombs" <jaraco@jaraco.com>
Date: Sun, 12 Apr 2020 13:46:08 -0400
Subject: [PATCH 1/2] Remove fixture, undocumented and presumed unneeded.
---
cheroot/test/test_server.py | 26 +-------------------------
1 file changed, 1 insertion(+), 25 deletions(-)
Index: cheroot-8.3.0/cheroot/test/test_server.py
===================================================================
--- cheroot-8.3.0.orig/cheroot/test/test_server.py
+++ cheroot-8.3.0/cheroot/test/test_server.py
@@ -23,7 +23,6 @@ from ..testing import (
ANY_INTERFACE_IPV4,
ANY_INTERFACE_IPV6,
EPHEMERAL_PORT,
- get_server_client,
)
@@ -167,19 +166,19 @@ class _TestGateway(Gateway):
@pytest.fixture
-def peercreds_enabled_server_and_client(http_server, unix_sock_file):
+def peercreds_enabled_server(http_server, unix_sock_file):
"""Construct a test server with ``peercreds_enabled``."""
httpserver = http_server.send(unix_sock_file)
httpserver.gateway = _TestGateway
httpserver.peercreds_enabled = True
- return httpserver, get_server_client(httpserver)
+ return httpserver
@unix_only_sock_test
@non_macos_sock_test
-def test_peercreds_unix_sock(peercreds_enabled_server_and_client):
+def test_peercreds_unix_sock(peercreds_enabled_server):
"""Check that ``PEERCRED`` lookup works when enabled."""
- httpserver, testclient = peercreds_enabled_server_and_client
+ httpserver = peercreds_enabled_server
bind_addr = httpserver.bind_addr
if isinstance(bind_addr, six.binary_type):
@@ -208,9 +207,9 @@ def test_peercreds_unix_sock(peercreds_e
)
@unix_only_sock_test
@non_macos_sock_test
-def test_peercreds_unix_sock_with_lookup(peercreds_enabled_server_and_client):
+def test_peercreds_unix_sock_with_lookup(peercreds_enabled_server):
"""Check that ``PEERCRED`` resolution works when enabled."""
- httpserver, testclient = peercreds_enabled_server_and_client
+ httpserver = peercreds_enabled_server
httpserver.peercreds_resolve_enabled = True
bind_addr = httpserver.bind_addr