[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: irc 2.11.0 fdopen bug



Hi,

Your patch will not work, either.  The limitiation is in Solaris's use of
a 'char' for 'fd' in the FILE struct.  That means even fopen() cannot be
used when fds 0-255 are already in use.  The quickest kludge is to do
something like this, instead:

http://www.comstud.com/irc2.11.0-fdopen2.diff

When the conf file is initially loaded, the fd used will be low enough
that it's fine to use with fdopen.  Now, just don't close it, until
immediately before reading the conf file again.  That'll make the kernel
re-use that same fd# (the kernel always returns the lowest fd# that is
available) in openconf() because nothing else uses a new fd between
your fclose() and the call of openconf().

That make sense?  It's definitely a kludge...leaving the file open.  The
real fix is obviously to not use 'FILE'. :)

- Chris / comstud@efnet

-- 
Chris Behrens
Senior Software Architect
XO Communications

On Sat, Feb 12, 2005 at 02:40:58AM +0100, Piotr KUCHARSKI wrote:
> Hello,
> 
> I am sorry to inform that some platforms (Solaris[1], SGI[2]) have
> fdopen implementation, which doesn't work with fd bigger than 255.
> 
> This affects ircd 2.11.0 if compiled with CONFIG_DIRECTIVE_INCLUDE
> define (default off) and MAXCONNECTIONS more than about 250. It is
> triggered by REHASH (either oper-issued or kill -HUP), when open()
> for ircd.conf returns fd bigger than 255.
> 
> A quick program to check:
>     http://42.pl/ircd/patches/test-fdopen.c
> Note that it only checks 256 limit; your fdopen() may behave wrong
> for bigger fds, check on your own with MAXCONNECTIONS.
> 
> There's a patch to apply to ircd, if you are affected:
>     http://42.pl/ircd/patches/irc2.11.0-fdopen.diff
>     ftp://ftp.irc.org/irc/server/irc2.11.0-fdopen.diff
> 
> Workaround: do not rehash. ;-)
> 
> Once again I am sorry for that.
> 
> p.
> 
> [1] Checked on 2.6, 8 and 9.
> [2] So I've heard.
> 
> -- 
> Beware of he who would deny you access to information, for in his
> heart he dreams himself your master.   -- Commissioner Pravin Lal
> http://nerdquiz.sgh.waw.pl/  -- polska wersja quizu dla nerdów ;)