summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2009-08-14 09:48:45 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2009-08-14 11:01:20 +1000
commit49046088f10cceaea7da97401d742d3fb59371f5 (patch)
tree2bde050e4c2bf51d6a104f6fb28833314879af93
parent1545a120df6dffb5b84fe96c5a992357520b7c8d (diff)
config: don't shutdown the libhal ctx if it failed to initialize (#23213)
Regression introduced by b1c3dc6ae226db178420e3b5f297b94afc87c94c. Shutting down the libhal_ctx if the init failed may cause an abort. This can happen if hald is not yet running at server startup. X.Org Bug 23213 <http://bugs.freedesktop.org/show_bug.cgi?id=23213> Tested-by: Stefan Dirsch Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--config/hal.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/config/hal.c b/config/hal.c
index 59bff6613..28f55a02f 100644
--- a/config/hal.c
+++ b/config/hal.c
@@ -489,13 +489,13 @@ connect_and_register(DBusConnection *connection, struct config_hal_info *info)
489 489
490 if (!libhal_ctx_set_dbus_connection(info->hal_ctx, info->system_bus)) { 490 if (!libhal_ctx_set_dbus_connection(info->hal_ctx, info->system_bus)) {
491 LogMessage(X_ERROR, "config/hal: couldn't associate HAL context with bus\n"); 491 LogMessage(X_ERROR, "config/hal: couldn't associate HAL context with bus\n");
492 goto out_ctx; 492 goto out_err;
493 } 493 }
494 if (!libhal_ctx_init(info->hal_ctx, &error)) { 494 if (!libhal_ctx_init(info->hal_ctx, &error)) {
495 LogMessage(X_ERROR, "config/hal: couldn't initialise context: %s (%s)\n", 495 LogMessage(X_ERROR, "config/hal: couldn't initialise context: %s (%s)\n",
496 error.name ? error.name : "unknown error", 496 error.name ? error.name : "unknown error",
497 error.message ? error.message : "null"); 497 error.message ? error.message : "null");
498 goto out_ctx; 498 goto out_err;
499 } 499 }
500 if (!libhal_device_property_watch_all(info->hal_ctx, &error)) { 500 if (!libhal_device_property_watch_all(info->hal_ctx, &error)) {
501 LogMessage(X_ERROR, "config/hal: couldn't watch all properties: %s (%s)\n", 501 LogMessage(X_ERROR, "config/hal: couldn't watch all properties: %s (%s)\n",
@@ -526,19 +526,20 @@ connect_and_register(DBusConnection *connection, struct config_hal_info *info)
526out_ctx: 526out_ctx:
527 dbus_error_free(&error); 527 dbus_error_free(&error);
528 528
529 if (info->hal_ctx) { 529 if (!libhal_ctx_shutdown(info->hal_ctx, &error)) {
530 if (!libhal_ctx_shutdown(info->hal_ctx, &error)) { 530 LogMessage(X_WARNING, "config/hal: couldn't shut down context: %s (%s)\n",
531 LogMessage(X_WARNING, "config/hal: couldn't shut down context: %s (%s)\n", 531 error.name ? error.name : "unknown error",
532 error.name ? error.name : "unknown error", 532 error.message ? error.message : "null");
533 error.message ? error.message : "null"); 533 dbus_error_free(&error);
534 dbus_error_free(&error);
535 }
536 libhal_ctx_free(info->hal_ctx);
537 } 534 }
538 535
539out_err: 536out_err:
540 dbus_error_free(&error); 537 dbus_error_free(&error);
541 538
539 if (info->hal_ctx) {
540 libhal_ctx_free(info->hal_ctx);
541 }
542
542 info->hal_ctx = NULL; 543 info->hal_ctx = NULL;
543 info->system_bus = NULL; 544 info->system_bus = NULL;
544 545