netipmid: make Handler asynchronous
The dbus call to the main ipmid queue was up to this point synchronous,
which means it blocks all other networking and execution until the main
queue returns (which may be on the order of seconds for some commands).
This is an unacceptable delay, especially when this queue is responsible
for timely updates of SOL traffic.
This turns the call into an asynchronous one by leveraging shared
pointers and an optional action on destruction. So as long as a
reference to the Handler object exists, it will live on, waiting to send
its response. Once the async dbus call has returned and set the reply in
the Handler, it will drop the reference to the shared pointer and the
destructor will send out the response over the channel.
Tested-by: Run multiple sessions at the same time while monitoring dbus
traffic. See that the requests and responses may be
interleaved instead of serial.
Change-Id: I16fca8dc3d13624eeb1592ec36d1a9af6575f115
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
diff --git a/sd_event_loop.cpp b/sd_event_loop.cpp
index 5be974a..8c9abf4 100644
--- a/sd_event_loop.cpp
+++ b/sd_event_loop.cpp
@@ -23,24 +23,9 @@
auto channelPtr = std::make_shared<udpsocket::Channel>(udpSocket);
// Initialize the Message Handler with the socket channel
- auto msgHandler = std::make_shared<message::Handler>(channelPtr);
+ auto msgHandler = std::make_shared<message::Handler>(channelPtr, io);
- // Read the incoming IPMI packet
- std::shared_ptr<message::Message> inMessage(msgHandler->receive());
- if (inMessage == nullptr)
- {
- return;
- }
-
- // Execute the Command
- std::shared_ptr<message::Message> outMessage =
- msgHandler->executeCommand(inMessage);
- if (outMessage == nullptr)
- {
- return;
- }
- // Send the response IPMI Message
- msgHandler->send(outMessage);
+ msgHandler->processIncoming();
}
catch (const std::exception& e)
{