aboutsummaryrefslogtreecommitdiffstats
path: root/load.c
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-12-05 11:10:05 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-12-05 11:10:05 +0000
commitf77307d4cb2d063fc57f6d1eed5f46946a0d8a37 (patch)
tree322d16949852d849aa86c1318eb199ebadbac4e1 /load.c
parent4e6d402fbff60ac58812eb4f264433bef0bcaa43 (diff)
downloadruby-f77307d4cb2d063fc57f6d1eed5f46946a0d8a37.tar.gz
Don't insert an entry to loading_tbl if another thread succeed to load.
If rb_thread_shield_wait() returns Qfalse, the file has been successfully loaded by another thread, so there is no need to insert a new entry into loading_tbl. [ruby-core:78464] [Bug #12999] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56985 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'load.c')
-rw-r--r--load.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/load.c b/load.c
index 3cf9ce0aba..c37f8bcf0b 100644
--- a/load.c
+++ b/load.c
@@ -745,9 +745,6 @@ load_lock(const char *ftptr)
}
switch (rb_thread_shield_wait((VALUE)data)) {
case Qfalse:
- data = (st_data_t)ftptr;
- st_insert(loading_tbl, data, (st_data_t)rb_thread_shield_new());
- return 0;
case Qnil:
return 0;
}
@@ -759,7 +756,10 @@ release_thread_shield(st_data_t *key, st_data_t *value, st_data_t done, int exis
{
VALUE thread_shield = (VALUE)*value;
if (!existing) return ST_STOP;
- if (done ? rb_thread_shield_destroy(thread_shield) : rb_thread_shield_release(thread_shield)) {
+ if (done) {
+ rb_thread_shield_destroy(thread_shield);
+ }
+ else if (rb_thread_shield_release(thread_shield)) {
/* still in-use */
return ST_CONTINUE;
}