the real problem is not that fstat and ftell lock the CRT
I agree with that, but rather than pointing the finger at accept(), (which (assumption!) locks the underlying file descriptor as it will be modified by when the call completes), but rather at the PerlIO that calls f*() calls on sockets.
I guess you could also blame the CRT for locking the file descriptors before checking whether they are valid handles for the operation to be performed.
Is it possible to recode accept to avoid the CRT?
On a cursory inspection I don't think so. accept() is just redined as win32_accept(), and that essentially just calls the CRT accept():
SOCKET
win32_accept(SOCKET s, struct sockaddr *addr, int *addrlen)
{
SOCKET r;
SOCKET_TEST((r = accept(TO_SOCKET(s), addr, addrlen)), INVALID_SOC
+KET);
return OPEN_SOCKET(r);
}
I don't have access to the MSCRT sources, (I think you can pay for such access?), but from my point of view it's an opaque box. And probably should be.
In the end, like so many others, the root of this problem lies in the difficulty of trying to make a non-POSIX OS act like POSIX. It's amazing that as much works as does.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
|