Clean-up: replace erroneous of empty parameter list by void
[lttng-tools.git] / src / bin / lttng-sessiond / cmd.c
index 39e824bdef7e4fc10fae81cafc8f2882d4a13e81..2ae0ba687e89df721bb9cb96385f2685f6b00277 100644 (file)
@@ -4295,8 +4295,7 @@ int cmd_register_trigger(struct command_ctx *cmd_ctx, int sock,
                        sock, trigger_payload.buffer.data, trigger_len);
        if (sock_recv_len < 0 || sock_recv_len != trigger_len) {
                ERR("Failed to receive \"register trigger\" command payload");
-               /* TODO: should this be a new error enum ? */
-               ret = LTTNG_ERR_INVALID_TRIGGER;
+               ret = LTTNG_ERR_INVALID_PROTOCOL;
                goto end;
        }
 
@@ -4342,6 +4341,15 @@ int cmd_register_trigger(struct command_ctx *cmd_ctx, int sock,
                }
        }
 
+       /*
+        * The bytecode generation also serves as a validation step for the
+        * bytecode expressions.
+        */
+       ret = lttng_trigger_generate_bytecode(trigger, &cmd_creds);
+       if (ret != LTTNG_OK) {
+               goto end;
+       }
+
        /*
         * A reference to the trigger is acquired by the notification thread.
         * It is safe to return the same trigger to the caller since it the
@@ -4450,6 +4458,29 @@ end:
        return ret;
 }
 
+int cmd_list_triggers(struct command_ctx *cmd_ctx,
+               struct notification_thread_handle *notification_thread,
+               struct lttng_triggers **return_triggers)
+{
+       int ret = 0;
+       enum lttng_error_code ret_code;
+       struct lttng_triggers *triggers = NULL;
+
+       /* Get the set of triggers from the notification thread. */
+       ret_code = notification_thread_command_list_triggers(
+                       notification_thread, cmd_ctx->creds.uid, &triggers);
+       if (ret_code != LTTNG_OK) {
+               ret = ret_code;
+               goto end;
+       }
+
+       *return_triggers = triggers;
+       triggers = NULL;
+       ret = LTTNG_OK;
+end:
+       lttng_triggers_destroy(triggers);
+       return ret;
+}
 /*
  * Send relayd sockets from snapshot output to consumer. Ignore request if the
  * snapshot output is *not* set with a remote destination.
This page took 0.024555 seconds and 4 git commands to generate.