X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fclear.c;fp=src%2Fbin%2Flttng-sessiond%2Fclear.c;h=a0917dca8186c57a9b0ffcbdc2e49b324de65935;hp=0000000000000000000000000000000000000000;hb=f3e3b7222f889a4e9f8936fc5ad3577400e4318d;hpb=dc722af3d0305807fca29ad00d694cbd5967497a diff --git a/src/bin/lttng-sessiond/clear.c b/src/bin/lttng-sessiond/clear.c new file mode 100644 index 000000000..a0917dca8 --- /dev/null +++ b/src/bin/lttng-sessiond/clear.c @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2019 - Jonathan Rajotte + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License, version 2 only, as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#define _LGPL_SOURCE +#include +#include +#include +#include + +#include +#include +#include + +#include "clear.h" +#include "session.h" +#include "ust-app.h" +#include "kernel.h" + + +int cmd_clear_session(struct ltt_session *session) +{ + int ret; + + if (!session->has_been_started) { + /* Nothing to be cleared, do not warn */ + ret = LTTNG_OK; + goto end; + } + + /* + * Unsupported feature in lttng-relayd before 2.12. + */ + if (session->consumer->type == CONSUMER_DST_NET && + (session->consumer->relay_major_version == 2 && + session->consumer->relay_minor_version < 12)) { + ret = LTTNG_ERR_CLEAR_NOT_AVAILABLE_RELAY; + goto end; + } + + /* TODO: Should we check for disallowed here or consumer side? */ + + /* Snapshot session are the only one supported for now */ + if (!session->snapshot_mode) { + /* + * TODO: this error code is temporary and will be removed since + * we will be supporting all session type + */ + ret = LTTNG_ERR_CLEAR_NOT_AVAILABLE; + goto end; + } + + if (session->kernel_session) { + ret = kernel_clear_session(session); + if (ret != LTTNG_OK) { + goto error; + } + } + if (session->ust_session) { + ret = ust_app_clear_session(session); + if (ret != LTTNG_OK) { + goto error; + } + } +error: +end: + return ret; +}