Fix for responding to a first request after socket activation 46/40846/4
authorLukasz Pawelczyk <l.pawelczyk@samsung.com>
Tue, 9 Jun 2015 15:30:14 +0000 (17:30 +0200)
committerLukasz Pawelczyk <l.pawelczyk@samsung.com>
Wed, 10 Jun 2015 11:31:58 +0000 (13:31 +0200)
[Bug]           When socket activated the first request might not be
                properly handled because all the callback might not have
                registered yet.
[Cause]         N/A
[Solution]      Delayed handling requests until all the callbacks have
                been registered.
[Verification]  Built, installed, run tests.
Did several tries with triggering socket activation:
                1. systemctl start vasum.service
2. vasum-cli create_zone test
3. systemctl stop vasum.service
                4. vasum-cli get_zone_ids
                5. observe no error and list of zones should show 'test'
                6. goto 3

Change-Id: I6de9742959d32afe68f496246065d3befc823955

server/host-ipc-connection.cpp
server/host-ipc-connection.hpp
server/zones-manager.cpp

index 1a003d4..e87adca 100644 (file)
@@ -41,10 +41,6 @@ HostIPCConnection::HostIPCConnection(ZonesManager* zonesManagerPtr)
     LOGT("Connecting to host IPC socket");
     mService.reset(new ipc::Service(mDispatcher.getPoll(), HOST_IPC_SOCKET));
 
-    LOGT("Starting IPC");
-    mService->start();
-    LOGD("Connected");
-
     using namespace std::placeholders;
     setGetZoneIdsCallback(std::bind(&ZonesManager::handleGetZoneIdsCall,
                                     mZonesManagerPtr, _1));
@@ -135,6 +131,13 @@ HostIPCConnection::~HostIPCConnection()
 {
 }
 
+void HostIPCConnection::start()
+{
+    LOGT("Starting IPC");
+    mService->start();
+    LOGD("Connected");
+}
+
 void HostIPCConnection::setGetZoneIdsCallback(const Method<api::ZoneIds>::type& callback)
 {
     typedef IPCMethodWrapper<api::ZoneIds> Callback;
index 3e4e7ff..8107612 100644 (file)
@@ -51,6 +51,7 @@ public:
     HostIPCConnection(ZonesManager* zm);
     ~HostIPCConnection();
 
+    void start();
     void signalZoneConnectionState(const api::ConnectionState& connectionState);
     void sendNotification(const api::Notification& notification);
 
index a66eff1..7e0f641 100644 (file)
@@ -151,6 +151,9 @@ ZonesManager::ZonesManager(const std::string& configPath)
                              std::bind(&ZonesManager::switchingSequenceMonitorNotify,
                                        this)));
     }
+
+    // After everything's initialized start to respond to clients' requests
+    mHostIPCConnection.start();
 }
 
 ZonesManager::~ZonesManager()