Skip to content

Commit

Permalink
Merge pull request cocaine#19 from 3Hren/bugfix/zombies
Browse files Browse the repository at this point in the history
[Process] Collecting zombies.
  • Loading branch information
3Hren committed Jul 8, 2015
2 parents 47341b9 + e4b1b97 commit 2eb2f2c
Show file tree
Hide file tree
Showing 13 changed files with 246 additions and 71 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ ADD_LIBRARY(cocaine-core SHARED
src/service/node.cpp
src/service/node/actor.cpp
src/service/node/app.cpp
src/service/node/app/stats.cpp
src/service/node/balancing/load.cpp
src/service/node/dispatch/client.cpp
src/service/node/dispatch/worker.cpp
Expand All @@ -124,13 +125,12 @@ ADD_LIBRARY(cocaine-core SHARED
src/service/node/slave/error.cpp
src/service/node/slave/fetcher.cpp
src/service/node/slave/state/active.cpp
src/service/node/slave/state/broken.cpp
src/service/node/slave/state/handshaking.cpp
src/service/node/slave/state/sealing.cpp
src/service/node/slave/state/spawning.cpp
src/service/node/slave/state/state.cpp
src/service/node/slave/state/sealing.cpp
src/service/node/slave/state/stopped.cpp
src/service/node/slave/state/terminating.cpp
src/service/node/app/stats.cpp

src/service/node/manifest.cpp
src/service/node/profile.cpp
Expand Down
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
cocaine-core (0.12.2.1) unstable; urgency=low

* Bug fix: collecting zombie processes during overseers destruction.

-- Evgeny Safronov <division494@gmail.com> Wed, 08 Jul 2015 15:20:37 +0300

cocaine-core (0.12.2.0) unstable; urgency=low

* Optional HPACK like headers extension. Mainly aims to ease internal protocol evolution.
Expand Down
10 changes: 6 additions & 4 deletions include/cocaine/api/isolate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

#include <mutex>

#include <asio/io_service.hpp>

namespace cocaine { namespace api {

struct handle_t {
Expand Down Expand Up @@ -97,7 +99,7 @@ struct isolate_t {
spawn(const std::string& path, const string_map_t& args, const string_map_t& environment) = 0;

protected:
isolate_t(context_t&, const std::string& /* name */, const dynamic_t& /* args */) {
isolate_t(context_t&, asio::io_service&, const std::string& /* name */, const dynamic_t& /* args */) {
// Empty.
}
};
Expand All @@ -109,21 +111,21 @@ struct category_traits<isolate_t> {
struct factory_type: public basic_factory<isolate_t> {
virtual
ptr_type
get(context_t& context, const std::string& name, const dynamic_t& args) = 0;
get(context_t& context, asio::io_service& io_context, const std::string& name, const dynamic_t& args) = 0;
};

template<class T>
struct default_factory: public factory_type {
virtual
ptr_type
get(context_t& context, const std::string& name, const dynamic_t& args) {
get(context_t& context, asio::io_service& io_context, const std::string& name, const dynamic_t& args) {
ptr_type instance;

instances.apply([&](std::map<std::string, std::weak_ptr<isolate_t>>& instances) {
auto weak_ptr = instances[name];

if((instance = weak_ptr.lock()) == nullptr) {
instance = std::make_shared<T>(context, name, args);
instance = std::make_shared<T>(context, io_context, name, args);
instances[name] = instance;
}
});
Expand Down
4 changes: 3 additions & 1 deletion include/cocaine/detail/isolate/process.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,20 @@ class process_t:
public api::isolate_t
{
context_t& m_context;
asio::io_service& io_context;

const std::unique_ptr<logging::log_t> m_log;

const std::string m_name;
const boost::filesystem::path m_working_directory;
const uint m_kill_timeout;

#ifdef COCAINE_ALLOW_CGROUPS
cgroup* m_cgroup;
#endif

public:
process_t(context_t& context, const std::string& name, const dynamic_t& args);
process_t(context_t& context, asio::io_service& io_context, const std::string& name, const dynamic_t& args);

virtual
~process_t();
Expand Down
4 changes: 2 additions & 2 deletions include/cocaine/detail/service/node/slave.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace cocaine {
class client_rpc_dispatch_t;

class active_t;
class broken_t;
class stopped_t;
class channel_t;
class handshaking_t;
class spawning_t;
Expand Down Expand Up @@ -110,7 +110,7 @@ class state_machine_t:
public std::enable_shared_from_this<state_machine_t>
{
friend class active_t;
friend class broken_t;
friend class stopped_t;
friend class handshaking_t;
friend class spawning_t;
friend class terminating_t;
Expand Down
3 changes: 2 additions & 1 deletion include/cocaine/detail/service/node/slave/state/spawning.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class spawning_t:
std::shared_ptr<state_machine_t> slave;

asio::deadline_timer timer;
std::unique_ptr<api::handle_t> handle;

public:
explicit
Expand All @@ -39,7 +40,7 @@ class spawning_t:

private:
void
on_spawn(std::unique_ptr<api::handle_t>& handle, std::chrono::high_resolution_clock::time_point start);
on_spawn(std::chrono::high_resolution_clock::time_point start);

void
on_timeout(const std::error_code& ec);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

namespace cocaine {

class broken_t:
class stopped_t:
public state_t
{
std::error_code ec;

public:
explicit
broken_t(std::error_code ec);
stopped_t(std::error_code ec);

virtual
void
Expand Down

0 comments on commit 2eb2f2c

Please sign in to comment.