diff --git a/src/dlt-qnx-system/dlt-qnx-slogger2-adapter.cpp b/src/dlt-qnx-system/dlt-qnx-slogger2-adapter.cpp index 2e5f78e2..a6a7001a 100644 --- a/src/dlt-qnx-system/dlt-qnx-slogger2-adapter.cpp +++ b/src/dlt-qnx-system/dlt-qnx-slogger2-adapter.cpp @@ -141,32 +141,36 @@ static DltContext *dlt_context_from_slog2file(const char *file_name) { } template -static void wait_for_buffer_space(const double max_usage_threshold, +static bool wait_for_buffer_space(const double max_usage_threshold, const std::chrono::duration max_wait_time) { int total_size = 0; int used_size = 0; double used_percent = 100.0; bool timeout = false; + static bool warning_sent = false; + const auto end_time = std::chrono::steady_clock::now() + max_wait_time; do { dlt_user_check_buffer(&total_size, &used_size); used_percent = static_cast(used_size) / total_size; if (used_percent < max_usage_threshold) { + warning_sent=false; break; } dlt_user_log_resend_buffer(); std::this_thread::sleep_for(10ms); - timeout = std::chrono::steady_clock::now() < end_time; + timeout = std::chrono::steady_clock::now() >= end_time; } while (!timeout); - if (timeout) { + if (timeout && !warning_sent) { DLT_LOG(dltQnxSystem, DLT_LOG_ERROR, DLT_STRING("failed to get enough buffer space")); - + warning_sent = true; } + return timeout; } /** @@ -217,7 +221,10 @@ static int sloggerinfo_callback(slog2_packet_info_t *info, void *payload, void * DltContextData log_local; /* Used in DLT_* macros, do not rename */ DltContext *ctxt = dlt_context_from_slog2file(info->file_name); - wait_for_buffer_space(0.8, std::chrono::milliseconds(DLT_QNX_SLOG_ADAPTER_WAIT_BUFFER_TIMEOUT_MS)); + if( wait_for_buffer_space(0.8, std::chrono::milliseconds(DLT_QNX_SLOG_ADAPTER_WAIT_BUFFER_TIMEOUT_MS)) + { + return 0; // discard message + } int ret; ret = dlt_user_log_write_start(ctxt, &log_local, loglevel);