Fix: consumer: fallback to flush when flush empty is unsupported
[lttng-tools.git] / src / common / consumer / consumer.c
index 0263489ddd8a908bacd2096ec14e68cfafbb1bd7..c043353b9e82b078d235aa55a0b90f85d452fb73 100644 (file)
@@ -1,20 +1,10 @@
 /*
- * Copyright (C) 2011 Julien Desfossez <julien.desfossez@polymtl.ca>
- *                      Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *               2012 - David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2011 Julien Desfossez <julien.desfossez@polymtl.ca>
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2 only,
- * as published by the Free Software Foundation.
+ * SPDX-License-Identifier: GPL-2.0-only
  *
- * This program 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 General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #define _LGPL_SOURCE
@@ -3963,8 +3953,18 @@ int consumer_flush_buffer(struct lttng_consumer_stream *stream, int producer_act
                } else {
                        ret = kernctl_buffer_flush_empty(stream->wait_fd);
                        if (ret < 0) {
-                               ERR("Failed to flush kernel stream");
-                               goto end;
+                               /*
+                                * Doing a buffer flush which does not take into
+                                * account empty packets. This is not perfect,
+                                * but required as a fall-back when
+                                * "flush_empty" is not implemented by
+                                * lttng-modules.
+                                */
+                               ret = kernctl_buffer_flush(stream->wait_fd);
+                               if (ret < 0) {
+                                       ERR("Failed to flush kernel stream");
+                                       goto end;
+                               }
                        }
                }
                break;
@@ -4203,7 +4203,7 @@ int consumer_clear_buffer(struct lttng_consumer_stream *stream)
        case LTTNG_CONSUMER_KERNEL:
                ret = kernctl_buffer_clear(stream->wait_fd);
                if (ret < 0) {
-                       ERR("Failed to flush kernel stream");
+                       ERR("Failed to clear kernel stream (ret = %d)", ret);
                        goto end;
                }
                break;
@@ -4282,11 +4282,6 @@ error_unlock:
        pthread_mutex_unlock(&stream->lock);
        pthread_mutex_unlock(&channel->lock);
        rcu_read_unlock();
-       if (ret) {
-               goto error;
-       }
-       ret = LTTCOMM_CONSUMERD_SUCCESS;
-error:
        return ret;
 }
 
This page took 0.024938 seconds and 4 git commands to generate.