summaryrefslogtreecommitdiff
path: root/sax
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2018-09-11 22:28:08 +0100
committerMichael Meeks <michael.meeks@collabora.com>2018-09-12 09:56:22 +0200
commitefa2681db1fb66e5f3677adff3a5e91ccba6b9ec (patch)
treed6a029087040ad5d6c215bdd41cfcbc4217760d1 /sax
parentec06ffdfd54b1f6997f905f9252cecabde3a1c5a (diff)
Ensure fastparser thread is joined in case of exceptions.
Change-Id: Ie0fb21776514a9a67e9fdff2ae856392cd711adb Reviewed-on: https://gerrit.libreoffice.org/60361 Tested-by: Jenkins Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'sax')
-rw-r--r--sax/source/fastparser/fastparser.cxx18
1 files changed, 17 insertions, 1 deletions
diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx
index a2b1e38b79fb..2c730685f526 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -744,6 +744,7 @@ namespace
private:
FastSaxParserImpl& m_rParser;
Entity& m_rEntity;
+ rtl::Reference<ParserThread> m_xParser;
public:
ParserCleanup(FastSaxParserImpl& rParser, Entity& rEntity)
: m_rParser(rParser)
@@ -759,6 +760,20 @@ namespace
xmlFreeParserCtxt(m_rEntity.mpParser);
}
m_rParser.popEntity();
+ joinThread();
+ }
+ void setThread(const rtl::Reference<ParserThread> &xParser)
+ {
+ m_xParser = xParser;
+ }
+ void joinThread()
+ {
+ if (m_xParser.is())
+ {
+ rtl::Reference<ParserThread> xToJoin = m_xParser;
+ m_xParser.clear();
+ xToJoin->join();
+ }
}
};
}
@@ -799,6 +814,7 @@ void FastSaxParserImpl::parseStream(const InputSource& rStructSource)
{
rtl::Reference<ParserThread> xParser;
xParser = new ParserThread(this);
+ aEnsureFree.setThread(xParser);
xParser->launch();
bool done = false;
do {
@@ -840,7 +856,7 @@ void FastSaxParserImpl::parseStream(const InputSource& rStructSource)
rEntity.maUsedEvents.push(std::move(xEventList));
}
} while (!done);
- xParser->join();
+ aEnsureFree.joinThread();
deleteUsedEvents();
// callbacks used inside XML_Parse may have caught an exception