From e681d41197e79fcef3007058b3d1b09cd130ef3f Mon Sep 17 00:00:00 2001 From: Lukasz Pawelczyk Date: Tue, 9 Jun 2015 17:30:14 +0200 Subject: [PATCH] Fix for responding to a first request after socket activation [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 | 11 +++++++---- server/host-ipc-connection.hpp | 1 + server/zones-manager.cpp | 3 +++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/server/host-ipc-connection.cpp b/server/host-ipc-connection.cpp index 1a003d4..e87adca 100644 --- a/server/host-ipc-connection.cpp +++ b/server/host-ipc-connection.cpp @@ -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::type& callback) { typedef IPCMethodWrapper Callback; diff --git a/server/host-ipc-connection.hpp b/server/host-ipc-connection.hpp index 3e4e7ff..8107612 100644 --- a/server/host-ipc-connection.hpp +++ b/server/host-ipc-connection.hpp @@ -51,6 +51,7 @@ public: HostIPCConnection(ZonesManager* zm); ~HostIPCConnection(); + void start(); void signalZoneConnectionState(const api::ConnectionState& connectionState); void sendNotification(const api::Notification& notification); diff --git a/server/zones-manager.cpp b/server/zones-manager.cpp index a66eff1..7e0f641 100644 --- a/server/zones-manager.cpp +++ b/server/zones-manager.cpp @@ -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() -- 2.7.4