3 ms·
Saw the red flag on the very first page: > the socket polling thread then dequeues these requests one by one, calls select() The select() API is not good reg
by Const-me 5y ago
Saw the red flag on the very first page:
> the socket polling thread then dequeues these requests one by one, calls select()
The select() API is not good regardless on the platform.
If you like the semantics and developing for Linux, use poll() instead. It does exactly the same thing, but the API is good.
Windows API supports thread pools, it's usually a good idea to use StartThreadpoolIo instead.
- zbentley 5y agoHow would poll() have helped in this case? It seems like the error condition in the article (interrupting syscalls in unexpected ways can trash whatever state your syscall wrapper manages for e.g. return values) is a risk regardless of the blocking operation being performed.
- Const-me 5y agopoll is not available for Windows. The semantic is similar to WaitForMultipleObjects with overlapped IO but not quite. Thread pool API doesn't have this class of bugs. One doesn't need to wake up any threads to change the set of handles being polled.
- Matthias247 5y agoThat's a bit of a apples-to-oranges comparison. The description on the blog says the `select` call runs on a thread which is mainly responsible for checking for IO readiness. They use the information somewhere else to perform IO. Probably on a threadpool.