diff options
author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-06-04 22:32:12 -0400 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-06-19 16:28:06 -0400 |
commit | d9c1fabbed87b29d96f0afb05bdc4a1d61c2ced4 (patch) | |
tree | cdb3f6371dde97efaaf10fe5c43e729c0063b7aa /src/main.cpp | |
parent | ce4fbe111da9375e9614e018547e90092df6ec4b (diff) | |
download | phosphor-dbus-monitor-d9c1fabbed87b29d96f0afb05bdc4a1d61c2ced4.tar.gz phosphor-dbus-monitor-d9c1fabbed87b29d96f0afb05bdc4a1d61c2ced4.zip |
Attach sdevent mainloop to dbus
Switch from sd_bus process to sd_event run so that sd event
handlers are invoked.
Change-Id: If7c1f046f30cc845c6e9fcc72eb99c5bdfb36052
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/src/main.cpp b/src/main.cpp index 00d7200..79c4062 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -13,27 +13,37 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include <sdbusplus/bus.hpp> +#include "sdbusplus.hpp" #include "generated.hpp" #include "monitor.hpp" -int main(void) -{ - auto bus = sdbusplus::bus::new_default(); +using namespace phosphor::dbus::monitoring; - phosphor::dbus::monitoring::Monitor monitor(bus); +struct Loop +{ + /** @brief indefinitely process dbus traffic. */ + static void run() + { + auto& bus = SDBusPlus::getBus(); + auto& event = SDEvent::getEvent(); + event.attach(bus); + event.loop(); + } +}; - for (auto& watch : phosphor::dbus::monitoring::ConfigPropertyWatches::get()) +int main(void) +{ + for (auto& watch : ConfigPropertyWatches::get()) { watch->start(); } - // Keep application running - while (true) + for (auto& watch : ConfigPropertyWatches::get()) { - bus.process_discard(); - bus.wait(); + watch->callback(); } + Loop::run(); + return -1; } |