Paulo César Pereira de Andrade wrote: >> I think it'd be better to set a timer to fire off the reinitialization >> rather >> than a simple usleep. Doing so allows us to finish the server >> initialization >> without having to wait for hal. Any opinions? > > I can rework my patch to remove the "hal_giveup()" function, and > use a timer firing like every 8 seconds. The idea of fallback to > load/use kbd/mouse would be really only useful in a few special > cases on broken setups (usually development setups :-), so that > one would have a functional keyboard/mouse after sometime, as long > as the kdb and mouse drivers were functional ("wrong" abi would > be enough to have a inputless X Server...).
Attached the new version without attempting any magic fallback (and using 8 spaces instead of tabs) Tested and functional by stoping hald, running startx, and starting hald from a ssh connection, so that in no more then 8 seconds the keyboard and mouse start responding... Paulo
>From 33e4f4ddc228a359f8a9493f37dd0edcdc2aa78a Mon Sep 17 00:00:00 2001 From: Paulo Cesar Pereira de Andrade <p...@mandriva.com.br> Date: Wed, 21 Jan 2009 14:54:48 -0200 Subject: [PATCH] Add a connect retry timer to interface hal daemon. Hal may be initialized in the background, and not accepting connections by the time the X Server attempts to connect to it. This patch adds a retry timer that fires every 8 seconds. --- config/hal.c | 49 +++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 41 insertions(+), 8 deletions(-) diff --git a/config/hal.c b/config/hal.c index 8dfbb07..3b17579 100644 --- a/config/hal.c +++ b/config/hal.c @@ -43,10 +43,13 @@ #define LIBHAL_PROP_KEY "input.x11_options." #define LIBHAL_XKB_PROP_KEY "input.xkb." +/* Retry hal connection every 8 seconds */ +#define RECONNECT_TIMEOUT (8 * 1000) struct config_hal_info { DBusConnection *system_bus; LibHalContext *hal_ctx; + OsTimerPtr timer; }; /* Used for special handling of xkb options. */ @@ -58,6 +61,11 @@ struct xkb_options { char* options; }; +static int +hal_connect(struct config_hal_info *info); + +static CARD32 +hal_connect_timer(OsTimerPtr timer, CARD32 time, pointer arg); static void remove_device(DeviceIntPtr dev) @@ -467,16 +475,13 @@ disconnect_hook(void *data) info->system_bus = NULL; } -static void -connect_hook(DBusConnection *connection, void *data) +static int +hal_connect(struct config_hal_info *info) { DBusError error; - struct config_hal_info *info = data; char **devices; int num_devices, i; - info->system_bus = connection; - dbus_error_init(&error); if (!info->hal_ctx) @@ -485,6 +490,7 @@ connect_hook(DBusConnection *connection, void *data) LogMessage(X_ERROR, "config/hal: couldn't create HAL context\n"); goto out_err; } + libhal_ctx_set_cache(info->hal_ctx, FALSE); if (!libhal_ctx_set_dbus_connection(info->hal_ctx, info->system_bus)) { LogMessage(X_ERROR, "config/hal: couldn't associate HAL context with bus\n"); @@ -512,7 +518,7 @@ connect_hook(DBusConnection *connection, void *data) dbus_error_free(&error); - return; + return 0; out_ctx2: if (!libhal_ctx_shutdown(info->hal_ctx, &error)) @@ -524,9 +530,36 @@ out_err: dbus_error_free(&error); info->hal_ctx = NULL; - info->system_bus = NULL; - return; + return 1; +} + +static CARD32 +hal_connect_timer(OsTimerPtr timer, CARD32 time, pointer arg) +{ + struct config_hal_info *info = (struct config_hal_info *)arg; + + if (hal_connect(info) == 0) { + TimerFree(info->timer); + info->timer = NULL; + return 0; + } + + return RECONNECT_TIMEOUT; +} + +static void +connect_hook(DBusConnection *connection, void *data) +{ + struct config_hal_info *info = data; + + info->system_bus = connection; + if (hal_connect(info) != 0) { + if (info->timer) + TimerFree(info->timer); + info->timer = TimerSet(NULL, 0, RECONNECT_TIMEOUT, + hal_connect_timer, info); + } } static struct config_hal_info hal_info; -- 1.6.0.5
_______________________________________________ xorg mailing list xorg@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/xorg