ust_cmd = zmalloc(sizeof(struct ust_command));
if (ust_cmd == NULL) {
PERROR("ust command zmalloc");
+ ret = close(sock);
+ if (ret) {
+ PERROR("close");
+ }
goto error;
}
* domain.
*/
if (session->kernel_session->consumer) {
- consumer_destroy_output(session->kernel_session->consumer);
+ consumer_output_put(session->kernel_session->consumer);
}
session->kernel_session->consumer =
consumer_copy_output(session->consumer);
case LTTNG_DOMAIN_UST:
DBG3("Copying tracing session consumer output in UST session");
if (session->ust_session->consumer) {
- consumer_destroy_output(session->ust_session->consumer);
+ consumer_output_put(session->ust_session->consumer);
}
session->ust_session->consumer =
consumer_copy_output(session->consumer);
session->kernel_session->consumer->dst.trace_path,
S_IRWXU | S_IRWXG, session->uid, session->gid);
if (ret < 0) {
- if (ret != -EEXIST) {
+ if (errno != EEXIST) {
ERR("Trace directory creation error");
goto error;
}
}
case LTTNG_DISABLE_EVENT:
{
+
+ /*
+ * FIXME: handle filter; for now we just receive the filter's
+ * bytecode along with the filter expression which are sent by
+ * liblttng-ctl and discard them.
+ *
+ * This fixes an issue where the client may block while sending
+ * the filter payload and encounter an error because the session
+ * daemon closes the socket without ever handling this data.
+ */
+ size_t count = cmd_ctx->lsm->u.disable.expression_len +
+ cmd_ctx->lsm->u.disable.bytecode_len;
+
+ if (count) {
+ char data[LTTNG_FILTER_MAX_LEN];
+
+ DBG("Discarding disable event command payload of size %zu", count);
+ while (count) {
+ ret = lttcomm_recv_unix_sock(sock, data,
+ count > sizeof(data) ? sizeof(data) : count);
+ if (ret < 0) {
+ goto error;
+ }
+
+ count -= (size_t) ret;
+ }
+ }
/* FIXME: passing packed structure to non-packed pointer */
- /* TODO: handle filter */
ret = cmd_disable_event(cmd_ctx->session, cmd_ctx->lsm->domain.type,
cmd_ctx->lsm->u.disable.channel_name,
&cmd_ctx->lsm->u.disable.event);
}
case LTTNG_DATA_PENDING:
{
- ret = cmd_data_pending(cmd_ctx->session);
+ int pending_ret;
+
+ /* 1 byte to return whether or not data is pending */
+ ret = setup_lttng_msg(cmd_ctx, 1);
+ if (ret < 0) {
+ goto setup_error;
+ }
+
+ pending_ret = cmd_data_pending(cmd_ctx->session);
+ /*
+ * FIXME
+ *
+ * This function may returns 0 or 1 to indicate whether or not
+ * there is data pending. In case of error, it should return an
+ * LTTNG_ERR code. However, some code paths may still return
+ * a nondescript error code, which we handle by returning an
+ * "unknown" error.
+ */
+ if (pending_ret == 0 || pending_ret == 1) {
+ ret = LTTNG_OK;
+ } else if (pending_ret < 0) {
+ ret = LTTNG_ERR_UNK;
+ goto setup_error;
+ } else {
+ ret = pending_ret;
+ goto setup_error;
+ }
+
+ *cmd_ctx->llm->payload = (uint8_t) pending_ret;
break;
}
case LTTNG_SNAPSHOT_ADD_OUTPUT:
health_code_update();
- DBG("Sending response (size: %d, retcode: %s)",
+ DBG("Sending response (size: %d, retcode: %s (%d))",
cmd_ctx->lttng_msg_size,
- lttng_strerror(-cmd_ctx->llm->ret_code));
+ lttng_strerror(-cmd_ctx->llm->ret_code),
+ cmd_ctx->llm->ret_code);
ret = send_unix_sock(sock, cmd_ctx->llm, cmd_ctx->lttng_msg_size);
if (ret < 0) {
ERR("Failed to send data back to client");