X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Frotate.c;h=3ca80ce6a8a16ad970b6a9c99ddf2a3543201b2d;hp=49ccea94e381fd6ee520162b8c362f310efe7e9e;hb=d88744a44aa5f2ca90ab87946692b9eed3120641;hpb=5c408ad8ef08a226c018702aca969536f36ac4e5 diff --git a/src/bin/lttng-sessiond/rotate.c b/src/bin/lttng-sessiond/rotate.c index 49ccea94e..3ca80ce6a 100644 --- a/src/bin/lttng-sessiond/rotate.c +++ b/src/bin/lttng-sessiond/rotate.c @@ -32,6 +32,8 @@ #include #include +#include + #include "session.h" #include "rotate.h" #include "rotation-thread.h" @@ -350,3 +352,50 @@ error: end: return ret; } + +int relay_rotate_pending(struct ltt_session *session, uint64_t chunk_id) +{ + int ret; + struct consumer_socket *socket; + struct consumer_output *output; + struct lttng_ht_iter iter; + + /* + * Either one of the sessions is enough to find the consumer_output + * and uid/gid. + */ + if (session->kernel_session) { + output = session->kernel_session->consumer; + } else if (session->ust_session) { + output = session->ust_session->consumer; + } else { + assert(0); + } + + if (!output || !output->socks) { + ERR("No consumer output found"); + ret = -1; + goto end; + } + + ret = -1; + + rcu_read_lock(); + /* + * We have to iterate to find a socket, but we only need to send the + * rotate pending command to one consumer, so we break after the first + * one. + */ + cds_lfht_for_each_entry(output->socks->ht, &iter.iter, socket, + node.node) { + pthread_mutex_lock(socket->lock); + ret = consumer_rotate_pending_relay(socket, output, session->id, + chunk_id); + pthread_mutex_unlock(socket->lock); + break; + } + rcu_read_unlock(); + +end: + return ret; +}