From 808a94d0ccb3203702bdc86e2fc8961f68398fc7 Mon Sep 17 00:00:00 2001
From: Yann Ylavic <ylavic@apache.org>
Date: Tue, 29 May 2018 21:09:31 +0000
Subject: [PATCH] Merge r1828879 from trunk:

On the trunk:

mod_http2: always wake up any conditional waits when streams are aborted. Fixes race conditions where timeouts would trigger instead.

Submitted by: icing
Reviewed by: icing, jim, ylavic


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1832487 13f79535-47bb-0310-9956-ffa450edef68
---
 CHANGES                        |  3 +++
 modules/http2/h2_bucket_beam.c | 11 +++++------
 2 files changed, 8 insertions(+), 6 deletions(-)

# diff --git a/CHANGES b/CHANGES
# index 9468c3ded7..e63f78f40f 100644
# --- a/CHANGES
# +++ b/CHANGES
# @@ -1,6 +1,9 @@
#                                                           -*- coding: utf-8 -*-
#  Changes with Apache 2.4.34
#  
# +  *) mod_http2: Fix unnecessary timeout waits in case streams are aborted.
# +     [Stefan Eissing]
# +
#    *) mod_proxy: Do not restrict the maximum pool size for backend connections
#       any longer by the maximum number of threads per process and use a better
#       default if mod_http2 is loaded.
diff --git a/modules/http2/h2_bucket_beam.c b/modules/http2/h2_bucket_beam.c
index 6b6750d1fa..7653ec1092 100644
--- a/modules/http2/h2_bucket_beam.c
+++ b/modules/http2/h2_bucket_beam.c
@@ -550,6 +550,7 @@ static void recv_buffer_cleanup(h2_bucket_beam *beam, h2_beam_lock *bl)
         apr_brigade_destroy(bb);
         if (bl) enter_yellow(beam, bl);
         
+        apr_thread_cond_broadcast(beam->change);
         if (beam->cons_ev_cb) { 
             beam->cons_ev_cb(beam->cons_ctx, beam);
         }
@@ -707,12 +708,10 @@ void h2_beam_abort(h2_bucket_beam *beam)
     h2_beam_lock bl;
     
     if (beam && enter_yellow(beam, &bl) == APR_SUCCESS) {
-        if (!beam->aborted) {
-            beam->aborted = 1;
-            r_purge_sent(beam);
-            h2_blist_cleanup(&beam->send_list);
-            report_consumption(beam, &bl);
-        }
+        beam->aborted = 1;
+        r_purge_sent(beam);
+        h2_blist_cleanup(&beam->send_list);
+        report_consumption(beam, &bl);
         apr_thread_cond_broadcast(beam->change);
         leave_yellow(beam, &bl);
     }
-- 
2.17.1

