From c51b97ff43dc5255f6c6942a6d305b1d37069990 Mon Sep 17 00:00:00 2001 From: Evgeny Safronov Date: Fri, 17 Apr 2015 19:46:06 +0300 Subject: [PATCH 1/4] [Bug Fix] Fixed app/service list consistency. When Cocaine was unable to start an app it threw an exception, which wasn't been caught. It led to app/service list inconsistency. This commit should fix that behavior. --- src/service/node.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/service/node.cpp b/src/service/node.cpp index f309cfb48..1fccd8acd 100644 --- a/src/service/node.cpp +++ b/src/service/node.cpp @@ -131,21 +131,19 @@ node_t::prototype() const { void node_t::on_start_app(const std::string& name, const std::string& profile) { - auto ptr = m_apps.synchronize(); - auto it = ptr->find(name); + m_apps.apply([&](std::map>& apps){ + COCAINE_LOG_DEBUG(m_log, "starting app '%s'", name); - COCAINE_LOG_INFO(m_log, "trying to start app '%s'", name); + auto it = apps.find(name); + if(it != apps.end()) { + throw cocaine::error_t("app '%s' is already running", name); + } - if(it != ptr->end()) { - throw cocaine::error_t("app '%s' is already running", name); - } + auto app = std::make_shared(m_context, name, profile); + app->start(); - std::tie(it, std::ignore) = ptr->insert({ - name, - std::make_shared(m_context, name, profile) + apps.insert(std::make_pair(name, app)); }); - - it->second->start(); } void From 43b64b08575e77338c91b3303cbb8cf0b8ceba4e Mon Sep 17 00:00:00 2001 From: Evgeny Safronov Date: Fri, 17 Apr 2015 19:46:30 +0300 Subject: [PATCH 2/4] [Node] Fixed misleading logging messages. --- src/service/node/app.cpp | 2 +- src/service/node/engine.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/service/node/app.cpp b/src/service/node/app.cpp index 44fc9a854..0e55e2403 100644 --- a/src/service/node/app.cpp +++ b/src/service/node/app.cpp @@ -207,7 +207,7 @@ app_t::~app_t() { void app_t::start() { - COCAINE_LOG_INFO(m_log, "creating engine '%s'", m_manifest->name); + COCAINE_LOG_DEBUG(m_log, "creating engine '%s'", m_manifest->name); // Start the engine thread. try { diff --git a/src/service/node/engine.cpp b/src/service/node/engine.cpp index 9cabcf00f..084aad581 100644 --- a/src/service/node/engine.cpp +++ b/src/service/node/engine.cpp @@ -179,8 +179,6 @@ engine_t::engine_t(context_t& context, const manifest_t& manifest, const profile } engine_t::~engine_t() { - COCAINE_LOG_DEBUG(m_log, "stopping '%s' engine", m_manifest.name); - boost::filesystem::remove(m_manifest.endpoint); m_loop.post(std::bind(&engine_t::migrate, this, states::stopping)); @@ -188,6 +186,8 @@ engine_t::~engine_t() { if(m_thread.joinable()) { m_thread.join(); } + + COCAINE_LOG_DEBUG(m_log, "app '%s' engine has been destroyed", m_manifest.name); } void From f95627c23538515e229bae157c53ce592553c7e2 Mon Sep 17 00:00:00 2001 From: Evgeny Safronov Date: Fri, 17 Apr 2015 19:59:11 +0300 Subject: [PATCH 3/4] [Version] Bumped. --- cocaine-bf.spec | 5 ++++- debian/changelog | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cocaine-bf.spec b/cocaine-bf.spec index f5e35dfc1..276ffb40e 100644 --- a/cocaine-bf.spec +++ b/cocaine-bf.spec @@ -2,7 +2,7 @@ Summary: Cocaine - Core Libraries Name: libcocaine-core3 -Version: 0.12.0.7 +Version: 0.12.0.8 Release: 1%{?dist} @@ -125,6 +125,9 @@ rm -rf %{buildroot} %{_sysconfdir}/cocaine/cocaine-default.conf %changelog +* Fri Apr 17 2015 Evgeny Safronov 0.12.0.8-1 +- Bugfix: fixed app vs. published services list inconsistency. + * Wed Apr 08 2015 Andrey Sibiryov 0.12.0.7-1 - Remote connections are now retried on failure. - Bugfix: endpoints while connecting remotes were corrupted in logs. diff --git a/debian/changelog b/debian/changelog index 816baed57..d6f5c3cf4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +cocaine-core (0.12.0.8) unstable; urgency=low + + * Bugfix: fixed app vs. published services list inconsistency. + + -- Evgeny Safronov Fri, 17 Apr 2015 19:56:54 +0300 + cocaine-core (0.12.0.7) unstable; urgency=low * Remote connections are now retried on failure. From 1503c13e2017c9128f24f6531822782ba72d7d58 Mon Sep 17 00:00:00 2001 From: Evgeny Safronov Date: Fri, 17 Apr 2015 23:25:43 +0400 Subject: [PATCH 4/4] [Misc] Codestyle. --- src/service/node.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/service/node.cpp b/src/service/node.cpp index 1fccd8acd..218b0f90d 100644 --- a/src/service/node.cpp +++ b/src/service/node.cpp @@ -131,7 +131,7 @@ node_t::prototype() const { void node_t::on_start_app(const std::string& name, const std::string& profile) { - m_apps.apply([&](std::map>& apps){ + m_apps.apply([&](std::map>& apps) { COCAINE_LOG_DEBUG(m_log, "starting app '%s'", name); auto it = apps.find(name);