Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmil Sandstø <emilalexer@hotmail.com>2016-09-12 13:19:00 +0300
committerZoltan Varga <vargaz@gmail.com>2016-10-14 20:53:08 +0300
commit2f4c98b3e099bc791c45d3ab190b70ce30d5ef01 (patch)
treef7ec8aac7958125d0e0cea5562a1e624da33fc67
parent0cbbc88be021dda65aac48f43ab17b4272bec79b (diff)
[threads] Correct the spin waiting in 'sleep_interruptable' (#3544)mono-4.6.1.13
After https://github.com/mono/mono/commit/089c47f1c07bf250d76c36e04675569fc6f5b4ba#diff-e7e458b6256eaa730c145f14a666652aR1141 the code started to use nanoseconds instead of milliseconds. The problem was that this caused 'sleep_interruptable' to spin wait the last millisecond before the wait was over, https://bugzilla.xamarin.com/show_bug.cgi?id=44132. Fix https://bugzilla.xamarin.com/show_bug.cgi?id=44132
-rw-r--r--mono/utils/mono-threads.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/mono/utils/mono-threads.c b/mono/utils/mono-threads.c
index 244df6a8870..4eb18256b72 100644
--- a/mono/utils/mono-threads.c
+++ b/mono/utils/mono-threads.c
@@ -1190,7 +1190,7 @@ sleep_interruptable (guint32 ms, gboolean *alerted)
*alerted = FALSE;
if (ms != INFINITE)
- end = mono_100ns_ticks () + (ms * 1000 * 10);
+ end = mono_msec_ticks() + ms;
mono_lazy_initialize (&sleep_init, sleep_initialize);
@@ -1198,8 +1198,8 @@ sleep_interruptable (guint32 ms, gboolean *alerted)
for (;;) {
if (ms != INFINITE) {
- now = mono_100ns_ticks ();
- if (now > end)
+ now = mono_msec_ticks();
+ if (now >= end)
break;
}
@@ -1210,7 +1210,7 @@ sleep_interruptable (guint32 ms, gboolean *alerted)
}
if (ms != INFINITE)
- mono_coop_cond_timedwait (&sleep_cond, &sleep_mutex, (end - now) / 10 / 1000);
+ mono_coop_cond_timedwait (&sleep_cond, &sleep_mutex, end - now);
else
mono_coop_cond_wait (&sleep_cond, &sleep_mutex);