Fix: ust: UST communication can return -EAGAIN
[lttng-tools.git] / src / bin / lttng-sessiond / ust-consumer.c
index a3e7eea008aee322566ff32a622871cfe6d060f9..2c92a37bc6dfdad081cc793b6b33909ce7778073 100644 (file)
@@ -1,18 +1,8 @@
 /*
- * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
  *
- * 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
@@ -56,6 +46,7 @@ static int ask_channel_creation(struct ust_app_session *ua_sess,
        char shm_path[PATH_MAX] = "";
        char root_shm_path[PATH_MAX] = "";
        bool is_local_trace;
+       size_t consumer_path_offset = 0;
 
        assert(ua_sess);
        assert(ua_chan);
@@ -67,7 +58,8 @@ static int ask_channel_creation(struct ust_app_session *ua_sess,
 
        is_local_trace = consumer->net_seq_index == -1ULL;
        /* Format the channel's path (relative to the current trace chunk). */
-       pathname = setup_channel_trace_path(consumer, ua_sess->path);
+       pathname = setup_channel_trace_path(consumer, ua_sess->path,
+                       &consumer_path_offset);
        if (!pathname) {
                ret = -1;
                goto error;
@@ -144,11 +136,12 @@ static int ask_channel_creation(struct ust_app_session *ua_sess,
                        ua_chan->attr.switch_timer_interval,
                        ua_chan->attr.read_timer_interval,
                        ua_sess->live_timer_interval,
+                       ua_sess->live_timer_interval != 0,
                        ua_chan->monitor_timer_interval,
                        output,
                        (int) ua_chan->attr.type,
                        ua_sess->tracing_id,
-                       pathname,
+                       &pathname[consumer_path_offset],
                        ua_chan->name,
                        consumer->net_seq_index,
                        ua_chan->key,
@@ -381,11 +374,16 @@ int ust_consumer_send_stream_to_ust(struct ust_app *app,
        ret = ustctl_send_stream_to_ust(app->sock, channel->obj, stream->obj);
        pthread_mutex_unlock(&app->sock_lock);
        if (ret < 0) {
-               if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
-                       ERR("ustctl send stream handle %d to app pid: %d with ret %d",
-                                       stream->obj->handle, app->pid, ret);
+               if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
+                       DBG3("UST app send stream to ust failed. Application is dead. (pid: %d, sock: %d).",
+                                       app->pid, app->sock);
+               } else if (ret == -EAGAIN) {
+                       WARN("UST app send stream to ust failed. Communication time out (pid: %d, sock: %d).",
+                                       app->pid, app->sock);
                } else {
-                       DBG3("UST app send stream to ust failed. Application is dead.");
+                       ERR("UST app send stream, handle %d, to ust failed with ret %d (pid: %d, sock: %d).",
+                                       stream->obj->handle, ret, app->pid,
+                                       app->sock);
                }
                goto error;
        }
@@ -418,11 +416,16 @@ int ust_consumer_send_channel_to_ust(struct ust_app *app,
        ret = ustctl_send_channel_to_ust(app->sock, ua_sess->handle, channel->obj);
        pthread_mutex_unlock(&app->sock_lock);
        if (ret < 0) {
-               if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
-                       ERR("Error ustctl send channel %s to app pid: %d with ret %d",
-                                       channel->name, app->pid, ret);
+               if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
+                       DBG3("UST app send channel to ust failed. Application is dead (pid: %d, sock: %d).",
+                                       app->pid, app->sock);
+               } else if (ret == -EAGAIN) {
+                       WARN("UST app send channel to ust failed. Communication timeout (pid: %d, sock: %d).",
+                                       app->pid, app->sock);
                } else {
-                       DBG3("UST app send channel to ust failed. Application is dead.");
+                       ERR("UST app send channel %s, to ust failed with ret %d (pid: %d, sock: %d).",
+                                       channel->name, ret, app->pid,
+                                       app->sock);
                }
                goto error;
        }
This page took 0.030839 seconds and 4 git commands to generate.