From dd463d3014ad3a8425191f0d5d50e8d966b0e5e5 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Thu, 30 Nov 2017 09:16:08 +0100 Subject: [PATCH] base: signal ref count independent of signal count --- repos/base/src/lib/base/signal_common.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/repos/base/src/lib/base/signal_common.cc b/repos/base/src/lib/base/signal_common.cc index 3e73427bf7..acd0002826 100644 --- a/repos/base/src/lib/base/signal_common.cc +++ b/repos/base/src/lib/base/signal_common.cc @@ -36,16 +36,17 @@ Signal::Signal(Signal const &other) Signal & Signal::operator=(Signal const &other) { - if ((_data.context == other._data.context) && - (_data.num == other._data.num)) - return *this; + bool const same_context = (_data.context == other._data.context); - _dec_ref_and_unlock(); + /* don't change ref cnt if it's the same context */ + if (!same_context) + _dec_ref_and_unlock(); _data.context = other._data.context; _data.num = other._data.num; - _inc_ref(); + if (!same_context) + _inc_ref(); return *this; }