From 90d147a1ee5340278506bbdf94edc32bb77154f2 Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Tue, 12 Jun 2018 16:42:33 -0700 Subject: elog_watch: Fix parsing of elog add requests Requests come in the form "oa{sa{sv}}". However, the way sdbusplus was interpreting the type of our message "a{oa{sa{sv}}}" since tuples are not allowed to consume multiple arguments during the read call as that would be ambiguous. This fixes the type issues. Prior to the change to sdbusplus that introduces error handling for the read calls, the sd_bus_message_{enter,exit}_container were failing during the read on the pair. Luckily this produces the expected result for the read and our old code was "working". This also cleans up an unnecessary string move. Tested: Builds and no longer produces errors on zaius when elogs are added. Change-Id: Ifc5394f3f361e8932c939376bd0bf5b4e3ca589c Signed-off-by: William A. Kennington III --- elog_watch.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/elog_watch.cpp b/elog_watch.cpp index e2a3866..6817f8b 100644 --- a/elog_watch.cpp +++ b/elog_watch.cpp @@ -28,7 +28,6 @@ using AttributeName = std::string; using AttributeMap = std::map; using PropertyName = std::string; using PropertyMap = std::map; -using LogEntryMsg = std::pair; Watch::Watch(sdbusplus::bus::bus& bus, IMgr& iMgr): iMgr(iMgr), @@ -65,10 +64,11 @@ void Watch::addCallback(sdbusplus::message::message& msg) using QuotaExceeded = sdbusplus::xyz::openbmc_project::Dump::Create::Error::QuotaExceeded; - LogEntryMsg logEntry; + sdbusplus::message::object_path objectPath; + PropertyMap propertyMap; try { - msg.read(logEntry); + msg.read(objectPath, propertyMap); } catch (const sdbusplus::exception::SdBusError& e) { @@ -78,9 +78,7 @@ void Watch::addCallback(sdbusplus::message::message& msg) return; } - std::string objectPath(std::move(logEntry.first)); - - std::size_t found = objectPath.find("entry"); + std::size_t found = objectPath.str.find("entry"); if (found == std::string::npos) { //Not a new error entry skip @@ -96,8 +94,8 @@ void Watch::addCallback(sdbusplus::message::message& msg) return; } - auto iter = logEntry.second.find("xyz.openbmc_project.Logging.Entry"); - if (iter == logEntry.second.end()) + auto iter = propertyMap.find("xyz.openbmc_project.Logging.Entry"); + if (iter == propertyMap.end()) { return; } @@ -145,10 +143,10 @@ void Watch::addCallback(sdbusplus::message::message& msg) void Watch::delCallback(sdbusplus::message::message& msg) { - sdbusplus::message::object_path logEntry; + sdbusplus::message::object_path objectPath; try { - msg.read(logEntry); + msg.read(objectPath); } catch (const sdbusplus::exception::SdBusError& e) { @@ -158,9 +156,6 @@ void Watch::delCallback(sdbusplus::message::message& msg) return; } - //Get elog entry message string. - std::string objectPath(logEntry); - //Get elog id auto eId = getEid(objectPath); -- cgit v1.2.1