[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - sax/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Sep 14 12:53:45 UTC 2018


 sax/source/fastparser/fastparser.cxx |   18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

New commits:
commit 815ff47bbd82c06bb7436a89e6ecf11fd59b8d76
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Tue Sep 11 22:28:08 2018 +0100
Commit:     Miklos Vajna <vmiklos at collabora.co.uk>
CommitDate: Fri Sep 14 14:53:18 2018 +0200

    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 at collabora.com>
    (cherry picked from commit efa2681db1fb66e5f3677adff3a5e91ccba6b9ec)
    Reviewed-on: https://gerrit.libreoffice.org/60372
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx
index 2765584a08fc..5655d7137056 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -740,6 +740,7 @@ namespace
     private:
         FastSaxParserImpl& m_rParser;
         Entity& m_rEntity;
+        rtl::Reference<ParserThread> m_xParser;
     public:
         ParserCleanup(FastSaxParserImpl& rParser, Entity& rEntity)
             : m_rParser(rParser)
@@ -751,6 +752,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();
+            }
         }
     };
 }
@@ -786,6 +801,7 @@ void FastSaxParserImpl::parseStream(const InputSource& rStructSource)
     {
         rtl::Reference<ParserThread> xParser;
         xParser = new ParserThread(this);
+        aEnsureFree.setThread(xParser);
         xParser->launch();
         bool done = false;
         do {
@@ -827,7 +843,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


More information about the Libreoffice-commits mailing list