2004-03-02 15:25:50

by Chris Friesen

[permalink] [raw]
Subject: Re: Fw: epoll and fork()

Davide Libenzi wrote:

> Sorry but what behaviour do you expect by unregistering an fd pushed by
> the parent from inside a child? Events work exactly the same. Since the
> context is shared, events are delivered only once.

For principle of least surprise, I would expect that the refcounts would
be bumped up so that the child could deregister without affecting the
parent.

Closing the fd in the child doesn't affect the fd in the parent.
Removing an fd from an fd_set in the child doesn't affect the fd_set in
the parent. Unregistering an fd from an epoll set in the child
shouldn't affect the parent either.

Chris

--
Chris Friesen | MailStop: 043/33/F10
Nortel Networks | work: (613) 765-0557
3500 Carling Avenue | fax: (613) 765-2986
Nepean, ON K2H 8E9 Canada | email: [email protected]


2004-03-03 10:37:45

by Davide Libenzi

[permalink] [raw]
Subject: Re: Fw: epoll and fork()

On Tue, 2 Mar 2004, Chris Friesen wrote:

> Davide Libenzi wrote:
>
> > Sorry but what behaviour do you expect by unregistering an fd pushed by
> > the parent from inside a child? Events work exactly the same. Since the
> > context is shared, events are delivered only once.
>
> For principle of least surprise, I would expect that the refcounts would
> be bumped up so that the child could deregister without affecting the
> parent.
>
> Closing the fd in the child doesn't affect the fd in the parent.
> Removing an fd from an fd_set in the child doesn't affect the fd_set in
> the parent. Unregistering an fd from an epoll set in the child
> shouldn't affect the parent either.

There are two issues here. One is the fact that *explicitly* unregistering
the fd in one task and expecting the other one to act as if it was
registered could be considered a sign of a not clean interaction between
parent and child. The ref-count thing would not work because it is the
kernel that automatically and directly bumps the ref count, w/out calling
any f_op->xxxx() (like for example use/release). So epoll would have to
hook the file get function, detect if the fd is inside an epoll fd, and
take proper action by bumping its count. IMO it is not worth even
considering.



- Davide