summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2023-11-24 12:20:33 +0100
committerMichael Stahl <michael.stahl@allotropia.de>2023-11-27 10:15:33 +0100
commit58594eaa9f4df52f919cf5b9c43959bcb9c2c452 (patch)
tree96622a49b1f847a13418ad1a8c9aee1d991e0dd4 /sd
parent60969b81dd710f26e50f3428f5544ae368010d79 (diff)
sd: remote: release Transmitter mutex when sending
The Bluetooth communication appears to be astonishingly slow on my system; the socket is deliberately cleared of O_NONBLOCK and what's even worse is that the Mutex that is held while sending prevents the main thread from adding new messages to the queues. It looks like there should be no issue with releasing the Mutex while sending, and if a separate Transmitter thread is used in the first place it makes no sense to hold the Mutex while doing so. Change-Id: Ic993e6c7a7799832c86fd4dd8c6ddad9dab1780b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159924 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'sd')
-rw-r--r--sd/source/ui/remotecontrol/Transmitter.cxx49
1 files changed, 31 insertions, 18 deletions
diff --git a/sd/source/ui/remotecontrol/Transmitter.cxx b/sd/source/ui/remotecontrol/Transmitter.cxx
index cca6a3bee460..7992e5b94bd6 100644
--- a/sd/source/ui/remotecontrol/Transmitter.cxx
+++ b/sd/source/ui/remotecontrol/Transmitter.cxx
@@ -27,29 +27,42 @@ void SAL_CALL Transmitter::run()
{
mProcessingRequired.wait();
- ::osl::MutexGuard aGuard( mMutex );
+ OString aMessage;
+ bool isHighPrio = {};
- if ( mFinishRequested ) {
- return;
- }
- if ( !mHighPriority.empty() )
- {
- OString aMessage( mHighPriority.front() );
- mHighPriority.pop();
- SAL_INFO( "sdremote.bluetooth", "write high prio line '" << aMessage << "'" );
- pStreamSocket->write( aMessage.getStr(), aMessage.getLength() );
- }
- else if ( !mLowPriority.empty() )
{
- OString aMessage( mLowPriority.front() );
- mLowPriority.pop();
- SAL_INFO( "sdremote.bluetooth", "write normal line '" << aMessage << "'" );
- pStreamSocket->write( aMessage.getStr(), aMessage.getLength() );
+ ::osl::MutexGuard aGuard(mMutex);
+
+ if (mFinishRequested) {
+ return;
+ }
+ if (!mHighPriority.empty())
+ {
+ aMessage = mHighPriority.front();
+ mHighPriority.pop();
+ isHighPrio = true;
+ }
+ else if (!mLowPriority.empty())
+ {
+ aMessage = mLowPriority.front();
+ mLowPriority.pop();
+ isHighPrio = false;
+ }
}
- if ( mLowPriority.empty() && mHighPriority.empty())
+ SAL_INFO("sdremote.bluetooth", "write " << (isHighPrio ? "high prio" : "normal") << " line '" << aMessage << "'");
+ // pStreamSocket is owned by Communicator, which joins this thread
+ // before destroying pStreamSocket so it can't die here.
+ // Sending is SLOW and blocks!
+ pStreamSocket->write( aMessage.getStr(), aMessage.getLength() );
+
{
- mProcessingRequired.reset();
+ ::osl::MutexGuard aGuard(mMutex);
+
+ if (mLowPriority.empty() && mHighPriority.empty())
+ {
+ mProcessingRequired.reset();
+ }
}
}
}