diff options
author | Biastoch, Darian (ADITG/ESM) <dbiastoch@de.adit-jv.com> | 2021-07-16 00:29:10 +0000 |
---|---|---|
committer | Saya Sugiura <39760799+ssugiura@users.noreply.github.com> | 2021-10-05 11:19:26 +0900 |
commit | 50a385e6afea50922569828438194477537a768b (patch) | |
tree | 120995ed2095145b31caf2958ddd259ced88786d /src/system/dlt-system-logfile.c | |
parent | 0ee7fdff3d6bb2f2055e7083fa48728f4d274661 (diff) | |
download | DLT-daemon-50a385e6afea50922569828438194477537a768b.tar.gz |
system: use signalfd for dlt-system
1: Move the call of pthread_sigmask in dlt-qnx-systems main before DLT_REGISTER_APP, because this already spawns a thread, what was done without applying pthread_sigmask before.
2: Replaced all threads in dlt-system, that are spawned for each feature, through one poll. This poll waits for a file descriptor event, that triggers the feature routine, that was executed before in the thread. Done this for following processes:
* reading syslog and journal
* frequently reading logfile and logprocess
* triggering filetransfer, if a file was added/changed in watched directory
* checking watchdog timer of systemd service file with defined intervall
Signed-off-by: dbiastoch <dbiastoch@de.adit-jv.com>
Diffstat (limited to 'src/system/dlt-system-logfile.c')
-rw-r--r-- | src/system/dlt-system-logfile.c | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/src/system/dlt-system-logfile.c b/src/system/dlt-system-logfile.c index 6466172..5e916d4 100644 --- a/src/system/dlt-system-logfile.c +++ b/src/system/dlt-system-logfile.c @@ -44,7 +44,6 @@ *******************************************************************************/ -#include <pthread.h> #include <unistd.h> #include "dlt-system.h" @@ -55,8 +54,8 @@ DLT_IMPORT_CONTEXT(dltsystem) -extern DltSystemThreads threads; DltContext logfileContext[DLT_SYSTEM_LOG_FILE_MAX]; +int logfile_delays[DLT_SYSTEM_LOG_FILE_MAX]; void send_file(LogFileOptions const *fileopt, int n) { @@ -108,7 +107,7 @@ void register_contexts(LogFileOptions const *fileopts) (*fileopts).Filename[i]); } -void logfile_thread(void *v_conf) +void logfile_init(void *v_conf) { DLT_LOG(dltsystem, DLT_LOG_DEBUG, DLT_STRING("dlt-system-logfile, in thread.")); @@ -116,29 +115,26 @@ void logfile_thread(void *v_conf) register_contexts(&(conf->LogFile)); - int logfile_delays[DLT_SYSTEM_LOG_FILE_MAX]; - int i; - - for (i = 0; i < conf->LogFile.Count; i++) + for (int i = 0; i < conf->LogFile.Count; i++) logfile_delays[i] = conf->LogFile.TimeDelay[i]; +} - while (!threads.shutdown) { - sleep(1); - - for (i = 0; i < conf->LogFile.Count; i++) { - if (conf->LogFile.Mode[i] == SEND_MODE_OFF) - continue; +void logfile_fd_handler(void *v_conf) +{ + DltSystemConfiguration *conf = (DltSystemConfiguration *)v_conf; + for (int i = 0; i < conf->LogFile.Count; i++) { + if (conf->LogFile.Mode[i] == SEND_MODE_OFF) + continue; - if (logfile_delays[i] <= 0) { - send_file(&(conf->LogFile), i); - logfile_delays[i] = conf->LogFile.TimeDelay[i]; + if (logfile_delays[i] <= 0) { + send_file(&(conf->LogFile), i); + logfile_delays[i] = conf->LogFile.TimeDelay[i]; - if (conf->LogFile.Mode[i] == SEND_MODE_ONCE) - conf->LogFile.Mode[i] = SEND_MODE_OFF; - } - else { - logfile_delays[i]--; - } + if (conf->LogFile.Mode[i] == SEND_MODE_ONCE) + conf->LogFile.Mode[i] = SEND_MODE_OFF; + } + else { + logfile_delays[i]--; } } } |