85cb4d
--- a/modules/generators/cgi_common.h	2020/09/04 13:16:53	1881458
85cb4d
+++ b/modules/generators/cgi_common.h	2020/09/04 13:56:25	1881459
85cb4d
@@ -259,6 +259,13 @@
85cb4d
         if ((ret = ap_scan_script_header_err_brigade_ex(r, bb, sbuf,
85cb4d
                                                         APLOG_MODULE_INDEX)))
85cb4d
         {
85cb4d
+            /* In the case of a timeout reading script output, clear
85cb4d
+             * the brigade to avoid a second attempt to read the
85cb4d
+             * output. */
85cb4d
+            if (ret == HTTP_GATEWAY_TIME_OUT) {
85cb4d
+                apr_brigade_cleanup(bb);
85cb4d
+            }
85cb4d
+
85cb4d
             ret = log_script(r, conf, ret, logdata, sbuf, bb, script_err);
85cb4d
 
85cb4d
             /*