2006-05-05 Dan Williams <dcbw@redhat.com>

* gnome/libnm_glib/libnm_glib.c
		- Don't suck CPU when dbus isn't around by scheduling idle handlers
			to reconnect; instead wait a bit more with each reconnect attempt
			up to a max of one minute.


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1718 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams 2006-05-05 15:36:46 +00:00
parent ad87e09b84
commit 8a2815e4ac
2 changed files with 28 additions and 4 deletions

View file

@ -1,3 +1,10 @@
2006-05-05 Dan Williams <dcbw@redhat.com>
* gnome/libnm_glib/libnm_glib.c
- Don't suck CPU when dbus isn't around by scheduling idle handlers
to reconnect; instead wait a bit more with each reconnect attempt
up to a max of one minute.
2006-05-04 Ryan Lortie <desrt@desrt.ca>
* gnome/applet/passphrase-dialog.c (update_button_cb): Get the SSID of

View file

@ -39,6 +39,7 @@ struct libnm_glib_ctx
GMainLoop * g_main_loop;
DBusConnection * dbus_con;
guint dbus_watcher;
guint dbus_watch_interval;
gboolean thread_done;
gboolean thread_inited;
@ -347,14 +348,29 @@ libnm_glib_dbus_watcher (gpointer user_data)
g_return_val_if_fail (ctx != NULL, FALSE);
ctx->dbus_watcher = 0;
if (!ctx->dbus_con)
ctx->dbus_con = libnm_glib_dbus_init ((gpointer)ctx, ctx->g_main_ctx);
if (ctx->dbus_con)
return (FALSE); /* Don't reschedule ourselves if we have a connection to dbus */
{
/* Get NM's state right away after we reconnect */
libnm_glib_get_nm_state (ctx);
ctx->dbus_watch_interval = 1000;
}
else
{
/* Wait 3 seconds longer each time we fail to reconnect to dbus,
* with a maximum wait of one minute.
*/
ctx->dbus_watch_interval = MIN(ctx->dbus_watch_interval + 3000, 60000);
/* Reschule ourselves if we _still_ don't have a connection to dbus */
return (TRUE);
/* Reschule ourselves if we _still_ don't have a connection to dbus */
libnm_glib_schedule_dbus_watcher (ctx);
}
return FALSE;
}
@ -372,7 +388,7 @@ libnm_glib_schedule_dbus_watcher (libnm_glib_ctx *ctx)
if (ctx->dbus_watcher == 0)
{
GSource *source = g_idle_source_new ();
GSource * source = g_timeout_source_new (ctx->dbus_watch_interval);
g_source_set_callback (source, libnm_glib_dbus_watcher, (gpointer) ctx, NULL);
ctx->dbus_watcher = g_source_attach (source, ctx->g_main_ctx);
g_source_unref (source);
@ -453,6 +469,7 @@ libnm_glib_ctx_new (void)
goto error;
if (!(ctx->callbacks_lock = g_mutex_new ()))
goto error;
ctx->dbus_watch_interval = 1000;
return ctx;