summaryrefslogtreecommitdiff
path: root/binaryurp
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-02-07 14:28:07 +0100
committerAndras Timar <andras.timar@collabora.com>2014-02-12 11:58:37 +0100
commit5ff44a89b59a6bdfe4cd471456b623eac91afcff (patch)
tree5df5d216eab40d48964d1910a89339f965734661 /binaryurp
parent877db2f59eef960ce92b5f3874798b5570165c9a (diff)
fdo#56511 Don't unduly delay Bridge termination
When terminate is called from the Reader or Writer thread, the final terminate was delayed until disposal of the BridgeFactory, as an unfortunate consequence of always trying to join on the Reader and Writer. Instead, forgo the join in such a case and rely on the underlying osl::Thread becoming detached after calling termiante. Change-Id: Ifba788c4d0d2e9b14b4f7f6b5f0f1380b712ce36 (cherry picked from commit f6245d5bcb18dff2721d5975cd84711559cefe65) Reviewed-on: https://gerrit.libreoffice.org/7926 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'binaryurp')
-rw-r--r--binaryurp/source/bridge.cxx16
-rw-r--r--binaryurp/source/reader.cxx1
-rw-r--r--binaryurp/source/writer.cxx1
3 files changed, 14 insertions, 4 deletions
diff --git a/binaryurp/source/bridge.cxx b/binaryurp/source/bridge.cxx
index 31fc3421d3e5..f27f37702adb 100644
--- a/binaryurp/source/bridge.cxx
+++ b/binaryurp/source/bridge.cxx
@@ -255,10 +255,18 @@ void Bridge::terminate(bool final) {
osl::MutexGuard g2(mutex_);
tp = threadPool_;
threadPool_ = 0;
- assert(!(reader_.is() && isThread(reader_.get())));
- std::swap(reader_, r);
- assert(!(writer_.is() && isThread(writer_.get())));
- std::swap(writer_, w);
+ if (reader_.is()) {
+ if (!isThread(reader_.get())) {
+ r = reader_;
+ }
+ reader_.clear();
+ }
+ if (writer_.is()) {
+ if (!isThread(writer_.get())) {
+ w = writer_;
+ }
+ writer_.clear();
+ }
state_ = STATE_FINAL;
}
assert(!(r.is() && w.is()));
diff --git a/binaryurp/source/reader.cxx b/binaryurp/source/reader.cxx
index 184f037721b9..331e4b333465 100644
--- a/binaryurp/source/reader.cxx
+++ b/binaryurp/source/reader.cxx
@@ -128,6 +128,7 @@ void Reader::execute() {
SAL_WARN("binaryurp", "caught C++ exception '" << e.what() << '\'');
}
bridge_->terminate(false);
+ bridge_.clear();
}
void Reader::readMessage(Unmarshal & unmarshal) {
diff --git a/binaryurp/source/writer.cxx b/binaryurp/source/writer.cxx
index 3d5c199befa0..edcb0f5090ce 100644
--- a/binaryurp/source/writer.cxx
+++ b/binaryurp/source/writer.cxx
@@ -177,6 +177,7 @@ void Writer::execute() {
OSL_TRACE(OSL_LOG_PREFIX "caught C++ exception '%s'", e.what());
}
bridge_->terminate(false);
+ bridge_.clear();
}
void Writer::sendRequest(