diff options
author | Stefan Vacek <stefan.vacek@intel.com> | 2015-08-31 09:29:07 +0200 |
---|---|---|
committer | Alexander Wenzel <Alexander.AW.Wenzel@bmw.de> | 2015-10-07 10:38:19 +0200 |
commit | 0d330db31f5df337cbb5780a0f6621a7b2cb6396 (patch) | |
tree | 7463ff88ee504cdeaf12f0627c53a05ad2250b70 /src | |
parent | ed412acac8e9f8a5745e55adeed9652b34b9ee4f (diff) | |
download | DLT-daemon-0d330db31f5df337cbb5780a0f6621a7b2cb6396.tar.gz |
Make timeout on exit configurable
- make timeout in at_exit handler configurable (was hardcoded to 10s), new api:
int dlt_set_resend_timeout_atexit(uint32_t timeout_in_milliseconds);
- add option -t to dlt-adaptor-stdin to set timeout in at_exit_handler
- add option -t to dlt-example-user to set timeout in at_exit_handler
Signed-off-by: Stefan Vacek <stefan.vacek@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/adaptor/dlt-adaptor-stdin.c | 19 | ||||
-rw-r--r-- | src/examples/dlt-example-user.c | 20 | ||||
-rw-r--r-- | src/lib/dlt_user.c | 18 |
3 files changed, 48 insertions, 9 deletions
diff --git a/src/adaptor/dlt-adaptor-stdin.c b/src/adaptor/dlt-adaptor-stdin.c index 2ad0ca5..33ab8a2 100644 --- a/src/adaptor/dlt-adaptor-stdin.c +++ b/src/adaptor/dlt-adaptor-stdin.c @@ -90,11 +90,12 @@ int main(int argc, char* argv[]) char apid[DLT_ID_SIZE]; char ctid[DLT_ID_SIZE]; char version[255]; + int timeout = -1; dlt_set_id(apid, PS_DLT_APP); dlt_set_id(ctid, PS_DLT_CONTEXT); - while ((opt = getopt(argc, argv, "a:c:h")) != -1) + while ((opt = getopt(argc, argv, "a:c:ht:")) != -1) { switch (opt) { @@ -108,6 +109,11 @@ int main(int argc, char* argv[]) dlt_set_id(ctid,optarg); break; } + case 't': + { + timeout = atoi(optarg); + break; + } case 'h': { dlt_get_version(version,255); @@ -116,9 +122,10 @@ int main(int argc, char* argv[]) printf("Adaptor for forwarding input from stdin to DLT daemon.\n"); printf("%s \n", version); printf("Options:\n"); - printf("-a apid - Set application id to apid (default: SINA)\n"); - printf("-c ctid - Set context id to ctid (default: SINC)\n"); - printf("-h - This help\n"); + printf(" -a apid - Set application id to apid (default: SINA)\n"); + printf(" -c ctid - Set context id to ctid (default: SINC)\n"); + printf(" -t timeout - Set timeout when sending messages at exit, in ms (Default: 10000 = 10sec)\n"); + printf(" -h - This help\n"); return 0; break; } @@ -132,6 +139,10 @@ int main(int argc, char* argv[]) DLT_REGISTER_APP(apid,PS_DLT_APP_DESC); DLT_REGISTER_CONTEXT(mycontext, ctid, PS_DLT_CONTEXT_DESC); + if (timeout > -1) + { + dlt_set_resend_timeout_atexit(timeout); + } while (fgets(str, MAXSTRLEN, stdin)) { diff --git a/src/examples/dlt-example-user.c b/src/examples/dlt-example-user.c index 61550fc..5822fde 100644 --- a/src/examples/dlt-example-user.c +++ b/src/examples/dlt-example-user.c @@ -102,8 +102,9 @@ void usage() printf(" -k Send marker message\n"); printf(" -m mode Set log mode 0=off,1=external,2=internal,3=both\n"); printf(" -l level Set log level to <level>, level=-1..6\n"); + printf(" -t timeout Set timeout when sending messages at exit, in ms (Default: 10000 = 10sec)\n"); #ifdef DLT_TEST_ENABLE - printf(" -c Corrupt user header\n"); + printf(" -c Corrupt user header\n"); printf(" -s size Corrupt message size\n"); printf(" -z size Size of message\n"); #endif /* DLT_TEST_ENABLE */ @@ -128,6 +129,7 @@ int main(int argc, char* argv[]) char *mvalue = 0; char *message = 0; int lvalue = DLT_LOG_WARN; + char *tvalue = 0; int index; int c; @@ -140,9 +142,9 @@ int main(int argc, char* argv[]) opterr = 0; #ifdef DLT_TEST_ENABLE - while ((c = getopt (argc, argv, "vgakcd:f:n:m:z:s:l:")) != -1) + while ((c = getopt (argc, argv, "vgakcd:f:n:m:z:s:l:t:")) != -1) #else - while ((c = getopt (argc, argv, "vgakd:f:n:m:l:")) != -1) + while ((c = getopt (argc, argv, "vgakd:f:n:m:l:t:")) != -1) #endif /* DLT_TEST_ENABLE */ { switch (c) @@ -204,9 +206,14 @@ int main(int argc, char* argv[]) lvalue = atoi(optarg); break; } + case 't': + { + tvalue = optarg; + break; + } case '?': { - if (optopt == 'd' || optopt == 'f' || optopt == 'n'|| optopt == 'l') + if (optopt == 'd' || optopt == 'f' || optopt == 'n'|| optopt == 'l' || optopt == 't') { fprintf (stderr, "Option -%c requires an argument.\n", optopt); } @@ -306,6 +313,11 @@ int main(int argc, char* argv[]) delay = 500 * 1000; } + if (tvalue) + { + dlt_set_resend_timeout_atexit(atoi(tvalue)); + } + if (gflag) { /* DLT messages to test Fibex non-verbose description: dlt-example-non-verbose.xml */ diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c index f961bb5..2164768 100644 --- a/src/lib/dlt_user.c +++ b/src/lib/dlt_user.c @@ -465,6 +465,8 @@ int dlt_init_common(void) dlt_user.local_print_mode = DLT_PM_UNSET; + dlt_user.timeout_at_exit_handler = DLT_USER_ATEXIT_RESEND_BUFFER_EXIT_TIMEOUT; + env_local_print = getenv(DLT_USER_ENV_LOCAL_PRINT_MODE); if (env_local_print) { @@ -555,7 +557,7 @@ int dlt_user_atexit_blow_out_user_buffer(void){ int count,ret; - uint32_t exitTime = dlt_uptime() + DLT_USER_ATEXIT_RESEND_BUFFER_EXIT_TIMEOUT; + uint32_t exitTime = dlt_uptime() + dlt_user.timeout_at_exit_handler; /* Send content of ringbuffer */ DLT_SEM_LOCK(); @@ -1202,6 +1204,20 @@ int dlt_set_log_mode(DltUserLogMode mode) return dlt_user_log_send_log_mode(mode); } +int dlt_set_resend_timeout_atexit(uint32_t timeout_in_milliseconds) +{ + if (dlt_user_initialised==0) + { + if (dlt_init()<0) + { + return -1; + } + } + dlt_user.timeout_at_exit_handler = timeout_in_milliseconds * 10; + return 0; +} + + int dlt_forward_msg(void *msgdata,size_t size) { DltUserHeader userheader; |