X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Futils%2Fmono-threads.c;h=40cd9b17dc4c1cc3dc4d337a8e2747d198b71929;hb=62972f9afb0a9ef302ab9a34de6cd9c6cf643351;hp=c208637cf3f768b33c62d361735699b9b6a7dcee;hpb=b51d0597eaa6dd46a68d97770b0411c8e2c04862;p=mono.git diff --git a/mono/utils/mono-threads.c b/mono/utils/mono-threads.c index c208637cf3f..40cd9b17dc4 100644 --- a/mono/utils/mono-threads.c +++ b/mono/utils/mono-threads.c @@ -540,6 +540,44 @@ mono_thread_info_disable_new_interrupt (gboolean disable) { disable_new_interrupt = disable; } + +/* + * This is a very specific function whose only purpose is to + * break a given thread from socket syscalls. + * + * This only exists because linux won't fail a call to connect + * if the underlying is closed. + * + * TODO We should cleanup and unify this with the other syscall abort + * facility. + */ +void +mono_thread_info_abort_socket_syscall_for_close (MonoNativeThreadId tid) +{ + MonoThreadHazardPointers *hp; + MonoThreadInfo *info; + + if (tid == mono_native_thread_id_get () || !mono_threads_core_needs_abort_syscall ()) + return; + + hp = mono_hazard_pointer_get (); + info = mono_thread_info_lookup (tid); /*info on HP1*/ + if (!info) + return; + + if (mono_thread_info_run_state (info) > STATE_RUNNING) { + mono_hazard_pointer_clear (hp, 1); + return; + } + + mono_thread_info_suspend_lock (); + + mono_threads_core_abort_syscall (info); + + mono_hazard_pointer_clear (hp, 1); + mono_thread_info_suspend_unlock (); +} + /* Disabled by default for now. To enable this we need mini to implement the callbacks by MonoThreadInfoRuntimeCallbacks