Fix: lttng-relayd: forcefully close stream on relayd shutdown
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Tue, 20 Dec 2016 23:25:17 +0000 (18:25 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 6 Jan 2017 16:38:20 +0000 (11:38 -0500)
Add an "aborted" field to relay_session struct to indicate that on
shutdown pending data for a stream is no relevant and should not be
waited for.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-relayd/main.c
src/bin/lttng-relayd/session.c
src/bin/lttng-relayd/session.h
src/bin/lttng-relayd/stream.c

index dc19a69c77a548df81fffc2aa7e44affd12279b4..7b313818e5c09a5719339740f47b2787304d461b 100644 (file)
@@ -2680,6 +2680,11 @@ error:
                        destroy_conn,
                        sock_n.node) {
                health_code_update();
+
+               if (session_abort(destroy_conn->session)) {
+                       assert(0);
+               }
+
                /*
                 * No need to grab another ref, because we own
                 * destroy_conn.
index 9702bd220b0d134bc4502ecd6e4435e682e22ba1..f76fb4a42e7606b8ebfea427033b00e3de192020 100644 (file)
@@ -228,6 +228,27 @@ rcu_unlock:
        return ret;
 }
 
+int session_abort(struct relay_session *session)
+{
+       int ret = 0;
+
+       if (!session) {
+               return 0;
+       }
+
+       pthread_mutex_lock(&session->lock);
+       DBG("aborting session %" PRIu64, session->id);
+       if (session->aborted) {
+               ERR("session %" PRIu64 " is already aborted", session->id);
+               ret = -1;
+               goto unlock;
+       }
+       session->aborted = true;
+unlock:
+       pthread_mutex_unlock(&session->lock);
+       return ret;
+}
+
 void print_sessions(void)
 {
        struct lttng_ht_iter iter;
index 3ee1c45c3d24c93605605336fb7b5ac426e05afd..4c8f8a61f402dcd98f36fbba780a86137fb02ad0 100644 (file)
@@ -67,6 +67,13 @@ struct relay_session {
        /* Tell if the session connection has been closed on the streaming side. */
        bool connection_closed;
 
+       /*
+        * Tell if the session is currently living in a exiting relayd and
+        * should be cleaned forcefully without waiting for pending data or
+        * pending ctrl data.
+        */
+       bool aborted;
+
        /* Contains ctf_trace object of that session indexed by path name. */
        struct lttng_ht *ctf_traces_ht;
 
@@ -111,6 +118,8 @@ bool session_get(struct relay_session *session);
 void session_put(struct relay_session *session);
 
 int session_close(struct relay_session *session);
+int session_abort(struct relay_session *session);
+
 void print_sessions(void);
 
 #endif /* _SESSION_H */
index c59bb9416b1c9609ca34884cbc6126daf1295b78..e9c7ad172bc0d2f0e44ff3925ae929bd0b8e1398 100644 (file)
@@ -345,7 +345,15 @@ void stream_put(struct relay_stream *stream)
 
 void try_stream_close(struct relay_stream *stream)
 {
+       bool session_aborted;
+       struct relay_session *session = stream->trace->session;
+
        DBG("Trying to close stream %" PRIu64, stream->stream_handle);
+
+       pthread_mutex_lock(&session->lock);
+       session_aborted = session->aborted;
+       pthread_mutex_unlock(&session->lock);
+
        pthread_mutex_lock(&stream->lock);
        /*
         * Can be called concurently by connection close and reception of last
@@ -387,7 +395,8 @@ void try_stream_close(struct relay_stream *stream)
        }
 
        if (stream->last_net_seq_num != -1ULL &&
-                       ((int64_t) (stream->prev_seq - stream->last_net_seq_num)) < 0) {
+                       ((int64_t) (stream->prev_seq - stream->last_net_seq_num)) < 0
+                       && !session_aborted) {
                /*
                 * Don't close since we still have data pending. This
                 * handles cases where an explicit close command has
This page took 0.041054 seconds and 4 git commands to generate.