MXS-1392 Remove remnats of DCB reference counting
This commit is contained in:
@ -46,23 +46,9 @@ struct mxs_poll_data;
|
||||
*/
|
||||
typedef uint32_t (*mxs_poll_handler_t)(struct mxs_poll_data* data, int wid, uint32_t events);
|
||||
|
||||
/**
|
||||
* Pointer to function that knows how to free a particular
|
||||
* 'struct mxs_poll_data' structure
|
||||
*
|
||||
* @param data The `mxs_poll_data` instance that contained this function pointer.
|
||||
*/
|
||||
typedef void (*mxs_poll_free_t)(struct mxs_poll_data* data);
|
||||
|
||||
typedef struct mxs_poll_data
|
||||
{
|
||||
mxs_poll_handler_t handler; /*< Handler for this particular kind of mxs_poll_data. */
|
||||
mxs_poll_free_t free; /*< Optional free function for mxs_poll_data. */
|
||||
uint32_t refcount; /*< Reference count, optionally used. If 'free' is provided,
|
||||
refcount will be incremented before events are delivered
|
||||
to the handler and decremented after. If reaches 0, then
|
||||
the free function is called.
|
||||
*/
|
||||
struct
|
||||
{
|
||||
int id; /*< The id of the worker thread. */
|
||||
@ -115,28 +101,4 @@ bool poll_add_fd_to_worker(int wid, int fd, uint32_t events, MXS_POLL_DATA* data
|
||||
*/
|
||||
bool poll_remove_fd_from_worker(int wid, int fd);
|
||||
|
||||
/**
|
||||
* Increase the reference count of the poll data.
|
||||
*
|
||||
* @param data The poll data whose reference count should be increased.
|
||||
*/
|
||||
static inline void poll_inc_ref(MXS_POLL_DATA* data)
|
||||
{
|
||||
atomic_add_uint32(&data->refcount, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrease the reference count of the poll data.
|
||||
*
|
||||
* @param data The poll data whose reference count should be decreased.
|
||||
*
|
||||
* @return The previous reference count. If the returned value is 1, then
|
||||
* the caller should call @c data->free(data) to dispose of the
|
||||
* poll data.
|
||||
*/
|
||||
static inline uint32_t poll_dec_ref(MXS_POLL_DATA* data)
|
||||
{
|
||||
return atomic_add_uint32(&data->refcount, -1);
|
||||
}
|
||||
|
||||
MXS_END_DECLS
|
||||
|
@ -23,14 +23,12 @@ struct MxsPollData : MXS_POLL_DATA
|
||||
MxsPollData()
|
||||
{
|
||||
handler = NULL;
|
||||
free = NULL;
|
||||
thread.id = 0;
|
||||
}
|
||||
|
||||
MxsPollData(mxs_poll_handler_t h)
|
||||
{
|
||||
handler = h;
|
||||
free = NULL;
|
||||
thread.id = 0;
|
||||
}
|
||||
};
|
||||
|
@ -122,12 +122,6 @@ static uint32_t dcb_poll_handler(MXS_POLL_DATA *data, int thread_id, 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 void poll_dcb_free(MXS_POLL_DATA* data)
|
||||
{
|
||||
// MXS_POLL_DATA is the first member of DCB.
|
||||
dcb_free_all_memory(reinterpret_cast<DCB*>(data));
|
||||
}
|
||||
|
||||
void dcb_global_init()
|
||||
{
|
||||
this_unit.dcb_initialized.dcb_chk_top = CHK_NUM_DCB;
|
||||
@ -135,8 +129,6 @@ void dcb_global_init()
|
||||
this_unit.dcb_initialized.state = DCB_STATE_ALLOC;
|
||||
this_unit.dcb_initialized.ssl_state = SSL_HANDSHAKE_UNKNOWN;
|
||||
this_unit.dcb_initialized.poll.handler = dcb_poll_handler;
|
||||
this_unit.dcb_initialized.poll.free = poll_dcb_free;
|
||||
this_unit.dcb_initialized.poll.refcount = 1;
|
||||
this_unit.dcb_initialized.dcb_chk_tail = CHK_NUM_DCB;
|
||||
|
||||
int nthreads = config_threadcount();
|
||||
|
@ -19,58 +19,4 @@ MXS_BEGIN_DECLS
|
||||
void dcb_free_all_memory(DCB *dcb);
|
||||
void dcb_final_close(DCB *dcb);
|
||||
|
||||
/**
|
||||
* @brief Increase the reference count of the DCB
|
||||
*
|
||||
* @param dcb The dcb whose reference count should be increased.
|
||||
*/
|
||||
static inline void dcb_inc_ref(DCB* dcb)
|
||||
{
|
||||
// A DCB starts out with a refcount of 1.
|
||||
ss_dassert(dcb->poll.refcount >= 1);
|
||||
|
||||
poll_inc_ref(&dcb->poll);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decrease the reference count of the DCB. If it reaches 0,
|
||||
* the DCB will be freed.
|
||||
*
|
||||
* @param dcb The dcb whose reference count should be decreased.
|
||||
*
|
||||
* @return True, if the dcb is still usable after the call, otherwise false.
|
||||
*
|
||||
* @note If the function returns false, the caller cannot use the dcb
|
||||
* for anything.
|
||||
*/
|
||||
static inline bool dcb_dec_ref(DCB* dcb)
|
||||
{
|
||||
// A DCB starts out with a refcount of 1.
|
||||
ss_dassert(dcb->poll.refcount >= 1);
|
||||
|
||||
bool rv = true;
|
||||
if (poll_dec_ref(&dcb->poll) == 1)
|
||||
{
|
||||
dcb_free_all_memory(dcb);
|
||||
rv = false;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increase the reference count of the DCB.
|
||||
*
|
||||
* Convenience function for the situation where a received dcb is stored
|
||||
* and the reference count needs to be increased.
|
||||
*
|
||||
* @param dcb The dcb whose reference count should be increased.
|
||||
*
|
||||
* @return The dcb provided as argument.
|
||||
*/
|
||||
static inline DCB* dcb_get_ref(DCB* dcb)
|
||||
{
|
||||
dcb_inc_ref(dcb);
|
||||
return dcb;
|
||||
}
|
||||
|
||||
MXS_END_DECLS
|
||||
|
@ -163,8 +163,6 @@ Worker::Worker(int id,
|
||||
, m_shutdown_initiated(false)
|
||||
{
|
||||
MXS_POLL_DATA::handler = &Worker::epoll_instance_handler;
|
||||
MXS_POLL_DATA::free = NULL;
|
||||
MXS_POLL_DATA::refcount = 0;
|
||||
MXS_POLL_DATA::thread.id = id;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user