summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authork0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-06 08:01:28 +0000
committerk0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-06 08:01:28 +0000
commitdbd90b2dff8a45969923073122dd54aede5a74ee (patch)
tree8e58212f7aa24d6db340d084f53bd50b2f3a484d
parent6c2014768eaee865fcd5ceabfbd6fcf4fed4b13c (diff)
mjit.c: don't use mutex before checking availability
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--mjit.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/mjit.c b/mjit.c
index 4ff5ff9..4f42575 100644
--- a/mjit.c
+++ b/mjit.c
@@ -26,16 +26,18 @@ mjit_copy_job_handler(void *data)
{
struct mjit_copy_job *job = data;
int finish_p;
+ if (stop_worker_p) {
+ /* `copy_cache_from_main_thread()` stops to wait for this job. Then job data which is
+ allocated by `alloca()` could be expired and we might not be able to access that.
+ Also this should be checked before CRITICAL_SECTION_START to ensure that mutex is alive. */
+ return;
+ }
+
CRITICAL_SECTION_START(3, "in mjit_copy_job_handler");
finish_p = job->finish_p;
CRITICAL_SECTION_FINISH(3, "in mjit_copy_job_handler");
-
- if (stop_worker_p || finish_p) {
- /* `stop_worker_p`: `copy_cache_from_main_thread()` stops to wait for this job.
- Then job data which is allocated by `alloca()` could be expired and we might
- not be able to access that.
- `finish_p`: make sure that this job is never executed while job is being modified. */
- return;
+ if (finish_p) {
+ return; /* make sure that this job is never executed while job is being modified. */
}
if (job->cc_entries) {