[socket] Enable Thread.Abort on blocking syscall
commit11096e3733b808a8bbfce262c256ec89887cac89
authorLudovic Henry <ludovic@xamarin.com>
Tue, 15 Sep 2015 10:21:55 +0000 (15 11:21 +0100)
committerLudovic Henry <ludovic@xamarin.com>
Tue, 6 Oct 2015 13:48:22 +0000 (6 14:48 +0100)
tree31d5318399d3809d2d5080ee0ca7bfb25dc4a973
parent0056f1ff018a9690a467f66aadae928728d7436f
[socket] Enable Thread.Abort on blocking syscall

By installing interrupt token around the blocking syscalls, we make it possible to abort them with signals.

Previously, the only way to interrupt a blocking syscall, would have been to dispose of the SafeSocketHandle associated to the socket. But that make it impossible to abort the following case:
 - thread T1 accept a socket S and launch T2 (as a background thread) to receive on S
 - T2 block on receive
 - T1 (the main thread) quit, and the shutdown code try to abort T2

T2 would never be aborted, because S would never return from its blocking syscall, and that's because T2:
 - would still have a reference to S, making it impossible to call the finalizer on S
 - will not call Dispose on S before returning from the blocking syscall

This fixes the hang observed on System.Net.HttpWebRequestTest.GetRequestStream with the cooperative GC.
mono/metadata/socket-io.c