Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
cd8aeed1
Kaydet (Commit)
cd8aeed1
authored
Eyl 11, 2017
tarafından
Stephan Bergmann
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix data races during CppunitTest_filter_xslt
Change-Id: I140ac8a24326959ba341adddbbf505ff16616283
üst
2c7d421a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
20 deletions
+48
-20
xslt-test.cxx
filter/qa/cppunit/xslt-test.cxx
+28
-16
LibXSLTTransformer.cxx
filter/source/xsltfilter/LibXSLTTransformer.cxx
+17
-4
LibXSLTTransformer.hxx
filter/source/xsltfilter/LibXSLTTransformer.hxx
+3
-0
No files found.
filter/qa/cppunit/xslt-test.cxx
Dosyayı görüntüle @
cd8aeed1
...
...
@@ -7,7 +7,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <sal/config.h>
#include <condition_variable>
#include <limits>
#include <mutex>
#include <cppunit/TestAssert.h>
#include <cppunit/TestFixture.h>
...
...
@@ -19,7 +23,6 @@
#include <rtl/ref.hxx>
#include <osl/file.hxx>
#include <osl/thread.h>
#include <com/sun/star/beans/NamedValue.hpp>
#include <com/sun/star/io/XStreamListener.hpp>
...
...
@@ -51,22 +54,37 @@ public:
CPPUNIT_TEST_SUITE_END
();
};
struct
Listener
:
public
::
cppu
::
WeakImplHelper
<
io
::
XStreamListener
>
class
Listener
:
public
::
cppu
::
WeakImplHelper
<
io
::
XStreamListener
>
{
bool
m_bDone
;
public
:
Listener
()
:
m_bDone
(
false
)
{}
void
wait
()
{
std
::
unique_lock
<
std
::
mutex
>
g
(
m_mutex
);
m_cond
.
wait
(
g
,
[
this
]()
{
return
m_bDone
;
});
}
private
:
std
::
mutex
m_mutex
;
std
::
condition_variable
m_cond
;
bool
m_bDone
;
virtual
void
SAL_CALL
disposing
(
const
lang
::
EventObject
&
)
throw
()
override
{}
virtual
void
SAL_CALL
started
()
throw
()
override
{
m_bDone
=
false
;
}
virtual
void
SAL_CALL
closed
()
throw
()
override
{
m_bDone
=
true
;
}
virtual
void
SAL_CALL
terminated
()
throw
()
override
{
m_bDone
=
true
;
}
virtual
void
SAL_CALL
started
()
throw
()
override
{}
virtual
void
SAL_CALL
closed
()
throw
()
override
{
notifyDone
()
;
}
virtual
void
SAL_CALL
terminated
()
throw
()
override
{
notifyDone
()
;
}
virtual
void
SAL_CALL
error
(
const
uno
::
Any
&
e
)
override
{
m_bDone
=
true
;
// set on error too, otherwise main thread waits forever
notifyDone
()
;
// set on error too, otherwise main thread waits forever
SAL_WARN
(
"filter.xslt"
,
"exception "
<<
e
);
CPPUNIT_FAIL
(
"exception while in XSLT"
);
}
void
notifyDone
()
{
std
::
unique_lock
<
std
::
mutex
>
g
(
m_mutex
);
m_bDone
=
true
;
m_cond
.
notify_all
();
}
};
void
XsltFilterTest
::
testXsltCopyNew
()
...
...
@@ -109,10 +127,7 @@ void XsltFilterTest::testXsltCopyNew()
xXslt
->
start
();
TimeValue
delay
;
delay
.
Seconds
=
0
;
delay
.
Nanosec
=
1000000
;
while
(
!
xListener
->
m_bDone
)
{
osl_waitThread
(
&
delay
);
}
xListener
->
wait
();
xIn
->
closeInput
();
xOut
->
closeOutput
();
...
...
@@ -171,10 +186,7 @@ void XsltFilterTest::testXsltCopyOld()
xXslt
->
start
();
TimeValue
delay
;
delay
.
Seconds
=
0
;
delay
.
Nanosec
=
1000000
;
while
(
!
xListener
->
m_bDone
)
{
osl_waitThread
(
&
delay
);
}
xListener
->
wait
();
xIn
->
closeInput
();
xOut
->
closeOutput
();
...
...
filter/source/xsltfilter/LibXSLTTransformer.cxx
Dosyayı görüntüle @
cd8aeed1
...
...
@@ -298,7 +298,12 @@ namespace XSLT
std
::
unique_ptr
<
OleHandler
>
oh
(
new
OleHandler
(
m_transformer
->
getComponentContext
()));
if
(
styleSheet
)
{
m_tcontext
=
xsltNewTransformContext
(
styleSheet
,
doc
);
xsltTransformContextPtr
tcontext
=
xsltNewTransformContext
(
styleSheet
,
doc
);
{
std
::
unique_lock
<
std
::
mutex
>
g
(
m_mutex
);
m_tcontext
=
tcontext
;
}
oh
->
registercontext
(
m_tcontext
);
xsltQuoteUserParams
(
m_tcontext
,
&
params
[
0
]);
result
=
xsltApplyStylesheetUser
(
styleSheet
,
doc
,
nullptr
,
nullptr
,
nullptr
,
...
...
@@ -331,7 +336,10 @@ namespace XSLT
oh
.
reset
();
xsltFreeStylesheet
(
styleSheet
);
xsltFreeTransformContext
(
m_tcontext
);
m_tcontext
=
nullptr
;
{
std
::
unique_lock
<
std
::
mutex
>
g
(
m_mutex
);
m_tcontext
=
nullptr
;
}
xmlFreeDoc
(
doc
);
xmlFreeDoc
(
result
);
}
...
...
@@ -354,12 +362,17 @@ namespace XSLT
void
Reader
::
forceStateStopped
()
{
if
(
!
m_tcontext
)
xsltTransformContextPtr
tcontext
;
{
std
::
unique_lock
<
std
::
mutex
>
g
(
m_mutex
);
tcontext
=
m_tcontext
;
}
if
(
!
tcontext
)
return
;
//tdf#100057 If we force a cancel, libxslt will of course just keep on going unless something
//tells it to stop. Here we force the stopped state so that libxslt will stop processing
//and so Reader::execute will complete and we can join cleanly
m_
tcontext
->
state
=
XSLT_STATE_STOPPED
;
tcontext
->
state
=
XSLT_STATE_STOPPED
;
}
Reader
::~
Reader
()
...
...
filter/source/xsltfilter/LibXSLTTransformer.hxx
Dosyayı görüntüle @
cd8aeed1
...
...
@@ -12,6 +12,7 @@
#include <list>
#include <map>
#include <mutex>
#include <libxml/parser.h>
#include <libxml/tree.h>
...
...
@@ -71,6 +72,8 @@ namespace XSLT
LibXSLTTransformer
*
m_transformer
;
Sequence
<
sal_Int8
>
m_readBuf
;
Sequence
<
sal_Int8
>
m_writeBuf
;
std
::
mutex
m_mutex
;
xsltTransformContextPtr
m_tcontext
;
virtual
void
execute
()
override
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment