mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-04-30 23:48:05 +02:00
2008-01-23 Dan Williams <dcbw@redhat.com>
* libnm-glib/libnm_glib.c - (libnm_glib_init): make thread joinable - (libnm_glib_ctx_free): join thread on exit to clean up memory git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3265 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
fe7259194b
commit
3d81b8f156
2 changed files with 14 additions and 7 deletions
|
|
@ -1,3 +1,9 @@
|
|||
2008-01-23 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* libnm-glib/libnm_glib.c
|
||||
- (libnm_glib_init): make thread joinable
|
||||
- (libnm_glib_ctx_free): join thread on exit to clean up memory
|
||||
|
||||
2008-01-23 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* test/libnm_glib_test.c
|
||||
|
|
|
|||
|
|
@ -42,8 +42,10 @@ struct libnm_glib_ctx
|
|||
DBusConnection * dbus_con;
|
||||
guint dbus_watcher;
|
||||
guint dbus_watch_interval;
|
||||
|
||||
gboolean thread_done;
|
||||
gboolean thread_inited;
|
||||
GThread * thread;
|
||||
|
||||
GSList * callbacks;
|
||||
GMutex * callbacks_lock;
|
||||
|
|
@ -460,6 +462,9 @@ libnm_glib_ctx_free (libnm_glib_ctx *ctx)
|
|||
g_slist_foreach (ctx->callbacks, (GFunc)g_free, NULL);
|
||||
g_slist_free (ctx->callbacks);
|
||||
|
||||
if (ctx->thread)
|
||||
g_thread_join (ctx->thread);
|
||||
|
||||
memset (ctx, 0, sizeof (libnm_glib_ctx));
|
||||
memset (&(ctx->check), 0xDD, sizeof (ctx->check));
|
||||
g_free (ctx);
|
||||
|
|
@ -490,7 +495,6 @@ error:
|
|||
libnm_glib_ctx *
|
||||
libnm_glib_init (void)
|
||||
{
|
||||
GError *error = NULL;
|
||||
libnm_glib_ctx *ctx = NULL;
|
||||
|
||||
g_type_init ();
|
||||
|
|
@ -498,15 +502,12 @@ libnm_glib_init (void)
|
|||
g_thread_init (NULL);
|
||||
dbus_g_thread_init ();
|
||||
|
||||
if (!(ctx = libnm_glib_ctx_new()))
|
||||
if (!(ctx = libnm_glib_ctx_new ()))
|
||||
return NULL;
|
||||
|
||||
if (!g_thread_create (libnm_glib_dbus_worker, ctx, FALSE, &error))
|
||||
{
|
||||
if (error)
|
||||
g_error_free (error);
|
||||
ctx->thread = g_thread_create (libnm_glib_dbus_worker, ctx, TRUE, NULL);
|
||||
if (!ctx->thread)
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Wait until initialization of the thread */
|
||||
while (!ctx->thread_inited)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue