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.
"I'd rather go naked than blow up my ass"

In reply to Re^6: threads + sockets stalling question by BrowserUk
in thread threads + sockets stalling question by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.