control: Correct subscribing/handling of signals
When subscribing to signals, a pointer to the signal packages should be
used for the location to store the list of signal packages. This way the
callback is bound to the pointer and not the local variable that was
then getting moved.
Also, in handling signal messages, since there could be more than one
signal package to check against the signal received, a rewind must be
done to the signal message so that additional signal packages can read
the message contents again.
Change-Id: Iddea2011d25068d6f71bdee91801537cd5994728
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/json/manager.hpp b/control/json/manager.hpp
index 2b913fe..310132d 100644
--- a/control/json/manager.hpp
+++ b/control/json/manager.hpp
@@ -104,11 +104,12 @@
/**
* Data associated to a subscribed signal
* Tuple constructed of:
- * std::vector<SignalPkg> = List of the signal's packages
+ * std::unique_ptr<std::vector<SignalPkg>> =
+ * Pointer to list of the signal's packages
* std::unique_ptr<sdbusplus::server::match::match> =
* Pointer to match holding the subscription to a signal
*/
-using SignalData = std::tuple<std::vector<SignalPkg>,
+using SignalData = std::tuple<std::unique_ptr<std::vector<SignalPkg>>,
std::unique_ptr<sdbusplus::server::match::match>>;
/**
@@ -411,7 +412,7 @@
* @param[in] pkgs - Signal packages associated to the signal being handled
*/
void handleSignal(sdbusplus::message::message& msg,
- const std::vector<SignalPkg>& pkgs);
+ const std::vector<SignalPkg>* pkgs);
/**
* @brief Get the sdbusplus bus object