bus: fix method_return
method_return was using sd_bus_call instead of sd_bus_send.
Fix to use sd_bus_send and move into 'message' directly since
the previous arguments for having it a static method in bus is
no longer valid.
Change-Id: Ib74508e87f7e8be030db02b91368da7639cb28f3
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/sdbusplus/bus.hpp b/sdbusplus/bus.hpp
index 119ae52..eae7cd2 100644
--- a/sdbusplus/bus.hpp
+++ b/sdbusplus/bus.hpp
@@ -142,30 +142,6 @@
sd_bus_call(_bus.get(), m.get(), timeout_us, nullptr, nullptr);
}
- /** @brief Perform a 'method-return' response call.
- *
- * @param[in] m - The method-return type message to send.
- *
- * This is a static method on bus because:
- * 1. The typical caller of this is from within a method callback
- * on an sd-bus managed object, which does not have access to
- * its own bus.
- * 2. Due to header dependency, sdbusplus::message cannot create
- * an sdbusplus::bus itself.
- * 3. We do not want sdbusplus::message to call sd_bus_call directly,
- * in order to have common error handling code with bus::call.
- */
- static void method_return(message::message& m)
- {
- auto b = bus(sd_bus_message_get_bus(m.get()));
-
- // Need to increment the reference since 'b' will now decrement
- // on destruction.
- sd_bus_ref(b._bus.get());
-
- b.call_noreply(m);
- }
-
friend struct server::interface::interface;
friend struct server::manager::manager;
@@ -195,10 +171,6 @@
return bus(b);
}
-/** Alias sdbusplus::bus::bus::method_return for convenience. */
-inline void method_return(message::message& m) { return bus::method_return(m); }
-
-
} // namespace bus
} // namespace sdbusplus
diff --git a/sdbusplus/message.hpp b/sdbusplus/message.hpp
index a3a07ed..327fb7e 100644
--- a/sdbusplus/message.hpp
+++ b/sdbusplus/message.hpp
@@ -120,6 +120,13 @@
return message(reply);
}
+ /** @brief Perform a 'method-return' response call. */
+ void method_return()
+ {
+ auto b = sd_bus_message_get_bus(this->get());
+ sd_bus_send(b, this->get(), nullptr);
+ }
+
friend struct sdbusplus::bus::bus;
private:
diff --git a/tools/templates/method.mako.prototype.hpp b/tools/templates/method.mako.prototype.hpp
index 29d75c8..5e8f2ac 100644
--- a/tools/templates/method.mako.prototype.hpp
+++ b/tools/templates/method.mako.prototype.hpp
@@ -114,7 +114,7 @@
reply.append(${returns_as_tuple_index("r")});
% endif
- sdbusplus::bus::method_return(reply);
+ reply.method_return();
return 0;
}