Remove bitmask.h & .c, since the container is no longer used
This commit is contained in:
@ -1,52 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2016 MariaDB Corporation Ab
|
|
||||||
*
|
|
||||||
* Use of this software is governed by the Business Source License included
|
|
||||||
* in the LICENSE.TXT file and at www.mariadb.com/bsl.
|
|
||||||
*
|
|
||||||
* Change Date: 2019-07-01
|
|
||||||
*
|
|
||||||
* On the date above, in accordance with the Business Source License, use
|
|
||||||
* of this software will be governed by version 2 or later of the General
|
|
||||||
* Public License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file bitmask.h An implementation of an arbitrarily long bitmask
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <maxscale/cdefs.h>
|
|
||||||
|
|
||||||
#include <maxscale/limits.h>
|
|
||||||
#include <maxscale/spinlock.h>
|
|
||||||
|
|
||||||
MXS_BEGIN_DECLS
|
|
||||||
|
|
||||||
/* This number MUST an be exact multiple of 8 */
|
|
||||||
#define MXS_BITMASK_LENGTH (MXS_MAX_THREADS + 1) /**< Number of bits in the bitmask */
|
|
||||||
|
|
||||||
#define MXS_BITMASK_SIZE (MXS_BITMASK_LENGTH / 8) /**< Number of bytes in the bitmask */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The bitmask structure used to store a fixed size bitmask
|
|
||||||
*/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
SPINLOCK lock; /**< Lock to protect the bitmask */
|
|
||||||
unsigned char bits[MXS_BITMASK_SIZE]; /**< The bits themselves */
|
|
||||||
} MXS_BITMASK;
|
|
||||||
|
|
||||||
#define MXS_BITMASK_INIT {SPINLOCK_INIT}
|
|
||||||
|
|
||||||
void bitmask_init(MXS_BITMASK *);
|
|
||||||
void bitmask_free(MXS_BITMASK *);
|
|
||||||
int bitmask_set(MXS_BITMASK *, int);
|
|
||||||
int bitmask_clear(MXS_BITMASK *, int);
|
|
||||||
int bitmask_clear_without_spinlock(MXS_BITMASK *, int);
|
|
||||||
int bitmask_isset(MXS_BITMASK *, int);
|
|
||||||
int bitmask_isallclear(MXS_BITMASK *);
|
|
||||||
void bitmask_copy(MXS_BITMASK *, MXS_BITMASK *);
|
|
||||||
char *bitmask_render_readable(MXS_BITMASK *);
|
|
||||||
|
|
||||||
MXS_END_DECLS
|
|
@ -52,7 +52,6 @@
|
|||||||
#include <maxscale/authenticator.h>
|
#include <maxscale/authenticator.h>
|
||||||
#include <maxscale/ssl.h>
|
#include <maxscale/ssl.h>
|
||||||
#include <maxscale/modinfo.h>
|
#include <maxscale/modinfo.h>
|
||||||
#include <maxscale/bitmask.h>
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
|
||||||
MXS_BEGIN_DECLS
|
MXS_BEGIN_DECLS
|
||||||
@ -130,11 +129,10 @@ typedef struct dcbstats
|
|||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
MXS_BITMASK bitmask; /*< The bitmask of threads */
|
|
||||||
struct dcb *next; /*< Next pointer for the zombie list */
|
struct dcb *next; /*< Next pointer for the zombie list */
|
||||||
} DCBMM;
|
} DCBMM;
|
||||||
|
|
||||||
#define DCBMM_INIT {MXS_BITMASK_INIT}
|
#define DCBMM_INIT { NULL }
|
||||||
|
|
||||||
/* DCB states */
|
/* DCB states */
|
||||||
typedef enum
|
typedef enum
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
add_library(maxscale-common SHARED adminusers.c alloc.c authenticator.c atomic.c buffer.c config.c config_runtime.c dcb.c filter.c filter.cc externcmd.c bitmask.c paths.c hashtable.c hint.c housekeeper.c load_utils.c log_manager.cc maxscale_pcre2.c memlog.c misc.c mlist.c modutil.c monitor.c queuemanager.c query_classifier.c poll.c random_jkiss.c resultset.c secrets.c server.c service.c session.c spinlock.c thread.c users.c utils.c skygw_utils.cc statistics.c listener.c ssl.c mysql_utils.c mysql_binlog.c modulecmd.c )
|
add_library(maxscale-common SHARED adminusers.c alloc.c authenticator.c atomic.c buffer.c config.c config_runtime.c dcb.c filter.c filter.cc externcmd.c paths.c hashtable.c hint.c housekeeper.c load_utils.c log_manager.cc maxscale_pcre2.c memlog.c misc.c mlist.c modutil.c monitor.c queuemanager.c query_classifier.c poll.c random_jkiss.c resultset.c secrets.c server.c service.c session.c spinlock.c thread.c users.c utils.c skygw_utils.cc statistics.c listener.c ssl.c mysql_utils.c mysql_binlog.c modulecmd.c )
|
||||||
|
|
||||||
target_link_libraries(maxscale-common ${MARIADB_CONNECTOR_LIBRARIES} ${LZMA_LINK_FLAGS} ${PCRE2_LIBRARIES} ${CURL_LIBRARIES} ssl pthread crypt dl crypto inih z rt m stdc++)
|
target_link_libraries(maxscale-common ${MARIADB_CONNECTOR_LIBRARIES} ${LZMA_LINK_FLAGS} ${PCRE2_LIBRARIES} ${CURL_LIBRARIES} ssl pthread crypt dl crypto inih z rt m stdc++)
|
||||||
|
|
||||||
|
@ -1,331 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016 MariaDB Corporation Ab
|
|
||||||
*
|
|
||||||
* Use of this software is governed by the Business Source License included
|
|
||||||
* in the LICENSE.TXT file and at www.mariadb.com/bsl.
|
|
||||||
*
|
|
||||||
* Change Date: 2019-07-01
|
|
||||||
*
|
|
||||||
* On the date above, in accordance with the Business Source License, use
|
|
||||||
* of this software will be governed by version 2 or later of the General
|
|
||||||
* Public License.
|
|
||||||
*/
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <maxscale/bitmask.h>
|
|
||||||
#include <maxscale/alloc.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file bitmask.c Implementation of bitmask operations for the gateway
|
|
||||||
*
|
|
||||||
* MXS_BITMASK is a fixed size bitmask with space for 256 bits.
|
|
||||||
*
|
|
||||||
* @verbatim
|
|
||||||
* Revision History
|
|
||||||
*
|
|
||||||
* Date Who Description
|
|
||||||
* 28/06/13 Mark Riddoch Initial implementation
|
|
||||||
* 20/08/15 Martin Brampton Added caveats about limitations (above)
|
|
||||||
* 17/10/15 Martin Brampton Added display of bitmask
|
|
||||||
* 04/01/16 Martin Brampton Changed bitmask_clear to not lock and return
|
|
||||||
* whether bitmask is clear; added bitmask_clear_with_lock.
|
|
||||||
*
|
|
||||||
* @endverbatim
|
|
||||||
*/
|
|
||||||
|
|
||||||
static int bitmask_isset_without_spinlock(MXS_BITMASK *bitmask, int bit);
|
|
||||||
static int bitmask_count_bits_set(MXS_BITMASK *bitmask);
|
|
||||||
|
|
||||||
static const unsigned char bitmapclear[8] =
|
|
||||||
{
|
|
||||||
255 - 1, 255 - 2, 255 - 4, 255 - 8, 255 - 16, 255 - 32, 255 - 64, 255 - 128
|
|
||||||
};
|
|
||||||
static const unsigned char bitmapset[8] =
|
|
||||||
{
|
|
||||||
1, 2, 4, 8, 16, 32, 64, 128
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialise a bitmask
|
|
||||||
*
|
|
||||||
* @param bitmask Pointer the bitmask
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
bitmask_init(MXS_BITMASK *bitmask)
|
|
||||||
{
|
|
||||||
spinlock_init(&bitmask->lock);
|
|
||||||
memset(bitmask->bits, 0, MXS_BITMASK_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Free a bitmask that is no longer required
|
|
||||||
*
|
|
||||||
* @param bitmask
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
bitmask_free(MXS_BITMASK *bitmask)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the bit at the specified bit position in the bitmask.
|
|
||||||
*
|
|
||||||
* @param bitmask Pointer the bitmask
|
|
||||||
* @param bit Bit to set
|
|
||||||
* @return 1 if the bit could be set, 0 otherwise.
|
|
||||||
* Setting a bit may fail only if the bit exceeds
|
|
||||||
* the maximum length of the bitmask.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
bitmask_set(MXS_BITMASK *bitmask, int bit)
|
|
||||||
{
|
|
||||||
ss_dassert(bit >= 0);
|
|
||||||
|
|
||||||
spinlock_acquire(&bitmask->lock);
|
|
||||||
|
|
||||||
if (bit < MXS_BITMASK_LENGTH)
|
|
||||||
{
|
|
||||||
unsigned char *ptr = bitmask->bits;
|
|
||||||
|
|
||||||
if (bit >= 8)
|
|
||||||
{
|
|
||||||
ptr += (bit / 8);
|
|
||||||
bit = bit % 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
*ptr |= bitmapset[bit];
|
|
||||||
}
|
|
||||||
|
|
||||||
spinlock_release(&bitmask->lock);
|
|
||||||
|
|
||||||
return bit < MXS_BITMASK_LENGTH;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clear the bit at the specified bit position in the bitmask.
|
|
||||||
* Bits beyond the bitmask length are always assumed to be clear, so no
|
|
||||||
* action is needed if the bit parameter is beyond the length.
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* @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_without_spinlock(MXS_BITMASK *bitmask, int bit)
|
|
||||||
{
|
|
||||||
ss_dassert(bit >= 0);
|
|
||||||
|
|
||||||
unsigned char *ptr = bitmask->bits;
|
|
||||||
|
|
||||||
if (bit < MXS_BITMASK_LENGTH)
|
|
||||||
{
|
|
||||||
if (bit >= 8)
|
|
||||||
{
|
|
||||||
ptr += (bit / 8);
|
|
||||||
bit = bit % 8;
|
|
||||||
}
|
|
||||||
*ptr &= bitmapclear[bit];
|
|
||||||
}
|
|
||||||
ptr = bitmask->bits;
|
|
||||||
for (int i = 0; i < MXS_BITMASK_SIZE; i++)
|
|
||||||
{
|
|
||||||
if (*(ptr + i) != 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clear the bit at the specified bit position in the bitmask using a spinlock.
|
|
||||||
* 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(MXS_BITMASK *bitmask, int bit)
|
|
||||||
{
|
|
||||||
int result;
|
|
||||||
|
|
||||||
spinlock_acquire(&bitmask->lock);
|
|
||||||
result = bitmask_clear_without_spinlock(bitmask, bit);
|
|
||||||
spinlock_release(&bitmask->lock);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a non-zero value if the bit at the specified bit
|
|
||||||
* position in the bitmask is set. If the specified bit is outside the
|
|
||||||
* bitmask, it is assumed to be unset; the bitmask is not extended.
|
|
||||||
* This function wraps bitmask_isset_without_spinlock with a spinlock.
|
|
||||||
*
|
|
||||||
* @param bitmask Pointer the bitmask
|
|
||||||
* @param bit Bit to test
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
bitmask_isset(MXS_BITMASK *bitmask, int bit)
|
|
||||||
{
|
|
||||||
int result;
|
|
||||||
|
|
||||||
spinlock_acquire(&bitmask->lock);
|
|
||||||
result = bitmask_isset_without_spinlock(bitmask, bit);
|
|
||||||
spinlock_release(&bitmask->lock);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a non-zero value if the bit at the specified bit
|
|
||||||
* position in the bitmask is set. Should be called while holding a
|
|
||||||
* lock on the bitmask or having control of it in some other way.
|
|
||||||
*
|
|
||||||
* Bits beyond the current length are deemed unset.
|
|
||||||
*
|
|
||||||
* @param bitmask Pointer the bitmask
|
|
||||||
* @param bit Bit to test
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
bitmask_isset_without_spinlock(MXS_BITMASK *bitmask, int bit)
|
|
||||||
{
|
|
||||||
ss_dassert(bit >= 0);
|
|
||||||
|
|
||||||
if (bit >= MXS_BITMASK_LENGTH)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned char *ptr = bitmask->bits;
|
|
||||||
|
|
||||||
if (bit >= 8)
|
|
||||||
{
|
|
||||||
ptr += (bit / 8);
|
|
||||||
bit = bit % 8;
|
|
||||||
}
|
|
||||||
return *ptr & bitmapset[bit];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a non-zero value of the bitmask has no bits set
|
|
||||||
* in it. This logic could be defeated if the bitmask is a
|
|
||||||
* copy and there was insufficient memory when the copy was
|
|
||||||
* made.
|
|
||||||
*
|
|
||||||
* @param bitmask Pointer the bitmask
|
|
||||||
* @return Non-zero if the bitmask has no bits set
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
bitmask_isallclear(MXS_BITMASK *bitmask)
|
|
||||||
{
|
|
||||||
unsigned char *ptr = bitmask->bits;
|
|
||||||
int result = 1;
|
|
||||||
|
|
||||||
spinlock_acquire(&bitmask->lock);
|
|
||||||
for (int i = 0; i < MXS_BITMASK_SIZE; i++)
|
|
||||||
{
|
|
||||||
if (*(ptr + i) != 0)
|
|
||||||
{
|
|
||||||
result = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
spinlock_release(&bitmask->lock);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy the contents of one bitmap to another.
|
|
||||||
*
|
|
||||||
* @param dest Bitmap tp update
|
|
||||||
* @param src Bitmap to copy
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
bitmask_copy(MXS_BITMASK *dest, MXS_BITMASK *src)
|
|
||||||
{
|
|
||||||
spinlock_acquire(&src->lock);
|
|
||||||
spinlock_acquire(&dest->lock);
|
|
||||||
memcpy(dest->bits, src->bits, MXS_BITMASK_SIZE);
|
|
||||||
spinlock_release(&dest->lock);
|
|
||||||
spinlock_release(&src->lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a comma separated list of the numbers of the bits that are set in
|
|
||||||
* a bitmask, numbering starting at zero. The returned string must be
|
|
||||||
* freed by the caller (unless it is null on account of memory allocation
|
|
||||||
* failure).
|
|
||||||
*
|
|
||||||
* @param bitmask Bitmap to make readable
|
|
||||||
* @return pointer to the newly allocated string, or null if no memory
|
|
||||||
*/
|
|
||||||
char *
|
|
||||||
bitmask_render_readable(MXS_BITMASK *bitmask)
|
|
||||||
{
|
|
||||||
static const char empty[] = "No bits are set";
|
|
||||||
char *result;
|
|
||||||
|
|
||||||
spinlock_acquire(&bitmask->lock);
|
|
||||||
int count_set = bitmask_count_bits_set(bitmask);
|
|
||||||
if (count_set)
|
|
||||||
{
|
|
||||||
result = MXS_MALLOC(1 + (4 * count_set));
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
result[0] = 0;
|
|
||||||
for (int i = 0; i < MXS_BITMASK_LENGTH; i++)
|
|
||||||
{
|
|
||||||
if (bitmask_isset_without_spinlock(bitmask, i))
|
|
||||||
{
|
|
||||||
char onebit[5];
|
|
||||||
sprintf(onebit, "%d,", i);
|
|
||||||
strcat(result, onebit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result[strlen(result) - 1] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result = MXS_MALLOC(sizeof(empty));
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
strcpy(result, empty);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
spinlock_release(&bitmask->lock);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a count of the number of bits set in a bitmask. Helpful for setting
|
|
||||||
* the size of string needed to show the set bits in readable form.
|
|
||||||
*
|
|
||||||
* @param bitmask Bitmap whose bits are to be counted
|
|
||||||
* @return int Number of set bits
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
bitmask_count_bits_set(MXS_BITMASK *bitmask)
|
|
||||||
{
|
|
||||||
static const unsigned char oneBits[] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4};
|
|
||||||
unsigned char partresults;
|
|
||||||
int result = 0;
|
|
||||||
unsigned char *ptr, *eptr;
|
|
||||||
|
|
||||||
ptr = bitmask->bits;
|
|
||||||
eptr = ptr + MXS_BITMASK_SIZE;
|
|
||||||
while (ptr < eptr)
|
|
||||||
{
|
|
||||||
partresults = oneBits[*ptr & 0x0f];
|
|
||||||
partresults += oneBits[*ptr >> 4];
|
|
||||||
result += partresults;
|
|
||||||
ptr++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
@ -79,6 +79,7 @@
|
|||||||
#include <maxscale/router.h>
|
#include <maxscale/router.h>
|
||||||
#include <maxscale/poll.h>
|
#include <maxscale/poll.h>
|
||||||
#include <maxscale/atomic.h>
|
#include <maxscale/atomic.h>
|
||||||
|
#include <maxscale/limits.h>
|
||||||
#include <maxscale/log_manager.h>
|
#include <maxscale/log_manager.h>
|
||||||
#include <maxscale/hashtable.h>
|
#include <maxscale/hashtable.h>
|
||||||
#include <maxscale/listener.h>
|
#include <maxscale/listener.h>
|
||||||
@ -208,7 +209,6 @@ static void
|
|||||||
dcb_initialize(void *dcb)
|
dcb_initialize(void *dcb)
|
||||||
{
|
{
|
||||||
*(DCB *)dcb = dcb_initialized;
|
*(DCB *)dcb = dcb_initialized;
|
||||||
bitmask_init(&((DCB *)dcb)->memdata.bitmask);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -441,7 +441,6 @@ dcb_free_all_memory(DCB *dcb)
|
|||||||
{
|
{
|
||||||
SSL_free(dcb->ssl);
|
SSL_free(dcb->ssl);
|
||||||
}
|
}
|
||||||
bitmask_free(&dcb->memdata.bitmask);
|
|
||||||
|
|
||||||
/* We never free the actual DCB, it is available for reuse*/
|
/* We never free the actual DCB, it is available for reuse*/
|
||||||
MXS_FREE(dcb);
|
MXS_FREE(dcb);
|
||||||
@ -1902,15 +1901,6 @@ dprintOneDCB(DCB *pdcb, DCB *dcb)
|
|||||||
dcb_printf(pdcb, "\tRole: %s\n", rolename);
|
dcb_printf(pdcb, "\tRole: %s\n", rolename);
|
||||||
MXS_FREE(rolename);
|
MXS_FREE(rolename);
|
||||||
}
|
}
|
||||||
if (!bitmask_isallclear(&dcb->memdata.bitmask))
|
|
||||||
{
|
|
||||||
char *bitmasktext = bitmask_render_readable(&dcb->memdata.bitmask);
|
|
||||||
if (bitmasktext)
|
|
||||||
{
|
|
||||||
dcb_printf(pdcb, "\tBitMask: %s\n", bitmasktext);
|
|
||||||
MXS_FREE(bitmasktext);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dcb_printf(pdcb, "\tStatistics:\n");
|
dcb_printf(pdcb, "\tStatistics:\n");
|
||||||
dcb_printf(pdcb, "\t\tNo. of Reads: %d\n", dcb->stats.n_reads);
|
dcb_printf(pdcb, "\t\tNo. of Reads: %d\n", dcb->stats.n_reads);
|
||||||
dcb_printf(pdcb, "\t\tNo. of Writes: %d\n", dcb->stats.n_writes);
|
dcb_printf(pdcb, "\t\tNo. of Writes: %d\n", dcb->stats.n_writes);
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
#include <maxscale/poll.h>
|
#include <maxscale/poll.h>
|
||||||
|
|
||||||
#include <maxscale/bitmask.h>
|
|
||||||
#include <maxscale/resultset.h>
|
#include <maxscale/resultset.h>
|
||||||
|
|
||||||
MXS_BEGIN_DECLS
|
MXS_BEGIN_DECLS
|
||||||
@ -58,7 +57,6 @@ void dShowThreads(DCB *dcb);
|
|||||||
void dShowEventQ(DCB *dcb);
|
void dShowEventQ(DCB *dcb);
|
||||||
void dShowEventStats(DCB *dcb);
|
void dShowEventStats(DCB *dcb);
|
||||||
|
|
||||||
MXS_BITMASK *poll_bitmask();
|
|
||||||
int poll_get_stat(POLL_STAT stat);
|
int poll_get_stat(POLL_STAT stat);
|
||||||
RESULTSET *eventTimesGetList();
|
RESULTSET *eventTimesGetList();
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
|
|
||||||
#include <maxscale/alloc.h>
|
#include <maxscale/alloc.h>
|
||||||
#include <maxscale/atomic.h>
|
#include <maxscale/atomic.h>
|
||||||
#include <maxscale/bitmask.h>
|
|
||||||
#include <maxscale/config.h>
|
#include <maxscale/config.h>
|
||||||
#include <maxscale/dcb.h>
|
#include <maxscale/dcb.h>
|
||||||
#include <maxscale/housekeeper.h>
|
#include <maxscale/housekeeper.h>
|
||||||
@ -105,7 +104,6 @@ static int next_epoll_fd = 0; /*< Which thread handles the next DCB */
|
|||||||
static fake_event_t **fake_events; /*< Thread-specific fake event queue */
|
static fake_event_t **fake_events; /*< Thread-specific fake event queue */
|
||||||
static SPINLOCK *fake_event_lock;
|
static SPINLOCK *fake_event_lock;
|
||||||
static int do_shutdown = 0; /*< Flag the shutdown of the poll subsystem */
|
static int do_shutdown = 0; /*< Flag the shutdown of the poll subsystem */
|
||||||
static MXS_BITMASK poll_mask;
|
|
||||||
|
|
||||||
/** Poll cross-thread messaging variables */
|
/** Poll cross-thread messaging variables */
|
||||||
static volatile int *poll_msg;
|
static volatile int *poll_msg;
|
||||||
@ -273,7 +271,6 @@ poll_init()
|
|||||||
|
|
||||||
memset(&pollStats, 0, sizeof(pollStats));
|
memset(&pollStats, 0, sizeof(pollStats));
|
||||||
memset(&queueStats, 0, sizeof(queueStats));
|
memset(&queueStats, 0, sizeof(queueStats));
|
||||||
bitmask_init(&poll_mask);
|
|
||||||
thread_data = (THREAD_DATA *)MXS_MALLOC(n_threads * sizeof(THREAD_DATA));
|
thread_data = (THREAD_DATA *)MXS_MALLOC(n_threads * sizeof(THREAD_DATA));
|
||||||
if (thread_data)
|
if (thread_data)
|
||||||
{
|
{
|
||||||
@ -676,8 +673,6 @@ poll_waitevents(void *arg)
|
|||||||
thread_id = (intptr_t)arg;
|
thread_id = (intptr_t)arg;
|
||||||
int poll_spins = 0;
|
int poll_spins = 0;
|
||||||
|
|
||||||
/** Add this thread to the bitmask of running polling threads */
|
|
||||||
bitmask_set(&poll_mask, thread_id);
|
|
||||||
if (thread_data)
|
if (thread_data)
|
||||||
{
|
{
|
||||||
thread_data[thread_id].state = THREAD_IDLE;
|
thread_data[thread_id].state = THREAD_IDLE;
|
||||||
@ -849,7 +844,6 @@ poll_waitevents(void *arg)
|
|||||||
{
|
{
|
||||||
thread_data[thread_id].state = THREAD_STOPPED;
|
thread_data[thread_id].state = THREAD_STOPPED;
|
||||||
}
|
}
|
||||||
bitmask_clear(&poll_mask, thread_id);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (thread_data)
|
if (thread_data)
|
||||||
@ -1190,17 +1184,6 @@ poll_shutdown()
|
|||||||
do_shutdown = 1;
|
do_shutdown = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the bitmask of polling threads
|
|
||||||
*
|
|
||||||
* @return The bitmask of the running polling threads
|
|
||||||
*/
|
|
||||||
MXS_BITMASK *
|
|
||||||
poll_bitmask()
|
|
||||||
{
|
|
||||||
return &poll_mask;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display an entry from the spinlock statistics data
|
* Display an entry from the spinlock statistics data
|
||||||
*
|
*
|
||||||
|
@ -2,7 +2,6 @@ add_executable(test_adminusers testadminusers.c)
|
|||||||
add_executable(test_buffer testbuffer.c)
|
add_executable(test_buffer testbuffer.c)
|
||||||
add_executable(test_dcb testdcb.c)
|
add_executable(test_dcb testdcb.c)
|
||||||
add_executable(test_filter testfilter.c)
|
add_executable(test_filter testfilter.c)
|
||||||
add_executable(test_gwbitmask testgwbitmask.c)
|
|
||||||
add_executable(test_hash testhash.c)
|
add_executable(test_hash testhash.c)
|
||||||
add_executable(test_hint testhint.c)
|
add_executable(test_hint testhint.c)
|
||||||
add_executable(test_log testlog.c)
|
add_executable(test_log testlog.c)
|
||||||
@ -24,7 +23,6 @@ target_link_libraries(test_adminusers maxscale-common)
|
|||||||
target_link_libraries(test_buffer maxscale-common)
|
target_link_libraries(test_buffer maxscale-common)
|
||||||
target_link_libraries(test_dcb maxscale-common)
|
target_link_libraries(test_dcb maxscale-common)
|
||||||
target_link_libraries(test_filter maxscale-common)
|
target_link_libraries(test_filter maxscale-common)
|
||||||
target_link_libraries(test_gwbitmask maxscale-common)
|
|
||||||
target_link_libraries(test_hash maxscale-common)
|
target_link_libraries(test_hash maxscale-common)
|
||||||
target_link_libraries(test_hint maxscale-common)
|
target_link_libraries(test_hint maxscale-common)
|
||||||
target_link_libraries(test_log maxscale-common)
|
target_link_libraries(test_log maxscale-common)
|
||||||
@ -46,7 +44,6 @@ add_test(TestAdminUsers test_adminusers)
|
|||||||
add_test(TestBuffer test_buffer)
|
add_test(TestBuffer test_buffer)
|
||||||
add_test(TestDCB test_dcb)
|
add_test(TestDCB test_dcb)
|
||||||
add_test(TestFilter test_filter)
|
add_test(TestFilter test_filter)
|
||||||
add_test(TestBitmask test_gwbitmask)
|
|
||||||
add_test(TestHash test_hash)
|
add_test(TestHash test_hash)
|
||||||
add_test(TestHint test_hint)
|
add_test(TestHint test_hint)
|
||||||
add_test(TestLog test_log)
|
add_test(TestLog test_log)
|
||||||
|
@ -1,84 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016 MariaDB Corporation Ab
|
|
||||||
*
|
|
||||||
* Use of this software is governed by the Business Source License included
|
|
||||||
* in the LICENSE.TXT file and at www.mariadb.com/bsl.
|
|
||||||
*
|
|
||||||
* Change Date: 2019-07-01
|
|
||||||
*
|
|
||||||
* On the date above, in accordance with the Business Source License, use
|
|
||||||
* of this software will be governed by version 2 or later of the General
|
|
||||||
* Public License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @verbatim
|
|
||||||
* Revision History
|
|
||||||
*
|
|
||||||
* Date Who Description
|
|
||||||
* 13-10-2014 Martin Brampton Initial implementation
|
|
||||||
*
|
|
||||||
* @endverbatim
|
|
||||||
*/
|
|
||||||
|
|
||||||
// To ensure that ss_info_assert asserts also when builing in non-debug mode.
|
|
||||||
#if !defined(SS_DEBUG)
|
|
||||||
#define SS_DEBUG
|
|
||||||
#endif
|
|
||||||
#if defined(NDEBUG)
|
|
||||||
#undef NDEBUG
|
|
||||||
#endif
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <maxscale/bitmask.h>
|
|
||||||
|
|
||||||
#include <maxscale/debug.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* test1 Create a bitmap and mess around with it
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
test1()
|
|
||||||
{
|
|
||||||
static MXS_BITMASK bitmask, another;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Hint tests */
|
|
||||||
ss_dfprintf(stderr,
|
|
||||||
"testgwbitmask : Initialise a bitmask");
|
|
||||||
bitmask_init(&bitmask);
|
|
||||||
for (i = 0; i < MXS_BITMASK_LENGTH; i++)
|
|
||||||
{
|
|
||||||
ss_info_dassert(0 == bitmask_isset(&bitmask, i), "All bits should initially be zero");
|
|
||||||
}
|
|
||||||
ss_info_dassert(0 != bitmask_isallclear(&bitmask), "Should be all clear");
|
|
||||||
ss_dfprintf(stderr, "\t..done\nSet an arbitrary bit.");
|
|
||||||
bitmask_set(&bitmask, 17);
|
|
||||||
bitmask_copy(&another, &bitmask);
|
|
||||||
ss_info_dassert(0 != bitmask_isset(&another, 17), "Test bit should be set");
|
|
||||||
ss_dfprintf(stderr, "\t..done\nClear the arbitrary bit.");
|
|
||||||
bitmask_clear(&bitmask, 17);
|
|
||||||
ss_info_dassert(0 != bitmask_isallclear(&bitmask), "Should be all clear");
|
|
||||||
ss_info_dassert(0 == bitmask_isset(&bitmask, 17), "Test bit should be clear");
|
|
||||||
|
|
||||||
ss_dfprintf(stderr, "\t..done\nFree the bitmask.");
|
|
||||||
bitmask_free(&bitmask);
|
|
||||||
ss_dfprintf(stderr, "\t..done\n");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
int result = 0;
|
|
||||||
|
|
||||||
result += test1();
|
|
||||||
|
|
||||||
exit(result);
|
|
||||||
}
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
|||||||
#define MXS_MODULE_NAME "MySQLBackend"
|
#define MXS_MODULE_NAME "MySQLBackend"
|
||||||
|
|
||||||
#include <maxscale/protocol/mysql.h>
|
#include <maxscale/protocol/mysql.h>
|
||||||
|
#include <maxscale/limits.h>
|
||||||
#include <maxscale/log_manager.h>
|
#include <maxscale/log_manager.h>
|
||||||
#include <maxscale/modutil.h>
|
#include <maxscale/modutil.h>
|
||||||
#include <maxscale/utils.h>
|
#include <maxscale/utils.h>
|
||||||
|
Reference in New Issue
Block a user