Skip to content

Commit

Permalink
proxy_util: revert timeout selection on a proxy tunnel back to
Browse files Browse the repository at this point in the history
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
  • Loading branch information
icing committed Jul 10, 2023
1 parent 1e2fef0 commit fe3b59d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
4 changes: 2 additions & 2 deletions modules/proxy/proxy_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
26 changes: 24 additions & 2 deletions test/modules/http2/test_800_websockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import subprocess
import time
from datetime import timedelta, datetime
from typing import Tuple, List
import packaging.version

import pytest
Expand All @@ -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
Expand Down Expand Up @@ -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}/ \\',
Expand Down Expand Up @@ -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}'

0 comments on commit fe3b59d

Please sign in to comment.