diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2018-09-11 22:28:08 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2018-09-17 13:47:43 +0200 |
commit | d06a8ce1434c1dcb45770e08395443771f57f1e9 (patch) | |
tree | 0e85c300585cbca77a67eccca8db80d288854df4 | |
parent | cce35f341ac5db00d2c45a09e462f9bb65c949ca (diff) |
Ensure fastparser thread is joined in case of exceptions.
Change-Id: Ie0fb21776514a9a67e9fdff2ae856392cd711adb
Reviewed-on: https://gerrit.libreoffice.org/60542
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r-- | sax/source/fastparser/fastparser.cxx | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx index a0b568c46e38..1c3ee79607af 100644 --- a/sax/source/fastparser/fastparser.cxx +++ b/sax/source/fastparser/fastparser.cxx @@ -754,6 +754,7 @@ namespace private: FastSaxParserImpl& m_rParser; Entity& m_rEntity; + rtl::Reference<ParserThread> m_xParser; public: ParserCleanup(FastSaxParserImpl& rParser, Entity& rEntity) : m_rParser(rParser) @@ -765,6 +766,20 @@ namespace //xmlFreeParserCtxt accepts a null arg 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(); + } } }; } @@ -810,6 +825,7 @@ void FastSaxParserImpl::parseStream(const InputSource& maStructSource) { rtl::Reference<ParserThread> xParser; xParser = new ParserThread(this); + aEnsureFree.setThread(xParser); xParser->launch(); bool done = false; do { @@ -851,7 +867,7 @@ void FastSaxParserImpl::parseStream(const InputSource& maStructSource) rEntity.maUsedEvents.push(std::move(xEventList)); } } while (!done); - xParser->join(); + aEnsureFree.joinThread(); deleteUsedEvents(); // callbacks used inside XML_Parse may have caught an exception |