MXS_WORKER passed to poll_waitevents
This commit is contained in:
@ -50,6 +50,18 @@ enum mxs_worker_msg_id
|
||||
*/
|
||||
MXS_WORKER* mxs_worker_get(int worker_id);
|
||||
|
||||
/**
|
||||
* Return the id of the worker.
|
||||
*
|
||||
* @param worker A worker.
|
||||
*
|
||||
* @return The id of the worker.
|
||||
*/
|
||||
static inline int mxs_worker_id(MXS_WORKER* worker)
|
||||
{
|
||||
return worker->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Post a message to a worker.
|
||||
*
|
||||
|
@ -22,6 +22,8 @@
|
||||
|
||||
MXS_BEGIN_DECLS
|
||||
|
||||
struct mxs_worker;
|
||||
|
||||
#define MAX_EVENTS 1000
|
||||
|
||||
/**
|
||||
@ -48,7 +50,7 @@ enum poll_message
|
||||
void poll_init();
|
||||
void poll_shutdown();
|
||||
|
||||
void poll_waitevents(void *);
|
||||
void poll_waitevents(struct mxs_worker *worker);
|
||||
void poll_set_maxwait(unsigned int);
|
||||
void poll_set_nonblocking_polls(unsigned int);
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <maxscale/log_manager.h>
|
||||
#include <maxscale/platform.h>
|
||||
#include <maxscale/query_classifier.h>
|
||||
#include <maxscale/worker.h>
|
||||
#include <maxscale/resultset.h>
|
||||
#include <maxscale/server.h>
|
||||
#include <maxscale/session.h>
|
||||
@ -552,11 +553,12 @@ poll_resolve_error(int fd, int errornum, int op)
|
||||
* @param arg The thread ID passed as a void * to satisfy the threading package
|
||||
*/
|
||||
void
|
||||
poll_waitevents(void *arg)
|
||||
poll_waitevents(MXS_WORKER *worker)
|
||||
{
|
||||
current_thread_id = mxs_worker_id(worker);
|
||||
|
||||
struct epoll_event events[MAX_EVENTS];
|
||||
int i, nfds, timeout_bias = 1;
|
||||
current_thread_id = (intptr_t)arg;
|
||||
int poll_spins = 0;
|
||||
|
||||
int thread_id = current_thread_id;
|
||||
|
@ -108,7 +108,7 @@ bool mxs_worker_post_message(MXS_WORKER *worker, int id, int64_t arg1, void* arg
|
||||
|
||||
void mxs_worker_main(MXS_WORKER* worker)
|
||||
{
|
||||
poll_waitevents((void*)(intptr_t)worker->id);
|
||||
poll_waitevents(worker);
|
||||
}
|
||||
|
||||
bool mxs_worker_start(MXS_WORKER* worker)
|
||||
|
Reference in New Issue
Block a user