aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2016-07-08 15:37:05 +0200
committerLukas Larsson <[email protected]>2016-07-11 09:11:13 +0200
commit382adc9e5d7c7dbd4e1f12adc483bc6eb7ed6c3d (patch)
treeadc7dbfc711be5644747ec84615240ca970b1309 /erts/emulator
parent0573efbc18fc20f8646cf3ff64d2affd06e03cb8 (diff)
downloadotp-382adc9e5d7c7dbd4e1f12adc483bc6eb7ed6c3d.tar.gz
otp-382adc9e5d7c7dbd4e1f12adc483bc6eb7ed6c3d.tar.bz2
otp-382adc9e5d7c7dbd4e1f12adc483bc6eb7ed6c3d.zip
erts: Optimize db_finalize_dbterm_hash
Always free term after WUNLOCK_HASH
Diffstat (limited to 'erts/emulator')
-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 74979f984a..6b23be1adf 100644
--- a/erts/emulator/beam/erl_db_hash.c
+++ b/erts/emulator/beam/erl_db_hash.c
@@ -2910,6 +2910,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 */
@@ -2921,7 +2922,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);
@@ -2930,12 +2931,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