[threadpool-io] Throw if backend won't be able to register a FD (mono/mono#16396)
authorAleksey Kliger (λgeek) <alklig@microsoft.com>
Mon, 26 Aug 2019 21:13:45 +0000 (17:13 -0400)
committerGitHub <noreply@github.com>
Mon, 26 Aug 2019 21:13:45 +0000 (17:13 -0400)
commit34b98acbc0888906795e5c7adcd901746e99ef7d
tree33d3389de872dba1e37cca38ce302ed0127a25db
parentf6c632a8ffe3012dcee9454253404e5f597da927
[threadpool-io] Throw if backend won't be able to register a FD (mono/mono#16396)

The poll+select i/o selector backend can't handle file descriptor ids greater
than FD_SETSIZE.  This can happen if too many files are open and we want to
wait on it.

Previously, mono would fail in the i/o selector thread by which point it was
too late to do anything.

With this change we will fail eagerly on the thread that calls IOSelector.Add
by throwing a NotSupportedException.

Addresses https://github.com/mono/mono/issues/15931

Commit migrated from https://github.com/mono/mono/commit/78edafd6e2d5ce886e2fd2ddc3cf8bbbffeeb860
src/mono/mono/metadata/threadpool-io-epoll.c
src/mono/mono/metadata/threadpool-io-kqueue.c
src/mono/mono/metadata/threadpool-io-poll.c
src/mono/mono/metadata/threadpool-io.c
src/mono/mono/utils/mono-poll.c
src/mono/mono/utils/mono-poll.h