A destructor assumes that it has an exclusive thread
access (no other library function can run in paralell).
This condition is not always met, which can lead to a
race condition and use after free situation. Since all
other, backend specific resources are not freed anyway,
we can get rid of the destructor to make things more
reliable.
The function itself is left because it is still necessary
in tests.
Change-Id: I3bc2a7b660c6c805182592a70a8a954beba16772
Signed-off-by: Maciej Slodczyk <m.slodczyk2@partner.samsung.com>
src/tests/queued_entry \
src/tests/filters
-check_CFLAGS = $(AM_CFLAGS) -O0 -fprofile-arcs -ftest-coverage
+check_CFLAGS = $(AM_CFLAGS) -O0 -fprofile-arcs -ftest-coverage -DUNIT_TEST
TESTS = $(check_PROGRAMS) \
src/tests/lcov.sh # doesn't test anything, but generates a test summary
return ret;
}
+#ifdef UNIT_TEST
/**
* @brief Finalize DLog
* @details Finalizes and deallocates the library
- * @notes Assumes it has exclusive thread access,
- * i.e. no other library function can run in parallel
+ * @notes Used in tests only
*/
-void __attribute__((destructor)) __dlog_fini(void)
+void __dlog_fini(void)
{
__log_limiter_destroy();
__dynamic_config_destroy();
write_to_log = __write_to_log_null;
is_initialized = false;
}
+#endif
+
#include <logconfig.h>
extern int (*write_to_log)(log_id_t, log_priority, const char *tag, const char *msg);
-void __attribute__((destructor)) __dlog_fini(void);
+void __dlog_fini(void);
void __log_limiter_update(struct log_config *config) { }
void __log_limiter_destroy(void) { }