X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Flttng%2Fnotification%2Fchannel.h;h=030c88cbd3e1829ee1db2bd34fb2dc6bf43e3d4a;hb=4bd69c5f1161cd065f487da0f4c1aa03a73c47e4;hp=23256463358dfe017941fcaaf73dea07405f6420;hpb=92eda4bd141a72dca012cf3aca1faf5a54000203;p=lttng-tools.git diff --git a/include/lttng/notification/channel.h b/include/lttng/notification/channel.h index 232564633..030c88cbd 100644 --- a/include/lttng/notification/channel.h +++ b/include/lttng/notification/channel.h @@ -1,23 +1,16 @@ /* - * Copyright (C) 2017 - Jérémie Galarneau + * Copyright (C) 2017 Jérémie Galarneau * - * 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. + * SPDX-License-Identifier: LGPL-2.1-only * - * 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_CHANNEL_H #define LTTNG_NOTIFICATION_CHANNEL_H +#include +#include + #ifdef __cplusplus extern "C" { #endif @@ -29,6 +22,7 @@ struct lttng_notification_channel; enum lttng_notification_channel_status { LTTNG_NOTIFICATION_CHANNEL_STATUS_NOTIFICATIONS_DROPPED = 1, + LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED = 2, LTTNG_NOTIFICATION_CHANNEL_STATUS_OK = 0, LTTNG_NOTIFICATION_CHANNEL_STATUS_ERROR = -1, LTTNG_NOTIFICATION_CHANNEL_STATUS_CLOSED = -2, @@ -64,7 +58,7 @@ enum lttng_notification_channel_status { * The returned lttng_notification_channel must be destroyed using * the lttng_notification_channel_destroy() function. */ -extern struct lttng_notification_channel *lttng_notification_channel_create( +LTTNG_EXPORT extern struct lttng_notification_channel *lttng_notification_channel_create( struct lttng_endpoint *endpoint); /* @@ -79,16 +73,41 @@ extern struct lttng_notification_channel *lttng_notification_channel_create( * Notifications can be dropped if a client consumes the notifications sent * through the notification channel too slowly. * - * Returns LTTNG_NOTIFICATION_CHANNEL_STATUS_OK and a notificationon success, - * LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID if an invalid parameter was - * provided, or LTTNG_NOTIFICATION_CHANNEL_STATUS_NOTIFICATIONS_DROPPED if - * notifications were dropped. + * Returns + * - LTTNG_NOTIFICATION_CHANNEL_STATUS_OK and a notification on success, + * - LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID if an invalid parameter was + * provided, + * - LTTNG_NOTIFICATION_CHANNEL_STATUS_NOTIFICATIONS_DROPPED if notifications + * were dropped, + * - LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED if a signal was received + * that caused the reception to fail. */ -extern enum lttng_notification_channel_status +LTTNG_EXPORT extern enum lttng_notification_channel_status lttng_notification_channel_get_next_notification( struct lttng_notification_channel *channel, struct lttng_notification **notification); +/* + * Check whether a notification is pending on a notification channel. + * + * This call allows the user to check whether a notification is pending on + * the notification channel. + * + * If pending is set to true and the return value is + * LTTNG_NOTIFICATION_CHANNEL_STATUS_OK, + * lttng_notification_channel_get_next_notification() can be called and + * is guaranteed to not block. + * + * Returns + * - LTTNG_NOTIFICATION_CHANNEL_STATUS_OK on success, + * - LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID if an invalid parameter was + * provided. + */ +LTTNG_EXPORT extern enum lttng_notification_channel_status +lttng_notification_channel_has_pending_notification( + struct lttng_notification_channel *channel, + bool *notification_pending); + /* * Subscribe to notifications of a condition through a notification channel. * @@ -98,12 +117,13 @@ lttng_notification_channel_get_next_notification( * An error will be reported if the client tries to subscribe to the same * condition multiple times without unsubscribing. * - * Returns LTTNG_NOTIFICATION_CHANNEL_STATUS_OK on success, - * LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID if an invalid parameter was - * provided, or LTTNG_NOTIFICATION_CHANNEL_STATUS_ALREADY_SUBSCRIBED if the - * client was already subscribed to the condition through this channel. + * Returns + * - LTTNG_NOTIFICATION_CHANNEL_STATUS_OK on success, + * - LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID if an invalid parameter was + * provided, or LTTNG_NOTIFICATION_CHANNEL_STATUS_ALREADY_SUBSCRIBED if the + * client was already subscribed to the condition through this channel. */ -extern enum lttng_notification_channel_status +LTTNG_EXPORT extern enum lttng_notification_channel_status lttng_notification_channel_subscribe( struct lttng_notification_channel *channel, const struct lttng_condition *condition); @@ -117,12 +137,13 @@ lttng_notification_channel_subscribe( * An error will be reported if the client tries to unsubscribe to from a * conditions' notifications to which it was not previously subscribed. * - * Returns LTTNG_NOTIFICATION_CHANNEL_STATUS_OK on success, - * LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID if an invalid parameter was - * provided, or LTTNG_NOTIFICATION_CHANNEL_STATUS_UNKNOWN_CONDITION if the - * client was not already subscribed to the condition through this channel. + * Returns + * - LTTNG_NOTIFICATION_CHANNEL_STATUS_OK on success, + * - LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID if an invalid parameter was + * provided, or LTTNG_NOTIFICATION_CHANNEL_STATUS_UNKNOWN_CONDITION if the + * client was not already subscribed to the condition through this channel. */ -extern enum lttng_notification_channel_status +LTTNG_EXPORT extern enum lttng_notification_channel_status lttng_notification_channel_unsubscribe( struct lttng_notification_channel *channel, const struct lttng_condition *condition); @@ -130,7 +151,7 @@ lttng_notification_channel_unsubscribe( /* * Closes and destroys (frees) a notification channel. */ -extern void lttng_notification_channel_destroy( +LTTNG_EXPORT extern void lttng_notification_channel_destroy( struct lttng_notification_channel *channel); #ifdef __cplusplus