static int enqueue_dropped_notification( struct lttng_notification_channel *channel) { int ret = 0; struct pending_notification *pending_notification; struct cds_list_head *last_element = channel->pending_notifications.list.prev; pending_notification = caa_container_of(last_element, struct pending_notification, node); if (!pending_notification->notification) { /* * The last enqueued notification indicates dropped * notifications; there is nothing to do as we group * dropped notifications together. */ goto end; } if (channel->pending_notifications.count >= DEFAULT_CLIENT_MAX_QUEUED_NOTIFICATIONS_COUNT && pending_notification->notification) { /* * Discard the last enqueued notification to indicate * that notifications were dropped at this point. */ lttng_notification_destroy( pending_notification->notification); pending_notification->notification = NULL; goto end; } pending_notification = zmalloc(sizeof(*pending_notification)); if (!pending_notification) { ret = -1; goto end; } CDS_INIT_LIST_HEAD(&pending_notification->node); cds_list_add(&pending_notification->node, &channel->pending_notifications.list); channel->pending_notifications.count++; end: return ret; }
static int enqueue_notification_from_current_message( struct lttng_notification_channel *channel) { int ret = 0; struct lttng_notification *notification; struct pending_notification *pending_notification; if (channel->pending_notifications.count >= DEFAULT_CLIENT_MAX_QUEUED_NOTIFICATIONS_COUNT) { /* Drop the notification. */ ret = enqueue_dropped_notification(channel); goto end; } pending_notification = zmalloc(sizeof(*pending_notification)); if (!pending_notification) { ret = -1; goto error; } CDS_INIT_LIST_HEAD(&pending_notification->node); notification = create_notification_from_current_message(channel); if (!notification) { ret = -1; goto error; } pending_notification->notification = notification; cds_list_add(&pending_notification->node, &channel->pending_notifications.list); channel->pending_notifications.count++; end: return ret; error: free(pending_notification); goto end; }
void deq_push_r(struct cds_list_head *e, struct deq *p) { cds_list_add(e, &p->chain); }
void deq_push_r(struct cds_list_head *e, struct deq *p) { spin_lock(&p->lock); cds_list_add(e, &p->chain); spin_unlock(&p->lock); }