summaryrefslogtreecommitdiff
path: root/src/lib/dlt_user.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/dlt_user.c')
-rwxr-xr-xsrc/lib/dlt_user.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c
index 8c82dd3..594fe39 100755
--- a/src/lib/dlt_user.c
+++ b/src/lib/dlt_user.c
@@ -331,6 +331,16 @@ int dlt_init_common(void)
void dlt_user_atexit_handler(void)
{
+
+ /* Try to resend potential log messages in the user buffer */
+ int count = dlt_user_atexit_blow_out_user_buffer();
+
+ if(count != 0){
+ char tmp[256];
+ sprintf(&tmp,"Lost log messages in user buffer when exiting: %i\n",count);
+ dlt_log(LOG_ERR, tmp);
+ }
+
/* Unregister app (this also unregisters all contexts in daemon) */
/* Ignore return value */
dlt_unregister_app();
@@ -340,6 +350,31 @@ void dlt_user_atexit_handler(void)
dlt_free();
}
+int dlt_user_atexit_blow_out_user_buffer(void){
+
+ int count,ret;
+
+ uint32_t exitTime = dlt_uptime() + DLT_USER_ATEXIT_RESEND_BUFFER_EXIT_TIMEOUT;
+
+ while(dlt_uptime() < exitTime ){
+
+ ret = dlt_user_log_resend_buffer();
+
+ if(ret == 0)
+ {
+ return 0;
+ }
+
+ usleep(DLT_USER_ATEXIT_RESEND_BUFFER_SLEEP);
+ }
+
+ DLT_SEM_LOCK();
+ count = dlt_buffer_get_message_count(&(dlt_user.startup_buffer));
+ DLT_SEM_FREE();
+
+ return count;
+}
+
int dlt_free(void)
{
int i;