Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
then all I'd like to see is the description of situations where the kernel would close your file descriptor

The mistake you keep making is assuming that it must be the (a) OS kernel that is doing this.

Perl is perhaps a more likely target for responsibility. For example:

{ my $sock = new IO::Socket::INET( 'localhost:12345' ); } ## Here the handle is closed.

And:

for( 1 .. 2 ){ my $sock = new IO::Socket::INET( 'localhost:12345' ); } ## The first handle was implicitly closed during the second iteration.

These examples probably won't convince you, because the scoping is too obvious. But scoping isn't always so obvious, especially when programming in the "global state and gotos" style often required by event-driven architectures.

Similarly, this is normally perfectly fine:

... my $client = $svr->accept; async { ## do things with $client }->detach;

But, this usually not:

... my $client = $svr->accept; async { sleep 10; ## attempts to use $client fail }->detach;

The reason is that before the thread gets around to using its copy of the client handle, the parent thread has accepted another client. Now imagine the sleep isn't a programmed delay, but rather one caused by system loading (cpu; memory; IO) preventing the new thread getting up and running in a timely manner, so that the parent thread implicitly overwrite (and therefore closes) $client before the child thread gets to the point where it increments the reference count.

But you'll dismiss that as a "threads-issue".

I can't offer you an explanation of the linux example I cited -- I don't know the guy, nor do I do Linux -- but if the p5p guys took his perlbug seriously enough to patch perl; that's good enough for me to believe that it was a real issue.

I can also find other references to linux sockets mysteriously going awol, even outside of Perl. What I cannot do is pass judgement on the validity of the claims.

But even if every single occasion when an attempt is made to remove a closed file handle from an IO::Select object is down to programmer error; silently doing nothing and thus screwing the entire select loop is ... is ... shall we stick with: not very friendly.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
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.

RIP Neil Armstrong


In reply to Re^5: Does IO::Select work? (Problem partially resolved) by BrowserUk
in thread Does IO::Select work? Anywhere? by BrowserUk

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-18 23:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found