mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
This patch fixes the error handling of cases where there are runtime errors in `socketserver`. For example, when creating a new thread (to handle a request) fails. `get_request` handles ssl connections by replacing the new client socket by a tuple containing `(server_socket, new_client_socket)` in order to later deal with handshakes in `process_request_thread` During the processing of a request, the socketserver `BaseServer` calls `handle_request`, calling the `_handle_request_noblock`, which is calling the following functions (https://github.com/python/cpython/blob/3.8/Lib/socketserver.py#L303): ``` request, client_addr = get_request() verify_request(request, client_address): process_request(request, client_address) handle_error(request, client_address) shutdown_request(request) ``` - `get_request` is overloaded in patroni and returns `request` as a tuple in case of ssl calls - `verify_request` defaults to `return True` and should be fixed if used but is fine in this case - `process_request` just calls `process_request_thread` (which is overloaded in patroni and handles tuple-style requests) - `handle_error` is overloaded in patroni and handles tuple-style requests) - but `shutdown_request` is not overloaded and thus missing support for tuple-style requests This patch adds support for tuple-style requests in patroni api