From dc722af3d0305807fca29ad00d694cbd5967497a Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Mon, 11 Feb 2019 10:24:35 -0500 Subject: [PATCH] Consumer: implement LTTNG_CONSUMER_CLEAR_CHANNEL Signed-off-by: Jonathan Rajotte --- src/common/consumer/consumer.h | 1 + src/common/kernel-consumer/kernel-consumer.c | 25 ++++++++++++++++++++ src/common/sessiond-comm/sessiond-comm.h | 3 +++ src/common/ust-consumer/ust-consumer.c | 25 ++++++++++++++++++++ 4 files changed, 54 insertions(+) diff --git a/src/common/consumer/consumer.h b/src/common/consumer/consumer.h index 0195e6884..568ba8c6f 100644 --- a/src/common/consumer/consumer.h +++ b/src/common/consumer/consumer.h @@ -68,6 +68,7 @@ enum lttng_consumer_command { LTTNG_CONSUMER_CHECK_ROTATION_PENDING_LOCAL, LTTNG_CONSUMER_CHECK_ROTATION_PENDING_RELAY, LTTNG_CONSUMER_MKDIR, + LTTNG_CONSUMER_CLEAR_CHANNEL, }; /* State of each fd in consumer */ diff --git a/src/common/kernel-consumer/kernel-consumer.c b/src/common/kernel-consumer/kernel-consumer.c index b2822721b..507a25e12 100644 --- a/src/common/kernel-consumer/kernel-consumer.c +++ b/src/common/kernel-consumer/kernel-consumer.c @@ -1257,6 +1257,31 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, } break; } + case LTTNG_CONSUMER_CLEAR_CHANNEL: + { + struct lttng_consumer_channel *channel; + uint64_t key = msg.u.clear_channel.key; + + channel = consumer_find_channel(key); + if (!channel) { + DBG("Channel %" PRIu64 " not found", key); + ret_code = LTTCOMM_CONSUMERD_CHAN_NOT_FOUND; + } else { + ret = lttng_consumer_clear_channel(channel); + if (ret) { + ERR("Clear channel failed"); + ret_code = ret; + } + + health_code_update(); + } + ret = consumer_send_status_msg(sock, ret_code); + if (ret < 0) { + /* Somehow, the session daemon is not responding anymore. */ + goto end_nosignal; + } + break; + } default: goto end_nosignal; } diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h index f40db1fdd..78b94532d 100644 --- a/src/common/sessiond-comm/sessiond-comm.h +++ b/src/common/sessiond-comm/sessiond-comm.h @@ -624,6 +624,9 @@ struct lttcomm_consumer_msg { uint32_t uid; uint32_t gid; } LTTNG_PACKED mkdir; + struct { + uint64_t key; + } LTTNG_PACKED clear_channel; } u; } LTTNG_PACKED; diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c index 8916daefa..4fcdd392b 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -2109,6 +2109,31 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, } break; } + case LTTNG_CONSUMER_CLEAR_CHANNEL: + { + struct lttng_consumer_channel *channel; + uint64_t key = msg.u.clear_channel.key; + + channel = consumer_find_channel(key); + if (!channel) { + DBG("Channel %" PRIu64 " not found", key); + ret_code = LTTCOMM_CONSUMERD_CHAN_NOT_FOUND; + } else { + ret = lttng_consumer_clear_channel(channel); + if (ret) { + ERR("Clear channel failed"); + ret_code = ret; + } + + health_code_update(); + } + ret = consumer_send_status_msg(sock, ret_code); + if (ret < 0) { + /* Somehow, the session daemon is not responding anymore. */ + goto end_nosignal; + } + break; + } default: break; } -- 2.34.1