diff --git a/ChangeLog b/ChangeLog index 2fd18b5b61..59070b9f9a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2005-01-24 Dan Williams + + * src/NetworkManagerDevice.c + src/NetworkManagerDevicePrivate.h + - Block nm_device_new() until our device's worker thread has had a + chance to start up. Fixes a race between main thread and worker + thread starting that caused activation requests to get lost. + 2005-01-24 Dan Williams * initscript/RedHat/NetworkManager diff --git a/src/NetworkManagerDevice.c b/src/NetworkManagerDevice.c index a26f9b88eb..c642cbfb56 100644 --- a/src/NetworkManagerDevice.c +++ b/src/NetworkManagerDevice.c @@ -319,6 +319,12 @@ NMDevice *nm_device_new (const char *iface, const char *udi, gboolean test_dev, dev = NULL; } + /* Block until our device thread has actually had a chance to start. */ + syslog (LOG_ERR, "nm_device_new(): waiting for device's worker thread to start.\n"); + while (dev->worker_started == FALSE) + g_usleep (G_USEC_PER_SEC / 2); + syslog (LOG_ERR, "nm_device_new(): device's worker thread started, continuing.\n"); + return (dev); } @@ -391,11 +397,17 @@ static gpointer nm_device_worker (gpointer user_data) { NMDevice *dev = (NMDevice *)user_data; - g_return_val_if_fail (dev != NULL, NULL); + if (!dev) + { + syslog (LOG_CRIT, "nm_device_worker(): received NULL device object, NetworkManager cannot continue.\n"); + exit (1); + } dev->context = g_main_context_new (); dev->loop = g_main_loop_new (dev->context, FALSE); + dev->worker_started = TRUE; + /* Do an initial wireless scan */ if (nm_device_is_wireless (dev)) { diff --git a/src/NetworkManagerDevicePrivate.h b/src/NetworkManagerDevicePrivate.h index c26d03cc2d..1abec22770 100644 --- a/src/NetworkManagerDevicePrivate.h +++ b/src/NetworkManagerDevicePrivate.h @@ -104,6 +104,7 @@ struct NMDevice GMainContext *context; GMainLoop *loop; gboolean worker_done; + gboolean worker_started; guint renew_timeout; guint rebind_timeout;