diff options
author | Daniel Stone <daniel@fooishbar.org> | 2006-08-24 23:16:17 +0300 |
---|---|---|
committer | Daniel Stone <daniels@endtroducing.fooishbar.org> | 2006-08-24 23:16:17 +0300 |
commit | 4e37c07ba6e5d299d4f8922dc6cf054c814f7baf (patch) | |
tree | 99652486051ff9a2abfa63acfcfe0bf75db04d34 /config | |
parent | 866ca1f929c95689bac9f0a0b3478f7b4d77214b (diff) |
config: clean up debugging messages, make failure to acquire name fatal
Bomb with FatalError when we can't acquire the bus and name.
Clean up a bunch of debugging ErrorFs to be hidden behind #ifdef DEBUG.
Diffstat (limited to 'config')
-rw-r--r-- | config/config.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/config/config.c b/config/config.c index d4cf23334..d980f76da 100644 --- a/config/config.c +++ b/config/config.c @@ -60,6 +60,7 @@ configMessage(DBusConnection *connection, DBusMessage *message, void *closure) int deviceid = -1; DeviceIntPtr pDev = NULL; +#ifdef DEBUG ErrorF("[dbus] new message!\n"); ErrorF(" source: %s\n", dbus_message_get_sender(message)); ErrorF(" destination: %s\n", dbus_message_get_destination(message)); @@ -70,6 +71,7 @@ configMessage(DBusConnection *connection, DBusMessage *message, void *closure) ErrorF(" method call? %s\n", (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_METHOD_CALL) ? "yes" : "no"); +#endif dbus_error_init(&error); @@ -81,7 +83,9 @@ configMessage(DBusConnection *connection, DBusMessage *message, void *closure) return DBUS_HANDLER_RESULT_NEED_MEMORY; /* ?? */ } if (strcmp(dbus_message_get_member(message), "add") == 0) { +#ifdef DEBUG ErrorF(" we want to add a device!\n"); +#endif /* signature should be [ss][ss]... */ while (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_ARRAY) { option = (InputOption *)xcalloc(sizeof(InputOption), 1); @@ -160,7 +164,9 @@ configMessage(DBusConnection *connection, DBusMessage *message, void *closure) return DBUS_HANDLER_RESULT_HANDLED; } else if (strcmp(dbus_message_get_member(message), "remove") == 0) { +#ifdef DEBUG ErrorF(" we want to remove a device!\n"); +#endif if (!dbus_message_get_args(message, &error, DBUS_TYPE_INT32, &deviceid, DBUS_TYPE_INVALID)) { ErrorF("couldn't get args: %s %s\n", error.name, error.message); @@ -172,7 +178,6 @@ configMessage(DBusConnection *connection, DBusMessage *message, void *closure) dbus_error_free(&error); return DBUS_HANDLER_RESULT_HANDLED; } - ErrorF("pDev is %p\n", pDev); /* Call PIE here so we don't try to dereference a device that's * already been removed. Technically there's still a small race * here, so we should ensure that SIGIO is blocked. */ @@ -200,56 +205,56 @@ configInitialise() dbus_error_init(&error); bus = dbus_bus_get(DBUS_BUS_SYSTEM, &error); if (!bus || dbus_error_is_set(&error)) { - ErrorF("[dbus] some kind of error occurred: %s (%s)\n", error.name, - error.message); dbus_error_free(&error); + FatalError("[dbus] some kind of error occurred: %s (%s)\n", error.name, + error.message); return; } if (!dbus_connection_get_unix_fd(bus, &configfd)) { - ErrorF("[dbus] couldn't get fd for bus\n"); dbus_connection_close(bus); configfd = -1; + FatalError("[dbus] couldn't get fd for bus\n"); return; } snprintf(busname, sizeof(busname), "org.x.config.display%d", atoi(display)); if (!dbus_bus_request_name(bus, busname, 0, &error) || dbus_error_is_set(&error)) { - ErrorF("[dbus] couldn't take over org.x.config: %s (%s)\n", - error.name, error.message); dbus_error_free(&error); dbus_connection_close(bus); configfd = -1; + FatalError("[dbus] couldn't take over org.x.config: %s (%s)\n", + error.name, error.message); return; } /* blocks until we get a reply. */ dbus_bus_add_match(bus, MATCH_RULE, &error); if (dbus_error_is_set(&error)) { - ErrorF("[dbus] couldn't match X.Org rule: %s (%s)\n", error.name, - error.message); dbus_error_free(&error); dbus_bus_release_name(bus, busname, &error); dbus_connection_close(bus); configfd = -1; + FatalError("[dbus] couldn't match X.Org rule: %s (%s)\n", error.name, + error.message); return; } vtable.message_function = configMessage; snprintf(busobject, sizeof(busobject), "/org/x/config/%d", atoi(display)); if (!dbus_connection_register_object_path(bus, busobject, &vtable, NULL)) { - ErrorF("[dbus] couldn't register object path\n"); configfd = -1; dbus_bus_release_name(bus, busname, &error); dbus_bus_remove_match(bus, MATCH_RULE, &error); dbus_connection_close(bus); - configfd = -1; + FatalError("[dbus] couldn't register object path\n"); return; } +#ifdef DEBUG ErrorF("[dbus] registered object path %s\n", busobject); - ErrorF("[dbus] registered and listening\n"); +#endif dbus_error_free(&error); @@ -265,7 +270,6 @@ configFini() if (configConnection) { dbus_error_init(&error); - ErrorF("configFini being called\n"); dbus_bus_remove_match(configConnection, MATCH_RULE, &error); dbus_bus_release_name(configConnection, busname, &error); dbus_connection_close(configConnection); |