summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/include/utils.h1
-rw-r--r--common/libavl/libavl.c23
-rw-r--r--common/src/log.cpp12
3 files changed, 24 insertions, 12 deletions
diff --git a/common/include/utils.h b/common/include/utils.h
index a94dde3..a42cf02 100644
--- a/common/include/utils.h
+++ b/common/include/utils.h
@@ -10,6 +10,7 @@ extern "C"
#define LOG_TAG_SHAPING "SHAPING"
#define LOG_TAG_SWARMKV "SWARMKV"
+#define LOG_TAG_STAT "STAT"
#define LOG_TAG_MAAT "MAAT"
#define LOG_TAG_MARSIO "MARSIO"
#define LOG_TAG_UTILS "UTILS"
diff --git a/common/libavl/libavl.c b/common/libavl/libavl.c
index 8d439a1..7bfeee2 100644
--- a/common/libavl/libavl.c
+++ b/common/libavl/libavl.c
@@ -1,14 +1,14 @@
+#include <assert.h>
#include <stdlib.h>
#include "libavl.h"
#include "avl_tree.h"
-#define AVL_NODE_IN_TREE 0x01
struct avl_node {
unsigned long long unique_key;
void *data;
void(*free_cb) (void *);
- unsigned int flag;
+ unsigned int ref_count;
struct avl_tree_node node;
};
@@ -131,7 +131,7 @@ int avl_node_in_tree(struct avl_node* pnode)
return 0;
}
- if (pnode->flag & AVL_NODE_IN_TREE) {
+ if (pnode->ref_count > 0) {
return 1;
}
@@ -162,6 +162,11 @@ int avl_tree_node_insert(struct avl_tree *tree, struct avl_node* pnode)
return -1;
}
+ if (avl_node_in_tree(pnode)) {
+ pnode->ref_count++;
+ return 0;
+ }
+
if (tree->curr_node_num == tree->max_node_num) {
return -1;
}
@@ -171,7 +176,7 @@ int avl_tree_node_insert(struct avl_tree *tree, struct avl_node* pnode)
return -1;
}
- pnode->flag |= AVL_NODE_IN_TREE;
+ pnode->ref_count = 1;
tree->curr_node_num++;
return 0;
@@ -179,12 +184,18 @@ int avl_tree_node_insert(struct avl_tree *tree, struct avl_node* pnode)
void avl_tree_node_remove(struct avl_tree *tree, struct avl_node* pnode)
{
- if (!pnode || !(pnode->flag & AVL_NODE_IN_TREE)) {
+ if (!pnode || pnode->ref_count == 0) {
+ return;
+ }
+
+ pnode->ref_count--;
+ assert(pnode->ref_count >= 0);
+
+ if (pnode->ref_count > 0) {
return;
}
avl_tree_remove(&tree->root, &pnode->node);
- pnode->flag &= ~AVL_NODE_IN_TREE;
tree->curr_node_num--;
return;
}
diff --git a/common/src/log.cpp b/common/src/log.cpp
index 290fbd9..af4794e 100644
--- a/common/src/log.cpp
+++ b/common/src/log.cpp
@@ -6,13 +6,13 @@ void *g_default_logger = NULL;
// return -1 : error
int LOG_INIT(const char *profile)
{
- // if (0 != MESA_handle_runtime_log_creation(profile))
- // {
- // fprintf(stderr, "FATAL: unable to create runtime logger\n");
- // return -1;
- // }
+ if (0 != MESA_handle_runtime_log_creation(profile))
+ {
+ fprintf(stderr, "FATAL: unable to create runtime logger\n");
+ return -1;
+ }
- g_default_logger = MESA_create_runtime_log_handle("./log/shaping", RLOG_LV_DEBUG);
+ g_default_logger = MESA_create_runtime_log_handle("log/shaping", RLOG_LV_DEBUG);
if (g_default_logger == NULL)
{
fprintf(stderr, "FATAL: unable to create log handle\n");