sf_status增加delete的API
This commit is contained in:
@@ -13,6 +13,7 @@ struct sf_status *sf_status_create(const char *profile);
|
||||
void sf_status_destory(struct sf_status *handle);
|
||||
void sf_status_reset(struct sf_status *handle);
|
||||
|
||||
void sf_status_delete(struct sf_status *handle, int sf_profile_id);
|
||||
void sf_status_update(struct sf_status *handle, int sf_profile_id, int sf_status, int sf_latency);
|
||||
void sf_status_send(struct sf_status *handle);
|
||||
int sf_status_get_interval(struct sf_status *handle);
|
||||
|
||||
@@ -161,6 +161,7 @@ int health_check_session_del(int session_id)
|
||||
struct bfd_vtysh_client client;
|
||||
struct session_iterm *tmp = NULL;
|
||||
|
||||
sf_status_delete(g_sf_status, session_id);
|
||||
tmp = health_check_get_iterm_by_id(session_id);
|
||||
if (!tmp) {
|
||||
LOG_DEBUG("health check session table delete: key %d not exists", session_id);
|
||||
|
||||
@@ -104,16 +104,13 @@ struct sf_status *sf_status_create(const char *profile)
|
||||
|
||||
void sf_status_reset(struct sf_status *handle)
|
||||
{
|
||||
if (handle == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (handle->config.enable == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LOG_DEBUG("%s: reset: elem_num %lu", LOG_TAG_SF_STATUS, handle->htable_elem_count);
|
||||
|
||||
struct node *temp = NULL;
|
||||
struct node *node = NULL;
|
||||
HASH_ITER(hh, handle->htable, node, temp)
|
||||
@@ -126,6 +123,27 @@ void sf_status_reset(struct sf_status *handle)
|
||||
}
|
||||
}
|
||||
|
||||
void sf_status_delete(struct sf_status *handle, int sf_profile_id)
|
||||
{
|
||||
if (handle->config.enable == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
struct node *temp = NULL;
|
||||
HASH_FIND(hh, handle->htable, &sf_profile_id, sizeof(sf_profile_id), temp);
|
||||
if (temp)
|
||||
{
|
||||
handle->htable_elem_count--;
|
||||
LOG_DEBUG("%s: delete: sf_profile %d success, elem_num %lu", LOG_TAG_SF_STATUS, sf_profile_id, handle->htable_elem_count);
|
||||
HASH_DELETE(hh, handle->htable, temp);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_DEBUG("%s: delete: sf_profile %d not exists, elem_num %lu", LOG_TAG_SF_STATUS, sf_profile_id, handle->htable_elem_count);
|
||||
}
|
||||
}
|
||||
|
||||
void sf_status_update(struct sf_status *handle, int sf_profile_id, int sf_status, int sf_latency)
|
||||
{
|
||||
if (handle->config.enable == 0)
|
||||
@@ -137,12 +155,15 @@ void sf_status_update(struct sf_status *handle, int sf_profile_id, int sf_status
|
||||
HASH_FIND(hh, handle->htable, &sf_profile_id, sizeof(sf_profile_id), temp);
|
||||
if (temp)
|
||||
{
|
||||
LOG_DEBUG("%s: update: sf_profile %d status %d success, elem_num %lu", LOG_TAG_SF_STATUS, sf_profile_id, sf_status, handle->htable_elem_count);
|
||||
temp->sf_profile_id = sf_profile_id;
|
||||
temp->sf_status = sf_status;
|
||||
temp->sf_latency = sf_latency;
|
||||
}
|
||||
else
|
||||
{
|
||||
handle->htable_elem_count++;
|
||||
LOG_DEBUG("%s: insert: sf_profile %d status %d success, elem_num %lu", LOG_TAG_SF_STATUS, sf_profile_id, sf_status, handle->htable_elem_count);
|
||||
temp = (struct node *)calloc(1, sizeof(struct node));
|
||||
temp->sf_profile_id = sf_profile_id;
|
||||
temp->sf_status = sf_status;
|
||||
|
||||
Reference in New Issue
Block a user