Add resendPayload function

Resolves openbmc/openbmc#856

Change-Id: I957ce889500840c067e97537e825571cfb77e1c4
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
diff --git a/sd_event_loop.cpp b/sd_event_loop.cpp
index 350a96c..af1a5ee 100644
--- a/sd_event_loop.cpp
+++ b/sd_event_loop.cpp
@@ -149,12 +149,12 @@
             --context.retryCounter;
             std::get<eventloop::EventLoop&>(singletonPool).switchTimer
                     (instance, Timers::RETRY, true);
-            // Resend the SOL payload
+            context.resendPayload(sol::Context::noClear);
         }
         else
         {
             context.retryCounter = context.maxRetryCount;
-            // Resend the SOL payload
+            context.resendPayload(sol::Context::clear);
             std::get<eventloop::EventLoop&>(singletonPool).switchTimer
                     (instance, Timers::RETRY, false);
             std::get<eventloop::EventLoop&>(singletonPool).switchTimer
diff --git a/sol/sol_context.cpp b/sol/sol_context.cpp
index 24339f0..ec48a59 100644
--- a/sol/sol_context.cpp
+++ b/sol/sol_context.cpp
@@ -185,7 +185,15 @@
 
 void Context::resendPayload(bool clear)
 {
+    sendPayload(payloadCache);
 
+    if(clear)
+    {
+        payloadCache.clear();
+        expectedCharCount = 0;
+        std::get<sol::Manager&>(singletonPool).dataBuffer.erase(
+                expectedCharCount);
+    }
 }
 
 void Context::sendPayload(const Buffer& out) const