Hello Adrian,

Thanks for looking at this again. More comments below.

On Fri, May 19, 2017 at 09:47:51AM +0200, John Paul Adrian Glaubitz wrote:
> But wouldn't that only address the symptoms instead of the actual cause
> of the problem? If I understood Laurent correctly, the NULL value of
> avahi_thread is a result of a race condition that can be avoided by
> calling net_avahi_init() later inside sane_init().

It might be that Laurents fix should *also* go in. It might make things
work more often, but still...

The net_avahi_init() function handles failures by setting avahi_thread
(etc.) to NULL.

The caller of net_avahi_init() does nothing to catch when net_avahi_init()
returns failure (maybe this should be caught and handled here? But I assumed
it was considered ok for it to fail.)

Thus, If for ANY reason net_avahi_init() failed and we continue running
with avahi_thread==NULL. Sane must make sure to not pass it to something
which does not accept a NULL argument, eg. the avahi lock functions.
Locking avahi when we're not using avahi at all is obviously not needed
as I see it.

Thus the patch I proposed. I'm not familiar with sane code so maybe this
is not the best fix, but either way Laurents change definitely doesn't
cover all theoretical bases (ie. it doesn't handle the failure, just
possibly makes failure happen less often)....

Hope this helps make my proposal more clear.

Regards,
Andreas Henriksson

Reply via email to