Kaydet (Commit) 5e161e9e authored tarafından Stephan Bergmann's avatar Stephan Bergmann Kaydeden (comit) Caolán McNamara

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 f6245d5b)
Reviewed-on: https://gerrit.libreoffice.org/7919Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst be3bba0e
......@@ -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()));
......
......@@ -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) {
......
......@@ -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(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment