[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.