🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #83873

Re: File descriptor limits.

#83873
From: Miquel van Smoorenburg
Date: Thu, 17 Feb 2011 14:58
38 lines
2432 bytes
In article <87lj1g4a0y.fsf@araminta.anjou.terraraq.org.uk>,
Richard Kettlewell  <rjk@greenend.org.uk> wrote:
>On many platforms it's sufficient to rebuild your program with an
>explicit, larger, definition for FD_SETSIZE; rebuilding the whole Libc
>is not required.
>
>Glibc makes this unusually awkward, for some reason, unconditionally
>using an internal __FD_SETSIZE and explicitly ignoring any attempts to
>override it.

#define LARGE_FD_SETSIZE 4096

/*
 * Cannot increase FD_SETSIZE on Linux, but we can increase __FD_SETSIZE
 * with glibc 2.2 and 2.3 at least. We do this by including
 * bits/types.h which defines __FD_SETSIZE first (before any other include),
 * then we redefine __FD_SETSIZE. Ofcourse a user program may NEVER
 * include bits/whatever.h directly, so this is a dirty hack!
 */
#if LARGE_FD_SETSIZE > 1024
#  ifdef __linux__
#    include <features.h>
#    if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
#      include <bits/types.h>
#      undef __FD_SETSIZE
#      define __FD_SETSIZE LARGE_FD_SETSIZE
#    endif
#  else
     /* Works on most BSDs */
#    define FD_SETSIZE LARGE_FD_SETSIZE
#  endif
#endif

#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>

Mike.
Technical Details
Message-ID: <4d5d37ad$0$41113$e4fe514c@news.xs4all.nl>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!border1.nntp.ams.giganews.com!nntp.giganews.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!193.201.147.78.MISMATCH!feeder.news-service.com!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
References: <ijc6vh$12l$1@snarked.org> <ijd9rf$vl6$2@selene.doeblitz.net> <87lj1g4a0y.fsf@araminta.anjou.terraraq.org.uk>

Show Full Headers
Complete Article Headers
Message-ID: <4d5d37ad$0$41113$e4fe514c@news.xs4all.nl>
Subject: Re: File descriptor limits.
Date: Thu, 17 Feb 2011 14:58:53 +0000
From: "Miquel van Smoorenburg" <miquels@netscum.invalid>
References: <ijc6vh$12l$1@snarked.org> <ijd9rf$vl6$2@selene.doeblitz.net> <87lj1g4a0y.fsf@araminta.anjou.terraraq.org.uk>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!border1.nntp.ams.giganews.com!nntp.giganews.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!193.201.147.78.MISMATCH!feeder.news-service.com!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Newsgroups: news.software.nntp
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15
Content-Transfer-Encoding: 8bit
X-Newsreader: trn 4.0-test76 (Apr 2, 2001)
Originator: mikevs@xs8.xs4all.nl (Miquel van Smoorenburg)
Lines: 38
NNTP-Posting-Host: 194.109.21.8
X-Trace: 1297954733 news.xs4all.nl 41113 [::ffff:194.109.21.8]:44596
X-Complaints-To: abuse@xs4all.nl