net: Add mutex lock logic around device additions

The avahi_thread may call add_device() as well.  This addresses a
concern raised in 313921 and may fix 314696 as well as 315044.
merge-requests/1/head
Olaf Meeuwissen 2015-09-24 20:56:00 +09:00 zatwierdzone przez m. allan noah
rodzic f219f7fbd8
commit 219a877858
1 zmienionych plików z 18 dodań i 1 usunięć

Wyświetl plik

@ -1044,9 +1044,14 @@ sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize)
continue;
}
#ifdef WITH_AVAHI
avahi_threaded_poll_lock (avahi_thread);
#endif /* WITH_AVAHI */
DBG (2, "sane_init: trying to add %s\n", device_name);
add_device (device_name, 0);
#ifdef WITH_AVAHI
avahi_threaded_poll_unlock (avahi_thread);
#endif /* WITH_AVAHI */
}
fclose (fp);
@ -1090,8 +1095,14 @@ sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize)
if (host[0] == '\0')
continue;
#endif /* ENABLE_IPV6 */
#ifdef WITH_AVAHI
avahi_threaded_poll_lock (avahi_thread);
#endif /* WITH_AVAHI */
DBG (2, "sane_init: trying to add %s\n", host);
add_device (host, 0);
#ifdef WITH_AVAHI
avahi_threaded_poll_unlock (avahi_thread);
#endif /* WITH_AVAHI */
}
free (copy);
}
@ -1507,7 +1518,13 @@ sane_open (SANE_String_Const full_name, SANE_Handle * meta_handle)
DBG (1,
"sane_open: device %s not found, trying to register it anyway\n",
nd_name);
#ifdef WITH_AVAHI
avahi_threaded_poll_lock (avahi_thread);
#endif /* WITH_AVAHI */
status = add_device (nd_name, &dev);
#ifdef WITH_AVAHI
avahi_threaded_poll_unlock (avahi_thread);
#endif /* WITH_AVAHI */
if (status != SANE_STATUS_GOOD)
{
DBG (1, "sane_open: could not open device\n");