X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fsave.c;h=6cb220c2f28d1e56bffeef8dbf49a68d4cd6d516;hp=d268f33190698d6f9bd920a5bbdbab140a377d70;hb=ccf10263bcd2ca4667b9e1fc4dab64a3c8d8c4d8;hpb=14ce5bd8eefa248c5abedc32b02394ef74307e81 diff --git a/src/bin/lttng-sessiond/save.c b/src/bin/lttng-sessiond/save.c index d268f3319..6cb220c2f 100644 --- a/src/bin/lttng-sessiond/save.c +++ b/src/bin/lttng-sessiond/save.c @@ -16,6 +16,7 @@ */ #define _GNU_SOURCE +#define _LGPL_SOURCE #include #include #include @@ -715,6 +716,8 @@ end: return ret; } +/* TODO: save/restore tracker pid */ + static int save_kernel_context(struct config_writer *writer, struct lttng_kernel_context *ctx) @@ -801,6 +804,11 @@ int save_kernel_contexts(struct config_writer *writer, int ret; struct ltt_kernel_context *ctx; + if (cds_list_empty(&kchan->ctx_list)) { + ret = 0; + goto end; + } + ret = config_writer_open_element(writer, config_element_contexts); if (ret) { ret = LTTNG_ERR_SAVE_IO_FAIL; @@ -1156,7 +1164,8 @@ int save_ust_session(struct config_writer *writer, ust_chan = caa_container_of(node, struct ltt_ust_channel, node); agent_channel = !strcmp(DEFAULT_JUL_CHANNEL_NAME, ust_chan->name) || - !strcmp(DEFAULT_LOG4J_CHANNEL_NAME, ust_chan->name); + !strcmp(DEFAULT_LOG4J_CHANNEL_NAME, ust_chan->name) || + !strcmp(DEFAULT_PYTHON_CHANNEL_NAME, ust_chan->name); if (!(save_agent ^ agent_channel)) { ret = save_ust_channel(writer, ust_chan, session->ust_session); if (ret) { @@ -1218,6 +1227,8 @@ int save_domains(struct config_writer *writer, struct ltt_session *session) } if (session->ust_session) { + unsigned long agent_count; + ret = config_writer_open_element(writer, config_element_domain); if (ret) { @@ -1236,30 +1247,37 @@ int save_domains(struct config_writer *writer, struct ltt_session *session) ret = LTTNG_ERR_SAVE_IO_FAIL; goto end; } - } - if (session->ust_session && - lttng_ht_get_count(session->ust_session->agents) > 0) { - ret = config_writer_open_element(writer, - config_element_domain); - if (ret) { - ret = LTTNG_ERR_SAVE_IO_FAIL; - goto end; - } + rcu_read_lock(); + agent_count = + lttng_ht_get_count(session->ust_session->agents); + rcu_read_unlock(); - ret = save_ust_session(writer, session, 1); - if (ret) { - goto end; - } + if (agent_count > 0) { + ret = config_writer_open_element(writer, + config_element_domain); + if (ret) { + ret = LTTNG_ERR_SAVE_IO_FAIL; + goto end; + } - /* /domain */ - ret = config_writer_close_element(writer); - if (ret) { - ret = LTTNG_ERR_SAVE_IO_FAIL; - goto end; + ret = save_ust_session(writer, session, 1); + if (ret) { + goto end; + } + + /* /domain */ + ret = config_writer_close_element(writer); + if (ret) { + ret = LTTNG_ERR_SAVE_IO_FAIL; + goto end; + } } } + if (session->ust_session) { + } + /* /domains */ ret = config_writer_close_element(writer); if (ret) {