consumer: Rename net_seq_idx to relayd_id
[lttng-tools.git] / src / common / consumer / consumer-stream.c
index d0b1ddef2259fc57342cac15ef5003f19fc03e6f..b2a5d41fd94a0d7fc9fd5660f6c8aaceb2ad5a33 100644 (file)
@@ -71,22 +71,18 @@ void consumer_stream_relayd_close(struct lttng_consumer_stream *stream,
        ret = relayd_send_close_stream(&relayd->control_sock,
                        stream->relayd_stream_id,
                        stream->next_net_seq_num - 1);
-       pthread_mutex_unlock(&relayd->ctrl_sock_mutex);
        if (ret < 0) {
-               DBG("Unable to close stream on the relayd. Continuing");
-               /*
-                * Continue here. There is nothing we can do for the relayd.
-                * Chances are that the relayd has closed the socket so we just
-                * continue cleaning up.
-                */
+               ERR("Relayd send close stream failed. Cleaning up relayd %" PRIu64 ".", relayd->id);
+               lttng_consumer_cleanup_relayd(relayd);
        }
+       pthread_mutex_unlock(&relayd->ctrl_sock_mutex);
 
        /* Both conditions are met, we destroy the relayd. */
        if (uatomic_read(&relayd->refcount) == 0 &&
                        uatomic_read(&relayd->destroy_flag)) {
                consumer_destroy_relayd(relayd);
        }
-       stream->net_seq_idx = (uint64_t) -1ULL;
+       stream->relayd_id = (uint64_t) -1ULL;
        stream->sent_to_relayd = 0;
 }
 
@@ -170,7 +166,7 @@ void consumer_stream_close(struct lttng_consumer_stream *stream)
 
        /* Check and cleanup relayd if needed. */
        rcu_read_lock();
-       relayd = consumer_find_relayd(stream->net_seq_idx);
+       relayd = consumer_find_relayd(stream->relayd_id);
        if (relayd != NULL) {
                consumer_stream_relayd_close(stream, relayd);
        }
@@ -364,17 +360,26 @@ int consumer_stream_write_index(struct lttng_consumer_stream *stream,
        assert(element);
 
        rcu_read_lock();
-       if (stream->net_seq_idx != (uint64_t) -1ULL) {
+       if (stream->relayd_id != (uint64_t) -1ULL) {
                struct consumer_relayd_sock_pair *relayd;
-               relayd = consumer_find_relayd(stream->net_seq_idx);
+               relayd = consumer_find_relayd(stream->relayd_id);
                if (relayd) {
                        pthread_mutex_lock(&relayd->ctrl_sock_mutex);
                        ret = relayd_send_index(&relayd->control_sock, element,
                                stream->relayd_stream_id, stream->next_net_seq_num - 1);
+                       if (ret < 0) {
+                               /*
+                                * Communication error with lttng-relayd,
+                                * perform cleanup now
+                                */
+                               ERR("Relayd send index failed. Cleaning up relayd %" PRIu64 ".", relayd->id);
+                               lttng_consumer_cleanup_relayd(relayd);
+                               ret = -1;
+                       }
                        pthread_mutex_unlock(&relayd->ctrl_sock_mutex);
                } else {
                        ERR("Stream %" PRIu64 " relayd ID %" PRIu64 " unknown. Can't write index.",
-                                       stream->key, stream->net_seq_idx);
+                                       stream->key, stream->relayd_id);
                        ret = -1;
                }
        } else {
This page took 0.036712 seconds and 5 git commands to generate.