Popup process fix.
authorAndrzej Surdej <a.surdej@samsung.com>
Thu, 18 Apr 2013 14:37:13 +0000 (16:37 +0200)
committerAndrzej Surdej <a.surdej@samsung.com>
Tue, 23 Apr 2013 11:56:42 +0000 (13:56 +0200)
[Issue#] N/A
[Problem] When fork process is created but, exec() return fail,
the process crash and writes nothing to pipe. As result the caller process hangs.
[Cause] N/A
[Solution] Write data to pipe (deny and do not remember).
[SCMRequest] N/A

Change-Id: Ibd47e586790608972d45b7e80805ad15b0b4503b

src/wrt-popup/wrt/popup-bin/InfoPopup.cpp
src/wrt-popup/wrt/popup-bin/YesNoCheckPopup.cpp
src/wrt-popup/wrt/popup-bin/YesNoPopup.cpp
src/wrt-popup/wrt/popup-runner/PopupInvoker.cpp

index faa3807..4536350 100644 (file)
@@ -69,6 +69,7 @@ void InfoPopup::show(DPL::BinaryQueueAutoPtr data, WrtPopup* parent)
 void InfoPopup::responseCallback(const Renderer::AnswerCallbackData &answer)
 {
     DPL::BinaryQueue retValue;
+    PopupSerializer::appendArg(true, retValue);
     PopupSerializer::appendArg(answer.buttonAnswer, retValue);
     m_parent->response(retValue);
 }
index ea743a6..7cdbf73 100644 (file)
@@ -41,6 +41,7 @@ void YesNoCheckPopup::responseCallback(
 {
     bool result = (POPUP_YES_VALUE == answer.buttonAnswer);
     DPL::BinaryQueue retValue;
+    PopupSerializer::appendArg(true, retValue);
     PopupSerializer::appendArg(result, retValue);
     LogDebug("Check state: " << answer.chackState);
     PopupSerializer::appendArg(answer.chackState, retValue);
index f2953a8..a47d205 100644 (file)
@@ -51,6 +51,7 @@ void YesNoPopup::responseCallback(const Renderer::AnswerCallbackData &answer)
 {
     bool result = (POPUP_YES_VALUE == answer.buttonAnswer);
     DPL::BinaryQueue retValue;
+    PopupSerializer::appendArg(true, retValue);
     PopupSerializer::appendArg(result, retValue);
     m_parent->response(retValue);
 }
index 28f32a1..16cbace 100644 (file)
@@ -84,17 +84,24 @@ bool PopupInvoker::askYesNo(const std::string& title,
         //Result from popup application is available. Read it.
         DPL::BinaryQueueAutoPtr resultData =
             m_input.Read(std::numeric_limits<std::size_t>::max());
-        const int result = PopupSerializer::getIntArg(*resultData);
+        const int success = PopupSerializer::getIntArg(*resultData);
+        bool retVal = false;
+        if (success) {
+            const int result = PopupSerializer::getIntArg(*resultData);
 
-        LogDebug("Popup result is: " << result);
+            LogDebug("Popup result is: " << result);
 
-        Assert(resultData->Empty());
+            Assert(resultData->Empty());
+            retVal = (!!result);
+        } else {
+            LogWarning("Failed to show popup.");
+        }
 
         tmp.Close();
         m_input.Close();
         m_output.Close();
 
-        return (!!result);
+        return retVal;
     }
     Catch(DPL::Exception)
     {
@@ -122,7 +129,12 @@ void PopupInvoker::showInfo(const std::string& title,
         m_output.Write(data, data.Size());
 
         executePopup();
-
+        DPL::BinaryQueueAutoPtr resultData =
+            m_input.Read(std::numeric_limits<std::size_t>::max());
+        const int success = PopupSerializer::getIntArg(*resultData);
+        if (!success) {
+            LogWarning("Failed to show popup.");
+        }
         //ignore result
 
         tmp.Close();
@@ -157,29 +169,38 @@ PopupResponse PopupInvoker::askYesNoCheckbox(const std::string& title,
         //Result from popup application is available. Read it.
         DPL::BinaryQueueAutoPtr resultData =
             m_input.Read(std::numeric_limits<std::size_t>::max());
-        const int result = PopupSerializer::getIntArg(*resultData);
-        const int rememberResult = PopupSerializer::getIntArg(*resultData);
-
-        LogDebug(
-            "Popup result is: " << result << " remeber: " << rememberResult);
-
-        Assert(resultData->Empty());
-        tmp.Close();
-        m_input.Close();
-        m_output.Close();
-
-        if (1 == result) {
-            if (rememberResult == 1) {
-                return YES_DO_REMEMBER;
+        const int success = PopupSerializer::getIntArg(*resultData);
+        if (success) {
+            const int result = PopupSerializer::getIntArg(*resultData);
+            const int rememberResult = PopupSerializer::getIntArg(*resultData);
+
+            LogDebug(
+                "Popup result is: " << result << " remeber: " << rememberResult);
+
+            Assert(resultData->Empty());
+            tmp.Close();
+            m_input.Close();
+            m_output.Close();
+
+            if (1 == result) {
+                if (rememberResult == 1) {
+                    return YES_DO_REMEMBER;
+                } else {
+                    return YES_DONT_REMEMBER;
+                }
             } else {
-                return YES_DONT_REMEMBER;
+                if (rememberResult == 1) {
+                    return NO_DO_REMEMBER;
+                } else {
+                    return NO_DONT_REMEMBER;
+                }
             }
         } else {
-            if (rememberResult == 1) {
-                return NO_DO_REMEMBER;
-            } else {
-                return NO_DONT_REMEMBER;
-            }
+            LogWarning("Popup failed to execute.");
+            tmp.Close();
+            m_input.Close();
+            m_output.Close();
+            return NO_DONT_REMEMBER;
         }
     }
     Catch(DPL::Exception)
@@ -194,7 +215,7 @@ void PopupInvoker::executePopup()
     pid_t pid = fork();
     if (pid == -1) {
         //error occured
-        LogError("Cannot display popup!");
+        LogError("Failed to create popup process.");
         Assert(false);
     }
     if (pid == 0) {
@@ -206,7 +227,15 @@ void PopupInvoker::executePopup()
                         NULL);
         if (ret == -1) {
             //execl returns -1 on error
-            LogError("Cannot display popup!");
+            LogError("Failed to set popup binary");
+            //write something to pipe to unblock caller process
+            DPL::NamedOutputPipe errOut;
+            errOut.Open(m_inputName);
+            DPL::BinaryQueue data;
+            PopupSerializer::appendArg(false, data);
+            errOut.Write(data, data.Size());
+            errOut.Close();
+
             Assert(false);
         }
     }