Index: src/modules/perl/modperl_filter.c
===================================================================
--- src/modules/perl/modperl_filter.c	(revision 1104242)
+++ src/modules/perl/modperl_filter.c	(working copy)
@@ -472,24 +472,6 @@
     return status;
 }
 
-
-#define MP_RUN_CROAK_RESET_OK(func)                                     \
-    {                                                                   \
-        apr_status_t rc = func(filter);                                 \
-        if (rc != APR_SUCCESS) {                                        \
-            if (APR_STATUS_IS_ECONNRESET(rc) ||                         \
-                APR_STATUS_IS_ECONNABORTED(rc)) {                       \
-                ap_log_error(APLOG_MARK, APLOG_INFO, 0, s,              \
-                             "Apache2::Filter internal flush got: %s",  \
-                             modperl_error_strerror(aTHX_ rc));         \
-            }                                                           \
-            else {                                                      \
-                modperl_croak(aTHX_ rc,                                 \
-                              "Apache2::Filter internal flush");        \
-            }                                                           \
-        }                                                               \
-    }
-
 int modperl_run_filter(modperl_filter_t *filter)
 {
     AV *args = Nullav;
@@ -563,10 +545,12 @@
             apr_brigade_destroy(filter->bb_in);
             filter->bb_in = NULL;
         }
-        MP_RUN_CROAK_RESET_OK(modperl_input_filter_flush);
+        MP_RUN_CROAK_RESET_OK(s, modperl_input_filter_flush(filter),
+                              "Apache2::Filter internal flush");
     }
     else {
-        MP_RUN_CROAK_RESET_OK(modperl_output_filter_flush);
+        MP_RUN_CROAK_RESET_OK(s, modperl_output_filter_flush(filter),
+                              "Apache2::Filter internal flush");
     }
 
     MP_FILTER_RESTORE_ERRSV(errsv);
Index: src/modules/perl/modperl_error.h
===================================================================
--- src/modules/perl/modperl_error.h	(revision 1104242)
+++ src/modules/perl/modperl_error.h	(working copy)
@@ -45,4 +45,20 @@
         }                                                    \
     } STMT_END
 
+#define MP_RUN_CROAK_RESET_OK(s, rc_run, func) STMT_START               \
+    {                                                                   \
+        apr_status_t rc = rc_run;                                       \
+        if (rc != APR_SUCCESS) {                                        \
+            if (APR_STATUS_IS_ECONNRESET(rc) ||                         \
+                APR_STATUS_IS_ECONNABORTED(rc)) {                       \
+                ap_log_error(APLOG_MARK, APLOG_INFO, 0, s,              \
+                             "%s got: %s", func,                        \
+                             modperl_error_strerror(aTHX_ rc));         \
+            }                                                           \
+            else {                                                      \
+                modperl_croak(aTHX_ rc, func);                          \
+            }                                                           \
+        }                                                               \
+    } STMT_END
+
 #endif /* MODPERL_ERROR_H */
Index: src/modules/perl/modperl_io_apache.c
===================================================================
--- src/modules/perl/modperl_io_apache.c	(revision 1104242)
+++ src/modules/perl/modperl_io_apache.c	(working copy)
@@ -169,8 +169,9 @@
                                   rcfg->wbucket->outbuf,
                                   rcfg->wbucket->outcnt));
 
-    MP_RUN_CROAK(modperl_wbucket_flush(rcfg->wbucket, FALSE),
-                 ":Apache2 IO flush");
+    MP_RUN_CROAK_RESET_OK(st->r->server,
+                          modperl_wbucket_flush(rcfg->wbucket, FALSE),
+                          ":Apache2 IO flush");
 
     return 0;
 }
Index: xs/Apache2/RequestIO/Apache2__RequestIO.h
===================================================================
--- xs/Apache2/RequestIO/Apache2__RequestIO.h	(revision 1104242)
+++ xs/Apache2/RequestIO/Apache2__RequestIO.h	(working copy)
@@ -179,8 +179,9 @@
                rcfg->wbucket->outcnt,
                apr_pstrmemdup(rcfg->wbucket->pool, rcfg->wbucket->outbuf,
                               rcfg->wbucket->outcnt));
-    MP_RUN_CROAK(modperl_wbucket_flush(rcfg->wbucket, TRUE),
-                 "Apache2::RequestIO::rflush");
+    MP_RUN_CROAK_RESET_OK(r->server,
+                          modperl_wbucket_flush(rcfg->wbucket, TRUE),
+                          "Apache2::RequestIO::rflush");
 }
 
 static MP_INLINE long mpxs_ap_get_client_block(pTHX_ request_rec *r,
