develooper Front page | perl.perl5.porters | Postings from October 2005

[perl #33831] EMFILE misinterpretation

From:
Steve Peters via RT
Date:
October 1, 2005 22:03
Subject:
[perl #33831] EMFILE misinterpretation
Message ID:
rt-3.0.11-33831-121883.3.37614056627316@perl.org
> [stmpeters - Wed Sep 28 07:56:54 2005]:
> 
> On Wed, Sep 28, 2005 at 12:38:06PM +0100, Nicholas Clark wrote:
> > On Tue, Sep 27, 2005 at 07:40:28PM -0700, Steve Peters via RT wrote:
> > 
> > > This problem has come up before with the solution being to simply
> > > increase the max open filehandles.  This error message, however,
is very
> > > confusing.  I'm suggesting something like the following patch to
clarify
> > > the situation.  Not knowing Perl's internals that well, can someone
> > > please look this over before I apply it?  Also, I'm simply using
> > > strerror(errno) to get the error message.  Any other suggestions?
> > > I tested the patch with and without threads and it worked fine. 
Here's
> > > a quick test showing the difference.
> > 
> > I don't know about errno particularly, but I see some messy logic in
> > case '!' in mg.c that sets $!, which seems to use a Strerror macro.
> > 
> > > steve@kirk:~/perl-current$ ulimit -n
> > > 4
> > > steve@kirk:~/perl-current$ perl5.8.7 -MCarp -e1
> > > Can't locate Carp.pm in @INC (@INC contains: /etc/perl
> > > /usr/local/lib/perl/5.8.7 /usr/local/share/perl/5.8.7 /usr/lib/perl5
> > > /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8
> > > /usr/local/lib/site_perl /usr/local/lib/perl/5.8.4
> > > /usr/local/share/perl/5.8.4 .).
> > > BEGIN failed--compilation aborted.
> > > 
> > > ... now the new version ...
> > > 
> > > steve@kirk:~/perl-current$ ./perl -I lib -MCarp -e1
> > > Too many open files.
> > 
> > I think I'd prefer the message to give some clue about what was up -
maybe
> > 
> >   Can't locate Carp.pm - Too many open files.
> > 
> 
> Great!  Thanks for the hints, and I'll look into this patch further this
> evening.
> 

OK, a few days later, but worth it.  The futzing in mg.c for setting $!
deal with specific values for errno on VMS and OS/2 that indicate an
OS-specific error message.  Since I'm simply looking for EMFILE, the
complex logic doesn't seem necessary.  I did change the code to use 
Strerror() and filled in the error message as above.  The fix has been
commited to blead at change #25677.



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About