}
/*
- * Add context to event and/or channel.
- * If event_name is NULL, the context is applied to all events of the channel.
- * If channel_name is NULL, a lookup of the event's channel is done.
- * If both are NULL, the context is applied to all events of all channels.
+ * Add context to a channel.
+ *
+ * If the given channel is NULL, add the contexts to all channels.
+ * The event_name param is ignored.
*
* Returns the size of the returned payload data or a negative error code.
*/
/* Copy channel name */
copy_string(lsm.u.context.channel_name, channel_name,
sizeof(lsm.u.context.channel_name));
- /* Copy event name */
- copy_string(lsm.u.context.event_name, event_name,
- sizeof(lsm.u.context.event_name));
copy_lttng_domain(&lsm.domain, &handle->domain);
}
/*
- * set filter for an event
+ * Create or enable an event with a filter expression.
+ *
* Return negative error value on error.
* Return size of returned session payload data if OK.
*/
-
-int lttng_set_event_filter(struct lttng_handle *handle,
- const char *event_name, const char *channel_name,
+int lttng_enable_event_with_filter(struct lttng_handle *handle,
+ struct lttng_event *event, const char *channel_name,
const char *filter_expression)
{
struct lttcomm_session_msg lsm;
FILE *fmem;
int ret = 0;
- /* Safety check. */
- if (handle == NULL) {
- return -LTTNG_ERR_INVALID;
+ if (!filter_expression) {
+ /*
+ * Fall back to normal event enabling if no filter
+ * specified.
+ */
+ return lttng_enable_event(handle, event, channel_name);
}
- if (!filter_expression) {
- return 0;
+ /*
+ * Empty filter string will always be rejected by the parser
+ * anyway, so treat this corner-case early to eliminate
+ * lttng_fmemopen error for 0-byte allocation.
+ */
+ if (handle == NULL || filter_expression[0] == '\0') {
+ return -LTTNG_ERR_INVALID;
}
/*
memset(&lsm, 0, sizeof(lsm));
- lsm.cmd_type = LTTNG_SET_FILTER;
+ lsm.cmd_type = LTTNG_ENABLE_EVENT_WITH_FILTER;
/* Copy channel name */
- copy_string(lsm.u.filter.channel_name, channel_name,
- sizeof(lsm.u.filter.channel_name));
+ copy_string(lsm.u.enable.channel_name, channel_name,
+ sizeof(lsm.u.enable.channel_name));
/* Copy event name */
- copy_string(lsm.u.filter.event_name, event_name,
- sizeof(lsm.u.filter.event_name));
- lsm.u.filter.bytecode_len = sizeof(ctx->bytecode->b)
+ if (event) {
+ memcpy(&lsm.u.enable.event, event, sizeof(lsm.u.enable.event));
+ }
+
+ lsm.u.enable.bytecode_len = sizeof(ctx->bytecode->b)
+ bytecode_get_len(&ctx->bytecode->b);
copy_lttng_domain(&lsm.domain, &handle->domain);
sizeof(lsm.session.name));
ret = ask_sessiond_varlen(&lsm, &ctx->bytecode->b,
- lsm.u.filter.bytecode_len, NULL);
+ lsm.u.enable.bytecode_len, NULL);
filter_bytecode_free(ctx);
filter_ir_free(ctx);
attr->switch_timer_interval = DEFAULT_CHANNEL_SWITCH_TIMER;
attr->read_timer_interval = DEFAULT_CHANNEL_READ_TIMER;
- attr->subbuf_size = DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE;
+ attr->subbuf_size = default_get_kernel_channel_subbuf_size();
attr->num_subbuf = DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM;
attr->output = DEFAULT_KERNEL_CHANNEL_OUTPUT;
break;
attr->switch_timer_interval = DEFAULT_CHANNEL_SWITCH_TIMER;
attr->read_timer_interval = DEFAULT_CHANNEL_READ_TIMER;
- attr->subbuf_size = DEFAULT_UST_CHANNEL_SUBBUF_SIZE;
+ attr->subbuf_size = default_get_ust_channel_subbuf_size();
attr->num_subbuf = DEFAULT_UST_CHANNEL_SUBBUF_NUM;
attr->output = DEFAULT_UST_CHANNEL_OUTPUT;
break;