lttng-ctl: Implement the notification interface
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 28 Feb 2017 00:21:50 +0000 (19:21 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 1 Mar 2017 04:02:50 +0000 (23:02 -0500)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/Makefile.am
include/lttng/notification/notification-internal.h [new file with mode: 0644]
include/lttng/notification/notification.h
src/lib/lttng-ctl/Makefile.am
src/lib/lttng-ctl/notification.c [new file with mode: 0644]

index ab104e4ab222b3e297673bf155ec19ad3e167b27..8c12072a87eb50efaf183ca92b814f6ea64678e3 100644 (file)
@@ -88,5 +88,5 @@ noinst_HEADERS = \
        lttng/action/notify-internal.h \
        lttng/condition/condition-internal.h \
        lttng/condition/buffer-usage-internal.h \
-       lttng/condition/evaluation-internal.h
-
+       lttng/condition/evaluation-internal.h \
+       lttng/notification/notification-internal.h
diff --git a/include/lttng/notification/notification-internal.h b/include/lttng/notification/notification-internal.h
new file mode 100644 (file)
index 0000000..d37db1e
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2017 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License, version 2.1 only,
+ * as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef LTTNG_NOTIFICATION_INTERNAL_H
+#define LTTNG_NOTIFICATION_INTERNAL_H
+
+#include <lttng/notification/notification.h>
+#include <common/macros.h>
+
+struct lttng_notification {
+       struct lttng_condition *condition;
+       struct lttng_evaluation *evaluation;
+};
+
+LTTNG_HIDDEN
+struct lttng_notification *lttng_notification_create(
+               struct lttng_condition *condition,
+               struct lttng_evaluation *evaluation);
+
+#endif /* LTTNG_NOTIFICATION_INTERNAL_H */
index 2f4cb1d59a9e4dc429264e0bd89ae9137f1e6040..100d0def459a8cf93e47691a0ae38851048b0ab2 100644 (file)
@@ -24,12 +24,18 @@ extern "C" {
 
 struct lttng_condition;
 struct lttng_evaluation;
+struct lttng_notification;
 
+/*
+ * The notification retains ownership of both the condition and evaluation.
+ * Destroying the notification will also destroy the notification and evaluation
+ * objects.
+ */
 extern struct lttng_condition *lttng_notification_get_condition(
                struct lttng_notification *notification);
 
-extern struct lttng_evaluation *
-lttng_notification_get_evaluation(struct lttng_notification *notification);
+extern struct lttng_evaluation *lttng_notification_get_evaluation(
+               struct lttng_notification *notification);
 
 extern void lttng_notification_destroy(struct lttng_notification *notification);
 
index abcbfee36bc86e6589bda890d492a76d76dca925..90252656afac6c8e88f9103705add0ec9affb278 100644 (file)
@@ -6,7 +6,8 @@ lib_LTLIBRARIES = liblttng-ctl.la
 
 liblttng_ctl_la_SOURCES = lttng-ctl.c snapshot.c lttng-ctl-helper.h \
                lttng-ctl-health.c save.c load.c deprecated-symbols.c \
-               action.c notify.c condition.c buffer-usage.c evaluation.c
+               action.c notify.c condition.c buffer-usage.c evaluation.c \
+               notification.c
 
 liblttng_ctl_la_LDFLAGS = \
                $(LT_NO_UNDEFINED)
diff --git a/src/lib/lttng-ctl/notification.c b/src/lib/lttng-ctl/notification.c
new file mode 100644 (file)
index 0000000..4d96406
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2017 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License, version 2.1 only,
+ * as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <lttng/notification/notification-internal.h>
+#include <lttng/condition/condition.h>
+#include <lttng/condition/evaluation.h>
+#include <assert.h>
+
+LTTNG_HIDDEN
+struct lttng_notification *lttng_notification_create(
+               struct lttng_condition *condition,
+               struct lttng_evaluation *evaluation)
+{
+       struct lttng_notification *notification = NULL;
+
+       if (!condition || !evaluation) {
+               goto end;
+       }
+
+       notification = zmalloc(sizeof(struct lttng_notification));
+       if (!notification) {
+               goto end;
+       }
+
+       notification->condition = condition;
+       notification->evaluation = evaluation;
+end:
+       return notification;
+}
+
+void lttng_notification_destroy(struct lttng_notification *notification)
+{
+       if (!notification) {
+               return;
+       }
+
+       lttng_condition_destroy(notification->condition);
+       lttng_evaluation_destroy(notification->evaluation);
+       free(notification);
+}
+
+struct lttng_condition *lttng_notification_get_condition(
+               struct lttng_notification *notification)
+{
+       return notification ? notification->condition : NULL;
+}
+
+struct lttng_evaluation *lttng_notification_get_evaluation(
+               struct lttng_notification *notification)
+{
+       return notification ? notification->evaluation : NULL;
+}
This page took 0.029184 seconds and 5 git commands to generate.