From: Eric Dumazet <dada1@cosmosbay.com>
To: Olaf van der Spek <olafvdspek@gmail.com>
Cc: Davide Libenzi <davidel@xmailserver.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: epoll behaviour after running out of descriptors
Date: Sun, 02 Nov 2008 20:10:37 +0100 [thread overview]
Message-ID: <490DFB2D.3090906@cosmosbay.com> (raw)
In-Reply-To: <b2cc26e40811021051kc748db3x44231dc0c085a8d6@mail.gmail.com>
Olaf van der Spek a écrit :
> On Sun, Nov 2, 2008 at 7:48 PM, Davide Libenzi <davidel@xmailserver.org> wrote:
>> Why don't you grep for TIME_WAIT?
>
> Because I don't have access to the test environment at the moment.
Hello Olaf
If your application calls accept() and accept() returns EMFILE, its a nullop.
On listen queue, socket is still ready for an accept().
Since you use edge trigered epoll, you'll only reveive new notification.
You probably had in you app a : listen(sock, 10), so after 10 notifications,
your listen queue is full and TCP stack refuses to handle new connections.
In order to cope with this kind of thing the trick I personnally use is to always keep
around a *free* fd, that is :
At start of program, reserve an "emergency fd"
free_fd = open("/dev/null", O_RDONLY)
Then later :
newfd = accept(...)
if (newfd == -1 && errno == EMFILE) {
/* emergency action : clean listen queue */
close(free_fd);
newfd = accept(...);
close(newfd); /* forget this incoming connection, we dont have enough fd */
free_fd = open("/dev/null"; O_RDONLY);
}
Of course, if your application is multi-threaded, you might adapt (and eventually reserve
one emergency fd per thread)
next prev parent reply other threads:[~2008-11-02 19:10 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-01 16:38 Olaf van der Spek
2008-11-02 18:25 ` Davide Libenzi
2008-11-02 18:33 ` Olaf van der Spek
2008-11-02 18:48 ` Davide Libenzi
2008-11-02 18:51 ` Olaf van der Spek
2008-11-02 19:10 ` Eric Dumazet [this message]
2008-11-02 19:15 ` Olaf van der Spek
2008-11-02 19:17 ` Davide Libenzi
2008-11-02 19:20 ` Olaf van der Spek
2008-11-02 19:27 ` Davide Libenzi
2008-11-02 20:41 ` Olaf van der Spek
2008-11-02 21:17 ` Davide Libenzi
2008-11-02 22:17 ` Olaf van der Spek
2008-11-02 22:49 ` Davide Libenzi
2008-11-03 8:07 ` Olaf van der Spek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=490DFB2D.3090906@cosmosbay.com \
--to=dada1@cosmosbay.com \
--cc=davidel@xmailserver.org \
--cc=linux-kernel@vger.kernel.org \
--cc=olafvdspek@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®