[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] Double FD close



On Thu, Oct 12, 2017 at 1:15 AM, Roger Morris <rmorris@xxxxxxxxxxxxxxxx> wrote:
> I'm looking at this change a695a72 from back in 2.1.6 (copied below), and I feel
> like the change was perhaps made quickly in reaction to a coverity
> warning without
> really thinking it through.
>
> In this code, a new connection is accepted from a listener. That new
> connection (new_fd)
> is then passed to the user's callback (cb), where ownership of that fd
> is effectively turned
> over to the user.  In this one case where the user happens to close
> the listener from within
> the callback, change a695a72 makes the assumption that the user didn't
> take ownership
> of new_fd, and didn't already or won't later close new_fd.
>
> This is the only scenario where, after passing the accepted new_fd to
> the callback, that
> libevent closes new_fd.  Am I missing something?  Is this correct behavior?

Hi Roger,

Your analysis is correct.

Well I guess that nobody though that accepted fd can be used after
listener was freed.
Do you have an example of such case?

But personally for me we shouldn't free fd there, since it makes
freeing resources a trickier instead of fixing real bug.

  Azat.

P.S. sorry for the delay and BTW nice catch
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.