}
} else {
const uint32_t output_path_length =
- strlen(session->output_path) + 1;
+ session ? strlen(session->output_path) + 1 : 0;
reply.output_path_length = htobe32(output_path_length);
- ret = lttng_dynamic_buffer_append(&reply_payload, &reply,
- sizeof(reply));
+ ret = lttng_dynamic_buffer_append(
+ &reply_payload, &reply, sizeof(reply));
if (ret) {
ERR("Failed to append \"create session\" command reply header to payload buffer");
goto end;
}
- ret = lttng_dynamic_buffer_append(&reply_payload,
- session->output_path, output_path_length);
- if (ret) {
- ERR("Failed to append \"create session\" command reply path to payload buffer");
- goto end;
+ if (output_path_length) {
+ ret = lttng_dynamic_buffer_append(&reply_payload,
+ session->output_path,
+ output_path_length);
+ if (ret) {
+ ERR("Failed to append \"create session\" command reply path to payload buffer");
+ goto end;
+ }
}
}
}
reply_code = LTTNG_OK;
+ ret = 0;
end:
if (stream) {
stream_put(stream);
send_ret);
ret = -1;
}
-
- ret = 0;
end_no_reply:
lttng_trace_chunk_put(next_trace_chunk);
return ret;
}
}
- ret = session_init_output_directory_handle(
- conn->session, &session_output);
- if (ret) {
- reply_code = LTTNG_ERR_CREATE_DIR_FAIL;
- goto end;
- }
-
chunk_status = lttng_trace_chunk_set_credentials_current_user(chunk);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
reply_code = LTTNG_ERR_UNK;
goto end;
}
+ ret = session_init_output_directory_handle(
+ conn->session, &session_output);
+ if (ret) {
+ reply_code = LTTNG_ERR_CREATE_DIR_FAIL;
+ goto end;
+ }
chunk_status = lttng_trace_chunk_set_as_owner(chunk, &session_output);
+ lttng_directory_handle_fini(&session_output);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
reply_code = LTTNG_ERR_UNK;
ret = -1;
end_no_reply:
lttng_trace_chunk_put(chunk);
lttng_trace_chunk_put(published_chunk);
- lttng_directory_handle_fini(&session_output);
return ret;
}
struct relay_connection *conn,
const struct lttng_buffer_view *payload)
{
- int ret = 0;
+ int ret = 0, buf_ret;
ssize_t send_ret;
struct relay_session *session = conn->session;
struct lttcomm_relayd_close_trace_chunk *msg;
end:
reply.generic.ret_code = htobe32((uint32_t) reply_code);
reply.path_length = htobe32((uint32_t) path_length);
- ret = lttng_dynamic_buffer_append(
+ buf_ret = lttng_dynamic_buffer_append(
&reply_payload, &reply, sizeof(reply));
- if (ret) {
+ if (buf_ret) {
ERR("Failed to append \"close trace chunk\" command reply header to payload buffer");
goto end_no_reply;
}
if (reply_code == LTTNG_OK) {
- ret = lttng_dynamic_buffer_append(&reply_payload,
+ buf_ret = lttng_dynamic_buffer_append(&reply_payload,
closed_trace_chunk_path, path_length);
- if (ret) {
+ if (buf_ret) {
ERR("Failed to append \"close trace chunk\" command reply path to payload buffer");
goto end_no_reply;
}