You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ji...@apache.org on 2025/01/07 15:06:41 UTC
svn commit: r1922960 - in /httpd/httpd/branches/2.4.x: ./ STATUS modules/http2/h2_session.c modules/http2/h2_stream.c test/modules/http2/test_200_header_invalid.py
Author: jim
Date: Tue Jan 7 15:06:41 2025
New Revision: 1922960
URL: http://svn.apache.org/viewvc?rev=1922960&view=rev
Log:
*) mod_http2: Fix failed request counting and keepalive timeout
Modified:
httpd/httpd/branches/2.4.x/ (props changed)
httpd/httpd/branches/2.4.x/STATUS
httpd/httpd/branches/2.4.x/modules/http2/h2_session.c
httpd/httpd/branches/2.4.x/modules/http2/h2_stream.c
httpd/httpd/branches/2.4.x/test/modules/http2/test_200_header_invalid.py
Propchange: httpd/httpd/branches/2.4.x/
------------------------------------------------------------------------------
Merged /httpd/httpd/trunk:r1921805
Modified: httpd/httpd/branches/2.4.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/STATUS?rev=1922960&r1=1922959&r2=1922960&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/STATUS (original)
+++ httpd/httpd/branches/2.4.x/STATUS Tue Jan 7 15:06:41 2025
@@ -157,18 +157,6 @@ RELEASE SHOWSTOPPERS:
PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
[ start all new proposals below, under PATCHES PROPOSED. ]
- *) mod_proxy_fcgi: Fix proxy-fcgi-pathinfo=full
- trunk patch: https://svn.apache.org/r1919547
- https://svn.apache.org/r1921238
- 2.4.x patch: https://patch-diff.githubusercontent.com/raw/apache/httpd/pull/489.diff
- PR: https://github.com/apache/httpd/pull/489
- +1: ylavic, covener, jim
-
- *) mod_http2: Fix failed request counting and keepalive timeout
- trunk patch: https://svn.apache.org/r1921805
- 2.4.x patch: svn merge -c r1921805 ^/httpd/httpd/trunk .
- +1: icing
-
*) mod_log_config: Fix LogFormat directive merging
trunk patch: https://svn.apache.org/r1921305
https://svn.apache.org/r1921306
Modified: httpd/httpd/branches/2.4.x/modules/http2/h2_session.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/http2/h2_session.c?rev=1922960&r1=1922959&r2=1922960&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/http2/h2_session.c (original)
+++ httpd/httpd/branches/2.4.x/modules/http2/h2_session.c Tue Jan 7 15:06:41 2025
@@ -326,6 +326,10 @@ static int on_header_cb(nghttp2_session
* with an informative HTTP error response like 413. But of the
* client is too wrong, we RESET the stream */
stream->request_headers_failed > 100)) {
+ ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, session->c1,
+ H2_SSSN_STRM_MSG(session, frame->hd.stream_id,
+ "RST stream, header failures: %d"),
+ (int)stream->request_headers_failed);
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
}
return 0;
@@ -1498,7 +1502,8 @@ static void h2_session_ev_conn_error(h2_
default:
ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c1,
H2_SSSN_LOG(APLOGNO(03401), session,
- "conn error -> shutdown"));
+ "conn error -> shutdown, remote.emitted=%d"),
+ (int)session->remote.emitted_count);
h2_session_shutdown(session, arg, msg, 0);
break;
}
@@ -1591,9 +1596,7 @@ static void ev_stream_created(h2_session
static void ev_stream_open(h2_session *session, h2_stream *stream)
{
if (H2_STREAM_CLIENT_INITIATED(stream->id)) {
- ++session->remote.emitted_count;
- if (stream->id > session->remote.emitted_max) {
- session->remote.emitted_max = stream->id;
+ if (stream->id > session->remote.accepted_max) {
session->local.accepted_max = stream->id;
}
}
@@ -1890,7 +1893,8 @@ apr_status_t h2_session_process(h2_sessi
/* Not an async mpm, we must continue waiting
* for client data to arrive until the configured
* server Timeout/KeepAliveTimeout happens */
- apr_time_t timeout = (session->open_streams == 0)?
+ apr_time_t timeout = ((session->open_streams == 0) &&
+ session->remote.emitted_count)?
session->s->keep_alive_timeout :
session->s->timeout;
ap_log_cerror(APLOG_MARK, APLOG_TRACE2, status, c,
Modified: httpd/httpd/branches/2.4.x/modules/http2/h2_stream.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/http2/h2_stream.c?rev=1922960&r1=1922959&r2=1922960&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/http2/h2_stream.c (original)
+++ httpd/httpd/branches/2.4.x/modules/http2/h2_stream.c Tue Jan 7 15:06:41 2025
@@ -761,6 +761,11 @@ apr_status_t h2_stream_add_header(h2_str
}
else if (H2_SS_IDLE == stream->state) {
if (!stream->rtmp) {
+ if (H2_STREAM_CLIENT_INITIATED(stream->id)) {
+ ++stream->session->remote.emitted_count;
+ if (stream->id > stream->session->remote.emitted_max)
+ session->remote.emitted_max = stream->id;
+ }
stream->rtmp = h2_request_create(stream->id, stream->pool,
NULL, NULL, NULL, NULL, NULL);
}
Modified: httpd/httpd/branches/2.4.x/test/modules/http2/test_200_header_invalid.py
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/test/modules/http2/test_200_header_invalid.py?rev=1922960&r1=1922959&r2=1922960&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/test/modules/http2/test_200_header_invalid.py (original)
+++ httpd/httpd/branches/2.4.x/test/modules/http2/test_200_header_invalid.py Tue Jan 7 15:06:41 2025
@@ -1,3 +1,4 @@
+import re
import pytest
from .env import H2Conf, H2TestEnv
@@ -227,3 +228,57 @@ class TestInvalidHeaders:
r = env.nghttp().get(url, options=opt)
assert r.exit_code == 0, r
assert r.response is None
+
+ # test few failed headers, should
+ def test_h2_200_17(self, env):
+ url = env.mkurl("https", "cgi", "/")
+
+ # test few failed headers, should give response
+ def test_h2_200_17(self, env):
+ conf = H2Conf(env)
+ conf.add("""
+ LimitRequestFieldSize 20
+ LogLevel http2:debug
+ """)
+ conf.add_vhost_cgi()
+ conf.install()
+ assert env.apache_restart() == 0
+ re_emitted = re.compile(r'.* AH03401: .* shutdown, remote.emitted=1')
+ url = env.mkurl("https", "cgi", "/")
+ opt = []
+ for i in range(10):
+ opt += ["-H", f"x{i}: 012345678901234567890123456789"]
+ r = env.curl_get(url, options=opt)
+ assert r.response
+ assert r.response["status"] == 431
+ assert env.httpd_error_log.scan_recent(re_emitted)
+
+ # test too many failed headers, should give RST
+ def test_h2_200_18(self, env):
+ conf = H2Conf(env)
+ conf.add("""
+ LimitRequestFieldSize 20
+ LogLevel http2:debug
+ """)
+ conf.add_vhost_cgi()
+ conf.install()
+ assert env.apache_restart() == 0
+ re_emitted = re.compile(r'.* AH03401: .* shutdown, remote.emitted=1')
+ url = env.mkurl("https", "cgi", "/")
+ opt = []
+ for i in range(100):
+ opt += ["-H", f"x{i}: 012345678901234567890123456789"]
+ r = env.curl_get(url, options=opt)
+ assert r.response is None
+ assert env.httpd_error_log.scan_recent(re_emitted)
+
+ # test header 10 invalid headers, should trigger stream RST
+ def test_h2_200_19(self, env):
+ url = env.mkurl("https", "cgi", "/")
+ opt = []
+ invalid = '\x7f'
+ for i in range(10):
+ opt += ["-H", f"x{i}: {invalid}"]
+ r = env.curl_get(url, options=opt)
+ assert r.response is None
+
Re: svn commit: r1922960 - in /httpd/httpd/branches/2.4.x: ./ STATUS modules/http2/h2_session.c modules/http2/h2_stream.c test/modules/http2/test_200_header_invalid.py
Posted by Jim Jagielski <ji...@jagunet.com>.
> On Jan 7, 2025, at 11:13 AM, Ruediger Pluem <rp...@apache.org> wrote:
>
>> - *) mod_http2: Fix failed request counting and keepalive timeout
>> - trunk patch: https://svn.apache.org/r1921805
>> - 2.4.x patch: svn merge -c r1921805 ^/httpd/httpd/trunk .
>> - +1: icing
Thanks! Mistaken cut/paste
--
Jim
"I don't need a compass to tell me which way the wind shines."
Re: svn commit: r1922960 - in /httpd/httpd/branches/2.4.x: ./ STATUS modules/http2/h2_session.c modules/http2/h2_stream.c test/modules/http2/test_200_header_invalid.py
Posted by Ruediger Pluem <rp...@apache.org>.
On 1/7/25 4:06 PM, jim@apache.org wrote:
> Author: jim
> Date: Tue Jan 7 15:06:41 2025
> New Revision: 1922960
>
> URL: http://svn.apache.org/viewvc?rev=1922960&view=rev
> Log:
> *) mod_http2: Fix failed request counting and keepalive timeout
>
>
> Modified:
> httpd/httpd/branches/2.4.x/ (props changed)
> httpd/httpd/branches/2.4.x/STATUS
> httpd/httpd/branches/2.4.x/modules/http2/h2_session.c
> httpd/httpd/branches/2.4.x/modules/http2/h2_stream.c
> httpd/httpd/branches/2.4.x/test/modules/http2/test_200_header_invalid.py
>
> Propchange: httpd/httpd/branches/2.4.x/
> ------------------------------------------------------------------------------
> Merged /httpd/httpd/trunk:r1921805
>
> Modified: httpd/httpd/branches/2.4.x/STATUS
> URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/STATUS?rev=1922960&r1=1922959&r2=1922960&view=diff
> ==============================================================================
> --- httpd/httpd/branches/2.4.x/STATUS (original)
> +++ httpd/httpd/branches/2.4.x/STATUS Tue Jan 7 15:06:41 2025
> @@ -157,18 +157,6 @@ RELEASE SHOWSTOPPERS:
> PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
> [ start all new proposals below, under PATCHES PROPOSED. ]
>
> - *) mod_proxy_fcgi: Fix proxy-fcgi-pathinfo=full
> - trunk patch: https://svn.apache.org/r1919547
> - https://svn.apache.org/r1921238
> - 2.4.x patch: https://patch-diff.githubusercontent.com/raw/apache/httpd/pull/489.diff
> - PR: https://github.com/apache/httpd/pull/489
> - +1: ylavic, covener, jim
> -
> - *) mod_http2: Fix failed request counting and keepalive timeout
> - trunk patch: https://svn.apache.org/r1921805
> - 2.4.x patch: svn merge -c r1921805 ^/httpd/httpd/trunk .
> - +1: icing
> -
Sorry for being picky, but I see only one vote for this backport. I just took the time to review it and it has my +1 here
which requires just one more +1 from someone else here.
Regards
Rüdiger