Browse Source

jackdbus: improved handling of server start/stop failures

* Don't override detailed error string with generic one
 * Set the D-Bus reply error in case of jackctl_server_stop() failure
 * Set the D-Bus reply error in case of jack_controller_patchbay_init() failure
 * Don't set the D-Bus reply error in case of jack_deactivate() failure because
   this failure does not cause jack_controller_stop_server() failure and thus
   will cause memory leak.
tags/v1.9.6
Nedko Arnaudov 15 years ago
parent
commit
becacb17a4
2 changed files with 11 additions and 10 deletions
  1. +4
    -6
      dbus/controller.c
  2. +7
    -4
      dbus/controller_iface_control.c

+ 4
- 6
dbus/controller.c View File

@@ -1,6 +1,6 @@
/* -*- Mode: C ; c-basic-offset: 4 -*- */ /* -*- Mode: C ; c-basic-offset: 4 -*- */
/* /*
Copyright (C) 2007,2008 Nedko Arnaudov
Copyright (C) 2007,2008,2010 Nedko Arnaudov
Copyright (C) 2007-2008 Juuso Alasuutari Copyright (C) 2007-2008 Juuso Alasuutari


This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
@@ -171,7 +171,6 @@ jack_controller_start_server(
if (controller_ptr->client == NULL) if (controller_ptr->client == NULL)
{ {
jack_dbus_error(dbus_call_context_ptr, JACK_DBUS_ERROR_GENERIC, "failed to create dbusapi jack client"); jack_dbus_error(dbus_call_context_ptr, JACK_DBUS_ERROR_GENERIC, "failed to create dbusapi jack client");

goto fail_stop_server; goto fail_stop_server;
} }


@@ -179,13 +178,12 @@ jack_controller_start_server(
if (ret != 0) if (ret != 0)
{ {
jack_dbus_error(dbus_call_context_ptr, JACK_DBUS_ERROR_GENERIC, "failed to set xrun callback. error is %d", ret); jack_dbus_error(dbus_call_context_ptr, JACK_DBUS_ERROR_GENERIC, "failed to set xrun callback. error is %d", ret);

goto fail_close_client; goto fail_close_client;
} }


if (!jack_controller_patchbay_init(controller_ptr)) if (!jack_controller_patchbay_init(controller_ptr))
{ {
jack_error("Failed to initialize patchbay district");
jack_dbus_error(dbus_call_context_ptr, JACK_DBUS_ERROR_GENERIC, "Failed to initialize patchbay district");
goto fail_close_client; goto fail_close_client;
} }


@@ -193,7 +191,6 @@ jack_controller_start_server(
if (ret != 0) if (ret != 0)
{ {
jack_dbus_error(dbus_call_context_ptr, JACK_DBUS_ERROR_GENERIC, "failed to activate dbusapi jack client. error is %d", ret); jack_dbus_error(dbus_call_context_ptr, JACK_DBUS_ERROR_GENERIC, "failed to activate dbusapi jack client. error is %d", ret);

goto fail_patchbay_uninit; goto fail_patchbay_uninit;
} }


@@ -241,7 +238,7 @@ jack_controller_stop_server(
ret = jack_deactivate(controller_ptr->client); ret = jack_deactivate(controller_ptr->client);
if (ret != 0) if (ret != 0)
{ {
jack_dbus_error(dbus_call_context_ptr, JACK_DBUS_ERROR_GENERIC, "failed to deactivate dbusapi jack client. error is %d", ret);
jack_error("failed to deactivate dbusapi jack client. error is %d", ret);
} }


jack_controller_patchbay_uninit(controller_ptr); jack_controller_patchbay_uninit(controller_ptr);
@@ -256,6 +253,7 @@ jack_controller_stop_server(


if (!jackctl_server_stop(controller_ptr->server)) if (!jackctl_server_stop(controller_ptr->server))
{ {
jack_dbus_error(dbus_call_context_ptr, JACK_DBUS_ERROR_GENERIC, "Failed to stop server");
return FALSE; return FALSE;
} }




+ 7
- 4
dbus/controller_iface_control.c View File

@@ -1,6 +1,6 @@
/* -*- Mode: C ; c-basic-offset: 4 -*- */ /* -*- Mode: C ; c-basic-offset: 4 -*- */
/* /*
Copyright (C) 2007,2008 Nedko Arnaudov
Copyright (C) 2007,2008,2010 Nedko Arnaudov
Copyright (C) 2007-2008 Juuso Alasuutari Copyright (C) 2007-2008 Juuso Alasuutari


This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
@@ -87,7 +87,8 @@ jack_control_run_method(
{ {
if (!jack_controller_start_server(controller_ptr, call)) if (!jack_controller_start_server(controller_ptr, call))
{ {
jack_dbus_error(call, JACK_DBUS_ERROR_GENERIC, "Failed to start server");
/* the reply is set by the failed function */
assert(call->reply != NULL);
return true; return true;
} }


@@ -97,7 +98,8 @@ jack_control_run_method(
{ {
if (!jack_controller_stop_server(controller_ptr, call)) if (!jack_controller_stop_server(controller_ptr, call))
{ {
jack_dbus_error(call, JACK_DBUS_ERROR_GENERIC, "Failed to stop server");
/* the reply is set by the failed function */
assert(call->reply != NULL);
return true; return true;
} }


@@ -107,7 +109,8 @@ jack_control_run_method(
{ {
if (!jack_controller_switch_master(controller_ptr, call)) if (!jack_controller_switch_master(controller_ptr, call))
{ {
jack_dbus_error(call, JACK_DBUS_ERROR_GENERIC, "Failed to switch master");
/* the reply is set by the failed function */
assert(call->reply != NULL);
return true; return true;
} }




Loading…
Cancel
Save