summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9c2c414)
raw | patch | inline | side by side (parent: 9c2c414)
author | Sebastian Harl <sh@tokkee.org> | |
Wed, 9 Jul 2014 07:55:23 +0000 (09:55 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Wed, 9 Jul 2014 07:55:23 +0000 (09:55 +0200) |
src/utils/avltree.c | patch | blob | history |
diff --git a/src/utils/avltree.c b/src/utils/avltree.c
index ce87c52ed726cd5c6048cfdbe2e35aeae6cd2401..8c13233b2eabb6dd7f3fbfd3e408eaccf99f5a0f 100644 (file)
--- a/src/utils/avltree.c
+++ b/src/utils/avltree.c
if (! n)
return -1;
+ pthread_rwlock_wrlock(&tree->lock);
+
if (! tree->root) {
tree->root = n;
tree->size = 1;
+ pthread_rwlock_unlock(&tree->lock);
return 0;
}
diff = tree->cmp(obj, parent->obj);
if (! diff) {
node_destroy(n);
+ pthread_rwlock_unlock(&tree->lock);
return -1;
}
++tree->size;
rebalance(tree, parent);
+ pthread_rwlock_unlock(&tree->lock);
return 0;
} /* sdb_avltree_insert */