X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;ds=sidebyside;f=src%2Fcommon%2Fhealth%2Fhealth.cpp;h=444621f3a94df593c74327f2eff5a940669e0167;hb=27b5aa577cff515f5273f75320190877a85317e2;hp=7682131e760e5aa53ad5bd7dd99ee1168214a031;hpb=28ab034a2c3582d07d3423d2d746731f87d3969f;p=lttng-tools.git diff --git a/src/common/health/health.cpp b/src/common/health/health.cpp index 7682131e7..444621f3a 100644 --- a/src/common/health/health.cpp +++ b/src/common/health/health.cpp @@ -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(); if (!ha) { - return NULL; + return nullptr; } ha->flags = calloc(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); }