mirror of
https://github.com/curl/curl.git
synced 2026-08-26 05:43:31 +03:00
conncache: apply multi limits to transfers using a shared pool
- Determine max host and total connection limits from the transfer's own multi handle and test that it works for shared connections. Prior to this change, sincedf67269(precedes 8.13.0), Curl_cpool_check_limits() took the limits from the multi handle that owns the pool. A share-owned pool is not owned by any multi, so the limit check always passed. Prior todf67269the limits came from the transfer's own multi handle. Fixes https://github.com/curl/curl/issues/22265 Closes https://github.com/curl/curl/pull/22266
This commit is contained in:
parent
6bad3db3d5
commit
02214d98f7
5 changed files with 51 additions and 23 deletions
|
|
@ -586,7 +586,8 @@ class TestDownload:
|
|||
|
||||
@pytest.mark.parametrize("proto", Env.http_h1_h2_protos())
|
||||
@pytest.mark.parametrize("max_host_conns", [0, 1, 5])
|
||||
def test_02_33_max_host_conns(self, env: Env, httpd, nghttpx, proto, max_host_conns):
|
||||
@pytest.mark.parametrize("share_connect", [False, True])
|
||||
def test_02_33_max_host_conns(self, env: Env, httpd, nghttpx, proto, max_host_conns, share_connect):
|
||||
if not env.curl_is_debug():
|
||||
pytest.skip('only works for curl debug builds')
|
||||
if not env.curl_is_verbose():
|
||||
|
|
@ -601,6 +602,7 @@ class TestDownload:
|
|||
client = LocalClient(name='cli_hx_download', env=env, run_env=run_env)
|
||||
if not client.exists():
|
||||
pytest.skip(f'example client not built: {client.name}')
|
||||
extra_args = ['-S'] if share_connect else [] # share connections
|
||||
r = client.run(args=[
|
||||
'-n', f'{count}',
|
||||
'-m', f'{max_parallel}',
|
||||
|
|
@ -608,8 +610,7 @@ class TestDownload:
|
|||
'-x', # always use a fresh connection
|
||||
'-M', str(max_host_conns), # limit conns per host
|
||||
'-r', f'{env.domain1}:{port}:127.0.0.1',
|
||||
'-V', proto, url
|
||||
])
|
||||
] + extra_args + ['-V', proto, url])
|
||||
r.check_exit_code(0)
|
||||
srcfile = os.path.join(httpd.docs_dir, docname)
|
||||
self.check_downloads(client, srcfile, count)
|
||||
|
|
@ -625,7 +626,8 @@ class TestDownload:
|
|||
|
||||
@pytest.mark.parametrize("proto", Env.http_h1_h2_protos())
|
||||
@pytest.mark.parametrize("max_total_conns", [0, 1, 5])
|
||||
def test_02_34_max_total_conns(self, env: Env, httpd, nghttpx, proto, max_total_conns):
|
||||
@pytest.mark.parametrize("share_connect", [False, True])
|
||||
def test_02_34_max_total_conns(self, env: Env, httpd, nghttpx, proto, max_total_conns, share_connect):
|
||||
if not env.curl_is_debug():
|
||||
pytest.skip('only works for curl debug builds')
|
||||
if not env.curl_is_verbose():
|
||||
|
|
@ -640,6 +642,7 @@ class TestDownload:
|
|||
client = LocalClient(name='cli_hx_download', env=env, run_env=run_env)
|
||||
if not client.exists():
|
||||
pytest.skip(f'example client not built: {client.name}')
|
||||
extra_args = ['-S'] if share_connect else [] # share connections
|
||||
r = client.run(args=[
|
||||
'-n', f'{count}',
|
||||
'-m', f'{max_parallel}',
|
||||
|
|
@ -647,8 +650,7 @@ class TestDownload:
|
|||
'-x', # always use a fresh connection
|
||||
'-T', str(max_total_conns), # limit total connections
|
||||
'-r', f'{env.domain1}:{port}:127.0.0.1',
|
||||
'-V', proto, url
|
||||
])
|
||||
] + extra_args + ['-V', proto, url])
|
||||
r.check_exit_code(0)
|
||||
srcfile = os.path.join(httpd.docs_dir, docname)
|
||||
self.check_downloads(client, srcfile, count)
|
||||
|
|
|
|||
|
|
@ -185,7 +185,8 @@ class TestShutdown:
|
|||
# run connection pressure, many small transfers, not reusing connections,
|
||||
# limited total
|
||||
@pytest.mark.parametrize("proto", ['http/1.1'])
|
||||
def test_19_07_shutdown_by_curl(self, env: Env, httpd, proto):
|
||||
@pytest.mark.parametrize("share_connect", [False, True])
|
||||
def test_19_07_shutdown_by_curl(self, env: Env, httpd, proto, share_connect):
|
||||
if not env.curl_is_debug():
|
||||
pytest.skip('only works for curl debug builds')
|
||||
count = 500
|
||||
|
|
@ -197,15 +198,14 @@ class TestShutdown:
|
|||
})
|
||||
if not client.exists():
|
||||
pytest.skip(f'example client not built: {client.name}')
|
||||
extra_args = ['-S'] if share_connect else [] # share connections
|
||||
r = client.run(args=[
|
||||
'-n', f'{count}', # that many transfers
|
||||
'-C', env.ca.cert_file,
|
||||
'-f', # forbid conn reuse
|
||||
'-m', '10', # max parallel
|
||||
'-T', '5', # max total conns at a time
|
||||
'-V', proto,
|
||||
url
|
||||
])
|
||||
] + extra_args + ['-V', proto, url])
|
||||
r.check_exit_code(0)
|
||||
shutdowns = [line for line in r.trace_lines
|
||||
if re.match(r'.*SHUTDOWN] shutdown, done=1', line)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue