MXS-2410: Uniquely identify DCBs

The address alone doesn't guarantee validity of a DCB.
This commit is contained in:
Markus Mäkelä 2019-03-27 11:58:31 +02:00
parent 3448a36b68
commit 04f70879d2
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
2 changed files with 9 additions and 2 deletions

View File

@ -184,6 +184,8 @@ typedef struct dcb
uint32_t n_close; /** How many times dcb_close has been called. */
char *path; /** If a Unix socket, the path it was bound to. */
skygw_chk_t dcb_chk_tail;
uint64_t m_uid; /**< Unique identifier for this DCB */
} DCB;
/**

View File

@ -168,6 +168,8 @@ dcb_initialize(DCB *dcb)
*dcb = this_unit.dcb_initialized;
}
static uint64_t uid_generator = 0;
/**
* @brief Allocate a new DCB.
*
@ -196,6 +198,7 @@ dcb_alloc(dcb_role_t role, SERV_LISTENER *listener)
newdcb->dcb_role = role;
newdcb->listener = listener;
newdcb->last_read = hkheartbeat;
newdcb->m_uid = atomic_add_uint64(&uid_generator, 1);
if (role == DCB_ROLE_SERVICE_LISTENER)
{
@ -3223,13 +3226,14 @@ public:
FakeEventTask(DCB* dcb, GWBUF* buf, uint32_t ev):
m_dcb(dcb),
m_buffer(buf),
m_ev(ev)
m_ev(ev),
m_uid(dcb->m_uid)
{
}
void execute(Worker& worker)
{
if (dcb_is_still_valid(m_dcb, worker.get_current_id()))
if (dcb_is_still_valid(m_dcb, worker.get_current_id()) && m_dcb->m_uid == m_uid)
{
m_dcb->fakeq = m_buffer;
dcb_handler(m_dcb, m_ev);
@ -3244,6 +3248,7 @@ private:
DCB* m_dcb;
GWBUF* m_buffer;
uint32_t m_ev;
uint64_t m_uid; /**< DCB UID guarantees we deliver the event to the correct DCB */
};
static void poll_add_event_to_dcb(DCB* dcb, GWBUF* buf, uint32_t ev)