MXS-1392 Re-introduce zombie queue
- Extend Worker interface so that zombies can be registered - Call deletion function at the end of event loop
This commit is contained in:
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include <maxscale/cppdefs.hh>
|
#include <maxscale/cppdefs.hh>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
#include <maxscale/platform.h>
|
#include <maxscale/platform.h>
|
||||||
#include <maxscale/session.h>
|
#include <maxscale/session.h>
|
||||||
#include <maxscale/utils.hh>
|
#include <maxscale/utils.hh>
|
||||||
@ -67,10 +68,11 @@ class Worker : public MXS_WORKER
|
|||||||
Worker& operator = (const Worker&);
|
Worker& operator = (const Worker&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef WORKER_STATISTICS STATISTICS;
|
typedef WORKER_STATISTICS STATISTICS;
|
||||||
typedef WorkerTask Task;
|
typedef WorkerTask Task;
|
||||||
typedef WorkerDisposableTask DisposableTask;
|
typedef WorkerDisposableTask DisposableTask;
|
||||||
typedef Registry<MXS_SESSION> SessionsById;
|
typedef Registry<MXS_SESSION> SessionsById;
|
||||||
|
typedef std::vector<DCB*> Zombies;
|
||||||
|
|
||||||
enum state_t
|
enum state_t
|
||||||
{
|
{
|
||||||
@ -226,6 +228,15 @@ public:
|
|||||||
*/
|
*/
|
||||||
static bool remove_shared_fd(int fd);
|
static bool remove_shared_fd(int fd);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register zombie for later deletion.
|
||||||
|
*
|
||||||
|
* @param pZombie DCB that will be deleted at end of event loop.
|
||||||
|
*
|
||||||
|
* @note The DCB must be owned by this worker.
|
||||||
|
*/
|
||||||
|
void register_zombie(DCB* pZombie);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main function of worker.
|
* Main function of worker.
|
||||||
*
|
*
|
||||||
@ -483,6 +494,8 @@ private:
|
|||||||
|
|
||||||
static Worker* create(int id, int epoll_listener_fd);
|
static Worker* create(int id, int epoll_listener_fd);
|
||||||
|
|
||||||
|
void delete_zombies();
|
||||||
|
|
||||||
bool post_disposable(DisposableTask* pTask, enum execute_mode_t mode = EXECUTE_AUTO);
|
bool post_disposable(DisposableTask* pTask, enum execute_mode_t mode = EXECUTE_AUTO);
|
||||||
|
|
||||||
void handle_message(MessageQueue& queue, const MessageQueue::Message& msg); // override
|
void handle_message(MessageQueue& queue, const MessageQueue::Message& msg); // override
|
||||||
@ -509,6 +522,7 @@ private:
|
|||||||
* worker and not e.g. listener sessions. For now,
|
* worker and not e.g. listener sessions. For now,
|
||||||
* it's up to the protocol to decide whether a new
|
* it's up to the protocol to decide whether a new
|
||||||
* session is added to the map. */
|
* session is added to the map. */
|
||||||
|
Zombies m_zombies; /*< DCBs to be deleted. */
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -836,6 +836,19 @@ json_t* mxs_worker_list_to_json(const char* host)
|
|||||||
return task.resource();
|
return task.resource();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Worker::register_zombie(DCB* pDcb)
|
||||||
|
{
|
||||||
|
ss_dassert(pDcb->poll.thread.id == m_id);
|
||||||
|
|
||||||
|
m_zombies.push_back(pDcb);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Worker::delete_zombies()
|
||||||
|
{
|
||||||
|
// TODO: for_each(m_zombies.begin(), m_zombies.end(), dcb_free_all_memory);
|
||||||
|
m_zombies.resize(0);
|
||||||
|
}
|
||||||
|
|
||||||
void Worker::run()
|
void Worker::run()
|
||||||
{
|
{
|
||||||
this_thread.current_worker_id = m_id;
|
this_thread.current_worker_id = m_id;
|
||||||
@ -1227,6 +1240,8 @@ void Worker::poll_waitevents()
|
|||||||
|
|
||||||
m_state = ZPROCESSING;
|
m_state = ZPROCESSING;
|
||||||
|
|
||||||
|
delete_zombies();
|
||||||
|
|
||||||
m_state = IDLE;
|
m_state = IDLE;
|
||||||
} /*< while(1) */
|
} /*< while(1) */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user