From 2805547d30f9a23e72a04ddaea1276b96d322de9 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Thu, 6 Jul 2023 07:44:21 +0000 Subject: [PATCH] proxy_util: revert timeout selection on a proxy tunnel back to take the large of client/origin values. Add websocket test to verify that longer proxypass timeout is in effect. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1910809 13f79535-47bb-0310-9956-ffa450edef68 --- modules/proxy/proxy_util.c | 4 ++-- test/modules/http2/test_800_websockets.py | 26 +++++++++++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c index e7267d6fd9a..05005709081 100644 --- a/modules/proxy/proxy_util.c +++ b/modules/proxy/proxy_util.c @@ -4776,8 +4776,8 @@ PROXY_DECLARE(apr_status_t) ap_proxy_tunnel_create(proxy_tunnel_rec **ptunnel, apr_socket_timeout_get(tunnel->origin->pfd->desc.s, &origin_timeout); apr_socket_opt_set(tunnel->origin->pfd->desc.s, APR_SO_NONBLOCK, 1); - /* Defaults to the smallest timeout of both connections */ - tunnel->timeout = (client_timeout >= 0 && client_timeout < origin_timeout ? + /* Defaults to the largest timeout of both connections */ + tunnel->timeout = (client_timeout >= 0 && client_timeout > origin_timeout ? client_timeout : origin_timeout); /* No coalescing filters */ diff --git a/test/modules/http2/test_800_websockets.py b/test/modules/http2/test_800_websockets.py index 3741d051b9d..5b46da8edbc 100644 --- a/test/modules/http2/test_800_websockets.py +++ b/test/modules/http2/test_800_websockets.py @@ -5,6 +5,7 @@ import subprocess import time from datetime import timedelta, datetime +from typing import Tuple, List import packaging.version import pytest @@ -23,7 +24,7 @@ def ws_run(env: H2TestEnv, path, authority=None, do_input=None, inbytes=None, send_close=True, timeout=5, scenario='ws-stdin', - wait_close: float = 0.0): + wait_close: float = 0.0) -> Tuple[ExecResult, List[str], List[WsFrame]]: """ Run the h2ws test client in various scenarios with given input and timings. :param env: the test environment @@ -95,6 +96,9 @@ def _class_scope(self, env): # with '/ws/' # The WebSocket server is started in pytest fixture 'ws_server' below. conf = H2Conf(env, extras={ + 'base': [ + 'Timeout 1', + ], f'cgi.{env.http_tld}': [ f' H2WebSockets on', f' ProxyPass /ws/ http://127.0.0.1:{env.ws_port}/ \\', @@ -338,4 +342,22 @@ def test_h2_800_17_ws_throughput(self, env: H2TestEnv, ws_server, frame_len): total_len = sum([f.data_len for f in frames if f.opcode == WsFrame.BINARY]) assert total_len == ncount * flen, f'{frames}\n{r}' # to see these logged, invoke: `pytest -o log_cli=true` - log.info(f'throughput (frame-len={frame_len}): {(total_len / (1024*1024)) / r.duration.total_seconds():0.2f} MB/s') + log.info(f'throughput (frame-len={frame_len}): "' + f'"{(total_len / (1024*1024)) / r.duration.total_seconds():0.2f} MB/s') + + # Check that the tunnel timeout is observed, e.g. the longer holds and + # the 1sec cleint conn timeout does not trigger + def test_h2_800_18_timeout(self, env: H2TestEnv, ws_server): + fname = "data-10k" + frame_delay = 1500 + flen = 10*1000 + frame_len = 8192 + # adjust frame_len to allow for 1 second overall duration + r, infos, frames = ws_run(env, path=f'/ws/file/{fname}/{frame_len}/{frame_delay}', + wait_close=2) + assert r.exit_code == 0, f'{r}' + assert infos == ['[1] :status: 200', '[1] EOF'], f'{r}' + assert len(frames) > 0 + total_len = sum([f.data_len for f in frames if f.opcode == WsFrame.BINARY]) + assert total_len == flen, f'{frames}\n{r}' +