summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBui Nguyen Quoc Thanh <thanh.buinguyenquoc@vn.bosch.com>2020-08-27 13:20:17 +0700
committerSaya Sugiura <39760799+ssugiura@users.noreply.github.com>2021-01-06 09:27:28 +0900
commit2fa8b0d10a401aadab068015c0c08dd4d39e6c98 (patch)
treef6c3bd57a525cea450d49bd92ff3c25807e01acb
parentf79087dc4f45a54fda53ffafa350c18beeca9dbf (diff)
downloadDLT-daemon-2fa8b0d10a401aadab068015c0c08dd4d39e6c98.tar.gz
dlt-daemon: log levels are not controlled
The issue happens in case: dlt_logstorage.conf is set available at startup via dlt.conf and both LogAppName and ContextName are wildcard. In such a case, when logstorage disconnection happens, dlt-daemon is missing a check for case in which both are wildcard. It causes the reset loglevel is not happening. Then the control message to change loglevel will be handled incorrectly. Signed-off-by: Bui Nguyen Quoc Thanh <thanh.buinguyenquoc@vn.bosch.com>
-rw-r--r--src/daemon/dlt_daemon_offline_logstorage.c55
-rw-r--r--src/daemon/dlt_daemon_offline_logstorage.h9
2 files changed, 33 insertions, 31 deletions
diff --git a/src/daemon/dlt_daemon_offline_logstorage.c b/src/daemon/dlt_daemon_offline_logstorage.c
index db9637e..dc06dc8 100644
--- a/src/daemon/dlt_daemon_offline_logstorage.c
+++ b/src/daemon/dlt_daemon_offline_logstorage.c
@@ -534,7 +534,7 @@ DLT_STATIC DltReturnValue dlt_daemon_logstorage_force_reset_level(DltDaemon *dae
* @param daemon_local DltDaemonLocal structure
* @param id application id or context id
* @param curr_log_level log level to be set to context
- * @param cmp_flag compare flag (1 id is apid, 2 id is ctid)
+ * @param cmp_flag compare flag
* @param ecuid ecu id where application runs
* @param verbose If set to true verbose information is printed out
* @return 0 on success, -1 on error
@@ -552,8 +552,8 @@ DltReturnValue dlt_logstorage_update_all_contexts(DltDaemon *daemon,
char tmp_id[DLT_ID_SIZE + 1] = { '\0' };
if ((daemon == NULL) || (daemon_local == NULL) || (id == NULL) ||
- (ecuid == NULL) || (cmp_flag < DLT_DAEMON_LOGSTORAGE_CMP_APID) ||
- (cmp_flag > DLT_DAEMON_LOGSTORAGE_CMP_CTID)) {
+ (ecuid == NULL) || (cmp_flag <= DLT_DAEMON_LOGSTORAGE_CMP_MIN) ||
+ (cmp_flag >= DLT_DAEMON_LOGSTORAGE_CMP_MAX)) {
dlt_vlog(LOG_ERR, "Wrong parameter in function %s\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
@@ -564,10 +564,13 @@ DltReturnValue dlt_logstorage_update_all_contexts(DltDaemon *daemon,
return DLT_RETURN_ERROR;
for (i = 0; i < user_list->num_contexts; i++) {
- if (cmp_flag == 1)
+ if (cmp_flag == DLT_DAEMON_LOGSTORAGE_CMP_APID)
dlt_set_id(tmp_id, user_list->contexts[i].apid);
- else
+ else if (cmp_flag == DLT_DAEMON_LOGSTORAGE_CMP_CTID)
dlt_set_id(tmp_id, user_list->contexts[i].ctid);
+ else
+ /* this is for the case when both apid and ctid are wildcard */
+ dlt_set_id(tmp_id, ".*");
if (strncmp(id, tmp_id, DLT_ID_SIZE) == 0) {
if (curr_log_level > 0)
@@ -705,8 +708,20 @@ DltReturnValue dlt_logstorage_update_context_loglevel(DltDaemon *daemon,
if (ecuid[0] == '\0') /* ECU id was not specified in filter configuration */
dlt_set_id(ecuid, daemon->ecuid);
- /* wildcard for context id, find all contexts of given application id */
- if (strcmp(ctid, ".*") == 0) {
+ /* check wildcard for both apid and ctid first of all */
+ if (strcmp(ctid, ".*") == 0 && strcmp(apid, ".*") == 0) {
+ cmp_flag = DLT_DAEMON_LOGSTORAGE_CMP_ECID;
+
+ if (dlt_logstorage_update_all_contexts(daemon,
+ daemon_local,
+ apid,
+ curr_log_level,
+ cmp_flag,
+ ecuid,
+ verbose) != 0)
+ return DLT_RETURN_ERROR;
+ }
+ else if (strcmp(ctid, ".*") == 0) {
cmp_flag = DLT_DAEMON_LOGSTORAGE_CMP_APID;
if (dlt_logstorage_update_all_contexts(daemon,
@@ -773,7 +788,6 @@ void dlt_daemon_logstorage_reset_application_loglevel(DltDaemon *daemon,
DltLogStorageFilterList **tmp = NULL;
int i = 0;
char key[DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN + 1] = { '\0' };
- int num_device_configured = 0;
unsigned int status;
int log_level = 0;
@@ -793,14 +807,6 @@ void dlt_daemon_logstorage_reset_application_loglevel(DltDaemon *daemon,
(handle->config_status != DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE))
return;
- /* First, check number of devices configured */
- for (i = 0; i < max_device; i++) {
- status = daemon->storage_handle[i].config_status;
-
- if (status == DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE)
- num_device_configured++;
- }
-
/* for all filters (keys) check if application context are already running
* and log level need to be reset*/
tmp = &(handle->config_list);
@@ -814,19 +820,10 @@ void dlt_daemon_logstorage_reset_application_loglevel(DltDaemon *daemon,
+ (i * DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN)),
DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN);
- if (num_device_configured == 1)
- {
- /* Reset context log level and send to application */
- log_level = DLT_DAEMON_LOGSTORAGE_RESET_SEND_LOGLEVEL;
- }
- else
- {
- /**
- * Reset context log level do not send to application as other
- * devices can have same configuration
- * */
- log_level = DLT_DAEMON_LOGSTORAGE_RESET_LOGLEVEL;
- }
+ /* dlt-daemon wants to reset loglevel if
+ * a logstorage device is disconnected.
+ */
+ log_level = DLT_DAEMON_LOGSTORAGE_RESET_LOGLEVEL;
dlt_logstorage_update_context_loglevel(
daemon,
diff --git a/src/daemon/dlt_daemon_offline_logstorage.h b/src/daemon/dlt_daemon_offline_logstorage.h
index 605ada4..956b09d 100644
--- a/src/daemon/dlt_daemon_offline_logstorage.h
+++ b/src/daemon/dlt_daemon_offline_logstorage.h
@@ -58,8 +58,13 @@
#define DLT_DAEMON_LOGSTORAGE_RESET_LOGLEVEL -1
#define DLT_DAEMON_LOGSTORAGE_RESET_SEND_LOGLEVEL 0
-#define DLT_DAEMON_LOGSTORAGE_CMP_APID 1
-#define DLT_DAEMON_LOGSTORAGE_CMP_CTID 2
+typedef enum {
+ DLT_DAEMON_LOGSTORAGE_CMP_MIN = 0,
+ DLT_DAEMON_LOGSTORAGE_CMP_APID = 1,
+ DLT_DAEMON_LOGSTORAGE_CMP_CTID = 2,
+ DLT_DAEMON_LOGSTORAGE_CMP_ECID = 3,
+ DLT_DAEMON_LOGSTORAGE_CMP_MAX,
+} DltCompareFlags;
/**
* dlt_daemon_logstorage_get_loglevel