diff options
author | Michael Stahl <mstahl@redhat.com> | 2018-02-23 13:19:01 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2018-02-26 13:44:00 +0100 |
commit | 0efd06de8fca4036c4132b2745a11273b1755df2 (patch) | |
tree | a3c6094ed42b59aecc700e3b44f8e0867fcdb489 /vcl/ios | |
parent | 238c6a45e02c8a0a3f462ab493c5d58b3d8f075f (diff) |
vcl: fix hangs in SvpSalInstance
Since commit cb8bfa9a32799bcde4e960fa56e388d5f7b2a928 the main thread
will read from the timer pipe until it is empty. But evidently this
introduces the problem that the poll() in another thread will not
return, as the file descriptor will no longer be readable; see
https://paste.debian.net/1011306/ for a reproducer of that rather
under-documented poll behaviour. So other threads can get stuck
forever in poll, and then the main thread can block in poll too with
no other thread to wake it up. This is the problem that plagues
UITest_writerperfect_epubexport.
The timer pipe is difficult to fix, since the main thread can block on
either the poll or the subsequent AcquireYieldMutex().
So replace the timer pipe with a condition etc. that is mostly
copied from the OSX AquaSalInstance/SalYieldMutex implementation.
The main thread now does something different than the other threads,
and blocks on a condition_variable with a timeout, while other
threads still block on acquiring the mutex.
Non-main threads can poke the main thread to do a DoYield()
on their behalf, and then get the result back with a blocking
read from a pipe, all while holding the YieldMutex. This
requires some fudging of the YieldMutex so that the main
thread can borrow the ownership temporarily.
Unfortunately SvpSalInstance, in addition to being directly
instantiable for --headless, has a whole bunch of subclasses:
* HeadlessSalInstance
* AndroidSalInstance
* IosSalInstance
* GtkInstance (in the gtk3 case)
* KDE5SalInstance
Of these GtkInstance overrides everything related to the
DoYield/SalYieldMutex implementation, but the others will be
affected by the change.
This commit will probably break IOS due to me not understanding the
point of the undocumented random #ifdef IOS in svpinst.cxx.
Change-Id: I1bbb143952dda89579e97ac32cd147e5b987573c
Reviewed-on: https://gerrit.libreoffice.org/50237
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'vcl/ios')
-rw-r--r-- | vcl/ios/iosinst.cxx | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/vcl/ios/iosinst.cxx b/vcl/ios/iosinst.cxx index 7fed7a485cd2..749541bf964a 100644 --- a/vcl/ios/iosinst.cxx +++ b/vcl/ios/iosinst.cxx @@ -170,7 +170,7 @@ SalData::~SalData() // This is our main entry point: SalInstance *CreateSalInstance() { - IosSalInstance* pInstance = new IosSalInstance( new SalYieldMutex() ); + IosSalInstance* pInstance = new IosSalInstance( new SvpSalYieldMutex() ); new IosSalData( pInstance ); pInstance->AcquireYieldMutex(); return pInstance; |