From c961f2bb3d1f4dff49f2f3d2f7ac477843997471 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 24 Sep 2019 13:48:08 -0400 Subject: [PATCH] LP#1845050: fix issue where reports interface was partially loaded This patch adjusts mod_xmlent to not free its XML parser prematurely in the face of an EOS bucket received while processing a sub-request. To test ------- [1] Test on a platform that has Apache 2.4.25 or later, such as Debian Stretch. [2] Note that when loading the reports interface that the source of the frame containing oils_rpt.xhtml is incomplete and that actions like creating a template or folder do not work in the interface. [3] Apply the patch and repeat step 2. This time, oils_rpt.xhtml should be fully loaded and the interface fuctional. Signed-off-by: Galen Charlton Signed-off-by: Jason Boyer --- Open-ILS/src/apachemods/mod_xmlent.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/apachemods/mod_xmlent.c b/Open-ILS/src/apachemods/mod_xmlent.c index d1a88ad6d9..1a57e8277d 100644 --- a/Open-ILS/src/apachemods/mod_xmlent.c +++ b/Open-ILS/src/apachemods/mod_xmlent.c @@ -323,6 +323,8 @@ static int xmlEntHandler( ap_filter_t *f, apr_bucket_brigade *brigade ) { if( parser == NULL ) { firstrun = 1; parser = XML_ParserCreate("UTF-8"); + ap_log_rerror( APLOG_MARK, APLOG_DEBUG, 0, f->r, + "XMLENT: created XML parser"); XML_SetUserData(parser, f); XML_SetElementHandler(parser, startElement, endElement); XML_SetCharacterDataHandler(parser, charHandler); @@ -364,8 +366,16 @@ static int xmlEntHandler( ap_filter_t *f, apr_bucket_brigade *brigade ) { APR_BUCKET_REMOVE(currentBucket); APR_BRIGADE_INSERT_TAIL(ctx->brigade, currentBucket); ap_pass_brigade(f->next, ctx->brigade); - XML_ParserFree(parser); - parser = NULL; + if (f->r->main == NULL) { + // free the XML parser only if we've seen the end + // for the main request; we'll keep it around if + // the EOS was for a sub-request, as we may get + // more to process. + XML_ParserFree(parser); + parser = NULL; + ap_log_rerror( APLOG_MARK, APLOG_DEBUG, 0, f->r, + "XMLENT: freed XML parser"); + } return APR_SUCCESS; } -- 2.43.2