Commit 6f7abfd5 authored by Stefan's avatar Stefan Committed by Lennart Poettering
Browse files

dfork: daemon_retval_done() might close socket already closed in daemon_close_allv()

No Avahi daemon is running. If I start it at command-line
with

        etc/init.d/avahi-daemon start

or simply with

        avahi-daemon -D

then the avahi-daemon eats all CPU-time.

Stracing the process shows, that it loops endlessly in

gettimeofday({1231956423, 692711}, NULL) = 0
gettimeofday({1231956423, 692735}, NULL) = 0
poll([{fd=5, events=POLLIN}, {fd=15, events=POLLIN}, \
        {fd=14, events=POLLIN}, {fd=13, events=POLLIN}, \
        {fd=12, events=POLLIN}, {fd=11, events=POLLIN}, \
        {fd=10, events=POLLIN}, {fd=8, events=POLLIN}], 8, 62150) = 1 \
        ([{fd=5, revents=POLLNVAL}])

The fd=5 is a BADFD.

I found out that the fd was closed by daemon_retval_send() from libdaemon.
(But: I think avahi-daemon should handle the POLLERR nevertheless.)

Looking in libdaemon I found, that the library had already closed the fd=5
in daemon_close_all(), and closed it "again" as _daemon_retval_pipe[0] in
daemon_retval_send() -> daemon_retval_done(), but in the meantime, this
is an fd from the application, not from the library. I think, after closing
_daemon_retval_pipe[0] in daemon_close_allv() the fd must be marked as closed.

I have attached a patch. For me it works fine.
parent 8312ea47
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment