diff options
| author | Adriana Kobylak <anoo@us.ibm.com> | 2017-01-21 13:52:17 -0600 |
|---|---|---|
| committer | Patrick Williams <patrick@stwcx.xyz> | 2017-02-01 23:08:11 +0000 |
| commit | 291f32642a65585dcb672db2f790ce37625f7006 (patch) | |
| tree | 43429749ff0f9ca41cf7929ae6a9523832c9919e /tools | |
| parent | 1afb4e60b8f4754d202af4f16822cea1c5c22eb3 (diff) | |
| download | sdbusplus-291f32642a65585dcb672db2f790ce37625f7006.tar.gz sdbusplus-291f32642a65585dcb672db2f790ce37625f7006.zip | |
Initialize transaction id
Initialize the transaction id in the code generated by the sdbusplus tool.
Generate a unique value if the transaction id has not been
initialized and a caller requests it. This is the scenario for
clients that have not made a dbus call yet and create journal
entries.
Change-Id: Ia7b926fd3f83963fac01fbd1ce4cdd59d2224008
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/sdbusplus/templates/interface.mako.server.cpp | 16 | ||||
| -rw-r--r-- | tools/sdbusplus/templates/method.mako.prototype.hpp | 8 |
2 files changed, 24 insertions, 0 deletions
diff --git a/tools/sdbusplus/templates/interface.mako.server.cpp b/tools/sdbusplus/templates/interface.mako.server.cpp index 89fa2a9..aec8cfb 100644 --- a/tools/sdbusplus/templates/interface.mako.server.cpp +++ b/tools/sdbusplus/templates/interface.mako.server.cpp @@ -52,6 +52,14 @@ int ${classname}::_callback_get_${p.name}( try { auto m = message::message(reply); +#ifndef DISABLE_TRANSACTION + { + auto tbus = m.get_bus(); + sdbusplus::server::transaction::Transaction t(tbus, m); + sdbusplus::server::transaction::set_id + (std::hash<sdbusplus::server::transaction::Transaction>{}(t)); + } +#endif auto o = static_cast<${classname}*>(context); m.append(convertForMessage(o->${p.camelCase}())); @@ -85,6 +93,14 @@ int ${classname}::_callback_set_${p.name}( try { auto m = message::message(value); +#ifndef DISABLE_TRANSACTION + { + auto tbus = m.get_bus(); + sdbusplus::server::transaction::Transaction t(tbus, m); + sdbusplus::server::transaction::set_id + (std::hash<sdbusplus::server::transaction::Transaction>{}(t)); + } +#endif auto o = static_cast<${classname}*>(context); diff --git a/tools/sdbusplus/templates/method.mako.prototype.hpp b/tools/sdbusplus/templates/method.mako.prototype.hpp index b58a2e3..0c4615e 100644 --- a/tools/sdbusplus/templates/method.mako.prototype.hpp +++ b/tools/sdbusplus/templates/method.mako.prototype.hpp @@ -128,6 +128,14 @@ int ${interface_name()}::_callback_${ method.CamelCase }( ### Need to add a ref to msg since we attached it to an ### sdbusplus::message. auto m = message::message(msg); +#ifndef DISABLE_TRANSACTION + { + auto tbus = m.get_bus(); + sdbusplus::server::transaction::Transaction t(tbus, m); + sdbusplus::server::transaction::set_id + (std::hash<sdbusplus::server::transaction::Transaction>{}(t)); + } +#endif % if len(method.parameters) != 0: ${parameters_as_local(as_param=False)}{}; |

