X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fclient.cpp;h=90ab4cdc02a38aef1aff28f4bfc1b7953f8d1421;hb=75f62e5383c6ea1f62fb488a94f4a8f98400db71;hp=123d07f857c39b905e8d6bee338cb9f942d4dc74;hpb=cd9adb8b829564212158943a0d279bb35322ab30;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/client.cpp b/src/bin/lttng-sessiond/client.cpp index 123d07f85..90ab4cdc0 100644 --- a/src/bin/lttng-sessiond/client.cpp +++ b/src/bin/lttng-sessiond/client.cpp @@ -30,6 +30,7 @@ #include "utils.hpp" #include +#include #include #include #include @@ -40,6 +41,7 @@ #include #include +#include #include #include #include @@ -1784,7 +1786,7 @@ skip_domain: } case LTTCOMM_SESSIOND_COMMAND_DESTROY_SESSION: { - ret = cmd_destroy_session(cmd_ctx->session, the_notification_thread_handle, sock); + ret = cmd_destroy_session(cmd_ctx->session, sock); break; } case LTTCOMM_SESSIOND_COMMAND_LIST_DOMAINS: @@ -2214,11 +2216,8 @@ skip_domain: cmd_ctx->lsm.u.rotation_set_schedule.type; value = cmd_ctx->lsm.u.rotation_set_schedule.value; - ret = cmd_rotation_set_schedule(cmd_ctx->session, - set_schedule, - schedule_type, - value, - the_notification_thread_handle); + ret = cmd_rotation_set_schedule( + cmd_ctx->session, set_schedule, schedule_type, value); if (ret != LTTNG_OK) { goto error; } @@ -2585,24 +2584,36 @@ static void *thread_manage_clients(void *data) * informations for the client. The command context struct contains * everything this function may needs. */ - ret = process_client_msg(&cmd_ctx, &sock, &sock_error); - rcu_thread_offline(); - if (ret < 0) { - if (sock >= 0) { - ret = close(sock); - if (ret) { - PERROR("close"); + try { + ret = process_client_msg(&cmd_ctx, &sock, &sock_error); + rcu_thread_offline(); + if (ret < 0) { + if (sock >= 0) { + ret = close(sock); + if (ret) { + PERROR("close"); + } } + sock = -1; + /* + * TODO: Inform client somehow of the fatal error. At + * this point, ret < 0 means that a zmalloc failed + * (ENOMEM). Error detected but still accept + * command, unless a socket error has been + * detected. + */ + continue; } - sock = -1; - /* - * TODO: Inform client somehow of the fatal error. At - * this point, ret < 0 means that a zmalloc failed - * (ENOMEM). Error detected but still accept - * command, unless a socket error has been - * detected. - */ - continue; + } catch (const std::bad_alloc& ex) { + WARN_FMT("Failed to allocate memory while handling client request: {}", + ex.what()); + ret = LTTNG_ERR_NOMEM; + } catch (const lttng::ctl::error& ex) { + WARN_FMT("Client request failed: {}", ex.what()); + ret = ex.code(); + } catch (const std::exception& ex) { + WARN_FMT("Client request failed: {}", ex.what()); + ret = LTTNG_ERR_UNK; } if (ret < LTTNG_OK || ret >= LTTNG_ERR_NR) {