Add each DCB to the owning thread's list

Each DCB needs to be added to the owning thread's list so that they can be
iterated through. As sessions always have a client DCB, the sessions don't
need to be added to a similar per thread list.

This change fixes a problem with dcb_hangup_foreach that the removal of
the list manager introduced. Now the hangup events are properly injected
for the DCBs that connect to the server in question.
This commit is contained in:
Markus Makela
2016-11-20 10:17:04 +02:00
parent fe56e65903
commit 30927455ef
3 changed files with 144 additions and 91 deletions

View File

@ -278,6 +278,8 @@ typedef struct dcb
bool ssl_write_want_write; /*< Flag */
int dcb_port; /**< port of target server */
bool was_persistent; /**< Whether this DCB was in the persistent pool */
struct dcb *thr_next; /**< Next DCB in owning thread's list */
struct dcb *thr_tail; /**< Last DCB in owning thread's list */
skygw_chk_t dcb_chk_tail;
} DCB;
@ -288,7 +290,7 @@ typedef struct dcb
.cb_lock = SPINLOCK_INIT, .pollinlock = SPINLOCK_INIT, \
.fd = DCBFD_CLOSED, .stats = DCBSTATS_INIT, .ssl_state = SSL_HANDSHAKE_UNKNOWN, \
.state = DCB_STATE_ALLOC, .polloutlock = SPINLOCK_INIT, .dcb_chk_tail = CHK_NUM_DCB, \
.authenticator_data = NULL}
.authenticator_data = NULL, .thr_next = NULL, .thr_tail = NULL}
/**
* The DCB usage filer used for returning DCB's in use for a certain reason
@ -344,6 +346,13 @@ void dcb_close(DCB *);
*/
void dcb_process_zombies(int threadid);
/**
* Add a DCB to the owner's list
*
* @param dcb DCB to add
*/
void dcb_add_to_list(DCB *dcb);
void printAllDCBs(); /* Debug to print all DCB in the system */
void printDCB(DCB *); /* Debug print routine */
void dprintDCBList(DCB *); /* Debug print DCB list statistics */