mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Davide Libenzi <davidel@xmailserver.org>
To: Olaf van der Spek <olafvdspek@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: epoll behaviour after running out of descriptors
Date: Sun, 2 Nov 2008 10:25:27 -0800 (PST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0811021022120.9451@alien.or.mcafeemobile.com> (raw)
In-Reply-To: <b2cc26e40811010938k3864c48j45ce55af09516302@mail.gmail.com>

On Sat, 1 Nov 2008, Olaf van der Spek wrote:

> Hi,
> 
> I noticed some strange behaviour of epoll after running out of descriptors.
> I've registered a listen socket to epoll with edge triggering. On the
> client-side I use an app that simply keeps opening connections.
> When accept returns EMFILE, I call epoll_wait and accept and it
> returns with another EMFILE.
> This happens 10 times or so, after that epoll_wait no longer returns
> with the listen socket ready.
> I then close all file descriptors, but epoll_wait will still not return.
> So my question is, why does it 'only' happen 10 times and what is the
> expected behaviour?
> And how should an app handle this?
> 
> The example in the epoll man page doesn't seem to handle this.
> 
> An idea I had was for epoll_wait to only return with accept / EMFILE
> once. Then after a descriptor becomes available, epoll_wait would
> return again.
> 
> See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=502901
> 
> Hi,
> 
> I've written a web app that should be able to handle a lot of new
> connections per second (1000+). On multiple servers I've hit a bug.
> After running out of descriptors, then closing descriptors, epoll_wait
> doesn't return anymore for the listen socket.
> I've attached code to reproduce the issue. And an strace log. Even
> before closing the descriptors you see epoll_wait already stops returning.

A bug? For starters, epoll_wait does NOT create new files, so no EMFILE 
can come out from there.
You are saturating the port space, and your whole code logic is rather (at 
least) buggy. Try a `netstat -n -t | grep TIME_WAIT | wc -l`



- Davide



  reply	other threads:[~2008-11-02 18:25 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 [this message]
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
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=Pine.LNX.4.64.0811021022120.9451@alien.or.mcafeemobile.com \
    --to=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®