aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/test/nif_SUITE_data
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2017-02-13 18:40:32 +0100
committerSverker Eriksson <[email protected]>2017-02-20 20:06:36 +0100
commit68ad03bc3661f4bf82afbbde65a8d04861a6f799 (patch)
treee02874450d0a348716b90151263f8e808291f192 /erts/emulator/test/nif_SUITE_data
parentcb2a5bd9e86ba49d9bbc83b3d8383fbe0cc90715 (diff)
downloadotp-68ad03bc3661f4bf82afbbde65a8d04861a6f799.tar.gz
otp-68ad03bc3661f4bf82afbbde65a8d04861a6f799.tar.bz2
otp-68ad03bc3661f4bf82afbbde65a8d04861a6f799.zip
Expand nif_SUITE:monitor_frenzy with binary_to_term
to provoke resource revival race.
Diffstat (limited to 'erts/emulator/test/nif_SUITE_data')
-rw-r--r--erts/emulator/test/nif_SUITE_data/nif_SUITE.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/erts/emulator/test/nif_SUITE_data/nif_SUITE.c b/erts/emulator/test/nif_SUITE_data/nif_SUITE.c
index d5dd379d76..97cb7e55d6 100644
--- a/erts/emulator/test/nif_SUITE_data/nif_SUITE.c
+++ b/erts/emulator/test/nif_SUITE_data/nif_SUITE.c
@@ -2669,19 +2669,24 @@ static ERL_NIF_TERM monitor_frenzy_nif(ErlNifEnv* env, int argc, const ERL_NIF_T
}
DBG_TRACE2("New resource at r=%p rix=%u\n", r, rix);
}
- else if (rand_bits(&rnd, 3) == 0) {
+ else {
+ unsigned int resource_op = rand_bits(&rnd, 3);
r = resv[rix].obj;
- resv[rix].obj = NULL;
- resv[rix].release_cnt++;
- enif_mutex_unlock(resv[rix].lock);
- DBG_TRACE2("Delete resource at r=%p rix=%u\n", r, rix);
- enif_release_resource(r);
- retval = atom_ok;
- break;
- }
- else {
- r = resv[rix].obj;
- }
+ if (resource_op == 0) {
+ resv[rix].obj = NULL;
+ resv[rix].release_cnt++;
+ enif_mutex_unlock(resv[rix].lock);
+ DBG_TRACE2("Delete resource at r=%p rix=%u\n", r, rix);
+ enif_release_resource(r);
+ retval = atom_ok;
+ break;
+ }
+ else if (resource_op == 1) {
+ retval = enif_make_resource(env, r);
+ enif_mutex_unlock(resv[rix].lock);
+ break;
+ }
+ }
enif_keep_resource(r);
enif_mutex_unlock(resv[rix].lock);