Skip to content

Commit

Permalink
Data stuck in receiver buffer when dlt_daemon_user_send_log_level() f…
Browse files Browse the repository at this point in the history
…ails (COVESA#21)

- When dlt_daemon_user_send_log_level() called in
dlt_daemon_process_user_message_register_context() fails -1 was returned
which caused dlt_daemon_process_user_messages() to stop processing
receiver buffer. Remaining data was stuck until new data arrived over
FIFO.

- Make debug output of dlt_daemon_user_send_log_level() more
verbose.

Signed-off-by: Lutz Helwing <[email protected]>
  • Loading branch information
lhelwing authored and clipka committed Aug 22, 2017
1 parent 1b8c74a commit cf30c44
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ config.h
include/dlt/dlt_version.h
.project
.cproject


.settings
.idea/
cmake-build-debug/
6 changes: 1 addition & 5 deletions src/daemon/dlt-daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -2423,14 +2423,10 @@ int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
/* This call also replaces the default values with the values defined for default */
if (dlt_daemon_user_send_log_level(daemon, context, verbose)==-1)
{
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"Can't send current log level as response to %s for (%.4s;%.4s)\n",
dlt_vlog(LOG_WARNING, "Can't send current log level as response to %s for (%.4s;%.4s)\n",
__func__,
context->apid,
context->ctid);
dlt_log(LOG_WARNING, local_str);
return -1;
}
}

Expand Down
25 changes: 20 additions & 5 deletions src/daemon/dlt_daemon_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1119,10 +1119,16 @@ int dlt_daemon_user_send_log_level(DltDaemon *daemon, DltDaemonContext *context,
PRINT_FUNCTION_VERBOSE(verbose);

if ((daemon == NULL) || (context == NULL))
{
dlt_vlog(LOG_ERR, "NULL parameter in %s", __func__);
return -1;
}

if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_LOG_LEVEL) < DLT_RETURN_OK)
{
dlt_vlog(LOG_ERR, "Failed to set userheader in %s", __func__);
return -1;
}

if(context->storage_log_level != DLT_LOG_DEFAULT)
{
Expand All @@ -1137,22 +1143,31 @@ int dlt_daemon_user_send_log_level(DltDaemon *daemon, DltDaemonContext *context,

usercontext.log_level_pos = context->log_level_pos;

snprintf(str,DLT_DAEMON_COMMON_TEXTBUFSIZE, "Send log-level to context: %.4s:%.4s [%i -> %i] [%i -> %i]\n",
context->apid, context->ctid, context->log_level, usercontext.log_level, context->trace_status, usercontext.trace_status);
dlt_log(LOG_NOTICE, str);
dlt_vlog(LOG_NOTICE, "Send log-level to context: %.4s:%.4s [%i -> %i] [%i -> %i]\n",
context->apid,
context->ctid,
context->log_level,
usercontext.log_level,
context->trace_status,
usercontext.trace_status);

/* log to FIFO */
errno = 0;
ret = dlt_user_log_out2(context->user_handle,
&(userheader), sizeof(DltUserHeader),
&(usercontext), sizeof(DltUserControlMsgLogLevel));

if (ret < DLT_RETURN_OK)
{
if (errno==EPIPE)
dlt_vlog(LOG_ERR, "Failed to send data to application in %s: %s",
__func__,
errno != 0 ? strerror(errno) : "Unknown error");

if (errno == EPIPE)
{
/* Close connection */
close(context->user_handle);
context->user_handle=DLT_FD_INIT;
context->user_handle = DLT_FD_INIT;
}
}

Expand Down

0 comments on commit cf30c44

Please sign in to comment.