ipmid taking too many dbus connections
diff --git a/ipmid.C b/ipmid.C
index 0c7be7b..6b1eacc 100644
--- a/ipmid.C
+++ b/ipmid.C
@@ -15,6 +15,7 @@
sd_bus *bus = NULL;
+
FILE *ipmiio, *ipmidbus, *ipmicmddetails;
void print_usage(void) {
@@ -367,6 +368,10 @@
return;
}
+sd_bus *ipmid_get_sd_bus_connection(void) {
+ return bus;
+}
+
int main(int argc, char *argv[])
{
sd_bus_slot *slot = NULL;
@@ -402,9 +407,6 @@
}
- // Register all the handlers that provider implementation to IPMI commands.
- ipmi_register_callback_handlers(HOST_IPMI_LIB_PATH);
-
/* Connect to system bus */
r = sd_bus_open_system(&bus);
if (r < 0) {
@@ -413,6 +415,9 @@
goto finish;
}
+ // Register all the handlers that provider implementation to IPMI commands.
+ ipmi_register_callback_handlers(HOST_IPMI_LIB_PATH);
+
r = sd_bus_add_match(bus, &slot, FILTER, handle_ipmi_command, NULL);
if (r < 0) {
fprintf(stderr, "Failed: sd_bus_add_match: %s : %s\n", strerror(-r), FILTER);