That's a good idea. Unfortunately, I think that the problems go much deeper than I've yet discovered.
If you stop the code from calling fstat(), it runs on a bit further before hanging again. This time it calls the CRT ftell() on a socket, which blocks because of the lock applied in the accept call. And if you fix that ....
I tried (more in hope than expectation), that compiling without USE_PERLIO and/or enabling USE_PERLCRT might avoid some of the show stoppers in PERLIO, but it seems that Perl has become dependant upon PerlIO now :(
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.
| [reply] |
Seems to me the real problem is not that fstat and ftell lock the CRT (since they only do so transiently), it's that accept locks the CRT (since it does so for an extended period of time). Is it possible to recode accept to avoid the CRT?
| [reply] [d/l] [select] |
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.
| [reply] [d/l] [select] |