aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2016-07-08 15:37:05 +0200
committerSverker Eriksson <[email protected]>2016-07-08 15:37:05 +0200
commit75fc0b498602e6d11961567a737a9e4163d498b7 (patch)
tree11909a3f67faa1ff29c89b9706eae62abdd23c9f
parent5cf780148575f1ea4c460d7c9783831e6fbce9ff (diff)
downloadotp-75fc0b498602e6d11961567a737a9e4163d498b7.tar.gz
otp-75fc0b498602e6d11961567a737a9e4163d498b7.tar.bz2
otp-75fc0b498602e6d11961567a737a9e4163d498b7.zip
erts: Optimize db_finalize_dbterm_hash
Always free term after WUNLOCK_HASH
-rw-r--r--erts/emulator/beam/erl_db_hash.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/erts/emulator/beam/erl_db_hash.c b/erts/emulator/beam/erl_db_hash.c
index fa925c94a5..ccffc2767a 100644
--- a/erts/emulator/beam/erl_db_hash.c
+++ b/erts/emulator/beam/erl_db_hash.c
@@ -2916,6 +2916,7 @@ db_finalize_dbterm_hash(int cret, DbUpdateHandle* handle)
HashDbTerm **bp = (HashDbTerm **) handle->bp;
HashDbTerm *b = *bp;
erts_smp_rwmtx_t* lck = (erts_smp_rwmtx_t*) handle->lck;
+ HashDbTerm* free_me = NULL;
ERTS_SMP_LC_ASSERT(IS_HASH_WLOCKED(tb, lck)); /* locked by db_lookup_dbterm_hash */
@@ -2927,7 +2928,7 @@ db_finalize_dbterm_hash(int cret, DbUpdateHandle* handle)
b->hvalue = INVALID_HASH;
} else {
*bp = b->next;
- free_term(tb, b);
+ free_me = b;
}
WUNLOCK_HASH(lck);
@@ -2936,12 +2937,15 @@ db_finalize_dbterm_hash(int cret, DbUpdateHandle* handle)
} else if (handle->flags & DB_MUST_RESIZE) {
db_finalize_resize(handle, offsetof(HashDbTerm,dbterm));
WUNLOCK_HASH(lck);
-
- free_term(tb, b);
+ free_me = b;
}
else {
WUNLOCK_HASH(lck);
}
+
+ if (free_me)
+ free_term(tb, free_me);
+
#ifdef DEBUG
handle->dbterm = 0;
#endif