From 4c3df65e1cdb4247df7f18787b4d9a586e742a71 Mon Sep 17 00:00:00 2001 From: Akshay Diddee Date: Tue, 26 Sep 2023 15:31:45 +0000 Subject: [PATCH 1/2] Adding a new event 'DOBBY_CTRL_EVENT_STOPPED_WITH_STATUS'. This event is a superset of 'DOBBY_CTRL_EVENT_STOPPED' event and contains an extra 'int32_t' parameter which is the return code of the app --- daemon/lib/source/Dobby.cpp | 11 +++++++++++ protocol/include/DobbyProtocol.h | 1 + 2 files changed, 12 insertions(+) diff --git a/daemon/lib/source/Dobby.cpp b/daemon/lib/source/Dobby.cpp index 5ed97164..d1a3d4bc 100644 --- a/daemon/lib/source/Dobby.cpp +++ b/daemon/lib/source/Dobby.cpp @@ -1865,6 +1865,17 @@ void Dobby::onContainerStopped(int32_t cd, const ContainerId& id, int status) DOBBY_CTRL_EVENT_STOPPED); } + + //Fire off a notification with status + if(!mIpcService->emitSignal(AI_IPC::Signal(mObjectPath, + DOBBY_CTRL_INTERFACE, + DOBBY_CTRL_EVENT_STOPPED_WITH_STATUS), + { cd, id.str(), int32_t(status) })) + { + AI_LOG_ERROR("failed to emit '%s' signal", + DOBBY_CTRL_EVENT_STOPPED_WITH_STATUS); + } + AI_LOG_MILESTONE("container '%s'(%d) stopped (status 0x%04x)", id.c_str(), cd, status); diff --git a/protocol/include/DobbyProtocol.h b/protocol/include/DobbyProtocol.h index 0c1f187a..b94198e2 100644 --- a/protocol/include/DobbyProtocol.h +++ b/protocol/include/DobbyProtocol.h @@ -58,6 +58,7 @@ #define DOBBY_CTRL_METHOD_LIST "List" #define DOBBY_CTRL_EVENT_STARTED "Started" #define DOBBY_CTRL_EVENT_STOPPED "Stopped" +#define DOBBY_CTRL_EVENT_STOPPED_WITH_STATUS "StoppedWithStatus" #define DOBBY_DEBUG_INTERFACE DOBBY_SERVICE ".debug1" #define DOBBY_DEBUG_METHOD_CREATE_BUNDLE "CreateBundle" From dd77b7358f08bcea5e5637e28c3647ec16d3177b Mon Sep 17 00:00:00 2001 From: Akshay Diddee Date: Wed, 27 Sep 2023 10:28:29 +0000 Subject: [PATCH 2/2] 1)Changing the order of the 2 STOPPED events. 2)Changing 'if(' to 'if (' --- daemon/lib/source/Dobby.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/daemon/lib/source/Dobby.cpp b/daemon/lib/source/Dobby.cpp index d1a3d4bc..e77fa47b 100644 --- a/daemon/lib/source/Dobby.cpp +++ b/daemon/lib/source/Dobby.cpp @@ -1856,24 +1856,25 @@ void Dobby::onContainerStopped(int32_t cd, const ContainerId& id, int status) // Regardless of whether of the not the hooks executed successfully // we fire off a notification event indicating that the container // has stopped. + + // Fire off a notification with status if (!mIpcService->emitSignal(AI_IPC::Signal(mObjectPath, DOBBY_CTRL_INTERFACE, - DOBBY_CTRL_EVENT_STOPPED), - { cd, id.str() })) + DOBBY_CTRL_EVENT_STOPPED_WITH_STATUS), + { cd, id.str(), int32_t(status) })) { AI_LOG_ERROR("failed to emit '%s' signal", - DOBBY_CTRL_EVENT_STOPPED); + DOBBY_CTRL_EVENT_STOPPED_WITH_STATUS); } - - //Fire off a notification with status - if(!mIpcService->emitSignal(AI_IPC::Signal(mObjectPath, + //Fire off a normal notification + if (!mIpcService->emitSignal(AI_IPC::Signal(mObjectPath, DOBBY_CTRL_INTERFACE, - DOBBY_CTRL_EVENT_STOPPED_WITH_STATUS), - { cd, id.str(), int32_t(status) })) + DOBBY_CTRL_EVENT_STOPPED), + { cd, id.str() })) { AI_LOG_ERROR("failed to emit '%s' signal", - DOBBY_CTRL_EVENT_STOPPED_WITH_STATUS); + DOBBY_CTRL_EVENT_STOPPED); } AI_LOG_MILESTONE("container '%s'(%d) stopped (status 0x%04x)", id.c_str(),