MXS-2008 Add maxbase/poll.[h|hh]

Remove maxscale/poll_core.h
This commit is contained in:
Johan Wikman
2018-08-17 15:01:58 +03:00
parent 8f257a51fe
commit 932956d5f6
14 changed files with 123 additions and 123 deletions

View File

@ -17,14 +17,14 @@
*/ */
#include <maxscale/cdefs.h> #include <maxscale/cdefs.h>
#include <maxscale/spinlock.h>
#include <maxscale/buffer.h>
#include <maxscale/protocol.h>
#include <maxscale/authenticator.h>
#include <maxscale/ssl.h>
#include <maxscale/modinfo.h>
#include <maxscale/poll_core.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <maxbase/poll.h>
#include <maxscale/authenticator.h>
#include <maxscale/buffer.h>
#include <maxscale/modinfo.h>
#include <maxscale/protocol.h>
#include <maxscale/spinlock.h>
#include <maxscale/ssl.h>
MXS_BEGIN_DECLS MXS_BEGIN_DECLS
@ -144,7 +144,7 @@ typedef enum
*/ */
typedef struct dcb typedef struct dcb
{ {
MXS_POLL_DATA poll; MXB_POLL_DATA poll;
bool dcb_errhandle_called; /*< this can be called only once */ bool dcb_errhandle_called; /*< this can be called only once */
dcb_role_t dcb_role; dcb_role_t dcb_role;
int fd; /**< The descriptor */ int fd; /**< The descriptor */

View File

@ -13,7 +13,7 @@
*/ */
#include <maxscale/ccdefs.hh> #include <maxscale/ccdefs.hh>
#include <maxscale/poll_core.hh> #include <maxbase/poll.hh>
namespace maxscale namespace maxscale
{ {
@ -107,7 +107,7 @@ public:
* The class @c MessageQueue provides a cross thread message queue implemented * The class @c MessageQueue provides a cross thread message queue implemented
* on top of a pipe. * on top of a pipe.
*/ */
class MessageQueue : private MxsPollData class MessageQueue : private mxb::PollData
{ {
MessageQueue(const MessageQueue&); MessageQueue(const MessageQueue&);
MessageQueue& operator = (const MessageQueue&); MessageQueue& operator = (const MessageQueue&);
@ -195,7 +195,7 @@ private:
uint32_t handle_poll_events(Worker* pWorker, uint32_t events); uint32_t handle_poll_events(Worker* pWorker, uint32_t events);
static uint32_t poll_handler(MXS_POLL_DATA* pData, void* worker, uint32_t events); static uint32_t poll_handler(MXB_POLL_DATA* pData, void* worker, uint32_t events);
private: private:
Handler& m_handler; Handler& m_handler;

View File

@ -1,55 +0,0 @@
#pragma once
/*
* Copyright (c) 2016 MariaDB Corporation Ab
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file and at www.mariadb.com/bsl.
*
* Change Date: 2022-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2 or later of the General
* Public License.
*/
/**
* @file poll_basic.h The Descriptor Control Block
*/
#include <maxscale/cdefs.h>
#include <sys/epoll.h>
MXS_BEGIN_DECLS
typedef enum mxs_poll_action
{
MXS_POLL_NOP = 0x00,
MXS_POLL_ACCEPT = 0x01,
MXS_POLL_READ = 0x02,
MXS_POLL_WRITE = 0x04,
MXS_POLL_HUP = 0x08,
MXS_POLL_ERROR = 0x10,
} mxs_poll_action_t;
struct mxs_poll_data;
/**
* Pointer to function that knows how to handle events for a particular
* 'struct mxs_poll_data' structure.
*
* @param data The `mxs_poll_data` instance that contained this function pointer.
* @param worker The worker.
* @param events The epoll events.
*
* @return A combination of mxs_poll_action_t enumeration values.
*/
// TODO: Change worker to mxs::Worker once this is C++-ified.
typedef uint32_t (*mxs_poll_handler_t)(struct mxs_poll_data* data, void* worker, uint32_t events);
typedef struct mxs_poll_data
{
mxs_poll_handler_t handler; /*< Handler for this particular kind of mxs_poll_data. */
void* owner; /*< Owning worker. */
} MXS_POLL_DATA;
MXS_END_DECLS

View File

@ -16,12 +16,13 @@
#include <deque> #include <deque>
#include <maxbase/poll.h>
#include <maxscale/buffer.hh> #include <maxscale/buffer.hh>
#include <maxscale/service.h> #include <maxscale/service.h>
#include <maxscale/protocol/mysql.h> #include <maxscale/protocol/mysql.h>
/** A DCB-like client abstraction which ignores responses */ /** A DCB-like client abstraction which ignores responses */
class LocalClient: public MXS_POLL_DATA class LocalClient: public MXB_POLL_DATA
{ {
LocalClient(const LocalClient&); LocalClient(const LocalClient&);
LocalClient& operator=(const LocalClient&); LocalClient& operator=(const LocalClient&);
@ -59,7 +60,7 @@ public:
private: private:
static LocalClient* create(MYSQL_session* session, MySQLProtocol* proto, const char* ip, uint64_t port); static LocalClient* create(MYSQL_session* session, MySQLProtocol* proto, const char* ip, uint64_t port);
LocalClient(MYSQL_session* session, MySQLProtocol* proto, int fd); LocalClient(MYSQL_session* session, MySQLProtocol* proto, int fd);
static uint32_t poll_handler(struct mxs_poll_data* data, void* worker, uint32_t events); static uint32_t poll_handler(MXB_POLL_DATA* data, void* worker, uint32_t events);
void process(uint32_t events); void process(uint32_t events);
GWBUF* read_complete_packet(); GWBUF* read_complete_packet();
void drain_queue(); void drain_queue();

View File

@ -13,12 +13,11 @@
*/ */
#include <maxscale/cdefs.h> #include <maxscale/cdefs.h>
#include <maxbase/poll.h>
MXS_BEGIN_DECLS MXS_BEGIN_DECLS
typedef struct mxs_worker typedef MXB_WORKER MXS_WORKER;
{
} MXS_WORKER;
enum mxs_worker_msg_id enum mxs_worker_msg_id
{ {

View File

@ -23,11 +23,11 @@
#include <maxbase/atomic.h> #include <maxbase/atomic.h>
#include <maxbase/semaphore.hh> #include <maxbase/semaphore.hh>
#include <maxscale/debug.h>
#include <maxscale/messagequeue.hh>
#include <maxscale/worker.h> #include <maxscale/worker.h>
#include <maxscale/workertask.hh> #include <maxscale/workertask.hh>
#include "messagequeue.hh"
namespace maxscale namespace maxscale
{ {
@ -431,7 +431,7 @@ private:
* too many WorkerTimer instances. In order to be used, a WorkerTimer * too many WorkerTimer instances. In order to be used, a WorkerTimer
* needs a Worker instance in whose context the timer is triggered. * needs a Worker instance in whose context the timer is triggered.
*/ */
class WorkerTimer : private MXS_POLL_DATA class WorkerTimer : private MXB_POLL_DATA
{ {
WorkerTimer(const WorkerTimer&) = delete; WorkerTimer(const WorkerTimer&) = delete;
WorkerTimer& operator = (const WorkerTimer&) = delete; WorkerTimer& operator = (const WorkerTimer&) = delete;
@ -471,7 +471,7 @@ protected:
private: private:
uint32_t handle(Worker* pWorker, uint32_t events); uint32_t handle(Worker* pWorker, uint32_t events);
static uint32_t handler(MXS_POLL_DATA* pThis, void* pWorker, uint32_t events); static uint32_t handler(MXB_POLL_DATA* pThis, void* pWorker, uint32_t events);
private: private:
int m_fd; /**< The timerfd descriptor. */ int m_fd; /**< The timerfd descriptor. */
@ -654,7 +654,7 @@ public:
* *
* @return True, if the descriptor could be added, false otherwise. * @return True, if the descriptor could be added, false otherwise.
*/ */
bool add_fd(int fd, uint32_t events, MXS_POLL_DATA* pData); bool add_fd(int fd, uint32_t events, MXB_POLL_DATA* pData);
/** /**
* Remove a file descriptor from the worker's epoll instance. * Remove a file descriptor from the worker's epoll instance.

View File

@ -0,0 +1,55 @@
#pragma once
/*
* Copyright (c) 2016 MariaDB Corporation Ab
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file and at www.mariadb.com/bsl.
*
* Change Date: 2022-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2 or later of the General
* Public License.
*/
#include <maxbase/cdefs.h>
#include <sys/epoll.h>
MXB_BEGIN_DECLS
typedef enum mxb_poll_action_t
{
MXB_POLL_NOP = 0x00,
MXB_POLL_ACCEPT = 0x01,
MXB_POLL_READ = 0x02,
MXB_POLL_WRITE = 0x04,
MXB_POLL_HUP = 0x08,
MXB_POLL_ERROR = 0x10,
} mxb_poll_action_t;
struct MXB_POLL_DATA;
typedef struct MXB_WORKER
{
} MXB_WORKER;
/**
* Pointer to function that knows how to handle events for a particular
* MXB_POLL_DATA structure.
*
* @param data The MXB_POLL_DATA instance that contained this function pointer.
* @param worker The worker.
* @param events The epoll events.
*
* @return A combination of mxb_poll_action_t enumeration values.
*/
// TODO: Change void* to MXS_WORKER
typedef uint32_t (*mxb_poll_handler_t)(struct MXB_POLL_DATA* data, void* worker, uint32_t events);
typedef struct MXB_POLL_DATA
{
mxb_poll_handler_t handler; /*< Handler for this particular kind of mxb_poll_data. */
void* owner; /*< Owning worker. */
} MXB_POLL_DATA;
MXB_END_DECLS

View File

@ -12,21 +12,22 @@
* Public License. * Public License.
*/ */
#include <maxscale/ccdefs.hh> #include <maxbase/ccdefs.hh>
#include <maxscale/poll_core.h> #include <maxbase/poll.h>
namespace maxscale namespace maxbase
{ {
struct MxsPollData : MXS_POLL_DATA class PollData : public MXB_POLL_DATA
{ {
MxsPollData() public:
PollData()
{ {
handler = NULL; handler = NULL;
owner = nullptr; owner = nullptr;
} }
MxsPollData(mxs_poll_handler_t h) PollData(mxb_poll_handler_t h)
{ {
handler = h; handler = h;
owner = nullptr; owner = nullptr;

View File

@ -115,7 +115,7 @@ static bool dcb_add_to_worker(Worker* worker, DCB *dcb, uint32_t events);
static DCB *dcb_find_free(); static DCB *dcb_find_free();
static void dcb_remove_from_list(DCB *dcb); static void dcb_remove_from_list(DCB *dcb);
static uint32_t dcb_poll_handler(MXS_POLL_DATA *data, void* worker, uint32_t events); static uint32_t dcb_poll_handler(MXB_POLL_DATA *data, void* worker, uint32_t events);
static uint32_t dcb_process_poll_events(DCB *dcb, uint32_t ev); static uint32_t dcb_process_poll_events(DCB *dcb, uint32_t ev);
static bool dcb_session_check(DCB *dcb, const char *); static bool dcb_session_check(DCB *dcb, const char *);
static int upstream_throttle_callback(DCB *dcb, DCB_REASON reason, void *userdata); static int upstream_throttle_callback(DCB *dcb, DCB_REASON reason, void *userdata);
@ -2985,7 +2985,7 @@ static uint32_t dcb_process_poll_events(DCB *dcb, uint32_t events)
ss_dassert(owner == RoutingWorker::get_current() || ss_dassert(owner == RoutingWorker::get_current() ||
dcb->dcb_role == DCB_ROLE_SERVICE_LISTENER); dcb->dcb_role == DCB_ROLE_SERVICE_LISTENER);
uint32_t rc = MXS_POLL_NOP; uint32_t rc = MXB_POLL_NOP;
/* It isn't obvious that this is impossible */ /* It isn't obvious that this is impossible */
/* ss_dassert(dcb->state != DCB_STATE_DISCONNECTED); */ /* ss_dassert(dcb->state != DCB_STATE_DISCONNECTED); */
@ -3021,7 +3021,7 @@ static uint32_t dcb_process_poll_events(DCB *dcb, uint32_t events)
if (eno == 0) if (eno == 0)
{ {
rc |= MXS_POLL_WRITE; rc |= MXB_POLL_WRITE;
if (dcb_session_check(dcb, "write_ready")) if (dcb_session_check(dcb, "write_ready"))
{ {
@ -3050,7 +3050,7 @@ static uint32_t dcb_process_poll_events(DCB *dcb, uint32_t events)
"Accept in fd %d", "Accept in fd %d",
pthread_self(), pthread_self(),
dcb->fd); dcb->fd);
rc |= MXS_POLL_ACCEPT; rc |= MXB_POLL_ACCEPT;
if (dcb_session_check(dcb, "accept")) if (dcb_session_check(dcb, "accept"))
{ {
@ -3065,7 +3065,7 @@ static uint32_t dcb_process_poll_events(DCB *dcb, uint32_t events)
pthread_self(), pthread_self(),
dcb, dcb,
dcb->fd); dcb->fd);
rc |= MXS_POLL_READ; rc |= MXB_POLL_READ;
if (dcb_session_check(dcb, "read")) if (dcb_session_check(dcb, "read"))
{ {
@ -3098,7 +3098,7 @@ static uint32_t dcb_process_poll_events(DCB *dcb, uint32_t events)
eno, eno,
strerror_r(eno, errbuf, sizeof(errbuf))); strerror_r(eno, errbuf, sizeof(errbuf)));
} }
rc |= MXS_POLL_ERROR; rc |= MXB_POLL_ERROR;
if (dcb_session_check(dcb, "error")) if (dcb_session_check(dcb, "error"))
{ {
@ -3119,7 +3119,7 @@ static uint32_t dcb_process_poll_events(DCB *dcb, uint32_t events)
dcb->fd, dcb->fd,
eno, eno,
strerror_r(eno, errbuf, sizeof(errbuf))); strerror_r(eno, errbuf, sizeof(errbuf)));
rc |= MXS_POLL_HUP; rc |= MXB_POLL_HUP;
if ((dcb->flags & DCBF_HUNG) == 0) if ((dcb->flags & DCBF_HUNG) == 0)
{ {
dcb->flags |= DCBF_HUNG; dcb->flags |= DCBF_HUNG;
@ -3145,7 +3145,7 @@ static uint32_t dcb_process_poll_events(DCB *dcb, uint32_t events)
dcb->fd, dcb->fd,
eno, eno,
strerror_r(eno, errbuf, sizeof(errbuf))); strerror_r(eno, errbuf, sizeof(errbuf)));
rc |= MXS_POLL_HUP; rc |= MXB_POLL_HUP;
if ((dcb->flags & DCBF_HUNG) == 0) if ((dcb->flags & DCBF_HUNG) == 0)
{ {
@ -3186,7 +3186,7 @@ static uint32_t dcb_handler(DCB* dcb, uint32_t events)
return rv; return rv;
} }
static uint32_t dcb_poll_handler(MXS_POLL_DATA *data, void* worker, uint32_t events) static uint32_t dcb_poll_handler(MXB_POLL_DATA *data, void* worker, uint32_t events)
{ {
uint32_t rval = 0; uint32_t rval = 0;
DCB *dcb = (DCB*)data; DCB *dcb = (DCB*)data;
@ -3406,7 +3406,7 @@ private:
} }
static bool add_fd_to_routing_workers(int fd, uint32_t events, MXS_POLL_DATA* data) static bool add_fd_to_routing_workers(int fd, uint32_t events, MXB_POLL_DATA* data)
{ {
bool rv = true; bool rv = true;
void* previous_owner = data->owner; void* previous_owner = data->owner;
@ -3447,7 +3447,7 @@ static bool dcb_add_to_worker(Worker* worker, DCB* dcb, uint32_t events)
ss_dassert(dcb->dcb_role == DCB_ROLE_SERVICE_LISTENER); ss_dassert(dcb->dcb_role == DCB_ROLE_SERVICE_LISTENER);
// A listening DCB, we add it immediately. // A listening DCB, we add it immediately.
if (add_fd_to_routing_workers(dcb->fd, events, (MXS_POLL_DATA*)dcb)) if (add_fd_to_routing_workers(dcb->fd, events, (MXB_POLL_DATA*)dcb))
{ {
// If this takes place on the main thread (all listening DCBs are // If this takes place on the main thread (all listening DCBs are
// stored on the main thread)... // stored on the main thread)...
@ -3483,7 +3483,7 @@ static bool dcb_add_to_worker(Worker* worker, DCB* dcb, uint32_t events)
{ {
// If the DCB should end up on the current thread, we can both add it // If the DCB should end up on the current thread, we can both add it
// to the epoll-instance and to the DCB book-keeping immediately. // to the epoll-instance and to the DCB book-keeping immediately.
if (worker->add_fd(dcb->fd, events, (MXS_POLL_DATA*)dcb)) if (worker->add_fd(dcb->fd, events, (MXB_POLL_DATA*)dcb))
{ {
dcb_add_to_list(dcb); dcb_add_to_list(dcb);
rv = true; rv = true;

View File

@ -28,7 +28,7 @@ namespace maxscale
{ {
class RoutingWorker : public Worker class RoutingWorker : public Worker
, private MXS_POLL_DATA , private MXB_POLL_DATA
{ {
RoutingWorker(const RoutingWorker&) = delete; RoutingWorker(const RoutingWorker&) = delete;
RoutingWorker& operator = (const RoutingWorker&) = delete; RoutingWorker& operator = (const RoutingWorker&) = delete;
@ -81,7 +81,7 @@ public:
* *
* @return True, if the descriptor could be added, false otherwise. * @return True, if the descriptor could be added, false otherwise.
*/ */
static bool add_shared_fd(int fd, uint32_t events, MXS_POLL_DATA* pData); static bool add_shared_fd(int fd, uint32_t events, MXB_POLL_DATA* pData);
/** /**
* Remove a file descriptor from the epoll instance shared between all workers. * Remove a file descriptor from the epoll instance shared between all workers.
@ -429,7 +429,7 @@ private:
void delete_zombies(); void delete_zombies();
static uint32_t epoll_instance_handler(struct mxs_poll_data* data, void* worker, uint32_t events); static uint32_t epoll_instance_handler(MXB_POLL_DATA* data, void* worker, uint32_t events);
uint32_t handle_epoll_events(uint32_t events); uint32_t handle_epoll_events(uint32_t events);
}; };

View File

@ -52,7 +52,7 @@ namespace maxscale
{ {
MessageQueue::MessageQueue(Handler* pHandler, int read_fd, int write_fd) MessageQueue::MessageQueue(Handler* pHandler, int read_fd, int write_fd)
: MxsPollData(&MessageQueue::poll_handler) : mxb::PollData(&MessageQueue::poll_handler)
, m_handler(*pHandler) , m_handler(*pHandler)
, m_read_fd(read_fd) , m_read_fd(read_fd)
, m_write_fd(write_fd) , m_write_fd(write_fd)
@ -267,7 +267,7 @@ Worker* MessageQueue::remove_from_worker()
uint32_t MessageQueue::handle_poll_events(Worker* pWorker, uint32_t events) uint32_t MessageQueue::handle_poll_events(Worker* pWorker, uint32_t events)
{ {
uint32_t rc = MXS_POLL_NOP; uint32_t rc = MXB_POLL_NOP;
ss_dassert(pWorker == m_pWorker); ss_dassert(pWorker == m_pWorker);
@ -308,14 +308,14 @@ uint32_t MessageQueue::handle_poll_events(Worker* pWorker, uint32_t events)
} }
while ((n != 0) && (n != -1)); while ((n != 0) && (n != -1));
rc = MXS_POLL_READ; rc = MXB_POLL_READ;
} }
return rc; return rc;
} }
//static //static
uint32_t MessageQueue::poll_handler(MXS_POLL_DATA* pData, void* pWorker, uint32_t events) uint32_t MessageQueue::poll_handler(MXB_POLL_DATA* pData, void* pWorker, uint32_t events)
{ {
MessageQueue* pThis = static_cast<MessageQueue*>(pData); MessageQueue* pThis = static_cast<MessageQueue*>(pData);

View File

@ -169,8 +169,8 @@ namespace maxscale
RoutingWorker::RoutingWorker() RoutingWorker::RoutingWorker()
: m_id(next_worker_id()) : m_id(next_worker_id())
{ {
MXS_POLL_DATA::handler = &RoutingWorker::epoll_instance_handler; MXB_POLL_DATA::handler = &RoutingWorker::epoll_instance_handler;
MXS_POLL_DATA::owner = this; MXB_POLL_DATA::owner = this;
} }
RoutingWorker::~RoutingWorker() RoutingWorker::~RoutingWorker()
@ -296,7 +296,7 @@ void RoutingWorker::finish()
} }
//static //static
bool RoutingWorker::add_shared_fd(int fd, uint32_t events, MXS_POLL_DATA* pData) bool RoutingWorker::add_shared_fd(int fd, uint32_t events, MXB_POLL_DATA* pData)
{ {
bool rv = true; bool rv = true;
@ -497,7 +497,7 @@ RoutingWorker* RoutingWorker::create(int epoll_listener_fd)
{ {
struct epoll_event ev; struct epoll_event ev;
ev.events = EPOLLIN; ev.events = EPOLLIN;
MXS_POLL_DATA* pData = pThis; MXB_POLL_DATA* pData = pThis;
ev.data.ptr = pData; // Necessary for pointer adjustment, otherwise downcast will not work. ev.data.ptr = pData; // Necessary for pointer adjustment, otherwise downcast will not work.
// The shared epoll instance descriptor is *not* added using EPOLLET (edge-triggered) // The shared epoll instance descriptor is *not* added using EPOLLET (edge-triggered)
@ -547,7 +547,7 @@ void RoutingWorker::epoll_tick()
* @return What actions were performed. * @return What actions were performed.
*/ */
//static //static
uint32_t RoutingWorker::epoll_instance_handler(struct mxs_poll_data* pData, void* pWorker, uint32_t events) uint32_t RoutingWorker::epoll_instance_handler(MXB_POLL_DATA* pData, void* pWorker, uint32_t events)
{ {
RoutingWorker* pThis = static_cast<RoutingWorker*>(pData); RoutingWorker* pThis = static_cast<RoutingWorker*>(pData);
ss_dassert(pThis == pWorker); ss_dassert(pThis == pWorker);
@ -569,7 +569,7 @@ uint32_t RoutingWorker::handle_epoll_events(uint32_t events)
// We extract just one event // We extract just one event
int nfds = epoll_wait(this_unit.epoll_listener_fd, epoll_events, 1, 0); int nfds = epoll_wait(this_unit.epoll_listener_fd, epoll_events, 1, 0);
uint32_t actions = MXS_POLL_NOP; uint32_t actions = MXB_POLL_NOP;
if (nfds == -1) if (nfds == -1)
{ {
@ -582,7 +582,7 @@ uint32_t RoutingWorker::handle_epoll_events(uint32_t events)
else else
{ {
MXS_DEBUG("1 event for worker %d.", m_id); MXS_DEBUG("1 event for worker %d.", m_id);
MXS_POLL_DATA* pData = static_cast<MXS_POLL_DATA*>(epoll_events[0].data.ptr); MXB_POLL_DATA* pData = static_cast<MXB_POLL_DATA*>(epoll_events[0].data.ptr);
actions = pData->handler(pData, this, epoll_events[0].events); actions = pData->handler(pData, this, epoll_events[0].events);
} }

View File

@ -22,7 +22,6 @@
#include <sstream> #include <sstream>
#include <sys/timerfd.h> #include <sys/timerfd.h>
#include <maxbase/atomic.h>
#include <maxscale/log.h> #include <maxscale/log.h>
#define WORKER_ABSENT_ID -1 #define WORKER_ABSENT_ID -1
@ -181,8 +180,8 @@ WorkerTimer::WorkerTimer(Worker* pWorker)
: m_fd(create_timerfd()) : m_fd(create_timerfd())
, m_pWorker(pWorker) , m_pWorker(pWorker)
{ {
MXS_POLL_DATA::handler = handler; MXB_POLL_DATA::handler = handler;
MXS_POLL_DATA::owner = m_pWorker; MXB_POLL_DATA::owner = m_pWorker;
if (m_fd != -1) if (m_fd != -1)
{ {
@ -252,11 +251,11 @@ uint32_t WorkerTimer::handle(Worker* pWorker, uint32_t events)
tick(); tick();
return MXS_POLL_READ; return MXB_POLL_READ;
} }
//static //static
uint32_t WorkerTimer::handler(MXS_POLL_DATA* pThis, void* pWorker, uint32_t events) uint32_t WorkerTimer::handler(MXB_POLL_DATA* pThis, void* pWorker, uint32_t events)
{ {
return static_cast<WorkerTimer*>(pThis)->handle(static_cast<Worker*>(pWorker), events); return static_cast<WorkerTimer*>(pThis)->handle(static_cast<Worker*>(pWorker), events);
} }
@ -358,7 +357,7 @@ void Worker::get_descriptor_counts(uint32_t* pnCurrent, uint64_t* pnTotal)
*pnTotal = atomic_load_uint64(&m_nTotal_descriptors); *pnTotal = atomic_load_uint64(&m_nTotal_descriptors);
} }
bool Worker::add_fd(int fd, uint32_t events, MXS_POLL_DATA* pData) bool Worker::add_fd(int fd, uint32_t events, MXB_POLL_DATA* pData)
{ {
bool rv = true; bool rv = true;
@ -843,31 +842,31 @@ void Worker::poll_waitevents()
m_statistics.maxqtime = MXS_MAX(m_statistics.maxqtime, qtime); m_statistics.maxqtime = MXS_MAX(m_statistics.maxqtime, qtime);
MXS_POLL_DATA *data = (MXS_POLL_DATA*)events[i].data.ptr; MXB_POLL_DATA *data = (MXB_POLL_DATA*)events[i].data.ptr;
uint32_t actions = data->handler(data, this, events[i].events); uint32_t actions = data->handler(data, this, events[i].events);
if (actions & MXS_POLL_ACCEPT) if (actions & MXB_POLL_ACCEPT)
{ {
atomic_add_int64(&m_statistics.n_accept, 1); atomic_add_int64(&m_statistics.n_accept, 1);
} }
if (actions & MXS_POLL_READ) if (actions & MXB_POLL_READ)
{ {
atomic_add_int64(&m_statistics.n_read, 1); atomic_add_int64(&m_statistics.n_read, 1);
} }
if (actions & MXS_POLL_WRITE) if (actions & MXB_POLL_WRITE)
{ {
atomic_add_int64(&m_statistics.n_write, 1); atomic_add_int64(&m_statistics.n_write, 1);
} }
if (actions & MXS_POLL_HUP) if (actions & MXB_POLL_HUP)
{ {
atomic_add_int64(&m_statistics.n_hup, 1); atomic_add_int64(&m_statistics.n_hup, 1);
} }
if (actions & MXS_POLL_ERROR) if (actions & MXB_POLL_ERROR)
{ {
atomic_add_int64(&m_statistics.n_error, 1); atomic_add_int64(&m_statistics.n_error, 1);
} }

View File

@ -33,7 +33,7 @@ LocalClient::LocalClient(MYSQL_session* session, MySQLProtocol* proto, int fd):
m_protocol(*proto), m_protocol(*proto),
m_self_destruct(false) m_self_destruct(false)
{ {
MXS_POLL_DATA::handler = LocalClient::poll_handler; MXB_POLL_DATA::handler = LocalClient::poll_handler;
} }
LocalClient::~LocalClient() LocalClient::~LocalClient()
@ -225,7 +225,7 @@ void LocalClient::drain_queue()
} }
} }
uint32_t LocalClient::poll_handler(struct mxs_poll_data* data, void* worker, uint32_t events) uint32_t LocalClient::poll_handler(MXB_POLL_DATA* data, void* worker, uint32_t events)
{ {
LocalClient* client = static_cast<LocalClient*>(data); LocalClient* client = static_cast<LocalClient*>(data);
client->process(events); client->process(events);
@ -246,7 +246,7 @@ LocalClient* LocalClient::create(MYSQL_session* session, MySQLProtocol* proto, c
{ {
mxs::Worker* worker = mxs::Worker::get_current(); mxs::Worker* worker = mxs::Worker::get_current();
if (worker->add_fd(fd, poll_events, (MXS_POLL_DATA*)relay)) if (worker->add_fd(fd, poll_events, (MXB_POLL_DATA*)relay))
{ {
rval = relay; rval = relay;
} }