MXS-1392 Manage DCB lifetime using refcounts

Now it is also possible to ensure that a DCB stays alive while
a task referring to it is posted from one worker to another.
That will be implemented in a subsequent commit.
This commit is contained in:
Johan Wikman
2017-09-07 16:59:37 +03:00
parent bf42d845cf
commit be94066b77
6 changed files with 102 additions and 16 deletions

View File

@ -216,7 +216,6 @@ void dcb_global_init();
int dcb_write(DCB *, GWBUF *);
DCB *dcb_accept(DCB *listener);
DCB *dcb_alloc(dcb_role_t, struct servlistener *);
void dcb_free_all_memory(DCB *dcb);
DCB *dcb_connect(struct server *, struct session *, const char *);
int dcb_read(DCB *, GWBUF **, int);
int dcb_drain_writeq(DCB *);

View File

@ -131,7 +131,8 @@ static inline void poll_inc_ref(MXS_POLL_DATA* 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 is the last user of the data.
* 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)
{

View File

@ -23,12 +23,14 @@ 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;
}
};