suricata
|
#include "threads.h"
Go to the source code of this file.
Data Structures | |
struct | THashData_ |
struct | THashHashRow_ |
struct | THashDataQueue_ |
struct | THashDataConfig_ |
struct | THashTableContext_ |
struct | THashDataGetResult |
Macros | |
#define | HRLOCK_MUTEX |
#define | HRLOCK_TYPE SCMutex |
#define | HRLOCK_INIT(fb) SCMutexInit(&(fb)->lock, NULL) |
#define | HRLOCK_DESTROY(fb) SCMutexDestroy(&(fb)->lock) |
#define | HRLOCK_LOCK(fb) SCMutexLock(&(fb)->lock) |
#define | HRLOCK_TRYLOCK(fb) SCMutexTrylock(&(fb)->lock) |
#define | HRLOCK_UNLOCK(fb) SCMutexUnlock(&(fb)->lock) |
#define | HQLOCK_MUTEX |
#define | HQLOCK_INIT(q) SCMutexInit(&(q)->m, NULL) |
#define | HQLOCK_DESTROY(q) SCMutexDestroy(&(q)->m) |
#define | HQLOCK_LOCK(q) SCMutexLock(&(q)->m) |
#define | HQLOCK_TRYLOCK(q) SCMutexTrylock(&(q)->m) |
#define | HQLOCK_UNLOCK(q) SCMutexUnlock(&(q)->m) |
#define | THASH_DATA_SIZE(ctx) (sizeof(THashData) + (ctx)->config.data_size) |
#define | THASH_CHECK_MEMCAP(ctx, size) |
check if a memory alloc would fit in the memcap More... | |
#define | THashIncrUsecnt(h) (void)SC_ATOMIC_ADD((h)->use_cnt, 1) |
#define | THashDecrUsecnt(h) (void)SC_ATOMIC_SUB((h)->use_cnt, 1) |
Typedefs | |
typedef struct THashData_ | THashData |
typedef struct THashDataQueue_ | THashDataQueue |
typedef int(* | THashOutputFunc) (void *output_ctx, const uint8_t *data, const uint32_t data_len) |
typedef int(* | THashFormatFunc) (const void *in_data, char *output, size_t output_size) |
typedef struct THashDataConfig_ | THashConfig |
typedef struct THashTableContext_ | THashTableContext |
Functions | |
struct THashHashRow_ | __attribute__ ((aligned(CLS))) THashHashRow |
THashTableContext * | THashInit (const char *cnf_prefix, size_t data_size, int(*DataSet)(void *dst, void *src), void(*DataFree)(void *), uint32_t(*DataHash)(uint32_t, void *), bool(*DataCompare)(void *, void *), bool(*DataExpired)(void *, SCTime_t), uint32_t(*DataSize)(void *), bool reset_memcap, uint64_t memcap, uint32_t hashsize) |
void | THashShutdown (THashTableContext *ctx) |
shutdown the flow engine More... | |
struct THashDataGetResult | THashGetFromHash (THashTableContext *ctx, void *data) |
THashData * | THashLookupFromHash (THashTableContext *ctx, void *data) |
look up data in the hash More... | |
THashDataQueue * | THashDataQueueNew (void) |
void | THashCleanup (THashTableContext *ctx) |
Cleanup the thash engine. More... | |
int | THashWalk (THashTableContext *, THashFormatFunc, THashOutputFunc, void *) |
Walk the hash. More... | |
int | THashRemoveFromHash (THashTableContext *ctx, void *data) |
void | THashConsolidateMemcap (THashTableContext *ctx) |
void | THashDataMoveToSpare (THashTableContext *ctx, THashData *h) |
uint32_t | THashExpire (THashTableContext *ctx, const SCTime_t ts) |
expire data from the hash Walk the hash table and remove data that is exprired according to the DataExpired callback. More... | |
Variables | |
HRLOCK_TYPE | lock |
THashData * | head |
THashData * | tail |
thash -> thread hash. Hash table with locking handling.
Definition in file util-thash.h.
#define HQLOCK_DESTROY | ( | q | ) | SCMutexDestroy(&(q)->m) |
Definition at line 78 of file util-thash.h.
#define HQLOCK_INIT | ( | q | ) | SCMutexInit(&(q)->m, NULL) |
Definition at line 77 of file util-thash.h.
#define HQLOCK_LOCK | ( | q | ) | SCMutexLock(&(q)->m) |
Definition at line 79 of file util-thash.h.
#define HQLOCK_MUTEX |
Spinlocks or Mutex for the queues.
Definition at line 62 of file util-thash.h.
#define HQLOCK_TRYLOCK | ( | q | ) | SCMutexTrylock(&(q)->m) |
Definition at line 80 of file util-thash.h.
#define HQLOCK_UNLOCK | ( | q | ) | SCMutexUnlock(&(q)->m) |
Definition at line 81 of file util-thash.h.
#define HRLOCK_DESTROY | ( | fb | ) | SCMutexDestroy(&(fb)->lock) |
Definition at line 52 of file util-thash.h.
#define HRLOCK_INIT | ( | fb | ) | SCMutexInit(&(fb)->lock, NULL) |
Definition at line 51 of file util-thash.h.
#define HRLOCK_LOCK | ( | fb | ) | SCMutexLock(&(fb)->lock) |
Definition at line 53 of file util-thash.h.
#define HRLOCK_MUTEX |
Spinlocks or Mutex for the buckets.
Definition at line 34 of file util-thash.h.
#define HRLOCK_TRYLOCK | ( | fb | ) | SCMutexTrylock(&(fb)->lock) |
Definition at line 54 of file util-thash.h.
#define HRLOCK_TYPE SCMutex |
Definition at line 50 of file util-thash.h.
#define HRLOCK_UNLOCK | ( | fb | ) | SCMutexUnlock(&(fb)->lock) |
Definition at line 55 of file util-thash.h.
#define THASH_CHECK_MEMCAP | ( | ctx, | |
size | |||
) |
check if a memory alloc would fit in the memcap
size | memory allocation size to check |
1 | it fits |
0 | no fit |
Definition at line 165 of file util-thash.h.
Definition at line 140 of file util-thash.h.
#define THashDecrUsecnt | ( | h | ) | (void)SC_ATOMIC_SUB((h)->use_cnt, 1) |
Definition at line 171 of file util-thash.h.
#define THashIncrUsecnt | ( | h | ) | (void)SC_ATOMIC_ADD((h)->use_cnt, 1) |
Definition at line 169 of file util-thash.h.
typedef struct THashDataConfig_ THashConfig |
typedef struct THashData_ THashData |
typedef struct THashDataQueue_ THashDataQueue |
typedef int(* THashFormatFunc) (const void *in_data, char *output, size_t output_size) |
Definition at line 122 of file util-thash.h.
typedef int(* THashOutputFunc) (void *output_ctx, const uint8_t *data, const uint32_t data_len) |
Definition at line 121 of file util-thash.h.
typedef struct THashTableContext_ THashTableContext |
struct THashHashRow_ __attribute__ | ( | (aligned(CLS)) | ) |
void THashCleanup | ( | THashTableContext * | ctx | ) |
Cleanup the thash engine.
Cleanup the thash engine from tag and threshold.
Definition at line 489 of file util-thash.c.
References ctx, THashData_::data, HRLOCK_LOCK, HRLOCK_UNLOCK, THashData_::next, THashData_::prev, SC_ATOMIC_GET, SC_ATOMIC_SUB, and THashDataMoveToSpare().
void THashConsolidateMemcap | ( | THashTableContext * | ctx | ) |
Definition at line 353 of file util-thash.c.
References ctx, MAX, SC_ATOMIC_GET, SC_ATOMIC_SET, and SCLogDebug.
void THashDataMoveToSpare | ( | THashTableContext * | ctx, |
THashData * | h | ||
) |
Definition at line 41 of file util-thash.c.
Referenced by THashCleanup().
THashDataQueue* THashDataQueueNew | ( | void | ) |
Definition at line 56 of file util-thash.c.
References SCLogError, and SCMalloc.
uint32_t THashExpire | ( | THashTableContext * | ctx, |
const SCTime_t | ts | ||
) |
expire data from the hash Walk the hash table and remove data that is exprired according to the DataExpired callback.
cnt | number of items successfully expired/removed |
Definition at line 431 of file util-thash.c.
References cnt, ctx, HRLOCK_TRYLOCK, next, THashData_::next, and SCLogDebug.
Referenced by HttpRangeContainersTimeoutHash(), and ThresholdsExpire().
struct THashDataGetResult THashGetFromHash | ( | THashTableContext * | ctx, |
void * | data | ||
) |
Definition at line 560 of file util-thash.c.
THashTableContext* THashInit | ( | const char * | cnf_prefix, |
size_t | data_size, | ||
int(*)(void *dst, void *src) | DataSet, | ||
void(*)(void *) | DataFree, | ||
uint32_t(*)(uint32_t, void *) | DataHash, | ||
bool(*)(void *, void *) | DataCompare, | ||
bool(*)(void *, SCTime_t) | DataExpired, | ||
uint32_t(*)(void *) | DataSize, | ||
bool | reset_memcap, | ||
uint64_t | memcap, | ||
uint32_t | hashsize | ||
) |
THashData* THashLookupFromHash | ( | THashTableContext * | ctx, |
void * | data | ||
) |
look up data in the hash
data | data to look up |
h | LOCKED data or NULL |
Definition at line 732 of file util-thash.c.
int THashRemoveFromHash | ( | THashTableContext * | ctx, |
void * | data | ||
) |
int | -1 not found |
int | 0 found, but it was busy (ref cnt) |
int | 1 found and removed |
Definition at line 875 of file util-thash.c.
void THashShutdown | ( | THashTableContext * | ctx | ) |
shutdown the flow engine
Definition at line 362 of file util-thash.c.
Referenced by HttpRangeContainersDestroy().
int THashWalk | ( | THashTableContext * | ctx, |
THashFormatFunc | FormatterFunc, | ||
THashOutputFunc | OutputterFunc, | ||
void * | output_ctx | ||
) |
Walk the hash.
Definition at line 396 of file util-thash.c.
References ctx, THashData_::data, HRLOCK_LOCK, HRLOCK_UNLOCK, and THashData_::next.
THashData* head |
Definition at line 1 of file util-thash.h.
HRLOCK_TYPE lock |
Definition at line 0 of file util-thash.h.
THashData* tail |
Definition at line 2 of file util-thash.h.