All of lore.kernel.org
 help / color / mirror / Atom feed
* epoll and shared fd's
@ 2008-01-18 13:43 Pierre Habouzit
  2008-01-18 21:10 ` Davide Libenzi
  0 siblings, 1 reply; 16+ messages in thread
From: Pierre Habouzit @ 2008-01-18 13:43 UTC (permalink / raw)
  To: linux-kernel; +Cc: madcoder

[-- Attachment #1: Type: text/plain, Size: 1595 bytes --]

  Hi,

  I just came across a strange behavior of epoll that seems to
contradict the documentation. Here is what happens:

* I have two processes P1 and P2, P1 accept()s connections, and send the
  resulting file descriptors to P2 through a unix socket.

* P2 registers the received socket in his epollfd.

  [time passes]

* P2 is done with the socket and closes it

* P2 gets events for the socket again !


  Though the documentation says that if a process closes a file
descriptor, it gets unregistered. And yes I'm sure that P2 doens't dup()
the file descriptor. Though (because of a bug) it was still open in
P1[0], hence the referenced socket still live at the kernel level.

  Of course the userland workaround is to force the EPOLL_CTL_DEL before
the close, which I now do, but costs me a syscall where I wanted to
spare one :|

  I _believe_ this is if not a bug, at least a misfeature, hence I'm
reporting the issue :)


PS: please Cc: on answers me I'm not subscribed.


  [0] and despite the bug in our software that leaked the socket, P1
      is supposed to only close the socket when P2 acks the fact that it
      received a valid fd (else P1 tries to send it to a P2'), and there
      may be uncontrollable races that could trigger the issue again
      (with P2 closing the socket before P1 had time to process the ACK
      and close the socket on its end).
-- 
·O·  Pierre Habouzit
··O                                                madcoder@debian.org
OOO                                                http://www.madism.org

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread
[parent not found: <9MZLT-1YO-33@gated-at.bofh.it>]

end of thread, other threads:[~2008-02-28 19:30 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-18 13:43 epoll and shared fd's Pierre Habouzit
2008-01-18 21:10 ` Davide Libenzi
2008-01-24  8:40   ` Pierre Habouzit
2008-01-24 23:57     ` Davide Libenzi
2008-01-26  7:37       ` Michael Kerrisk
     [not found]         ` <Pine.LNX.4.64.0801261308270.10472@alien.or.mcafeemobile.com>
2008-02-26 15:13           ` Michael Kerrisk
2008-02-26 19:04             ` Davide Libenzi
2008-02-26 19:14               ` Michael Kerrisk
2008-02-26 19:31                 ` Davide Libenzi
     [not found] <9MZLT-1YO-33@gated-at.bofh.it>
     [not found] ` <9N6Ng-5tn-21@gated-at.bofh.it>
     [not found]   ` <9P5WE-33i-11@gated-at.bofh.it>
     [not found]     ` <9Pk9l-1KA-1@gated-at.bofh.it>
     [not found]       ` <9PNNZ-b0-5@gated-at.bofh.it>
     [not found]         ` <a19Lb-1F0-13@gated-at.bofh.it>
     [not found]           ` <a19Lb-1F0-11@gated-at.bofh.it>
2008-02-26 18:16             ` Bodo Eggert
2008-02-28 12:10               ` Michael Kerrisk
2008-02-28 19:17                 ` Bodo Eggert
2008-02-28 19:30                   ` Davide Libenzi
2008-02-28 13:53               ` Valdis.Kletnieks
2008-02-28 15:08                 ` Michael Kerrisk
2008-02-28 19:27                 ` Davide Libenzi

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.