diff options
author | Dinh Cong Toan <toan.dinhcong@vn.bosch.com> | 2021-02-24 16:32:48 +0700 |
---|---|---|
committer | Saya Sugiura <39760799+ssugiura@users.noreply.github.com> | 2021-06-30 10:54:59 +0900 |
commit | 438f3550ea904f6d206b7c620934660c1b879029 (patch) | |
tree | 100ac9a80be024d481e3cc6cf2e69d88e52872f8 /src/lib | |
parent | 12b9aefc50a9c6a04c6f64dbb31e2294df9b56ba (diff) | |
download | DLT-daemon-438f3550ea904f6d206b7c620934660c1b879029.tar.gz |
dlt_user: correct handling return value
When processing dlt_user_log_send_log() function, message logs will be stored in
internal buffer in error case. Then, the error value is needed to handle correctly
before exiting.
Signed-off-by: Dinh Cong Toan <toan.dinhcong@vn.bosch.com>
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/dlt_user.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c index 20392a6..8332356 100644 --- a/src/lib/dlt_user.c +++ b/src/lib/dlt_user.c @@ -3802,32 +3802,36 @@ DltReturnValue dlt_user_log_send_log(DltContextData *log, int mtype) #endif } + DltReturnValue process_error_ret = DLT_RETURN_OK; /* store message in ringbuffer, if an error has occured */ if ((ret != DLT_RETURN_OK) || (dlt_user.appID[0] == '\0')) - ret = dlt_user_log_out_error_handling(&(userheader), + process_error_ret = dlt_user_log_out_error_handling(&(userheader), sizeof(DltUserHeader), msg.headerbuffer + sizeof(DltStorageHeader), msg.headersize - sizeof(DltStorageHeader), log->buffer, log->size); - switch (ret) { - case DLT_RETURN_BUFFER_FULL: - { + if (process_error_ret == DLT_RETURN_OK) + return DLT_RETURN_OK; + if (process_error_ret == DLT_RETURN_BUFFER_FULL) { /* Buffer full */ dlt_user.overflow_counter += 1; return DLT_RETURN_BUFFER_FULL; } - case DLT_RETURN_PIPE_FULL: - { - /* data could not be written */ - return DLT_RETURN_PIPE_FULL; - } - case DLT_RETURN_PIPE_ERROR: - { - /* handle not open or pipe error */ - close(dlt_user.dlt_log_handle); - dlt_user.dlt_log_handle = -1; + + /* handle return value of function dlt_user_log_out3() when process_error_ret < 0*/ + switch (ret) { + case DLT_RETURN_PIPE_FULL: + { + /* data could not be written */ + return DLT_RETURN_PIPE_FULL; + } + case DLT_RETURN_PIPE_ERROR: + { + /* handle not open or pipe error */ + close(dlt_user.dlt_log_handle); + dlt_user.dlt_log_handle = -1; #if defined DLT_LIB_USE_UNIX_SOCKET_IPC || defined DLT_LIB_USE_VSOCK_IPC dlt_user.connection_state = DLT_USER_RETRY_CONNECT; #endif |