diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-01-22 02:15:01 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-01-22 02:15:01 +0000 |
commit | 039868965d6679379f1b87b7336986605229430b (patch) | |
tree | 24a07c8f2c70c351413311e83632aaddce690aba /libgo/runtime/go-go.c | |
parent | 2e8e58aa8adc4cb4a276a54f139eb40c5e19e00d (diff) | |
download | gcc-039868965d6679379f1b87b7336986605229430b.tar.gz |
libgo: Adjust deadlock avoidance.
From-SVN: r169120
Diffstat (limited to 'libgo/runtime/go-go.c')
-rw-r--r-- | libgo/runtime/go-go.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/libgo/runtime/go-go.c b/libgo/runtime/go-go.c index 7c5f40de5ef..31462685afb 100644 --- a/libgo/runtime/go-go.c +++ b/libgo/runtime/go-go.c @@ -297,6 +297,15 @@ gc_stop_handler (int sig __attribute__ ((unused))) { struct M *pm = m; + if (__sync_bool_compare_and_swap (&pm->holds_finlock, 1, 1)) + { + /* We can't interrupt the thread while it holds the finalizer + lock. Otherwise we can get into a deadlock when mark calls + runtime_walkfintab. */ + __sync_bool_compare_and_swap (&pm->gcing_for_finlock, 0, 1); + return; + } + if (__sync_bool_compare_and_swap (&pm->mallocing, 1, 1)) { /* m->mallocing was already non-zero. We can't interrupt the @@ -315,15 +324,6 @@ gc_stop_handler (int sig __attribute__ ((unused))) return; } - if (__sync_bool_compare_and_swap (&pm->holds_finlock, 1, 1)) - { - /* Similarly, we can't interrupt the thread while it holds the - finalizer lock. Otherwise we can get into a deadlock when - mark calls runtime_walkfintab. */ - __sync_bool_compare_and_swap (&pm->gcing_for_finlock, 0, 1); - return; - } - stop_for_gc (); } |