X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fclient.cpp;h=90ab4cdc02a38aef1aff28f4bfc1b7953f8d1421;hb=dd7ef1243236f524e57b25baa038973e793d5d72;hp=d6d894cfbeced044cc463a43be08e9271af29a34;hpb=671e39d79a1ad9c3f13c4784a26710a5b1f14237;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/client.cpp b/src/bin/lttng-sessiond/client.cpp index d6d894cfb..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 @@ -2583,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) {