projects
/
mono.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3f3be88
)
[threads] Remove ThreadState_StopRequested (#4462)
author
Ludovic Henry
<ludovic@xamarin.com>
Fri, 3 Mar 2017 02:26:00 +0000
(21:26 -0500)
committer
GitHub
<noreply@github.com>
Fri, 3 Mar 2017 02:26:00 +0000
(21:26 -0500)
12 files changed:
mcs/class/corlib/System.Threading/Thread.cs
patch
|
blob
|
history
mono/metadata/gc.c
patch
|
blob
|
history
mono/metadata/monitor.c
patch
|
blob
|
history
mono/metadata/object-internals.h
patch
|
blob
|
history
mono/metadata/threadpool-io-epoll.c
patch
|
blob
|
history
mono/metadata/threadpool-io-kqueue.c
patch
|
blob
|
history
mono/metadata/threadpool-io-poll.c
patch
|
blob
|
history
mono/metadata/threadpool-worker-default.c
patch
|
blob
|
history
mono/metadata/threads-types.h
patch
|
blob
|
history
mono/metadata/threads.c
patch
|
blob
|
history
mono/metadata/w32socket-win32.c
patch
|
blob
|
history
mono/metadata/w32socket.c
patch
|
blob
|
history
diff --git
a/mcs/class/corlib/System.Threading/Thread.cs
b/mcs/class/corlib/System.Threading/Thread.cs
index 6d96fe1b3673632ac00b57d23b4fc1c1011be851..c6564db34730f631515ea77b99de90790a6a32c4 100644
(file)
--- a/
mcs/class/corlib/System.Threading/Thread.cs
+++ b/
mcs/class/corlib/System.Threading/Thread.cs
@@
-81,7
+81,7
@@
namespace System.Threading {
internal int managed_id;
private int small_id;
private IntPtr manage_callback;
internal int managed_id;
private int small_id;
private IntPtr manage_callback;
- private IntPtr
interrupt_on_stop
;
+ private IntPtr
unused4
;
private IntPtr flags;
private IntPtr thread_pinning_ref;
private IntPtr abort_protected_block_count;
private IntPtr flags;
private IntPtr thread_pinning_ref;
private IntPtr abort_protected_block_count;
diff --git
a/mono/metadata/gc.c
b/mono/metadata/gc.c
index 499e3840063685256683cf588a7c2b5f04bac232..f3bc6aba7c5cefa793da20e97c590ed9c0103356 100644
(file)
--- a/
mono/metadata/gc.c
+++ b/
mono/metadata/gc.c
@@
-478,7
+478,7
@@
mono_domain_finalize (MonoDomain *domain, guint32 timeout)
if (res == MONO_SEM_TIMEDWAIT_RET_SUCCESS) {
break;
} else if (res == MONO_SEM_TIMEDWAIT_RET_ALERTED) {
if (res == MONO_SEM_TIMEDWAIT_RET_SUCCESS) {
break;
} else if (res == MONO_SEM_TIMEDWAIT_RET_ALERTED) {
- if ((thread->state & (ThreadState_
Stop
Requested | ThreadState_SuspendRequested)) != 0) {
+ if ((thread->state & (ThreadState_
Abort
Requested | ThreadState_SuspendRequested)) != 0) {
ret = FALSE;
break;
}
ret = FALSE;
break;
}
diff --git
a/mono/metadata/monitor.c
b/mono/metadata/monitor.c
index dd2cc0eb9a7186b6a6d77471adeb1a914570bef9..676400c152e8d414dbf72f87b4d74e86037e0fb2 100644
(file)
--- a/
mono/metadata/monitor.c
+++ b/
mono/metadata/monitor.c
@@
-891,7
+891,7
@@
retry_contended:
*
*/
if (allow_interruption) {
*
*/
if (allow_interruption) {
- if (!mono_thread_test_and_set_state (thread,
(MonoThreadState)(ThreadState_StopRequested | ThreadState_AbortRequested)
, ThreadState_WaitSleepJoin)) {
+ if (!mono_thread_test_and_set_state (thread,
ThreadState_AbortRequested
, ThreadState_WaitSleepJoin)) {
wait_ret = MONO_SEM_TIMEDWAIT_RET_ALERTED;
goto done_waiting;
}
wait_ret = MONO_SEM_TIMEDWAIT_RET_ALERTED;
goto done_waiting;
}
@@
-918,7
+918,7
@@
done_waiting:
* We have to obey a stop/suspend request even if
* allow_interruption is FALSE to avoid hangs at shutdown.
*/
* We have to obey a stop/suspend request even if
* allow_interruption is FALSE to avoid hangs at shutdown.
*/
- if (!mono_thread_test_state (mono_thread_internal_current (),
(MonoThreadState)(ThreadState_StopRequested | ThreadState_SuspendRequested | ThreadState_AbortRequested)
)) {
+ if (!mono_thread_test_state (mono_thread_internal_current (),
ThreadState_SuspendRequested | ThreadState_AbortRequested
)) {
if (ms != MONO_INFINITE_WAIT) {
now = mono_msec_ticks ();
if (ms != MONO_INFINITE_WAIT) {
now = mono_msec_ticks ();
diff --git
a/mono/metadata/object-internals.h
b/mono/metadata/object-internals.h
index 958d25ac914fe47c075d4a2722da3d76b48534b9..3e6c7f3e47ba3a874700f2cbb341563f2fa0df42 100644
(file)
--- a/
mono/metadata/object-internals.h
+++ b/
mono/metadata/object-internals.h
@@
-388,7
+388,7
@@
struct _MonoInternalThread {
gint32 managed_id;
guint32 small_id;
MonoThreadManageCallback manage_callback;
gint32 managed_id;
guint32 small_id;
MonoThreadManageCallback manage_callback;
- gpointer
interrupt_on_stop
;
+ gpointer
unused4
;
gsize flags;
gpointer thread_pinning_ref;
gsize __abort_protected_block_count;
gsize flags;
gpointer thread_pinning_ref;
gsize __abort_protected_block_count;
diff --git
a/mono/metadata/threadpool-io-epoll.c
b/mono/metadata/threadpool-io-epoll.c
index 2bc99e105b9cca5e57845d28d8ff21e3a68a305d..82d9b07ad14de051920b533ef9245005641a981e 100644
(file)
--- a/
mono/metadata/threadpool-io-epoll.c
+++ b/
mono/metadata/threadpool-io-epoll.c
@@
-93,7
+93,6
@@
epoll_event_wait (void (*callback) (gint fd, gint events, gpointer user_data), g
if (ready == -1) {
switch (errno) {
case EINTR:
if (ready == -1) {
switch (errno) {
case EINTR:
- mono_thread_internal_check_for_interruption_critical (mono_thread_internal_current ());
ready = 0;
break;
default:
ready = 0;
break;
default:
diff --git
a/mono/metadata/threadpool-io-kqueue.c
b/mono/metadata/threadpool-io-kqueue.c
index 4422b668e8f61c7c2d2a630e1b1cb702dfb5fd56..47f346a28918863dfae0fae8fcc8568f28d1874d 100644
(file)
--- a/
mono/metadata/threadpool-io-kqueue.c
+++ b/
mono/metadata/threadpool-io-kqueue.c
@@
-90,7
+90,6
@@
kqueue_event_wait (void (*callback) (gint fd, gint events, gpointer user_data),
if (ready == -1) {
switch (errno) {
case EINTR:
if (ready == -1) {
switch (errno) {
case EINTR:
- mono_thread_internal_check_for_interruption_critical (mono_thread_internal_current ());
ready = 0;
break;
default:
ready = 0;
break;
default:
diff --git
a/mono/metadata/threadpool-io-poll.c
b/mono/metadata/threadpool-io-poll.c
index 3d32130d3b530cc14ad38ce04cffaf5258ac28cf..d7eff1c210c9feee2ed71ddd206a90f13af9d5fc 100644
(file)
--- a/
mono/metadata/threadpool-io-poll.c
+++ b/
mono/metadata/threadpool-io-poll.c
@@
-163,7
+163,6
@@
poll_event_wait (void (*callback) (gint fd, gint events, gpointer user_data), gp
{
case EINTR:
{
{
case EINTR:
{
- mono_thread_internal_check_for_interruption_critical (mono_thread_internal_current ());
ready = 0;
break;
}
ready = 0;
break;
}
diff --git
a/mono/metadata/threadpool-worker-default.c
b/mono/metadata/threadpool-worker-default.c
index c1f4a878e9916f65673e6a93b09aa8cad22407bc..3a87574aab1015efd48bcca798342fa1ac8759e8 100644
(file)
--- a/
mono/metadata/threadpool-worker-default.c
+++ b/
mono/metadata/threadpool-worker-default.c
@@
-743,7
+743,6
@@
monitor_thread (gpointer unused)
break;
interval_left -= mono_msec_ticks () - ts;
break;
interval_left -= mono_msec_ticks () - ts;
- g_assert (!(internal->state & ThreadState_StopRequested));
mono_thread_interruption_checkpoint ();
} while (interval_left > 0 && ++awake < 10);
mono_thread_interruption_checkpoint ();
} while (interval_left > 0 && ++awake < 10);
diff --git
a/mono/metadata/threads-types.h
b/mono/metadata/threads-types.h
index cc1ee27d936dabcb0cc2fb0852465b46658f842a..25571e7f896f7877aed0cb90fef41920d6320ffd 100644
(file)
--- a/
mono/metadata/threads-types.h
+++ b/
mono/metadata/threads-types.h
@@
-23,7
+23,6
@@
/* This is a copy of System.Threading.ThreadState */
typedef enum {
ThreadState_Running = 0x00000000,
/* This is a copy of System.Threading.ThreadState */
typedef enum {
ThreadState_Running = 0x00000000,
- ThreadState_StopRequested = 0x00000001,
ThreadState_SuspendRequested = 0x00000002,
ThreadState_Background = 0x00000004,
ThreadState_Unstarted = 0x00000008,
ThreadState_SuspendRequested = 0x00000002,
ThreadState_Background = 0x00000004,
ThreadState_Unstarted = 0x00000008,
@@
-183,8
+182,6
@@
void ves_icall_System_Runtime_Remoting_Contexts_Context_ReleaseContext (MonoAppC
MonoInternalThread *mono_thread_internal_current (void);
MonoInternalThread *mono_thread_internal_current (void);
-void mono_thread_internal_check_for_interruption_critical (MonoInternalThread *thread);
-
void mono_thread_internal_abort (MonoInternalThread *thread);
void mono_thread_internal_suspend_for_shutdown (MonoInternalThread *thread);
void mono_thread_internal_abort (MonoInternalThread *thread);
void mono_thread_internal_suspend_for_shutdown (MonoInternalThread *thread);
diff --git
a/mono/metadata/threads.c
b/mono/metadata/threads.c
index 5f290cf3dc253021723fcc2acd6496021cb021b8..57e1d9addf3d489102d8bab5e5219a1d1dcabd41 100644
(file)
--- a/
mono/metadata/threads.c
+++ b/
mono/metadata/threads.c
@@
-2352,9
+2352,7
@@
request_thread_abort (MonoInternalThread *thread, MonoObject *state)
{
LOCK_THREAD (thread);
{
LOCK_THREAD (thread);
- if ((thread->state & ThreadState_AbortRequested) != 0 ||
- (thread->state & ThreadState_StopRequested) != 0 ||
- (thread->state & ThreadState_Stopped) != 0)
+ if (thread->state & (ThreadState_AbortRequested | ThreadState_Stopped))
{
UNLOCK_THREAD (thread);
return FALSE;
{
UNLOCK_THREAD (thread);
return FALSE;
@@
-2506,17
+2504,13
@@
mono_thread_suspend (MonoInternalThread *thread)
{
LOCK_THREAD (thread);
{
LOCK_THREAD (thread);
- if ((thread->state & ThreadState_Unstarted) != 0 ||
- (thread->state & ThreadState_Aborted) != 0 ||
- (thread->state & ThreadState_Stopped) != 0)
+ if (thread->state & (ThreadState_Unstarted | ThreadState_Aborted | ThreadState_Stopped))
{
UNLOCK_THREAD (thread);
return FALSE;
}
{
UNLOCK_THREAD (thread);
return FALSE;
}
- if ((thread->state & ThreadState_Suspended) != 0 ||
- (thread->state & ThreadState_SuspendRequested) != 0 ||
- (thread->state & ThreadState_StopRequested) != 0)
+ if (thread->state & (ThreadState_Suspended | ThreadState_SuspendRequested | ThreadState_AbortRequested))
{
UNLOCK_THREAD (thread);
return TRUE;
{
UNLOCK_THREAD (thread);
return TRUE;
@@
-2635,21
+2629,8
@@
mono_thread_stop (MonoThread *thread)
{
MonoInternalThread *internal = thread->internal_thread;
{
MonoInternalThread *internal = thread->internal_thread;
- LOCK_THREAD (internal);
-
- if (internal->state & (ThreadState_StopRequested | ThreadState_Stopped))
- {
- UNLOCK_THREAD (internal);
+ if (!request_thread_abort (internal, NULL))
return;
return;
- }
-
- /* Make sure the internal is awake */
- mono_thread_resume (internal);
-
- internal->state |= ThreadState_StopRequested;
- internal->state &= ~ThreadState_AbortRequested;
-
- UNLOCK_THREAD (internal);
if (internal == mono_thread_internal_current ()) {
MonoError error;
if (internal == mono_thread_internal_current ()) {
MonoError error;
@@
-3221,13
+3202,10
@@
mono_threads_set_shutting_down (void)
LOCK_THREAD (current_thread);
LOCK_THREAD (current_thread);
- if ((current_thread->state & ThreadState_SuspendRequested) ||
- (current_thread->state & ThreadState_AbortRequested) ||
- (current_thread->state & ThreadState_StopRequested)) {
+ if (current_thread->state & (ThreadState_SuspendRequested | ThreadState_AbortRequested)) {
UNLOCK_THREAD (current_thread);
mono_thread_execute_interruption ();
} else {
UNLOCK_THREAD (current_thread);
mono_thread_execute_interruption ();
} else {
- current_thread->state |= ThreadState_Stopped;
UNLOCK_THREAD (current_thread);
}
UNLOCK_THREAD (current_thread);
}
@@
-3410,9
+3388,7
@@
void mono_thread_suspend_all_other_threads (void)
LOCK_THREAD (thread);
LOCK_THREAD (thread);
- if ((thread->state & ThreadState_Suspended) != 0 ||
- (thread->state & ThreadState_StopRequested) != 0 ||
- (thread->state & ThreadState_Stopped) != 0) {
+ if (thread->state & (ThreadState_Suspended | ThreadState_Stopped)) {
UNLOCK_THREAD (thread);
mono_threads_close_thread_handle (wait->handles [i]);
wait->threads [i] = NULL;
UNLOCK_THREAD (thread);
mono_threads_close_thread_handle (wait->handles [i]);
wait->threads [i] = NULL;
@@
-4426,7
+4402,7
@@
mono_thread_execute_interruption (void)
UNLOCK_THREAD (thread);
return exc;
UNLOCK_THREAD (thread);
return exc;
- } else if (
(thread->state & ThreadState_AbortRequested) != 0
) {
+ } else if (
thread->state & (ThreadState_AbortRequested)
) {
UNLOCK_THREAD (thread);
g_assert (sys_thread->pending_exception == NULL);
if (thread->abort_exc == NULL) {
UNLOCK_THREAD (thread);
g_assert (sys_thread->pending_exception == NULL);
if (thread->abort_exc == NULL) {
@@
-4437,19
+4413,10
@@
mono_thread_execute_interruption (void)
MONO_OBJECT_SETREF (thread, abort_exc, mono_get_exception_thread_abort ());
}
return thread->abort_exc;
MONO_OBJECT_SETREF (thread, abort_exc, mono_get_exception_thread_abort ());
}
return thread->abort_exc;
- }
- else if ((thread->state & ThreadState_SuspendRequested) != 0) {
+ } else if (thread->state & (ThreadState_SuspendRequested)) {
/* calls UNLOCK_THREAD (thread) */
self_suspend_internal ();
return NULL;
/* calls UNLOCK_THREAD (thread) */
self_suspend_internal ();
return NULL;
- }
- else if ((thread->state & ThreadState_StopRequested) != 0) {
- /* FIXME: do this through the JIT? */
-
- UNLOCK_THREAD (thread);
-
- mono_thread_exit ();
- return NULL;
} else if (thread->thread_interrupt_requested) {
thread->thread_interrupt_requested = FALSE;
} else if (thread->thread_interrupt_requested) {
thread->thread_interrupt_requested = FALSE;
@@
-4480,12
+4447,6
@@
mono_thread_request_interruption (gboolean running_managed)
if (thread == NULL)
return NULL;
if (thread == NULL)
return NULL;
-#ifdef HOST_WIN32
- if (thread->interrupt_on_stop &&
- thread->state & ThreadState_StopRequested &&
- thread->state & ThreadState_Background)
- ExitThread (1);
-#endif
if (!mono_thread_set_interruption_requested (thread))
return NULL;
InterlockedIncrement (&thread_interruption_requested);
if (!mono_thread_set_interruption_requested (thread))
return NULL;
InterlockedIncrement (&thread_interruption_requested);
@@
-4523,7
+4484,7
@@
mono_thread_resume_interruption (void)
return NULL;
LOCK_THREAD (thread);
return NULL;
LOCK_THREAD (thread);
- still_aborting = (thread->state & (ThreadState_AbortRequested
|ThreadState_StopRequested
)) != 0;
+ still_aborting = (thread->state & (ThreadState_AbortRequested)) != 0;
UNLOCK_THREAD (thread);
/*This can happen if the protected block called Thread::ResetAbort*/
UNLOCK_THREAD (thread);
/*This can happen if the protected block called Thread::ResetAbort*/
@@
-5083,13
+5044,6
@@
mono_thread_join (gpointer tid)
#endif
}
#endif
}
-void
-mono_thread_internal_check_for_interruption_critical (MonoInternalThread *thread)
-{
- if ((thread->state & (ThreadState_StopRequested | ThreadState_SuspendRequested)) != 0)
- mono_thread_interruption_checkpoint ();
-}
-
void
mono_thread_internal_unhandled_exception (MonoObject* exc)
{
void
mono_thread_internal_unhandled_exception (MonoObject* exc)
{
@@
-5236,7
+5190,7
@@
mono_threads_is_ready_to_be_interrupted (void)
thread = mono_thread_internal_current ();
LOCK_THREAD (thread);
thread = mono_thread_internal_current ();
LOCK_THREAD (thread);
- if (thread->state & (
MonoThreadState)(ThreadState_StopRequested |
ThreadState_SuspendRequested | ThreadState_AbortRequested)) {
+ if (thread->state & (ThreadState_SuspendRequested | ThreadState_AbortRequested)) {
UNLOCK_THREAD (thread);
return FALSE;
}
UNLOCK_THREAD (thread);
return FALSE;
}
diff --git
a/mono/metadata/w32socket-win32.c
b/mono/metadata/w32socket-win32.c
index 4d71777f06d350bef9a6f218d92cf3574441c129..1c6f8fd8307a8203a200e041380a1dff4048d4f2 100644
(file)
--- a/
mono/metadata/w32socket-win32.c
+++ b/
mono/metadata/w32socket-win32.c
@@
-136,9
+136,7
@@
SOCKET mono_w32socket_accept (SOCKET s, struct sockaddr *addr, socklen_t *addrle
{
MonoInternalThread *curthread = mono_thread_internal_current ();
SOCKET newsock = INVALID_SOCKET;
{
MonoInternalThread *curthread = mono_thread_internal_current ();
SOCKET newsock = INVALID_SOCKET;
- curthread->interrupt_on_stop = (gpointer)TRUE;
ALERTABLE_SOCKET_CALL (FD_ACCEPT_BIT, blocking, TRUE, newsock, accept, s, addr, addrlen);
ALERTABLE_SOCKET_CALL (FD_ACCEPT_BIT, blocking, TRUE, newsock, accept, s, addr, addrlen);
- curthread->interrupt_on_stop = (gpointer)FALSE;
return newsock;
}
return newsock;
}
@@
-154,9
+152,7
@@
int mono_w32socket_recv (SOCKET s, char *buf, int len, int flags, gboolean block
{
MonoInternalThread *curthread = mono_thread_internal_current ();
int ret = SOCKET_ERROR;
{
MonoInternalThread *curthread = mono_thread_internal_current ();
int ret = SOCKET_ERROR;
- curthread->interrupt_on_stop = (gpointer)TRUE;
ALERTABLE_SOCKET_CALL (FD_READ_BIT, blocking, TRUE, ret, recv, s, buf, len, flags);
ALERTABLE_SOCKET_CALL (FD_READ_BIT, blocking, TRUE, ret, recv, s, buf, len, flags);
- curthread->interrupt_on_stop = (gpointer)FALSE;
return ret;
}
return ret;
}
diff --git
a/mono/metadata/w32socket.c
b/mono/metadata/w32socket.c
index 5312790ad644b21b43d518ab238c73ab15ea2458..8bc8b49a8c5b70bb2043829c7bb12797141bf069 100644
(file)
--- a/
mono/metadata/w32socket.c
+++ b/
mono/metadata/w32socket.c
@@
-1270,7
+1270,7
@@
ves_icall_System_Net_Sockets_Socket_Poll_internal (gsize sock, gint mode,
}
if (ret == -1 && errno == EINTR) {
}
if (ret == -1 && errno == EINTR) {
- if (mono_thread_test_state (thread,
(MonoThreadState)(ThreadState_AbortRequested | ThreadState_StopRequested)
)) {
+ if (mono_thread_test_state (thread,
ThreadState_AbortRequested
)) {
g_free (pfds);
return FALSE;
}
g_free (pfds);
return FALSE;
}
@@
-1777,7
+1777,7
@@
ves_icall_System_Net_Sockets_Socket_Select_internal (MonoArray **sockets, gint32
}
if (ret == -1 && errno == EINTR) {
}
if (ret == -1 && errno == EINTR) {
- if (mono_thread_test_state (thread,
(MonoThreadState)(ThreadState_AbortRequested | ThreadState_StopRequested)
)) {
+ if (mono_thread_test_state (thread,
ThreadState_AbortRequested
)) {
g_free (pfds);
*sockets = NULL;
return;
g_free (pfds);
*sockets = NULL;
return;