修改hash表超时淘汰释放函数
This commit is contained in:
@@ -438,29 +438,42 @@ static void certstore_rpc_on_fail(enum e_future_error err, const char * what, vo
|
||||
/*
|
||||
* Certificate, including private key and keyring chain.
|
||||
*/
|
||||
static int __wrapper_MESA_htable_set_opt(MESA_htable_handle table, enum MESA_htable_opt opt_type, unsigned int value)
|
||||
static int __wrapper_MESA_htable_set_opt_int(MESA_htable_handle table, enum MESA_htable_opt opt_type, unsigned int value)
|
||||
{
|
||||
int ret = MESA_htable_set_opt(table, opt_type, &value, (int)(sizeof(value)));
|
||||
assert(ret == 0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int __wrapper_MESA_htable_set_opt_func(MESA_htable_handle table, enum MESA_htable_opt opt_type, void * val, size_t len)
|
||||
{
|
||||
int ret = MESA_htable_set_opt(table, opt_type, val, (int)len);
|
||||
assert(ret == 0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void key_keeper_free_serialized(void* data)
|
||||
{
|
||||
printf("call key_keeper_free_serialized\n");
|
||||
struct keyring_private* kyr = (struct keyring_private*)data;
|
||||
key_keeper_free_keyring(&(kyr->head));
|
||||
}
|
||||
|
||||
static MESA_htable_handle create_hash_table(unsigned int slot_size, unsigned int expire_seconds)
|
||||
{
|
||||
int ret = 0;
|
||||
unsigned max_num = slot_size * 4;
|
||||
MESA_htable_handle htable = MESA_htable_born();
|
||||
ret = __wrapper_MESA_htable_set_opt(htable, MHO_SCREEN_PRINT_CTRL, 0);
|
||||
ret = __wrapper_MESA_htable_set_opt(htable, MHO_THREAD_SAFE, 1);
|
||||
ret = __wrapper_MESA_htable_set_opt(htable, MHO_MUTEX_NUM, 16);
|
||||
ret = __wrapper_MESA_htable_set_opt(htable, MHO_HASH_SLOT_SIZE, slot_size);
|
||||
ret = __wrapper_MESA_htable_set_opt(htable, MHO_HASH_MAX_ELEMENT_NUM, max_num);
|
||||
ret = __wrapper_MESA_htable_set_opt(htable, MHO_EXPIRE_TIME, expire_seconds);
|
||||
ret = __wrapper_MESA_htable_set_opt(htable, MHO_ELIMIMINATE_TYPE,
|
||||
ret = __wrapper_MESA_htable_set_opt_int(htable, MHO_SCREEN_PRINT_CTRL, 0);
|
||||
ret = __wrapper_MESA_htable_set_opt_int(htable, MHO_THREAD_SAFE, 1);
|
||||
ret = __wrapper_MESA_htable_set_opt_int(htable, MHO_MUTEX_NUM, 16);
|
||||
ret = __wrapper_MESA_htable_set_opt_int(htable, MHO_HASH_SLOT_SIZE, slot_size);
|
||||
ret = __wrapper_MESA_htable_set_opt_int(htable, MHO_HASH_MAX_ELEMENT_NUM, max_num);
|
||||
ret = __wrapper_MESA_htable_set_opt_int(htable, MHO_EXPIRE_TIME, expire_seconds);
|
||||
ret = __wrapper_MESA_htable_set_opt_int(htable, MHO_ELIMIMINATE_TYPE,
|
||||
HASH_ELIMINATE_ALGO_FIFO);
|
||||
//TODO: how to do overide?
|
||||
//ret = __wrapper_MESA_htable_set_opt(htable, MHO_CBFUN_DATA_FREE,
|
||||
// (void *)key_keeper_free_serialized);
|
||||
ret = __wrapper_MESA_htable_set_opt_func(htable, MHO_CBFUN_DATA_FREE,
|
||||
(void *)key_keeper_free_serialized, sizeof(&key_keeper_free_serialized));
|
||||
//ret = __wrapper_MESA_htable_set_opt(htable, MHO_CBFUN_DATA_EXPIRE_NOTIFY,
|
||||
// (void *)key_keeper_verify_cb);
|
||||
ret = MESA_htable_mature(htable);
|
||||
|
||||
Reference in New Issue
Block a user