All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Gilad Benjamini" <gilad@altornetworks.com>
To: "'Bryan Donlan'" <bdonlan@gmail.com>
Cc: "'Davide Libenzi'" <davidel@xmailserver.org>,
	"'Linux Kernel Mailing List'" <linux-kernel@vger.kernel.org>
Subject: RE: epoll and closed file descriptors
Date: Wed, 16 Sep 2009 17:53:05 -0700	[thread overview]
Message-ID: <024801ca3731$38833ad0$a989b070$@com> (raw)
In-Reply-To: <3e8340490909161745h5c58c165j1726c3433df3baeb@mail.gmail.com>

> Subject: Re: epoll and closed file descriptors
> 
> On Wed, Sep 16, 2009 at 8:40 PM, Gilad Benjamini
> <gilad@altornetworks.com> wrote:
> > Davide wrote:
> >> On Wed, 16 Sep 2009, Gilad Benjamini wrote:
> >>
> >> > I would, but epoll is preventing me from doing so.
> >> > Early in sys_epoll_ctl there are these lines
> >> >
> >> >   file = fget(epfd);
> >> >   if (!file)
> >> >     goto error_return;
> >> >
> >> > Leaving me in a kind of dead lock
> >>
> >> The 'epfd' in there, is the _epoll fd_, which, if fget() fails,
> means
> >> you
> >> close it.
> >> You see likely failing the 'tfile = fget(fd)' (of course, you closed
> >> it),
> >> so if someone else keeps the socket open and you have no chance in
> >> telling
> >> it to drop it (really?), you need to remove the socket from the set
> >> before
> >> closing it.
> >>
> >>
> >>
> >> - Davide
> >
> > My bad. I meant to quote the line that you mentioned.
> > I agree that the right thing to do is to remove the fd from epoll
> before
> > closing it.
> > However, due to the way curl works, I cannot do that. Changing the
> curl code
> > doesn't seem trivial.
> >
> > Regardless, I still don't see how the kernel got into this situation,
> and if
> > this situation is valid, why it doesn't bail out of it.
> 
> epoll references the underlying file object; the fd is used _only_ to
> obtain this file object, and then never used again. Determining when
> the fd goes away then requires iterating over all fds, and since epoll
> was designed to avoid doing exactly that, it isn't an acceptable
> solution.

Regarding bailing out of the situation, I see the logic in your answer.
What about the first part ? Any ideas how the kernel actually got into that
tight spot ?
Looking into the code I can't find a path that can lead into this situation.





  reply	other threads:[~2009-09-17  0:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-16 23:22 epoll and closed file descriptors Gilad Benjamini
2009-09-17  0:07 ` Davide Libenzi
2009-09-17  0:23   ` Gilad Benjamini
2009-09-17  0:28     ` Bryan Donlan
2009-09-17  0:30     ` Davide Libenzi
2009-09-17  0:40       ` Gilad Benjamini
2009-09-17  0:45         ` Bryan Donlan
2009-09-17  0:53           ` Gilad Benjamini [this message]
2009-09-17  0:57             ` Bryan Donlan
2009-09-17  0:55         ` Davide Libenzi

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='024801ca3731$38833ad0$a989b070$@com' \
    --to=gilad@altornetworks.com \
    --cc=bdonlan@gmail.com \
    --cc=davidel@xmailserver.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.