mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* load.c (rb_require_safe): destroys barrier after successfully
loaded, to get rid of loading same library again. [ruby-core:19798] * thread.c (rb_barrier_wait): can not wait destroyed barrier. * thread.c (rb_barrier_destroy): destroys barrier so that no longer waited. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20223 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8bc28d82b4
commit
99cd3c512b
4 changed files with 50 additions and 9 deletions
12
load.c
12
load.c
|
@ -366,7 +366,7 @@ load_lock(const char *ftptr)
|
|||
}
|
||||
|
||||
static void
|
||||
load_unlock(const char *ftptr)
|
||||
load_unlock(const char *ftptr, int done)
|
||||
{
|
||||
if (ftptr) {
|
||||
st_data_t key = (st_data_t)ftptr;
|
||||
|
@ -374,8 +374,12 @@ load_unlock(const char *ftptr)
|
|||
st_table *loading_tbl = get_loading_table();
|
||||
|
||||
if (st_delete(loading_tbl, &key, &data)) {
|
||||
VALUE barrier = (VALUE)data;
|
||||
xfree((char *)key);
|
||||
rb_barrier_release((VALUE)data);
|
||||
if (done)
|
||||
rb_barrier_destroy(barrier);
|
||||
else
|
||||
rb_barrier_release(barrier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -561,7 +565,7 @@ rb_require_safe(VALUE fname, int safe)
|
|||
}
|
||||
}
|
||||
POP_TAG();
|
||||
load_unlock(ftptr);
|
||||
load_unlock(ftptr, !state);
|
||||
|
||||
rb_set_safe_level_force(saved.safe);
|
||||
if (state) {
|
||||
|
@ -600,7 +604,7 @@ ruby_init_ext(const char *name, void (*init)(void))
|
|||
rb_vm_call_cfunc(rb_vm_top_self(), init_ext_call, (VALUE)init,
|
||||
0, rb_str_new2(name));
|
||||
rb_provide(name);
|
||||
load_unlock(name);
|
||||
load_unlock(name, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue