MXS-1378 Provide access to the current DCB in 2.1
Conceptually this is a cherry-pick of commit 67efd1daeabbc398b8a8fbc0cd02c2af26e4cb6c (2.2), but too much has changed to actually be able to cherry-pick that commit.
This commit is contained in:
@ -351,6 +351,14 @@ bool dcb_foreach(bool (*func)(DCB *, void *), void *data);
|
||||
*/
|
||||
int dcb_get_port(const DCB *dcb);
|
||||
|
||||
/**
|
||||
* @brief Return the DCB currently being handled by the calling thread.
|
||||
*
|
||||
* @return A DCB, or NULL if the calling thread is not currently handling
|
||||
* a DCB or if the calling thread is not a polling/worker thread.
|
||||
*/
|
||||
DCB* dcb_get_current();
|
||||
|
||||
/**
|
||||
* DCB flags values
|
||||
*/
|
||||
|
@ -49,6 +49,7 @@ extern unsigned long hkheartbeat;
|
||||
|
||||
int number_poll_spins;
|
||||
int max_poll_sleep;
|
||||
static thread_local DCB* current_dcb;
|
||||
|
||||
/**
|
||||
* @file poll.c - Abstraction of the epoll functionality
|
||||
@ -894,6 +895,7 @@ process_pollq(int thread_id, struct epoll_event *event)
|
||||
uint32_t ev = event->events;
|
||||
DCB *dcb = event->data.ptr;
|
||||
ss_dassert(dcb->thread.id == thread_id || dcb->dcb_role == DCB_ROLE_SERVICE_LISTENER);
|
||||
current_dcb = dcb; // thread local
|
||||
|
||||
/** Calculate event queue statistics */
|
||||
uint64_t started = hkheartbeat;
|
||||
@ -1086,6 +1088,8 @@ process_pollq(int thread_id, struct epoll_event *event)
|
||||
|
||||
ts_stats_set_max(queueStats.maxexectime, qtime, thread_id);
|
||||
|
||||
current_dcb = NULL; // thread local
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1661,3 +1665,8 @@ static void poll_check_message()
|
||||
poll_msg[thread_id] &= ~POLL_MSG_CLEAN_PERSISTENT;
|
||||
}
|
||||
}
|
||||
|
||||
DCB* dcb_get_current()
|
||||
{
|
||||
return current_dcb;
|
||||
}
|
||||
|
Reference in New Issue
Block a user