tests: Make test_per_application_leaks more robust
[lttng-tools.git] / src / common / health / health.cpp
index 7682131e760e5aa53ad5bd7dd99ee1168214a031..444621f3a94df593c74327f2eff5a940669e0167 100644 (file)
@@ -44,7 +44,7 @@ struct health_app {
 };
 
 /* Define TLS health state. */
-DEFINE_URCU_TLS(struct health_state, health_state);
+thread_local struct health_state health_state;
 
 /*
  * Initialize health check subsytem.
@@ -66,14 +66,14 @@ struct health_app *health_app_create(int nr_types)
 
        ha = zmalloc<health_app>();
        if (!ha) {
-               return NULL;
+               return nullptr;
        }
        ha->flags = calloc<health_flags>(nr_types);
        if (!ha->flags) {
                goto error_flags;
        }
        CDS_INIT_LIST_HEAD(&ha->list);
-       pthread_mutex_init(&ha->lock, NULL);
+       pthread_mutex_init(&ha->lock, nullptr);
        ha->nr_types = nr_types;
        ha->time_delta.tv_sec = DEFAULT_HEALTH_CHECK_DELTA_S;
        ha->time_delta.tv_nsec = DEFAULT_HEALTH_CHECK_DELTA_NS;
@@ -82,7 +82,7 @@ struct health_app *health_app_create(int nr_types)
 
 error_flags:
        free(ha);
-       return NULL;
+       return nullptr;
 }
 
 void health_app_destroy(struct health_app *ha)
@@ -258,16 +258,16 @@ void health_register(struct health_app *ha, int type)
        LTTNG_ASSERT(type < ha->nr_types);
 
        /* Init TLS state. */
-       uatomic_set(&URCU_TLS(health_state).last, 0);
-       uatomic_set(&URCU_TLS(health_state).last_time.tv_sec, 0);
-       uatomic_set(&URCU_TLS(health_state).last_time.tv_nsec, 0);
-       uatomic_set(&URCU_TLS(health_state).current, 0);
-       uatomic_set(&URCU_TLS(health_state).flags, (health_flags) 0);
-       uatomic_set(&URCU_TLS(health_state).type, type);
+       uatomic_set(&health_state.last, 0);
+       uatomic_set(&health_state.last_time.tv_sec, 0);
+       uatomic_set(&health_state.last_time.tv_nsec, 0);
+       uatomic_set(&health_state.current, 0);
+       uatomic_set(&health_state.flags, (health_flags) 0);
+       uatomic_set(&health_state.type, type);
 
        /* Add it to the global TLS state list. */
        state_lock(ha);
-       cds_list_add(&URCU_TLS(health_state).node, &ha->list);
+       cds_list_add(&health_state.node, &ha->list);
        state_unlock(ha);
 }
 
@@ -281,9 +281,9 @@ void health_unregister(struct health_app *ha)
         * On error, set the global_error_state since we are about to remove
         * the node from the global list.
         */
-       if (uatomic_read(&URCU_TLS(health_state).flags) & HEALTH_ERROR) {
-               uatomic_set(&ha->flags[URCU_TLS(health_state).type], HEALTH_ERROR);
+       if (uatomic_read(&health_state.flags) & HEALTH_ERROR) {
+               uatomic_set(&ha->flags[health_state.type], HEALTH_ERROR);
        }
-       cds_list_del(&URCU_TLS(health_state).node);
+       cds_list_del(&health_state.node);
        state_unlock(ha);
 }
This page took 0.025041 seconds and 4 git commands to generate.