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:
counterpoint
2016-01-08 12:19:29 +00:00
parent 4461cd9398
commit fb5fdb17db
4 changed files with 9 additions and 11 deletions

View File

@ -489,9 +489,7 @@ dcb_process_zombies(int threadid)
else else
{ {
bitmask_clear(&zombiedcb->memdata.bitmask, threadid); if (bitmask_clear_without_spinlock(&zombiedcb->memdata.bitmask))
if (bitmask_isallclear(&zombiedcb->memdata.bitmask))
{ {
/** /**
* Remove the DCB from the zombie queue * Remove the DCB from the zombie queue

View File

@ -140,14 +140,14 @@ bitmask_set(GWBITMASK *bitmask, int bit)
* Note that this function does not lock the bitmask, but assumes that * 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 * 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 * 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 bitmask Pointer the bitmask
* @param bit Bit to clear * @param bit Bit to clear
* @return int 1 if the bitmask is all clear after the operation, else 0. * @return int 1 if the bitmask is all clear after the operation, else 0.
*/ */
int int
bitmask_clear(GWBITMASK *bitmask, int bit) bitmask_clear_without_spinlock(GWBITMASK *bitmask, int bit)
{ {
unsigned char *ptr = bitmask->bits; unsigned char *ptr = bitmask->bits;
int i; 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. * 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 bitmask Pointer the bitmask
* @param bit Bit to clear * @param bit Bit to clear
* @return int 1 if the bitmask is all clear after the operation, else 0 * @return int 1 if the bitmask is all clear after the operation, else 0
*/ */
int int
bitmask_clear_with_lock(GWBITMASK *bitmask, int bit) bitmask_clear(GWBITMASK *bitmask, int bit)
{ {
int result; int result;
spinlock_acquire(&bitmask->lock); spinlock_acquire(&bitmask->lock);
result = bitmask_clear(bitmask, bit); result = bitmask_clear_without_spinlock(bitmask, bit);
spinlock_release(&bitmask->lock); spinlock_release(&bitmask->lock);
return result; return result;
} }

View File

@ -725,7 +725,7 @@ poll_waitevents(void *arg)
{ {
thread_data[thread_id].state = THREAD_STOPPED; 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 */ /** Release mysql thread context */
mysql_thread_end(); mysql_thread_end();
return; return;

View File

@ -52,7 +52,7 @@ extern void bitmask_init(GWBITMASK *);
extern void bitmask_free(GWBITMASK *); extern void bitmask_free(GWBITMASK *);
extern void bitmask_set(GWBITMASK *, int); extern void bitmask_set(GWBITMASK *, int);
extern int bitmask_clear(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_isset(GWBITMASK *, int);
extern int bitmask_isallclear(GWBITMASK *); extern int bitmask_isallclear(GWBITMASK *);
extern void bitmask_copy(GWBITMASK *, GWBITMASK *); extern void bitmask_copy(GWBITMASK *, GWBITMASK *);