Switch bitmask_clear to be locking and offer bitmask_clear_without_spinlock for non-locking version, in response to review comments. Revert poll.c to use bitmask_clear (with locking) and amend dcb.c to use the non-locking version and to take advantage of the return of an indication of whether the whole bitmask is then clearn.
This commit is contained in:
@ -489,9 +489,7 @@ dcb_process_zombies(int threadid)
|
||||
else
|
||||
{
|
||||
|
||||
bitmask_clear(&zombiedcb->memdata.bitmask, threadid);
|
||||
|
||||
if (bitmask_isallclear(&zombiedcb->memdata.bitmask))
|
||||
if (bitmask_clear_without_spinlock(&zombiedcb->memdata.bitmask))
|
||||
{
|
||||
/**
|
||||
* Remove the DCB from the zombie queue
|
||||
|
@ -140,14 +140,14 @@ bitmask_set(GWBITMASK *bitmask, int bit)
|
||||
* Note that this function does not lock the bitmask, but assumes that
|
||||
* it is under the exclusive control of the caller. If you want to use the
|
||||
* bitmask spinlock to protect access while clearing the bit, then call
|
||||
* the alternative bitmask_clear_with_lock.
|
||||
* the alternative bitmask_clear.
|
||||
*
|
||||
* @param bitmask Pointer the bitmask
|
||||
* @param bit Bit to clear
|
||||
* @return int 1 if the bitmask is all clear after the operation, else 0.
|
||||
*/
|
||||
int
|
||||
bitmask_clear(GWBITMASK *bitmask, int bit)
|
||||
bitmask_clear_without_spinlock(GWBITMASK *bitmask, int bit)
|
||||
{
|
||||
unsigned char *ptr = bitmask->bits;
|
||||
int i;
|
||||
@ -174,19 +174,19 @@ bitmask_clear(GWBITMASK *bitmask, int bit)
|
||||
|
||||
/**
|
||||
* Clear the bit at the specified bit position in the bitmask using a spinlock.
|
||||
* See bitmask_clear for more details
|
||||
* See bitmask_clear_without_spinlock for more details
|
||||
*
|
||||
* @param bitmask Pointer the bitmask
|
||||
* @param bit Bit to clear
|
||||
* @return int 1 if the bitmask is all clear after the operation, else 0
|
||||
*/
|
||||
int
|
||||
bitmask_clear_with_lock(GWBITMASK *bitmask, int bit)
|
||||
bitmask_clear(GWBITMASK *bitmask, int bit)
|
||||
{
|
||||
int result;
|
||||
|
||||
spinlock_acquire(&bitmask->lock);
|
||||
result = bitmask_clear(bitmask, bit);
|
||||
result = bitmask_clear_without_spinlock(bitmask, bit);
|
||||
spinlock_release(&bitmask->lock);
|
||||
return result;
|
||||
}
|
||||
|
@ -725,7 +725,7 @@ poll_waitevents(void *arg)
|
||||
{
|
||||
thread_data[thread_id].state = THREAD_STOPPED;
|
||||
}
|
||||
bitmask_clear_with_lock(&poll_mask, thread_id);
|
||||
bitmask_clear(&poll_mask, thread_id);
|
||||
/** Release mysql thread context */
|
||||
mysql_thread_end();
|
||||
return;
|
||||
|
@ -52,7 +52,7 @@ extern void bitmask_init(GWBITMASK *);
|
||||
extern void bitmask_free(GWBITMASK *);
|
||||
extern void bitmask_set(GWBITMASK *, int);
|
||||
extern int bitmask_clear(GWBITMASK *, int);
|
||||
extern int bitmask_clear_with_lock(GWBITMASK *, int);
|
||||
extern int bitmask_clear_without_spinlock(GWBITMASK *, int);
|
||||
extern int bitmask_isset(GWBITMASK *, int);
|
||||
extern int bitmask_isallclear(GWBITMASK *);
|
||||
extern void bitmask_copy(GWBITMASK *, GWBITMASK *);
|
||||
|
Reference in New Issue
Block a user