Build fix: Missing message in LTTNG_DEPRECATED invocation
[lttng-tools.git] / src / common / location.c
index c79f8547546f6e65e0aa2dd5012c9c187f1108b7..e68051ee50b5e36aaffd787e2cba7999cf6a8904 100644 (file)
@@ -8,6 +8,7 @@
 #include <lttng/location-internal.h>
 #include <common/macros.h>
 #include <stdlib.h>
+#include <common/error.h>
 
 static
 struct lttng_trace_archive_location *lttng_trace_archive_location_create(
@@ -20,18 +21,17 @@ struct lttng_trace_archive_location *lttng_trace_archive_location_create(
                goto end;
        }
 
+       urcu_ref_init(&location->ref);
        location->type = type;
 end:
        return location;
 }
 
-LTTNG_HIDDEN
-void lttng_trace_archive_location_destroy(
-               struct lttng_trace_archive_location *location)
+static
+void trace_archive_location_destroy_ref(struct urcu_ref *ref)
 {
-       if (!location) {
-               return;
-       }
+       struct lttng_trace_archive_location *location =
+                       container_of(ref, struct lttng_trace_archive_location, ref);
 
        switch (location->type) {
        case LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_LOCAL:
@@ -48,7 +48,20 @@ void lttng_trace_archive_location_destroy(
        free(location);
 }
 
-LTTNG_HIDDEN
+void lttng_trace_archive_location_get(struct lttng_trace_archive_location *location)
+{
+       urcu_ref_get(&location->ref);
+}
+
+void lttng_trace_archive_location_put(struct lttng_trace_archive_location *location)
+{
+       if (!location) {
+               return;
+       }
+
+       urcu_ref_put(&location->ref, trace_archive_location_destroy_ref);
+}
+
 struct lttng_trace_archive_location *lttng_trace_archive_location_local_create(
                const char *absolute_path)
 {
@@ -72,11 +85,10 @@ struct lttng_trace_archive_location *lttng_trace_archive_location_local_create(
 end:
        return location;
 error:
-       lttng_trace_archive_location_destroy(location);
+       lttng_trace_archive_location_put(location);
        return NULL;
 }
 
-LTTNG_HIDDEN
 struct lttng_trace_archive_location *lttng_trace_archive_location_relay_create(
                const char *host,
                enum lttng_trace_archive_location_relay_protocol_type protocol,
@@ -110,11 +122,10 @@ struct lttng_trace_archive_location *lttng_trace_archive_location_relay_create(
 end:
        return location;
 error:
-       lttng_trace_archive_location_destroy(location);
+       lttng_trace_archive_location_put(location);
        return NULL;
 }
 
-LTTNG_HIDDEN
 ssize_t lttng_trace_archive_location_create_from_buffer(
                const struct lttng_buffer_view *view,
                struct lttng_trace_archive_location **location)
@@ -199,7 +210,6 @@ error:
        return -1;
 }
 
-LTTNG_HIDDEN
 ssize_t lttng_trace_archive_location_serialize(
                const struct lttng_trace_archive_location *location,
                struct lttng_dynamic_buffer *buffer)
This page took 0.024889 seconds and 4 git commands to generate.