diff --git a/docs/dev/debugging.md b/docs/dev/debugging.md new file mode 100644 index 0000000..ca648c5 --- /dev/null +++ b/docs/dev/debugging.md @@ -0,0 +1,90 @@ +# Troubleshooting Travis CI builds locally in a Docker image + +This document describes how to run a Travis CI build locally using docker. + +Most of the information is available in the Getting Started guide under +[Common Build Problems](https://docs.travis-ci.com/user/common-build-problems/#running-a-container-based-docker-image-locally), +but this guide is specifically tailored towards building Cyclone. + +> Ensure [Docker](https://www.docker.com/) is installed, the daemon is running +> and you have the required privileges. + +> See this [entry](https://developer.fedoraproject.org/tools/docker/about.html) +> on the Fedora Developer Portal for setting up and using Docker on Fedora. + +> The *instance:* line under *Worker information* in the *Job log* will show +> exactly which instance of the *ci-garnet* image is used, but the latest image +> will do just fine. + +``` +Worker information +... +instance: travis-job-70cf1506-780a-445e-8f0d-da928d16ed65 travis-ci-garnet-trusty-1512502259-986baf0 (via amqp) +... +``` + +1. Start a Docker container detached with `/sbin/init`. + + ``` +$ docker run --name travis-debug --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -dit travisci/ci-garnet:packer-1515445631-7dfb2e1 /sbin/init +``` + + > The image is quite large (4 GB) and it will take some time to download. + +2. Open a login shell in the running container. + + ``` +$ docker exec -it travis-debug bash -l +``` + +3. Install all packages required to build Cyclone. + + ``` +$ add-apt-repository ppa:ubuntu-toolchain-r/test +$ echo "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-6.0 main" >> /etc/apt/sources.list.d/llvm-toolchain-6.0.list +$ wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - +$ apt-get update +$ apt-get install gcc-8 g++-8 clang-6.0 oracle-java8-set-default maven +``` + +4. Switch to the *travis* user. + + ``` +su - travis +``` + +5. Install The [Conan C/C++ Package Manager](https://conan.io). + + ``` +$ pip intall conan --upgrade --user +$ conan user +``` + +6. Add the required repositories. + + ``` +$ conan remote add atolab https://api.bintray.com/conan/atolab/public-conan +$ conan remote add bincrafters https://api.bintray.com/conan/bincrafters/public-conan +``` + +7. Clone the git repository. + + ``` +$ git clone https://github.com/eclipse-cyclonedds/cyclonedds.git +``` + +8. Build the project and run the tests. + + > By default CMake and Conan will choose *gcc*. To switch to *clang*, set the + > CC and CXX environment variables to clang and clang++ respectively. + + ``` +$ export CC=gcc-8 +$ export CXX=g++-8 +$ cd cyclonedds +$ mkdir build +$ conan install .. +$ cmake -DBUILD_TESTING=on ../src +$ cmake --build . +$ ctest -T test +``` diff --git a/docs/dev/logging.md b/docs/dev/logging.md new file mode 100644 index 0000000..c8c1b2d --- /dev/null +++ b/docs/dev/logging.md @@ -0,0 +1,194 @@ +# Logging and tracing in Cyclone DDS +A lot of effort has gone into providing as much useful information as possible +when a log message is written and a fair number of mechanisms were put in +place to be able to do so. + +The difficulty with logging in Cyclone DDS is the fact that it is both used by +user applications and internal services alike. Both use-cases have different +needs with regard to logging. e.g. a service may just want to write all +information to a log file, whereas a user application may want to display the +message in a graphical user interface or reformat it and write it to stdout. + +> This document does not concern itself with error handling, return codes, +> etc. Only logging and tracing are covered. + + +## Design +The logging and tracing api offered by Cyclone DDS is a merger of the reporting +functionality that existed in the various modules that Cyclone is made out of. +Why the API needed to change is documented in the section +[Issues with previous implementation]. + +The new and improved logging mechanism in Cyclone DDS allows the user to simply +register a callback function, as is customary for libraries, that matches the +signature `dds_log_write_fn_t`. The callback can be registered by passing it +to `dds_set_log_sink` or `dds_set_trace_sink`. The functions also allow for +registering a `void *` that will be passed along on every invocation of the +the callback. To unregister a log or trace sink, call the respective function +and pass NULL for the callback. This will cause Cyclone DDS to reinstate the +default handler. aka stdout, stderr, or the file specified in the configuration +file. + +```C +typedef void(*dds_log_write_fn_t)(dds_log_data_t *, void *); + +struct dds_log_data { + uint32_t priority; + const char *file; + uint32_t line; + const char *function; + const char *message; +}; + +typedef struct dds_log_data dds_log_data_t; + +dds_return_t dds_set_log_sink(dds_log_write_fn_t *, const void *); +dds_return_t dds_set_trace_sink(dds_log_write_fn_t *, const void *); +``` + +> Cyclone DDS offers both a logging and a tracing callback to allow the user to +> easily send traces to a different device than the log messages. The trace +> function receives both the log messages and trace messages, while the log +> function will only receive the log messages. + +> The user is responsible for managing resources himself. Cyclone DDS will not +> attempt to free *userdata* under any circumstance. The user should revert to +> the default handler, or register a different sink before invalidating the +> userdata pointer. + +> The *dds_set_log_sink* and *dds_set_trace_sink* functions are synchronous. +> It is guaranteed that on return no thread in the Cyclone DDS stack will +> reference the sink or the *userdata*. + +To minimize the amount of information that is outputted when tracing is +enabled, the user can enable/disable tracing per category. Actually the +priority member that is passed to the handler consists of the priority, +e.g. error, info, etc and (if it's a trace message) the category. + +To be specific. The last four bits of the 32-bit integer contain the priority. +The other bits implicity indicate it's a trace message and are reserved to +specify the category to which a message belongs. + +```C +#define DDS_LC_FATAL 1u +#define DDS_LC_ERROR 2u +#define DDS_LC_WARNING 4u +#define DDS_LC_INFO 8u +#define DDS_LC_CONFIG 16u +... +``` + +> DDSI is the Cyclone DDS module that the log and trace mechanism originated +> from. For that reason not all categories make sense to use in API code and +> some categories that you would expect may be missing. For now the categories +> are a work-in-progress and may be changed without prior notice. + +To control which messages are passed to the registered sinks, the user +must call `dds_set_log_mask` or `dds_set_trace_mask`. Whether or not to call +the internal log and trace functions depends on it. The user is strongly +discouraged to enable all categories and filter messages in the registered +handler, because of the performance impact! + +> Tests have shown performance to decrease by roughly 5% if the descision on +> whether or not to write the message is done outside the function. The reason +> obviously not being the *if*-statement, but the creation of the stack frame. + +For developer convenience, a couple of macro's are be introduced so the +developer does not have to write boilerplate code each time. The +implementation will roughly follow what is specified below. + +```C +#define DDS_FATAL(fmt, ...) +#define DDS_ERROR(fmt, ...) +#define DDS_INFO(fmt, ...) +#define DDS_WARNING(fmt, ...) +#define DDS_TRACE(cat, fmt, ...) +``` + +> Log and trace messages are finalized by a newline. If a newline is not +> present, the buffer is not flushed. This is can be used to extend messages, +> e.g. to easily append summaries and decisions, and already used throughout +> the ddsi module. The newline is replaced by a null character when the +> message is passed to a sink. + +### Default handlers and behavior + +If the user does not register a sink, messages are printed to the default +location. Usually this means a cyclonedds.log file created in the working +directory, but the location can be changed in the configuration file. By +default only error and warning messages will be printed. + +> As long as no file is open (or e.g. a syslog connection is established), +> messages are printed to stderr. + +For convenience a number of log handlers will ship with Cyclone. Initially +the set will consist of a handler that prints to stdout/stderr and one that +prints to a file. However, at some point it would be nice to ship handlers +that can print to the native log api offered by a target. e.g. + + * Windows Event Log on Microsoft Windows + * Syslog on Linux + * Unified Logging on macOS + * logMsg or the ED&R (Error Detection and Reporting) subsystem on VxWorks + +> For now it is unclear what configuration options are available for all the +> default handlers or how the API to update them will look exactly. + +## Log message guidelines +* Write concise reports. + * Do not leave out information, but also don't turn it into an essay. + e.g. a message for a failed write operation could include topic and + partition names to indicate the affected system scope. +* Write consistent reports. + * Use the name of the parameter as it appears in the documentation for that + language binding to reference a parameter where applicable. + * Use the same formatting style as other messages in the same module. + * e.g. use "could not ..." or "failed to ..." consitently. + * Avoid duplicate reports as much as possible. + e.g. if a problem is reported in a lower layer, do not report it again when + the error is propagated. + * Discuss with one of the team members if you must deviate from the + formatting rules/guidelines and update this page if applicable. +* Report only meaningful events. + + +## Issues with previous implementation +* Multiple files are opened. DDSI, by default, writes to cyclonedds-trace.log, + but also contains info, warning and error log messages written by DDSI + itself. All other modules write to cyclone-info.log and cyclone-error.log. + Options are available, but they're all over the place. Some are adjusted by + setting certain environment variables, others are configured by modifying the + configuration file. Not exactly what you'd call user friendly. Also, simply + writing a bunch of files from a library is not considered good practice. + +* Cyclone only offers writing to a *FILE* handle. The filenames mentioned + above by default, but a combination of stdout/stderr can also be used. There + is no easy way to display them in a GUI or redirect them to a logging API. + e.g. syslog on Linux or the Windows Event Log on Microsoft Windows. + +* The report stack is a cumbersome mechanism to use and (to a certain extend) + error prone. Every function (at least every function in the "public" APIs) + must start with a report stack instruction and end with a report flush + instruction. + +* Cyclone assumes files can always be written. For a number of supported + targets, e.g. FreeRTOS and VxWorks, this is often not the case. Also, + filling the memory with log files is proably undesirable. + +* Cyclone (except for DDSI) does not support log categories to selectively + enable/disable messages that the user is interested in. Causing trace logs + to contain (possibly) too much information. + +* The report mechanism expects an error code, but it's unclear what "type" of + code it is. It can be a valid errno value, os_result, utility result, DDS + return code, etc. While the problem can be fixed by adding a module field to + the log message struct. The message is often generated in the layer above + the layer that the error originated from. Apart from that, the report + callback is not the place to handle errors gracefully. Return codes and + exceptions are the mechanism to do that. + +* The logging API is different across modules. DDSI uses the nn_log macro + family, the abstraction layer uses the OS_REPORT family and DDS uses the + dds_report family. Apart from the macros used, the information that would + end up in the report callback is also different. + diff --git a/src/cmake/modules/CUnit.cmake b/src/cmake/modules/CUnit.cmake index 85dbee2..7c5364c 100644 --- a/src/cmake/modules/CUnit.cmake +++ b/src/cmake/modules/CUnit.cmake @@ -69,7 +69,7 @@ function(process_cunit_source_file SOURCE_FILE HEADER_FILE SUITES TESTS) # - fini # - disabled # - timeout - set(data_expr "(${s}*,${s}*\\.${w}+${s}*=[^,]+)*") + set(data_expr "(${s}*,${s}*\\.${w}+${s}*=[^,\\)]+)*") set(suites_wo_init_n_clean) set(suites_w_init) diff --git a/src/core/ddsc/.fileids b/src/core/ddsc/.fileids index 89472e2..f24df98 100644 --- a/src/core/ddsc/.fileids +++ b/src/core/ddsc/.fileids @@ -28,7 +28,6 @@ 66 src/dds_readcond.c 67 src/dds_subscriber.c 68 src/dds_write.c -69 src/dds_report.c 70 src/dds_builtin.c 72 src/dds_guardcond.c 73 src/dds_whc.c diff --git a/src/core/ddsc/CMakeLists.txt b/src/core/ddsc/CMakeLists.txt index d895ce3..b29de10 100644 --- a/src/core/ddsc/CMakeLists.txt +++ b/src/core/ddsc/CMakeLists.txt @@ -29,13 +29,11 @@ PREPEND(srcs_ddsc "${CMAKE_CURRENT_LIST_DIR}/src" dds_key.c dds_querycond.c dds_topic.c - dds_report.c dds_err.c dds_listener.c dds_read.c dds_stream.c dds_waitset.c - dds_log.c dds_readcond.c dds_guardcond.c dds_subscriber.c @@ -48,7 +46,6 @@ PREPEND(hdrs_public_ddsc "$ 0) int32_t dds_entity_t; #include "ddsc/dds_public_error.h" #include "ddsc/dds_public_status.h" #include "ddsc/dds_public_listener.h" -#include "ddsc/dds_public_log.h" #include "dds_dcps_builtintopics.h" #if defined (__cplusplus) diff --git a/src/core/ddsc/include/ddsc/dds_public_log.h b/src/core/ddsc/include/ddsc/dds_public_log.h deleted file mode 100644 index 4556cdf..0000000 --- a/src/core/ddsc/include/ddsc/dds_public_log.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright(c) 2006 to 2018 ADLINK Technology Limited and others - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License - * v. 1.0 which is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause - */ -/* TODO: do we really need to expose this as an API? */ - -/** @file - * - * @brief DDS C Logging API - * - * This header file defines the public API for logging in the - * CycloneDDS C language binding. - */ -#ifndef DDS_LOG_H -#define DDS_LOG_H - -#include "os/os_public.h" -#include "ddsc/dds_export.h" - -#if defined (__cplusplus) -extern "C" { -#endif - -DDS_EXPORT void dds_log_info (const char * fmt, ...); -DDS_EXPORT void dds_log_warn (const char * fmt, ...); -DDS_EXPORT void dds_log_error (const char * fmt, ...); -DDS_EXPORT void dds_log_fatal (const char * fmt, ...); - -#if defined (__cplusplus) -} -#endif -#endif diff --git a/src/core/ddsc/src/dds__err.h b/src/core/ddsc/src/dds__err.h index 0e65a16..2bf976a 100644 --- a/src/core/ddsc/src/dds__err.h +++ b/src/core/ddsc/src/dds__err.h @@ -31,9 +31,8 @@ extern "C" { #define DDS__FILE_ID__ (((__FILE_ID__ & 0x1ff)) << 22) #define DDS__LINE__ ((__LINE__ & 0x3fff) << 8) -#define DDS_ERR_NO(err) -(DDS__FILE_ID__ + DDS__LINE__ + (err)) - -#define DDS_ERRNO(e,msg,...) (assert(e > DDS_RETCODE_OK), os_report(OS_REPORT_ERROR, OS_FUNCTION, __FILE__, __LINE__, DDS_ERR_NO(e), (msg), ##__VA_ARGS__), DDS_ERR_NO(e)) +#define DDS_ERRNO(err) \ + (assert(err > DDS_RETCODE_OK), -(DDS__FILE_ID__ + DDS__LINE__ + (err))) #if defined (__cplusplus) } diff --git a/src/core/ddsc/src/dds__report.h b/src/core/ddsc/src/dds__report.h deleted file mode 100644 index ced10af..0000000 --- a/src/core/ddsc/src/dds__report.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright(c) 2006 to 2018 ADLINK Technology Limited and others - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License - * v. 1.0 which is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause - */ -#ifndef DDS_REPORT_H -#define DDS_REPORT_H - -#include -#include "os/os_report.h" - -#define DDS_REPORT_STACK() \ - os_report_stack () - -#define DDS_CRITICAL(...) \ - dds_report ( \ - OS_REPORT_CRITICAL, \ - __FILE__, \ - __LINE__, \ - OS_FUNCTION, \ - DDS_RETCODE_ERROR, \ - __VA_ARGS__) - -#define DDS_ERROR(code,...) \ - dds_report ( \ - OS_REPORT_ERROR, \ - __FILE__, \ - __LINE__, \ - OS_FUNCTION, \ - (code), \ - __VA_ARGS__) - -#define DDS_INFO(...) \ - dds_report ( \ - OS_REPORT_INFO, \ - __FILE__, \ - __LINE__, \ - OS_FUNCTION, \ - DDS_RETCODE_OK, \ - __VA_ARGS__) - -#define DDS_WARNING(code,...) \ - dds_report ( \ - OS_REPORT_WARNING, \ - __FILE__, \ - __LINE__, \ - OS_FUNCTION, \ - (code), \ - __VA_ARGS__) - -#define DDS_REPORT(type, code,...) \ - dds_report ( \ - type, \ - __FILE__, \ - __LINE__, \ - OS_FUNCTION, \ - (code), \ - __VA_ARGS__) - -#define DDS_REPORT_FLUSH OS_REPORT_FLUSH - -void -dds_report( - os_reportType reportType, - const char *file, - int32_t line, - const char *function, - dds_return_t code, - const char *format, - ...); - -#endif diff --git a/src/core/ddsc/src/dds_alloc.c b/src/core/ddsc/src/dds_alloc.c index d3c566b..049d9aa 100644 --- a/src/core/ddsc/src/dds_alloc.c +++ b/src/core/ddsc/src/dds_alloc.c @@ -103,7 +103,7 @@ void dds_sample_free_contents (char * data, const uint32_t * ops) { type = DDS_OP_TYPE (op); #ifdef OP_DEBUG_FREE - TRACE (("F-ADR: %s offset %d\n", stream_op_type[type], ops[1])); + DDS_TRACE("F-ADR: %s offset %d\n", stream_op_type[type], ops[1]); #endif addr = data + ops[1]; ops += 2; @@ -119,7 +119,7 @@ void dds_sample_free_contents (char * data, const uint32_t * ops) case DDS_OP_VAL_STR: { #ifdef OP_DEBUG_FREE - TRACE (("F-STR: @ %p %s\n", addr, *((char**) addr))); + DDS_TRACE("F-STR: @ %p %s\n", addr, *((char**) addr)); #endif dds_free (*((char**) addr)); *((char**) addr) = NULL; @@ -132,7 +132,7 @@ void dds_sample_free_contents (char * data, const uint32_t * ops) num = (seq->_maximum > seq->_length) ? seq->_maximum : seq->_length; #ifdef OP_DEBUG_FREE - TRACE (("F-SEQ: of %s\n", stream_op_type[subtype])); + DDS_TRACE("F-SEQ: of %s\n", stream_op_type[subtype]); #endif if ((seq->_release && num) || (subtype > DDS_OP_VAL_STR)) { @@ -189,7 +189,7 @@ void dds_sample_free_contents (char * data, const uint32_t * ops) num = *ops++; #ifdef OP_DEBUG_FREE - TRACE (("F-ARR: of %s size %d\n", stream_op_type[subtype], num)); + DDS_TRACE("F-ARR: of %s size %d\n", stream_op_type[subtype], num); #endif switch (subtype) { @@ -242,7 +242,7 @@ void dds_sample_free_contents (char * data, const uint32_t * ops) assert (subtype <= DDS_OP_VAL_4BY); #ifdef OP_DEBUG_FREE - TRACE (("F-UNI: switch %s cases %d\n", stream_op_type[subtype], num)); + DDS_TRACE("F-UNI: switch %s cases %d\n", stream_op_type[subtype], num); #endif /* Get discriminant */ @@ -320,7 +320,7 @@ void dds_sample_free_contents (char * data, const uint32_t * ops) case DDS_OP_JSR: /* Implies nested type */ { #ifdef OP_DEBUG_FREE - TRACE (("F-JSR: %d\n", DDS_OP_JUMP (op))); + DDS_TRACE("F-JSR: %d\n", DDS_OP_JUMP (op)); #endif dds_sample_free_contents (data, ops + DDS_OP_JUMP (op)); ops++; @@ -330,7 +330,7 @@ void dds_sample_free_contents (char * data, const uint32_t * ops) } } #ifdef OP_DEBUG_FREE - TRACE (("F-RTS:\n")); + DDS_TRACE("F-RTS:\n"); #endif } diff --git a/src/core/ddsc/src/dds_builtin.c b/src/core/ddsc/src/dds_builtin.c index 15cfcf0..a93dabc 100644 --- a/src/core/ddsc/src/dds_builtin.c +++ b/src/core/ddsc/src/dds_builtin.c @@ -21,7 +21,6 @@ #include "dds__participant.h" #include "dds__err.h" #include "dds__types.h" -#include "dds__report.h" #include "dds__builtin.h" #include "dds__subscriber.h" @@ -125,7 +124,8 @@ dds__create_builtin_participant( } if (q_rc != 0) { - participant = DDS_ERRNO(DDS_RETCODE_ERROR, "Internal builtin error"); + DDS_ERROR("Internal builtin error\n"); + participant = DDS_ERRNO(DDS_RETCODE_ERROR); goto fail; } @@ -311,7 +311,8 @@ dds__get_builtin_topic( desc = &DDS_CMDataReaderBuiltinTopicData_desc; name = "CMDataReader"; } else { - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Invalid builtin-topic handle(%d)", topic); + DDS_ERROR("Invalid builtin-topic handle(%d)\n", topic); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); goto err_invalid_topic; } @@ -319,10 +320,6 @@ dds__get_builtin_topic( if (ret < 0 && dds_err_nr(ret) == DDS_RETCODE_PRECONDITION_NOT_MET) { dds_qos_t *tqos; - /* drop the precondition-no-met error */ - DDS_REPORT_FLUSH(0); - DDS_REPORT_STACK(); - tqos = dds_create_qos(); dds_qset_durability(tqos, DDS_DURABILITY_TRANSIENT_LOCAL); dds_qset_presentation(tqos, DDS_PRESENTATION_TOPIC, false, false); @@ -358,7 +355,8 @@ dds__get_builtin_writer( } os_mutexUnlock(&g_builtin_mutex); } else { - wr = DDS_ERRNO(DDS_RETCODE_ERROR, "Given topic is not a builtin topic."); + DDS_ERROR("Given topic is not a builtin topic\n"); + wr = DDS_ERRNO(DDS_RETCODE_ERROR); } return wr; } @@ -420,10 +418,7 @@ forward_builtin_participant( _In_ nn_wctime_t timestamp, _In_ int alive) { - dds_return_t ret; - DDS_REPORT_STACK(); - ret = dds__builtin_write(DDS_BUILTIN_TOPIC_DCPSPARTICIPANT, data, timestamp.v, alive); - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); + dds__builtin_write(DDS_BUILTIN_TOPIC_DCPSPARTICIPANT, data, timestamp.v, alive); } void @@ -432,8 +427,5 @@ forward_builtin_cmparticipant( _In_ nn_wctime_t timestamp, _In_ int alive) { - dds_return_t ret; - DDS_REPORT_STACK(); - ret = dds__builtin_write(DDS_BUILTIN_TOPIC_CMPARTICIPANT, data, timestamp.v, alive); - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); + dds__builtin_write(DDS_BUILTIN_TOPIC_CMPARTICIPANT, data, timestamp.v, alive); } diff --git a/src/core/ddsc/src/dds_coherent.c b/src/core/ddsc/src/dds_coherent.c index 9fbd81f..bf6832d 100644 --- a/src/core/ddsc/src/dds_coherent.c +++ b/src/core/ddsc/src/dds_coherent.c @@ -16,7 +16,6 @@ #include "dds__subscriber.h" #include "dds__publisher.h" #include "dds__err.h" -#include "dds__report.h" _Pre_satisfies_(((entity & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) || \ ((entity & DDS_ENTITY_KIND_MASK) == DDS_KIND_SUBSCRIBER) || \ @@ -42,7 +41,8 @@ dds_begin_coherent( ret = dds_subscriber_begin_coherent(entity); break; default: - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Given entity can not control coherency"); + DDS_ERROR("Given entity can not control coherency\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); break; } return ret; @@ -72,7 +72,8 @@ dds_end_coherent( ret = dds_subscriber_end_coherent(entity); break; default: - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Given entity can not control coherency"); + DDS_ERROR("Given entity can not control coherency\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); break; } return ret; diff --git a/src/core/ddsc/src/dds_entity.c b/src/core/ddsc/src/dds_entity.c index 2bd17ec..a55d59c 100644 --- a/src/core/ddsc/src/dds_entity.c +++ b/src/core/ddsc/src/dds_entity.c @@ -17,8 +17,6 @@ #include "dds__reader.h" #include "dds__listener.h" #include "dds__err.h" -#include "os/os_report.h" -#include "dds__report.h" #include "ddsc/ddsc_project.h" /* Sanity check. */ @@ -272,11 +270,14 @@ dds_entity_init( assert(e->m_hdllink); } else{ if (e->m_hdl == UT_HANDLE_OUT_OF_RESOURCES) { - e->m_hdl = DDS_ERRNO(DDS_RETCODE_OUT_OF_RESOURCES, "Can not create new entity; too many where created previously."); + DDS_ERROR("Can not create new entity; too many where created previously\n"); + e->m_hdl = DDS_ERRNO(DDS_RETCODE_OUT_OF_RESOURCES); } else if (e->m_hdl == UT_HANDLE_NOT_INITALIZED) { - e->m_hdl = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET, DDSC_PROJECT_NAME" is not yet initialized. Please create a participant before executing an other method."); + DDS_ERROR(DDSC_PROJECT_NAME" is not yet initialized. Please create a participant before executing an other method\n"); + e->m_hdl = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET); } else { - e->m_hdl = DDS_ERRNO(DDS_RETCODE_ERROR, "An internal error has occurred."); + DDS_ERROR("An internal error has occurred\n"); + e->m_hdl = DDS_ERRNO(DDS_RETCODE_ERROR); } } @@ -291,9 +292,9 @@ dds_delete( _In_ dds_entity_t entity) { dds_return_t ret; - DDS_REPORT_STACK(); + ret = dds_delete_impl(entity, false); - DDS_REPORT_FLUSH(ret < 0); + return ret; } @@ -315,7 +316,8 @@ dds_delete_impl( rc = dds_entity_lock(entity, UT_HANDLE_DONTCARE_KIND, &e); if (rc != DDS_RETCODE_OK) { - return DDS_ERRNO(rc, "Error on locking entity"); + DDS_ERROR("Error on locking entity\n"); + return DDS_ERRNO(rc); } if(keep_if_explicit == true && ((e->m_flags & DDS_ENTITY_IMPLICIT) == 0)){ @@ -397,7 +399,8 @@ dds_delete_impl( * is released. It is possible that this last release will be done by a thread * that was kicked during the close(). */ if (ut_handle_delete(e->m_hdl, e->m_hdllink, timeout) != UT_HANDLE_OK) { - return DDS_ERRNO(DDS_RETCODE_TIMEOUT, "Entity deletion did not release resources."); + DDS_ERROR("Entity deletion did not release resources\n"); + return DDS_ERRNO(DDS_RETCODE_TIMEOUT); } } @@ -454,8 +457,6 @@ dds_get_parent( dds_entity_t hdl; dds_entity *parent; - DDS_REPORT_STACK(); - rc = dds_entity_lock(entity, DDS_KIND_DONTCARE, &e); if (rc == DDS_RETCODE_OK) { if ((parent = dds__nonself_parent(e)) != NULL) { @@ -466,9 +467,10 @@ dds_get_parent( } dds_entity_unlock(e); } else { - hdl = DDS_ERRNO(rc, "Error on locking handle entity"); + DDS_ERROR("Error on locking handle entity\n"); + hdl = DDS_ERRNO(rc); } - DDS_REPORT_FLUSH(hdl <= 0); + return hdl; } @@ -483,17 +485,16 @@ dds_get_participant ( dds__retcode_t rc; dds_entity_t hdl; - DDS_REPORT_STACK(); - rc = dds_entity_lock(entity, DDS_KIND_DONTCARE, &e); if (rc == DDS_RETCODE_OK) { assert(e->m_participant); hdl = e->m_participant->m_hdl; dds_entity_unlock(e); } else { - hdl = DDS_ERRNO(rc, "Error on locking handle entity"); + DDS_ERROR("Error on locking handle entity\n"); + hdl = DDS_ERRNO(rc); } - DDS_REPORT_FLUSH( hdl <= 0); + return hdl; } @@ -511,21 +512,22 @@ dds_get_children( dds_return_t ret; dds_entity* iter; - DDS_REPORT_STACK(); - if ((children != NULL) && ((size <= 0) || (size >= INT32_MAX))) { - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Array is given, but with invalid size"); + DDS_ERROR("Array is given, but with invalid size\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); goto err; } if ((children == NULL) && (size != 0)) { - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Size is given, but no array"); + DDS_ERROR("Size is given, but no array\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); goto err; } rc = dds_entity_lock(entity, DDS_KIND_DONTCARE, &e); if (rc != DDS_RETCODE_OK) { - ret = DDS_ERRNO(rc, "Error occurred on locking entity"); + DDS_ERROR("Error occurred on locking entity\n"); + ret = DDS_ERRNO(rc); goto err; } /* Initialize first child to satisfy SAL. */ @@ -545,7 +547,6 @@ dds_get_children( dds_entity_unlock(e); err: - DDS_REPORT_FLUSH(ret < 0); return ret; } @@ -561,26 +562,26 @@ dds_get_qos( dds__retcode_t rc; dds_return_t ret = DDS_RETCODE_OK; - DDS_REPORT_STACK(); - if (qos == NULL) { - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER,"Argument qos is NULL"); + DDS_ERROR("Argument qos is NULL\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); goto fail; } rc = dds_entity_lock(entity, DDS_KIND_DONTCARE, &e); if (rc != DDS_RETCODE_OK) { - ret = DDS_ERRNO(rc, "Error occurred on locking entity"); + DDS_ERROR("Error occurred on locking entity\n"); + ret = DDS_ERRNO(rc); goto fail; } if (e->m_deriver.set_qos) { rc = dds_copy_qos(qos, e->m_qos); } else { rc = DDS_RETCODE_ILLEGAL_OPERATION; - ret = DDS_ERRNO(rc, "QoS cannot be set on this entity"); + DDS_ERROR("QoS cannot be set on this entity\n"); + ret = DDS_ERRNO(rc); } dds_entity_unlock(e); fail: - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK ); return ret; } @@ -596,15 +597,14 @@ dds_set_qos( dds__retcode_t rc; dds_return_t ret; - DDS_REPORT_STACK(); - if (qos != NULL) { rc = dds_entity_lock(entity, DDS_KIND_DONTCARE, &e); if (rc == DDS_RETCODE_OK) { if (e->m_deriver.set_qos) { ret = e->m_deriver.set_qos(e, qos, e->m_flags & DDS_ENTITY_ENABLED); } else { - ret = DDS_ERRNO(DDS_RETCODE_ILLEGAL_OPERATION, "QoS cannot be set on this entity"); + DDS_ERROR("QoS cannot be set on this entity\n"); + ret = DDS_ERRNO(DDS_RETCODE_ILLEGAL_OPERATION); } if (ret == DDS_RETCODE_OK) { /* Remember this QoS. */ @@ -612,16 +612,19 @@ dds_set_qos( e->m_qos = dds_create_qos(); } rc = dds_copy_qos(e->m_qos, qos); - ret = DDS_ERRNO(rc, "QoS cannot be set on this entity"); + DDS_ERROR("QoS cannot be set on this entity\n"); + ret = DDS_ERRNO(rc); } dds_entity_unlock(e); } else { - ret = DDS_ERRNO(rc, "Error occurred on locking entity"); + DDS_ERROR("Error occurred on locking entity\n"); + ret = DDS_ERRNO(rc); } } else { - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL"); + DDS_ERROR("Argument QoS is NULL\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); } - DDS_REPORT_FLUSH( ret != DDS_RETCODE_OK); + return ret; } @@ -637,8 +640,6 @@ dds_get_listener( dds_return_t ret = DDS_RETCODE_OK; dds__retcode_t rc; - DDS_REPORT_STACK(); - if (listener != NULL) { rc = dds_entity_lock(entity, DDS_KIND_DONTCARE, &e); if (rc == DDS_RETCODE_OK) { @@ -646,12 +647,14 @@ dds_get_listener( dds_copy_listener (listener, &e->m_listener); dds_entity_unlock(e); } else { - ret = DDS_ERRNO(rc, "Error occurred on locking entity"); + DDS_ERROR("Error occurred on locking entity\n"); + ret = DDS_ERRNO(rc); } } else { - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL"); + DDS_ERROR("Argument listener is NULL\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); } - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK ); + return ret; } @@ -667,11 +670,10 @@ dds_set_listener( dds__retcode_t rc; dds_return_t ret = DDS_RETCODE_OK; - DDS_REPORT_STACK(); - rc = dds_entity_lock(entity, DDS_KIND_DONTCARE, &e); if(rc != DDS_RETCODE_OK){ - ret = DDS_ERRNO(rc, "Error occurred on locking entity"); + DDS_ERROR("Error occurred on locking entity\n"); + ret = DDS_ERRNO(rc); goto fail; } dds_entity_cb_wait(e); @@ -682,7 +684,6 @@ dds_set_listener( } dds_entity_unlock(e); fail: - DDS_REPORT_FLUSH( ret != DDS_RETCODE_OK); return ret; } @@ -697,20 +698,19 @@ dds_enable( dds__retcode_t rc; dds_return_t ret = DDS_RETCODE_OK; - DDS_REPORT_STACK(); - rc = dds_entity_lock(entity, DDS_KIND_DONTCARE, &e); if (rc == DDS_RETCODE_OK) { if ((e->m_flags & DDS_ENTITY_ENABLED) == 0) { /* TODO: CHAM-96: Really enable. */ e->m_flags |= DDS_ENTITY_ENABLED; - DDS_ERROR(DDS_RETCODE_UNSUPPORTED, "Delayed entity enabling is not supported"); + DDS_ERROR("Delayed entity enabling is not supported\n"); } dds_entity_unlock(e); } else { - ret = DDS_ERRNO(rc, "Error occurred on locking entity"); + DDS_ERROR("Error occurred on locking entity\n"); + ret = DDS_ERRNO(rc); } - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); + return ret; } @@ -726,8 +726,6 @@ dds_get_status_changes( dds__retcode_t rc; dds_return_t ret; - DDS_REPORT_STACK(); - if (status != NULL) { rc = dds_entity_lock(entity, DDS_KIND_DONTCARE, &e); if (rc == DDS_RETCODE_OK) { @@ -735,16 +733,19 @@ dds_get_status_changes( *status = e->m_trigger; ret = DDS_RETCODE_OK; } else { - ret = DDS_ERRNO(DDS_RETCODE_ILLEGAL_OPERATION, "This entity does not maintain a status."); + DDS_ERROR("This entity does not maintain a status\n"); + ret = DDS_ERRNO(DDS_RETCODE_ILLEGAL_OPERATION); } dds_entity_unlock(e); } else { - ret = DDS_ERRNO(rc, "Error occurred on locking entity"); + DDS_ERROR("Error occurred on locking entity\n"); + ret = DDS_ERRNO(rc); } } else { - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument status is NULL"); + DDS_ERROR("Argument status is NULL\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); } - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); + return ret; } @@ -760,8 +761,6 @@ dds_get_enabled_status( dds__retcode_t rc; dds_return_t ret; - DDS_REPORT_STACK(); - if (status != NULL) { rc = dds_entity_lock(entity, DDS_KIND_DONTCARE, &e); if (rc == DDS_RETCODE_OK) { @@ -769,16 +768,19 @@ dds_get_enabled_status( *status = (e->m_status_enable & ~DDS_INTERNAL_STATUS_MASK); ret = DDS_RETCODE_OK; } else { - ret = DDS_ERRNO(DDS_RETCODE_ILLEGAL_OPERATION, "This entity does not maintain a status."); + DDS_ERROR("This entity does not maintain a status\n"); + ret = DDS_ERRNO(DDS_RETCODE_ILLEGAL_OPERATION); } dds_entity_unlock(e); } else { - ret = DDS_ERRNO(rc, "Error occurred on locking entity"); + DDS_ERROR("Error occurred on locking entity\n"); + ret = DDS_ERRNO(rc); } } else{ - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument status is NULL"); + DDS_ERROR("Argument status is NULL\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); } - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); + return ret; } @@ -794,8 +796,6 @@ dds_set_enabled_status( dds__retcode_t rc; dds_return_t ret; - DDS_REPORT_STACK(); - rc = dds_entity_lock(entity, DDS_KIND_DONTCARE, &e); if (rc == DDS_RETCODE_OK) { if (e->m_deriver.validate_status) { @@ -810,13 +810,15 @@ dds_set_enabled_status( } } } else { - ret = DDS_ERRNO (DDS_RETCODE_ILLEGAL_OPERATION, "This entity does not maintain a status."); + DDS_ERROR("This entity does not maintain a status\n"); + ret = DDS_ERRNO (DDS_RETCODE_ILLEGAL_OPERATION); } dds_entity_unlock(e); } else { - ret = DDS_ERRNO(rc, "Error occurred on locking entity"); + DDS_ERROR("Error occurred on locking entity\n"); + ret = DDS_ERRNO(rc); } - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); + return ret; } @@ -834,8 +836,6 @@ dds_read_status( dds__retcode_t rc; dds_return_t ret; - DDS_REPORT_STACK(); - if (status != NULL) { rc = dds_entity_lock(entity, DDS_KIND_DONTCARE, &e); if (rc == DDS_RETCODE_OK) { @@ -846,16 +846,19 @@ dds_read_status( *status = e->m_trigger & mask; } } else { - ret = DDS_ERRNO(DDS_RETCODE_ILLEGAL_OPERATION, "This entity does not maintain a status."); + DDS_ERROR("This entity does not maintain a status\n"); + ret = DDS_ERRNO(DDS_RETCODE_ILLEGAL_OPERATION); } dds_entity_unlock(e); } else { - ret = DDS_ERRNO(rc, "Error occurred on locking entity"); + DDS_ERROR("Error occurred on locking entity\n"); + ret = DDS_ERRNO(rc); } } else { - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument status is NULL"); + DDS_ERROR("Argument status is NULL\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); } - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); + return ret; } @@ -873,7 +876,6 @@ dds_take_status( dds__retcode_t rc; dds_return_t ret; - DDS_REPORT_STACK(); if (status != NULL) { rc = dds_entity_lock(entity, DDS_KIND_DONTCARE, &e); if (rc == DDS_RETCODE_OK) { @@ -888,16 +890,19 @@ dds_take_status( e->m_trigger &= ~mask; } } else { - ret = DDS_ERRNO(DDS_RETCODE_ILLEGAL_OPERATION, "This entity does not maintain a status."); + DDS_ERROR("This entity does not maintain a status\n"); + ret = DDS_ERRNO(DDS_RETCODE_ILLEGAL_OPERATION); } dds_entity_unlock(e); } else { - ret = DDS_ERRNO(rc, "Error occurred on locking entity"); + DDS_ERROR("Error occurred on locking entity\n"); + ret = DDS_ERRNO(rc); } } else { - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument status is NUL"); + DDS_ERROR("Argument status is NUL\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); } - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); + return ret; } @@ -927,21 +932,20 @@ dds_get_domainid( dds__retcode_t rc; dds_return_t ret = DDS_RETCODE_OK; - DDS_REPORT_STACK(); - if (id != NULL) { rc = dds_entity_lock(entity, DDS_KIND_DONTCARE, &e); if (rc == DDS_RETCODE_OK) { *id = e->m_domainid; dds_entity_unlock(e); } else{ - ret = DDS_ERRNO(rc, "Error occurred on locking entity"); + DDS_ERROR("Error occurred on locking entity\n"); + ret = DDS_ERRNO(rc); } } else{ - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument domain id is NULL"); + DDS_ERROR("Argument domain id is NULL\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); } - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); return ret; } @@ -957,24 +961,25 @@ dds_get_instance_handle( dds__retcode_t rc; dds_return_t ret; - DDS_REPORT_STACK(); - if (ihdl != NULL) { rc = dds_entity_lock(entity, DDS_KIND_DONTCARE, &e); if (rc == DDS_RETCODE_OK) { if (e->m_deriver.get_instance_hdl) { ret = e->m_deriver.get_instance_hdl(e, ihdl); } else { - ret = DDS_ERRNO(DDS_RETCODE_ILLEGAL_OPERATION, "Instance handle is not valid"); + DDS_ERROR("Instance handle is not valid\n"); + ret = DDS_ERRNO(DDS_RETCODE_ILLEGAL_OPERATION); } dds_entity_unlock(e); } else { - ret = DDS_ERRNO(rc, "Error occurred on locking entity"); + DDS_ERROR("Error occurred on locking entity\n"); + ret = DDS_ERRNO(rc); } } else { - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument instance handle is NULL"); + DDS_ERROR("Argument instance handle is NULL\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); } - DDS_REPORT_FLUSH(ret < 0); + return ret; } @@ -995,23 +1000,23 @@ dds_valid_hdl( rc = DDS_RETCODE_OK; } else if(utr == UT_HANDLE_UNEQUAL_KIND){ rc = DDS_RETCODE_ILLEGAL_OPERATION; - DDS_WARNING(rc, "Given (%s) [0x%08lx] entity type can not perform this operation.", dds__entity_kind_str(hdl), hdl); + DDS_WARNING("Given (%s) [0x%08"PRIx32"] entity type can not perform this operation\n", dds__entity_kind_str(hdl), hdl); } else if(utr == UT_HANDLE_INVALID){ rc = DDS_RETCODE_BAD_PARAMETER; - DDS_WARNING(rc, "Given (%s) [0x%08lx] entity is invalid", dds__entity_kind_str(hdl), hdl); + DDS_WARNING("Given (%s) [0x%08"PRIx32"] entity is invalid\n", dds__entity_kind_str(hdl), hdl); } else if(utr == UT_HANDLE_DELETED){ rc = DDS_RETCODE_ALREADY_DELETED; - DDS_WARNING(rc, "Given (%s) [0x%08lx] entity is already deleted.", dds__entity_kind_str(hdl), hdl); + DDS_WARNING("Given (%s) [0x%08"PRIx32"] entity is already deleted\n", dds__entity_kind_str(hdl), hdl); } else if(utr == UT_HANDLE_CLOSED){ rc = DDS_RETCODE_ALREADY_DELETED; - DDS_WARNING(rc, "Given (%s) [0x%08lx] entity is already deleted.", dds__entity_kind_str(hdl), hdl); + DDS_WARNING("Given (%s) [0x%08"PRIx32"] entity is already deleted\n", dds__entity_kind_str(hdl), hdl); } else { rc = DDS_RETCODE_ERROR; - DDS_WARNING(rc, "An internal error occurred."); + DDS_WARNING("An internal error occurred\n"); } } else { rc = DDS_RETCODE_BAD_PARAMETER; - DDS_WARNING(rc, "Given entity (0x%08lx) was not properly created.", hdl); + DDS_WARNING("Given entity (0x%08"PRIx32") was not properly created\n", hdl); } return rc; } @@ -1042,23 +1047,23 @@ dds_entity_lock( rc = DDS_RETCODE_OK; } else if(utr == UT_HANDLE_UNEQUAL_KIND){ rc = DDS_RETCODE_ILLEGAL_OPERATION; - DDS_WARNING(rc, "Given (%s) [0x%08lx] entity type can not perform this operation.", dds__entity_kind_str(hdl), hdl); + DDS_WARNING("Given (%s) [0x%08"PRIx32"] entity type can not perform this operation\n", dds__entity_kind_str(hdl), hdl); } else if(utr == UT_HANDLE_INVALID){ rc = DDS_RETCODE_BAD_PARAMETER; - DDS_WARNING(rc, "Given (%s) [0x%08lx] entity is invalid", dds__entity_kind_str(hdl), hdl); + DDS_WARNING("Given (%s) [0x%08"PRIx32"] entity is invalid\n", dds__entity_kind_str(hdl), hdl); } else if(utr == UT_HANDLE_DELETED){ rc = DDS_RETCODE_ALREADY_DELETED; - DDS_WARNING(rc , "Given (%s) [0x%08lx] entity is already deleted", dds__entity_kind_str(hdl), hdl); + DDS_WARNING("Given (%s) [0x%08"PRIx32"] entity is already deleted\n", dds__entity_kind_str(hdl), hdl); } else if(utr == UT_HANDLE_CLOSED){ rc = DDS_RETCODE_ALREADY_DELETED; - DDS_WARNING(rc, "Given (%s) [0x%08lx] entity is already deleted", dds__entity_kind_str(hdl), hdl); + DDS_WARNING("Given (%s) [0x%08"PRIx32"] entity is already deleted\n", dds__entity_kind_str(hdl), hdl); } else { rc = DDS_RETCODE_ERROR; - DDS_WARNING(rc, "An internal error occurred"); + DDS_WARNING("An internal error occurred\n"); } } else { rc = DDS_RETCODE_BAD_PARAMETER; - DDS_WARNING(rc, "Given entity (0x%08lx) was not properly created.", hdl); + DDS_WARNING("Given entity (0x%08"PRIx32") was not properly created\n", hdl); } return rc; } @@ -1085,16 +1090,15 @@ dds_triggered( dds_return_t ret; dds__retcode_t rc; - DDS_REPORT_STACK(); - rc = dds_entity_lock(entity, DDS_KIND_DONTCARE, &e); if (rc == DDS_RETCODE_OK) { ret = (e->m_trigger != 0); dds_entity_unlock(e); } else { - ret = DDS_ERRNO(rc, "Error occurred on locking entity"); + DDS_ERROR("Error occurred on locking entity\n"); + ret = DDS_ERRNO(rc); } - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); + return ret; } @@ -1151,7 +1155,7 @@ dds_entity_observer_register( rc = dds_entity_observer_register_nl(e, observer, cb); dds_entity_unlock(e); } else{ - DDS_ERROR(rc, "Error occurred on locking observer"); + DDS_ERROR("Error occurred on locking observer\n"); } return rc; } @@ -1201,7 +1205,8 @@ dds_entity_observer_unregister( rc = dds_entity_observer_unregister_nl(e, observer); dds_entity_unlock(e); } else{ - (void)DDS_ERRNO(rc, "Error occurred on locking entity"); + DDS_ERROR("Error occurred on locking entity\n"); + (void)DDS_ERRNO(rc); } return rc; } @@ -1252,8 +1257,6 @@ dds_get_topic( dds_reader *rd; dds_writer *wr; - DDS_REPORT_STACK(); - rc = dds_reader_lock(entity, &rd); if(rc == DDS_RETCODE_OK) { hdl = rd->m_topic->m_entity.m_hdl; @@ -1269,9 +1272,10 @@ dds_get_topic( } } if (rc != DDS_RETCODE_OK) { - hdl = DDS_ERRNO(rc, "Error occurred on locking entity"); + DDS_ERROR("Error occurred on locking entity\n"); + hdl = DDS_ERRNO(rc); } - DDS_REPORT_FLUSH(hdl <= 0); + return hdl; } diff --git a/src/core/ddsc/src/dds_guardcond.c b/src/core/ddsc/src/dds_guardcond.c index 32d2f52..3262aa6 100644 --- a/src/core/ddsc/src/dds_guardcond.c +++ b/src/core/ddsc/src/dds_guardcond.c @@ -18,7 +18,6 @@ #include "ddsi/q_ephash.h" #include "ddsi/q_entity.h" #include "ddsi/q_thread.h" -#include "dds__report.h" _Must_inspect_result_ dds_guardcond* dds_create_guardcond( @@ -38,7 +37,6 @@ dds_create_guardcondition( dds_entity * pp; dds__retcode_t rc; - DDS_REPORT_STACK(); rc = dds_entity_lock(participant, DDS_KIND_PARTICIPANT, &pp); if (rc == DDS_RETCODE_OK) { dds_guardcond *cond = dds_create_guardcond((dds_participant *)pp); @@ -46,9 +44,10 @@ dds_create_guardcondition( hdl = cond->m_entity.m_hdl; dds_entity_unlock(pp); } else { - hdl = DDS_ERRNO(rc, "Error occurred on locking reader"); + DDS_ERROR("Error occurred on locking reader\n"); + hdl = DDS_ERRNO(rc); } - DDS_REPORT_FLUSH(hdl <= 0); + return hdl; } @@ -62,7 +61,6 @@ dds_set_guardcondition( dds_guardcond *gcond; dds__retcode_t rc; - DDS_REPORT_STACK(); rc = dds_entity_lock(condition, DDS_KIND_COND_GUARD, (dds_entity**)&gcond); if (rc == DDS_RETCODE_OK) { if (triggered) { @@ -74,9 +72,10 @@ dds_set_guardcondition( dds_entity_unlock(&gcond->m_entity); ret = DDS_RETCODE_OK; } else { - ret = DDS_ERRNO(dds_valid_hdl(condition, DDS_KIND_COND_GUARD), "Argument condition is not valid"); + DDS_ERROR("Argument condition is not valid\n"); + ret = DDS_ERRNO(dds_valid_hdl(condition, DDS_KIND_COND_GUARD)); } - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); + return ret; } @@ -90,7 +89,6 @@ dds_read_guardcondition( dds_guardcond *gcond; dds__retcode_t rc; - DDS_REPORT_STACK(); if (triggered != NULL) { *triggered = false; rc = dds_entity_lock(condition, DDS_KIND_COND_GUARD, (dds_entity**)&gcond); @@ -99,12 +97,14 @@ dds_read_guardcondition( dds_entity_unlock((dds_entity*)gcond); ret = DDS_RETCODE_OK; } else { - ret = DDS_ERRNO(dds_valid_hdl(condition, DDS_KIND_COND_GUARD), "Argument condition is not valid"); + DDS_ERROR("Argument condition is not valid\n"); + ret = DDS_ERRNO(dds_valid_hdl(condition, DDS_KIND_COND_GUARD)); } } else { - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument triggered is NULL"); + DDS_ERROR("Argument triggered is NULL\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); } - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); + return ret; } @@ -118,7 +118,6 @@ dds_take_guardcondition( dds_guardcond *gcond; dds__retcode_t rc; - DDS_REPORT_STACK(); if (triggered != NULL) { *triggered = false; rc = dds_entity_lock(condition, DDS_KIND_COND_GUARD, (dds_entity**)&gcond); @@ -128,11 +127,13 @@ dds_take_guardcondition( dds_entity_unlock((dds_entity*)gcond); ret = DDS_RETCODE_OK; } else { - ret = DDS_ERRNO(dds_valid_hdl(condition, DDS_KIND_COND_GUARD), "Argument condition is not valid"); + DDS_ERROR("Argument condition is not valid\n"); + ret = DDS_ERRNO(dds_valid_hdl(condition, DDS_KIND_COND_GUARD)); } } else { - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument triggered is NULL"); + DDS_ERROR("Argument triggered is NULL\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); } - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); + return ret; } diff --git a/src/core/ddsc/src/dds_init.c b/src/core/ddsc/src/dds_init.c index f4d057d..5759f75 100644 --- a/src/core/ddsc/src/dds_init.c +++ b/src/core/ddsc/src/dds_init.c @@ -12,8 +12,7 @@ #include #include #include -#include -#include +#include "os/os.h" #include "dds__init.h" #include "dds__rhc.h" #include "dds__tkmap.h" @@ -21,11 +20,10 @@ #include "dds__domain.h" #include "dds__err.h" #include "dds__builtin.h" -#include "dds__report.h" #include "ddsi/ddsi_serdata.h" #include "ddsi/q_servicelease.h" #include "ddsi/q_entity.h" -#include +#include "ddsi/q_config.h" #include "ddsc/ddsc_project.h" #ifdef _WRS_KERNEL @@ -54,8 +52,6 @@ dds_init(dds_domainid_t domain) os_osInit(); init_mutex = os_getSingletonMutex(); - DDS_REPORT_STACK(); - os_mutexLock(init_mutex); dds_global.m_init_count++; @@ -66,16 +62,13 @@ dds_init(dds_domainid_t domain) if (ut_handleserver_init() != UT_HANDLE_OK) { - ret = DDS_ERRNO(DDS_RETCODE_ERROR, "Failed to initialize internal handle server"); + DDS_ERROR("Failed to initialize internal handle server\n"); + ret = DDS_ERRNO(DDS_RETCODE_ERROR); goto fail_handleserver; } gv.tstart = now (); gv.exception = false; - gv.static_logbuf_lock_inited = 0; - logbuf_init (&gv.static_logbuf); - os_mutexInit (&gv.static_logbuf_lock); - gv.static_logbuf_lock_inited = 1; os_mutexInit (&dds_global.m_mutex); thread_states_init_static(); @@ -83,7 +76,8 @@ dds_init(dds_domainid_t domain) dds_cfgst = config_init (uri); if (dds_cfgst == NULL) { - ret = DDS_ERRNO(DDS_RETCODE_ERROR, "Failed to parse configuration XML file %s", uri); + DDS_ERROR("Failed to parse configuration XML file %s\n", uri); + ret = DDS_ERRNO(DDS_RETCODE_ERROR); goto fail_config; } @@ -92,7 +86,8 @@ dds_init(dds_domainid_t domain) { if (domain < 0 || domain > 230) { - ret = DDS_ERRNO(DDS_RETCODE_ERROR, "requested domain id %d is out of range", domain); + DDS_ERROR("requested domain id %d is out of range\n", domain); + ret = DDS_ERRNO(DDS_RETCODE_ERROR); goto fail_config; } else if (config.domainId.isdefault) @@ -101,7 +96,8 @@ dds_init(dds_domainid_t domain) } else if (domain != config.domainId.value) { - ret = DDS_ERRNO(DDS_RETCODE_ERROR, "requested domain id %d is inconsistent with configured value %d", domain, config.domainId.value); + DDS_ERROR("requested domain id %d is inconsistent with configured value %d\n", domain, config.domainId.value); + ret = DDS_ERRNO(DDS_RETCODE_ERROR); goto fail_config; } } @@ -114,7 +110,8 @@ dds_init(dds_domainid_t domain) if (rtps_config_prep(dds_cfgst) != 0) { - ret = DDS_ERRNO(DDS_RETCODE_ERROR, "Failed to configure RTPS."); + DDS_ERROR("Failed to configure RTPS\n"); + ret = DDS_ERRNO(DDS_RETCODE_ERROR); goto fail_rtps_config; } @@ -128,20 +125,23 @@ dds_init(dds_domainid_t domain) gv.servicelease = nn_servicelease_new(0, 0); if (gv.servicelease == NULL) { - ret = DDS_ERRNO(DDS_RETCODE_OUT_OF_RESOURCES, "Failed to create a servicelease."); + DDS_ERROR("Failed to create a servicelease\n"); + ret = DDS_ERRNO(DDS_RETCODE_OUT_OF_RESOURCES); goto fail_servicelease_new; } } if (rtps_init() < 0) { - ret = DDS_ERRNO(DDS_RETCODE_ERROR, "Failed to initialize RTPS."); + DDS_ERROR("Failed to initialize RTPS\n"); + ret = DDS_ERRNO(DDS_RETCODE_ERROR); goto fail_rtps_init; } if (gv.servicelease && nn_servicelease_start_renewing(gv.servicelease) < 0) { - ret = DDS_ERRNO(DDS_RETCODE_ERROR, "Failed to start the servicelease."); + DDS_ERROR("Failed to start the servicelease\n"); + ret = DDS_ERRNO(DDS_RETCODE_ERROR); goto fail_servicelease_start; } @@ -174,7 +174,6 @@ dds_init(dds_domainid_t domain) skip: os_mutexUnlock(init_mutex); - DDS_REPORT_FLUSH(false); return DDS_RETCODE_OK; fail_servicelease_start: @@ -195,14 +194,11 @@ fail_rtps_config: config_fini (dds_cfgst); dds_cfgst = NULL; fail_config: - gv.static_logbuf_lock_inited = 0; - os_mutexDestroy (&gv.static_logbuf_lock); os_mutexDestroy (&dds_global.m_mutex); ut_handleserver_fini(); fail_handleserver: dds_global.m_init_count--; os_mutexUnlock(init_mutex); - DDS_REPORT_FLUSH(true); os_osExit(); return ret; } @@ -229,7 +225,6 @@ extern void dds_fini (void) config_fini (dds_cfgst); dds_cfgst = NULL; - os_mutexDestroy (&gv.static_logbuf_lock); os_mutexDestroy (&dds_global.m_mutex); ut_handleserver_fini(); dds_global.m_default_domain = DDS_DOMAIN_DEFAULT; @@ -298,9 +293,9 @@ dds__check_domain( /* Specific domain has to be the same as the configured domain. */ if (domain != dds_global.m_default_domain) { - ret = DDS_ERRNO(DDS_RETCODE_ERROR, - "Inconsistent domain configuration detected: domain on configuration: %d, domain %d", - dds_global.m_default_domain, domain); + DDS_ERROR("Inconsistent domain configuration detected: domain on " + "configuration: %d, domain %d\n", dds_global.m_default_domain, domain); + ret = DDS_ERRNO(DDS_RETCODE_ERROR); } } return ret; diff --git a/src/core/ddsc/src/dds_instance.c b/src/core/ddsc/src/dds_instance.c index 9441780..f1f6ec4 100644 --- a/src/core/ddsc/src/dds_instance.c +++ b/src/core/ddsc/src/dds_instance.c @@ -21,7 +21,6 @@ #include "ddsi/ddsi_serdata.h" #include "ddsi/q_entity.h" #include "ddsi/q_thread.h" -#include "dds__report.h" _Pre_satisfies_((writer & DDS_ENTITY_KIND_MASK) == DDS_KIND_WRITER) @@ -30,11 +29,7 @@ dds_writedispose( _In_ dds_entity_t writer, _In_ const void *data) { - dds_return_t ret; - DDS_REPORT_STACK(); - ret = dds_writedispose_ts(writer, data, dds_time()); - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK ); - return ret; + return dds_writedispose_ts(writer, data, dds_time()); } _Pre_satisfies_((writer & DDS_ENTITY_KIND_MASK) == DDS_KIND_WRITER) @@ -43,11 +38,7 @@ dds_dispose( _In_ dds_entity_t writer, _In_ const void *data) { - dds_return_t ret; - DDS_REPORT_STACK(); - ret = dds_dispose_ts(writer, data, dds_time()); - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK ); - return ret; + return dds_dispose_ts(writer, data, dds_time()); } _Pre_satisfies_((writer & DDS_ENTITY_KIND_MASK) == DDS_KIND_WRITER) @@ -56,11 +47,7 @@ dds_dispose_ih( _In_ dds_entity_t writer, _In_ dds_instance_handle_t handle) { - dds_return_t ret; - DDS_REPORT_STACK(); - ret = dds_dispose_ih_ts(writer, handle, dds_time()); - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK ); - return ret; + return dds_dispose_ih_ts(writer, handle, dds_time()); } static struct tkmap_instance* @@ -133,9 +120,8 @@ static const dds_topic * dds_instance_info_by_hdl (dds_entity_t e) if (rc == DDS_RETCODE_OK) { topic = dds_instance_info(w_or_r); dds_entity_unlock(w_or_r); - } - else { - DDS_ERROR(rc, "Error occurred on locking entity"); + } else { + DDS_ERROR("Error occurred on locking entity"); } return topic; } @@ -152,19 +138,20 @@ dds_register_instance( dds_return_t ret; dds__retcode_t rc; - DDS_REPORT_STACK(); - if(data == NULL){ - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument data is NULL"); + DDS_ERROR("Argument data is NULL\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); goto err; } if(handle == NULL){ - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument handle is NULL"); + DDS_ERROR("Argument handle is NULL\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); goto err; } rc = dds_entity_lock(writer, DDS_KIND_WRITER, &wr); if (rc != DDS_RETCODE_OK) { - ret = DDS_ERRNO(rc, "Error occurred on locking writer"); + DDS_ERROR("Error occurred on locking writer\n"); + ret = DDS_ERRNO(rc); goto err; } inst = dds_instance_find (((dds_writer*) wr)->m_topic, data, true); @@ -172,11 +159,11 @@ dds_register_instance( *handle = inst->m_iid; ret = DDS_RETCODE_OK; } else{ - ret = DDS_ERRNO(DDS_RETCODE_ERROR, "Unable to create instance"); + DDS_ERROR("Unable to create instance\n"); + ret = DDS_ERRNO(DDS_RETCODE_ERROR); } dds_entity_unlock(wr); err: - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); return ret; } @@ -186,11 +173,7 @@ dds_unregister_instance( _In_ dds_entity_t writer, _In_opt_ const void *data) { - dds_return_t ret; - DDS_REPORT_STACK(); - ret = dds_unregister_instance_ts (writer, data, dds_time()); - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK ); - return ret; + return dds_unregister_instance_ts (writer, data, dds_time()); } _Pre_satisfies_((writer & DDS_ENTITY_KIND_MASK) == DDS_KIND_WRITER) @@ -199,11 +182,7 @@ dds_unregister_instance_ih( _In_ dds_entity_t writer, _In_opt_ dds_instance_handle_t handle) { - dds_return_t ret; - DDS_REPORT_STACK(); - ret = dds_unregister_instance_ih_ts(writer, handle, dds_time()); - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK ); - return ret; + return dds_unregister_instance_ih_ts(writer, handle, dds_time()); } _Pre_satisfies_((writer & DDS_ENTITY_KIND_MASK) == DDS_KIND_WRITER) @@ -220,19 +199,20 @@ dds_unregister_instance_ts( void * sample = (void*) data; dds_entity *wr; - DDS_REPORT_STACK(); - if (data == NULL){ - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument data is NULL"); + DDS_ERROR("Argument data is NULL\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); goto err; } if(timestamp < 0){ - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument timestamp has negative value"); + DDS_ERROR("Argument timestamp has negative value\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); goto err; } rc = dds_entity_lock(writer, DDS_KIND_WRITER, &wr); if (rc != DDS_RETCODE_OK) { - ret = DDS_ERRNO(rc, "Error occurred on locking writer"); + DDS_ERROR("Error occurred on locking writer\n"); + ret = DDS_ERRNO(rc); goto err; } @@ -246,7 +226,6 @@ dds_unregister_instance_ts( ret = dds_write_impl ((dds_writer*)wr, sample, timestamp, action); dds_entity_unlock(wr); err: - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); return ret; } @@ -266,11 +245,10 @@ dds_unregister_instance_ih_ts( const dds_topic *topic; void *sample; - DDS_REPORT_STACK(); - rc = dds_entity_lock(writer, DDS_KIND_WRITER, &wr); if (rc != DDS_RETCODE_OK) { - ret = DDS_ERRNO(rc, "Error occurred on locking writer"); + DDS_ERROR("Error occurred on locking writer\n"); + ret = DDS_ERRNO(rc); goto err; } @@ -288,13 +266,13 @@ dds_unregister_instance_ih_ts( if (dds_tkmap_get_key (map, topic->m_stopic, handle, sample)) { ret = dds_write_impl ((dds_writer*)wr, sample, timestamp, action); } else{ - ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET, "No instance related with the provided handle is found"); + DDS_ERROR("No instance related with the provided handle is found\n"); + ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET); } dds_sample_free (sample, topic->m_descriptor, DDS_FREE_ALL); dds_entity_unlock(wr); err: - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); return ret; } @@ -309,8 +287,6 @@ dds_writedispose_ts( dds__retcode_t rc; dds_writer *wr; - DDS_REPORT_STACK(); - rc = dds_writer_lock(writer, &wr); if (rc == DDS_RETCODE_OK) { ret = dds_write_impl (wr, data, timestamp, DDS_WR_ACTION_WRITE_DISPOSE); @@ -319,9 +295,10 @@ dds_writedispose_ts( } dds_writer_unlock(wr); } else { - ret = DDS_ERRNO(rc, "Error occurred on locking writer"); + DDS_ERROR("Error occurred on locking writer\n"); + ret = DDS_ERRNO(rc); } - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); + return ret; } @@ -352,16 +329,15 @@ dds_dispose_ts( dds__retcode_t rc; dds_writer *wr; - DDS_REPORT_STACK(); - rc = dds_writer_lock(writer, &wr); if (rc == DDS_RETCODE_OK) { ret = dds_dispose_impl(wr, data, DDS_HANDLE_NIL, timestamp); dds_writer_unlock(wr); } else { - ret = DDS_ERRNO(rc, "Error occurred on locking writer"); + DDS_ERROR("Error occurred on locking writer\n"); + ret = DDS_ERRNO(rc); } - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); + return ret; } @@ -376,8 +352,6 @@ dds_dispose_ih_ts( dds__retcode_t rc; dds_writer *wr; - DDS_REPORT_STACK(); - rc = dds_writer_lock(writer, &wr); if (rc == DDS_RETCODE_OK) { struct tkmap *map = gv.m_tkmap; @@ -386,14 +360,16 @@ dds_dispose_ih_ts( if (dds_tkmap_get_key (map, topic->m_stopic, handle, sample)) { ret = dds_dispose_impl(wr, sample, handle, timestamp); } else { - ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET, "No instance related with the provided handle is found"); + DDS_ERROR("No instance related with the provided handle is found\n"); + ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET); } dds_free(sample); dds_writer_unlock(wr); } else { - ret = DDS_ERRNO(rc, "Error occurred on locking writer"); + DDS_ERROR("Error occurred on locking writer\n"); + ret = DDS_ERRNO(rc); } - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); + return ret; } @@ -407,12 +383,9 @@ dds_instance_lookup( const dds_topic * topic; struct tkmap * map = gv.m_tkmap; struct ddsi_serdata *sd; - dds_return_t ret; - - DDS_REPORT_STACK(); if(data == NULL){ - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument data is NULL"); + DDS_ERROR("Argument data is NULL\n"); goto err; } @@ -421,12 +394,10 @@ dds_instance_lookup( sd = ddsi_serdata_from_sample (topic->m_stopic, SDK_KEY, data); ih = dds_tkmap_lookup (map, sd); ddsi_serdata_unref (sd); - ret = DDS_RETCODE_OK; } else { - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Acquired topic is NULL"); + DDS_ERROR("Acquired topic is NULL\n"); } err: - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); return ih; } @@ -441,16 +412,16 @@ dds_instance_get_key( const dds_topic * topic; struct tkmap * map = gv.m_tkmap; - DDS_REPORT_STACK(); - if(data == NULL){ - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument data is NULL"); + DDS_ERROR("Argument data is NULL\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); goto err; } topic = dds_instance_info_by_hdl (entity); if(topic == NULL){ - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Could not find topic related to the given entity"); + DDS_ERROR("Could not find topic related to the given entity\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); goto err; } memset (data, 0, topic->m_descriptor->m_size); @@ -458,10 +429,10 @@ dds_instance_get_key( if (dds_tkmap_get_key (map, topic->m_stopic, inst, data)) { ret = DDS_RETCODE_OK; } else{ - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "No instance related with the provided entity is found"); + DDS_ERROR("No instance related with the provided entity is found\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); } err: - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); return ret; } diff --git a/src/core/ddsc/src/dds_listener.c b/src/core/ddsc/src/dds_listener.c index ab344fb..dcc26a6 100644 --- a/src/core/ddsc/src/dds_listener.c +++ b/src/core/ddsc/src/dds_listener.c @@ -12,7 +12,6 @@ #include #include "ddsc/dds.h" #include "dds__listener.h" -#include "dds__report.h" @@ -66,7 +65,7 @@ dds_reset_listener(_Out_ dds_listener_t * __restrict listener) l->on_sample_rejected = DDS_LUNSET; l->on_subscription_matched = DDS_LUNSET; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL"); + DDS_ERROR("Argument listener is NULL\n"); } } @@ -83,11 +82,11 @@ dds_copy_listener(_Out_ dds_listener_t * __restrict dst, _In_ const dds_listener c_listener_t *dstl = dst; if(!src){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument source(src) is NULL"); + DDS_ERROR("Argument source(src) is NULL\n"); return ; } if(!dst){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument destination(dst) is NULL"); + DDS_ERROR("Argument destination(dst) is NULL\n"); return ; } dstl->on_data_available = srcl->on_data_available; @@ -119,11 +118,11 @@ dds_merge_listener (_Inout_ dds_listener_t * __restrict dst, _In_ const dds_list c_listener_t *dstl = dst; if(!src){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument source(src) is NULL"); + DDS_ERROR("Argument source(src) is NULL\n"); return ; } if(!dst){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument destination(dst) is NULL"); + DDS_ERROR("Argument destination(dst) is NULL\n"); return ; } if (dstl->on_data_available == DDS_LUNSET) { @@ -183,7 +182,7 @@ dds_lset_data_available (_Inout_ dds_listener_t * __restrict listener, _In_opt_ if (listener) { ((c_listener_t*)listener)->on_data_available = callback; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL"); + DDS_ERROR("Argument listener is NULL\n"); } } @@ -193,7 +192,7 @@ dds_lset_data_on_readers (_Inout_ dds_listener_t * __restrict listener, _In_opt_ if (listener) { ((c_listener_t*)listener)->on_data_on_readers = callback; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL"); + DDS_ERROR("Argument listener is NULL\n"); } } @@ -203,7 +202,7 @@ dds_lset_inconsistent_topic (_Inout_ dds_listener_t * __restrict listener, _In_o if (listener) { ((c_listener_t*)listener)->on_inconsistent_topic = callback; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL"); + DDS_ERROR("Argument listener is NULL\n"); } } @@ -213,7 +212,7 @@ dds_lset_liveliness_changed (_Inout_ dds_listener_t * __restrict listener, _In_o if (listener) { ((c_listener_t*)listener)->on_liveliness_changed = callback; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL"); + DDS_ERROR("Argument listener is NULL\n"); } } @@ -223,7 +222,7 @@ dds_lset_liveliness_lost (_Inout_ dds_listener_t * __restrict listener, _In_opt_ if (listener) { ((c_listener_t*)listener)->on_liveliness_lost = callback; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL"); + DDS_ERROR("Argument listener is NULL\n"); } } @@ -233,7 +232,7 @@ dds_lset_offered_deadline_missed (_Inout_ dds_listener_t * __restrict listener, if (listener) { ((c_listener_t*)listener)->on_offered_deadline_missed = callback; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL"); + DDS_ERROR("Argument listener is NULL\n"); } } @@ -243,7 +242,7 @@ dds_lset_offered_incompatible_qos (_Inout_ dds_listener_t * __restrict listener, if (listener) { ((c_listener_t*)listener)->on_offered_incompatible_qos = callback; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL"); + DDS_ERROR("Argument listener is NULL\n"); } } @@ -253,7 +252,7 @@ dds_lset_publication_matched (_Inout_ dds_listener_t * __restrict listener, _In_ if (listener) { ((c_listener_t*)listener)->on_publication_matched = callback; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL"); + DDS_ERROR("Argument listener is NULL"); } } @@ -263,7 +262,7 @@ dds_lset_requested_deadline_missed (_Inout_ dds_listener_t * __restrict listener if (listener) { ((c_listener_t*)listener)->on_requested_deadline_missed = callback; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL"); + DDS_ERROR("Argument listener is NULL\n"); } } @@ -273,7 +272,7 @@ dds_lset_requested_incompatible_qos (_Inout_ dds_listener_t * __restrict listene if (listener) { ((c_listener_t*)listener)->on_requested_incompatible_qos = callback; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL"); + DDS_ERROR("Argument listener is NULL\n"); } } @@ -283,7 +282,7 @@ dds_lset_sample_lost (_Inout_ dds_listener_t * __restrict listener, _In_opt_ dds if (listener) { ((c_listener_t*)listener)->on_sample_lost = callback; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL"); + DDS_ERROR("Argument listener is NULL\n"); } } @@ -293,7 +292,7 @@ dds_lset_sample_rejected (_Inout_ dds_listener_t * __restrict listener, _In_opt_ if (listener) { ((c_listener_t*)listener)->on_sample_rejected = callback; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL"); + DDS_ERROR("Argument listener is NULL\n"); } } @@ -303,7 +302,7 @@ dds_lset_subscription_matched (_Inout_ dds_listener_t * __restrict listener, _In if (listener) { ((c_listener_t*)listener)->on_subscription_matched = callback; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL"); + DDS_ERROR("Argument listener is NULL\n"); } } @@ -315,11 +314,11 @@ void dds_lget_data_available (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_data_available_fn *callback) { if(!callback){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument callback is NULL"); + DDS_ERROR("Argument callback is NULL\n"); return ; } if (!listener) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL"); + DDS_ERROR("Argument listener is NULL\n"); return ; } *callback = ((c_listener_t*)listener)->on_data_available; @@ -329,11 +328,11 @@ void dds_lget_data_on_readers (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_data_on_readers_fn *callback) { if(!callback){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument callback is NULL"); + DDS_ERROR("Argument callback is NULL\n"); return ; } if (!listener) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL"); + DDS_ERROR("Argument listener is NULL\n"); return ; } *callback = ((c_listener_t*)listener)->on_data_on_readers; @@ -342,11 +341,11 @@ dds_lget_data_on_readers (_In_ const dds_listener_t * __restrict listener, _Outp void dds_lget_inconsistent_topic (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_inconsistent_topic_fn *callback) { if(!callback){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument callback is NULL"); + DDS_ERROR("Argument callback is NULL\n"); return ; } if (!listener) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL"); + DDS_ERROR("Argument listener is NULL\n"); return ; } *callback = ((c_listener_t*)listener)->on_inconsistent_topic; @@ -356,11 +355,11 @@ void dds_lget_liveliness_changed (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_liveliness_changed_fn *callback) { if(!callback){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument callback is NULL"); + DDS_ERROR("Argument callback is NULL\n"); return ; } if (!listener) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL"); + DDS_ERROR("Argument listener is NULL\n"); return ; } *callback = ((c_listener_t*)listener)->on_liveliness_changed; @@ -370,11 +369,11 @@ void dds_lget_liveliness_lost (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_liveliness_lost_fn *callback) { if(!callback){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument callback is NULL"); + DDS_ERROR("Argument callback is NULL\n"); return ; } if (!listener) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL"); + DDS_ERROR("Argument listener is NULL\n"); return ; } *callback = ((c_listener_t*)listener)->on_liveliness_lost; @@ -384,11 +383,11 @@ void dds_lget_offered_deadline_missed (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_offered_deadline_missed_fn *callback) { if(!callback){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument callback is NULL"); + DDS_ERROR("Argument callback is NULL\n"); return ; } if (!listener) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL"); + DDS_ERROR("Argument listener is NULL\n"); return ; } *callback = ((c_listener_t*)listener)->on_offered_deadline_missed; @@ -398,11 +397,11 @@ void dds_lget_offered_incompatible_qos (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_offered_incompatible_qos_fn *callback) { if(!callback){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument callback is NULL"); + DDS_ERROR("Argument callback is NULL\n"); return ; } if (!listener) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL"); + DDS_ERROR("Argument listener is NULL\n"); return ; } *callback = ((c_listener_t*)listener)->on_offered_incompatible_qos; @@ -412,11 +411,11 @@ void dds_lget_publication_matched (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_publication_matched_fn *callback) { if(!callback){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument callback is NULL"); + DDS_ERROR("Argument callback is NULL\n"); return ; } if (!listener) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL"); + DDS_ERROR("Argument listener is NULL\n"); return ; } *callback = ((c_listener_t*)listener)->on_publication_matched; @@ -426,11 +425,11 @@ void dds_lget_requested_deadline_missed (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_requested_deadline_missed_fn *callback) { if(!callback) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument callback is NULL"); + DDS_ERROR("Argument callback is NULL\n"); return ; } if (!listener) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL"); + DDS_ERROR("Argument listener is NULL\n"); return ; } *callback = ((c_listener_t*)listener)->on_requested_deadline_missed; @@ -440,11 +439,11 @@ void dds_lget_requested_incompatible_qos (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_requested_incompatible_qos_fn *callback) { if(!callback) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument callback is NULL"); + DDS_ERROR("Argument callback is NULL\n"); return ; } if (!listener) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL"); + DDS_ERROR("Argument listener is NULL\n"); return ; } *callback = ((c_listener_t*)listener)->on_requested_incompatible_qos; @@ -454,11 +453,11 @@ void dds_lget_sample_lost (_In_ const dds_listener_t *__restrict listener, _Outptr_result_maybenull_ dds_on_sample_lost_fn *callback) { if(!callback) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument callback is NULL"); + DDS_ERROR("Argument callback is NULL\n"); return ; } if (!listener) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL"); + DDS_ERROR("Argument listener is NULL\n"); return ; } *callback = ((c_listener_t*)listener)->on_sample_lost; @@ -468,11 +467,11 @@ void dds_lget_sample_rejected (_In_ const dds_listener_t *__restrict listener, _Outptr_result_maybenull_ dds_on_sample_rejected_fn *callback) { if(!callback) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument callback is NULL"); + DDS_ERROR("Argument callback is NULL\n"); return ; } if (!listener) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL"); + DDS_ERROR("Argument listener is NULL\n"); return ; } *callback = ((c_listener_t*)listener)->on_sample_rejected; @@ -482,11 +481,11 @@ void dds_lget_subscription_matched (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_subscription_matched_fn *callback) { if(!callback) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument callback is NULL"); + DDS_ERROR("Argument callback is NULL\n"); return ; } if (!listener) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL"); + DDS_ERROR("Argument listener is NULL\n"); return ; } *callback = ((c_listener_t*)listener)->on_subscription_matched; diff --git a/src/core/ddsc/src/dds_log.c b/src/core/ddsc/src/dds_log.c deleted file mode 100644 index eb94586..0000000 --- a/src/core/ddsc/src/dds_log.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright(c) 2006 to 2018 ADLINK Technology Limited and others - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License - * v. 1.0 which is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause - */ -#include -#include -#include -#include "ddsc/dds.h" -#include "ddsi/q_log.h" - -#define DDS_FMT_MAX 128 - -void dds_log_info (const char * fmt, ...) -{ - va_list args; - - va_start (args, fmt); - nn_vlog (LC_INFO, fmt, args); - va_end (args); -} - -void dds_log_warn (const char * fmt, ...) -{ - va_list args; - char fmt2 [DDS_FMT_MAX]; - - strcpy (fmt2, " "); - strncat (fmt2, fmt, DDS_FMT_MAX - 11); - fmt2[DDS_FMT_MAX-1] = 0; - fmt = fmt2; - - va_start (args, fmt); - nn_vlog (LC_WARNING, fmt, args); - va_end (args); -} - -void dds_log_error (const char * fmt, ...) -{ - va_list args; - char fmt2 [DDS_FMT_MAX]; - - strcpy (fmt2, " "); - strncat (fmt2, fmt, DDS_FMT_MAX - 9); - fmt2[DDS_FMT_MAX-1] = 0; - fmt = fmt2; - - va_start (args, fmt); - nn_vlog (LC_ERROR, fmt, args); - va_end (args); -} - -void dds_log_fatal (const char * fmt, ...) -{ - va_list args; - char fmt2 [DDS_FMT_MAX]; - - strcpy (fmt2, " "); - strncat (fmt2, fmt, DDS_FMT_MAX - 9); - fmt2[DDS_FMT_MAX-1] = 0; - fmt = fmt2; - - va_start (args, fmt); - nn_vlog (LC_FATAL, fmt, args); - va_end (args); - DDS_FAIL (fmt); -} diff --git a/src/core/ddsc/src/dds_participant.c b/src/core/ddsc/src/dds_participant.c index 577c10b..7c4d399 100644 --- a/src/core/ddsc/src/dds_participant.c +++ b/src/core/ddsc/src/dds_participant.c @@ -18,7 +18,6 @@ #include "dds__domain.h" #include "dds__participant.h" #include "dds__err.h" -#include "dds__report.h" #define DDS_PARTICIPANT_STATUS_MASK 0u @@ -30,9 +29,14 @@ static dds_return_t dds_participant_status_validate( uint32_t mask) { - return (mask & ~(DDS_PARTICIPANT_STATUS_MASK)) ? - DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument mask is invalid") : - DDS_RETCODE_OK; + dds_return_t ret = DDS_RETCODE_OK; + + if (mask & ~(DDS_PARTICIPANT_STATUS_MASK)) { + DDS_ERROR("Argument mask is invalid\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); + } + + return ret; } static dds_return_t @@ -104,10 +108,12 @@ dds_participant_qos_validate( /* Check consistency. */ if ((qos->present & QP_USER_DATA) && !validate_octetseq(&qos->user_data)) { - ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "User data QoS policy is inconsistent and caused an error"); + DDS_ERROR("User data QoS policy is inconsistent and caused an error\n"); + ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY); } if ((qos->present & QP_PRISMTECH_ENTITY_FACTORY) && !validate_entityfactory_qospolicy(&qos->entity_factory)) { - ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "Prismtech entity factory QoS policy is inconsistent and caused an error"); + DDS_ERROR("Prismtech entity factory QoS policy is inconsistent and caused an error\n"); + ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY); } return ret; } @@ -124,7 +130,8 @@ dds_participant_qos_set( if (ret == DDS_RETCODE_OK) { if (enabled) { /* TODO: CHAM-95: DDSI does not support changing QoS policies. */ - ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, "Changing the participant QoS is not supported."); + DDS_ERROR("Changing the participant QoS is not supported\n"); + ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED); } } return ret; @@ -153,9 +160,6 @@ dds_create_participant( goto fail_dds_init; } - /* Report stack is only useful after dds (and thus os) init. */ - DDS_REPORT_STACK(); - /* Check domain id */ ret = dds__check_domain (domain); if (ret != DDS_RETCODE_OK) { @@ -194,7 +198,8 @@ dds_create_participant( } nn_plist_fini (&plist); if (q_rc != 0) { - e = DDS_ERRNO(DDS_RETCODE_ERROR, "Internal error"); + DDS_ERROR("Internal error"); + e = DDS_ERRNO(DDS_RETCODE_ERROR); goto fail_new_participant; } @@ -219,7 +224,6 @@ dds_create_participant( dds_pp_head = &pp->m_entity; os_mutexUnlock (&dds_global.m_mutex); - DDS_REPORT_FLUSH(false); return e; fail_entity_init: @@ -228,7 +232,6 @@ fail_new_participant: dds_delete_qos(new_qos); fail_qos_validation: fail_domain_check: - DDS_REPORT_FLUSH(true); dds_fini(); fail_dds_init: return e; @@ -247,14 +250,14 @@ dds_lookup_participant( os_osInit(); init_mutex = os_getSingletonMutex(); - DDS_REPORT_STACK(); - if ((participants != NULL) && ((size <= 0) || (size >= INT32_MAX))) { - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Array is given, but with invalid size"); + DDS_ERROR("Array is given, but with invalid size\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); goto err; } if ((participants == NULL) && (size != 0)) { - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Size is given, but no array"); + DDS_ERROR("Size is given, but no array\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); goto err; } @@ -284,7 +287,6 @@ dds_lookup_participant( os_mutexUnlock (init_mutex); err: - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); os_osExit(); return ret; } diff --git a/src/core/ddsc/src/dds_publisher.c b/src/core/ddsc/src/dds_publisher.c index 816e457..807f5b7 100644 --- a/src/core/ddsc/src/dds_publisher.c +++ b/src/core/ddsc/src/dds_publisher.c @@ -15,7 +15,6 @@ #include "dds__qos.h" #include "dds__err.h" #include "ddsi/q_entity.h" -#include "dds__report.h" #include "ddsc/ddsc_project.h" #define DDS_PUBLISHER_STATUS_MASK 0u @@ -28,7 +27,8 @@ dds_publisher_instance_hdl( (void)e; (void)i; /* TODO: Get/generate proper handle. */ - return DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, "Getting publisher instance handle is not supported"); + DDS_ERROR("Getting publisher instance handle is not supported\n"); + return DDS_ERRNO(DDS_RETCODE_UNSUPPORTED); } static dds_return_t @@ -41,20 +41,25 @@ dds_publisher_qos_validate( /* Check consistency. */ if((qos->present & QP_GROUP_DATA) && !validate_octetseq(&qos->group_data)){ - ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "Group data policy is inconsistent and caused an error"); + DDS_ERROR("Group data policy is inconsistent and caused an error\n"); + ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY); } if((qos->present & QP_PRESENTATION) && (validate_presentation_qospolicy(&qos->presentation) != 0)){ - ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "Presentation policy is inconsistent and caused an error"); + DDS_ERROR("Presentation policy is inconsistent and caused an error\n"); + ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY); } if((qos->present & QP_PARTITION) && !validate_stringseq(&qos->partition)){ - ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "Partition policy is inconsistent and caused an error"); + DDS_ERROR("Partition policy is inconsistent and caused an error\n"); + ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY); } if((qos->present & QP_PRISMTECH_ENTITY_FACTORY) && !validate_entityfactory_qospolicy(&qos->entity_factory)){ - ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "Prismtech entity factory policy is inconsistent and caused an error"); + DDS_ERROR("Prismtech entity factory policy is inconsistent and caused an error\n"); + ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY); } if(ret == DDS_RETCODE_OK && enabled && (qos->present & QP_PRESENTATION)){ /* TODO: Improve/check immutable check. */ - ret = DDS_ERRNO(DDS_RETCODE_IMMUTABLE_POLICY, "Presentation policy is immutable"); + DDS_ERROR("Presentation policy is immutable\n"); + ret = DDS_ERRNO(DDS_RETCODE_IMMUTABLE_POLICY); } return ret; } @@ -70,7 +75,8 @@ dds_publisher_qos_set( if (ret == DDS_RETCODE_OK) { if (enabled) { /* TODO: CHAM-95: DDSI does not support changing QoS policies. */ - ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, DDSC_PROJECT_NAME" does not support changing QoS policies yet"); + DDS_ERROR(DDSC_PROJECT_NAME" does not support changing QoS policies yet\n"); + ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED); } } return ret; @@ -78,9 +84,14 @@ dds_publisher_qos_set( static dds_return_t dds_publisher_status_validate (uint32_t mask) { - return (mask & ~(DDS_PUBLISHER_STATUS_MASK)) ? - DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Invalid status mask") : - DDS_RETCODE_OK; + dds_return_t ret = DDS_RETCODE_OK; + + if (mask & ~(DDS_PUBLISHER_STATUS_MASK)) { + DDS_ERROR("Invalid status mask\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); + } + + return ret; } _Pre_satisfies_((participant & DDS_ENTITY_KIND_MASK) == DDS_KIND_PARTICIPANT) @@ -97,11 +108,10 @@ dds_create_publisher( dds_return_t ret; dds__retcode_t rc; - DDS_REPORT_STACK(); - rc = dds_entity_lock(participant, DDS_KIND_PARTICIPANT, &par); if (rc != DDS_RETCODE_OK) { - hdl = DDS_ERRNO(rc, "Error occurred on locking participant"); + DDS_ERROR("Error occurred on locking participant\n"); + hdl = DDS_ERRNO(rc); goto lock_err; } @@ -128,7 +138,6 @@ dds_create_publisher( qos_err: dds_entity_unlock(par); lock_err: - DDS_REPORT_FLUSH(hdl <= 0); return hdl; } @@ -140,16 +149,15 @@ dds_suspend( { dds_return_t ret; - DDS_REPORT_STACK(); - if(dds_entity_kind(publisher) != DDS_KIND_PUBLISHER) { - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Provided entity is not a publisher kind"); + DDS_ERROR("Provided entity is not a publisher kind\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); goto err; } /* TODO: CHAM-123 Currently unsupported. */ - ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, "Suspend publication operation does not being supported yet"); + DDS_ERROR("Suspend publication operation does not being supported yet\n"); + ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED); err: - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); return ret; } @@ -161,16 +169,15 @@ dds_resume( { dds_return_t ret = DDS_RETCODE_OK; - DDS_REPORT_STACK(); - if(dds_entity_kind(publisher) != DDS_KIND_PUBLISHER) { - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER,"Provided entity is not a publisher kind"); + DDS_ERROR("Provided entity is not a publisher kind\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); goto err; } /* TODO: CHAM-123 Currently unsupported. */ - ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, "Suspend publication operation does not being supported yet"); + DDS_ERROR("Suspend publication operation does not being supported yet\n"); + ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED); err: - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); return ret; } @@ -183,23 +190,25 @@ dds_wait_for_acks( _In_ dds_duration_t timeout) { dds_return_t ret; - DDS_REPORT_STACK(); /* TODO: CHAM-125 Currently unsupported. */ OS_UNUSED_ARG(timeout); switch(dds_entity_kind(publisher_or_writer)) { case DDS_KIND_WRITER: - ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, "Wait for acknowledgments on a writer is not being supported yet"); + DDS_ERROR("Wait for acknowledgments on a writer is not being supported yet\n"); + ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED); break; case DDS_KIND_PUBLISHER: - ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, "Wait for acknowledgments on a publisher is not being supported yet"); + DDS_ERROR("Wait for acknowledgments on a publisher is not being supported yet\n"); + ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED); break; default: - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Provided entity is not a publisher nor a writer"); + DDS_ERROR("Provided entity is not a publisher nor a writer\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); break; } - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); + return ret; } @@ -209,7 +218,8 @@ dds_publisher_begin_coherent( { /* TODO: CHAM-124 Currently unsupported. */ (void)e; - return DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, "Using coherency to get a coherent data set is not being supported yet"); + DDS_ERROR("Using coherency to get a coherent data set is not being supported yet\n"); + return DDS_ERRNO(DDS_RETCODE_UNSUPPORTED); } dds_return_t @@ -218,6 +228,7 @@ dds_publisher_end_coherent( { /* TODO: CHAM-124 Currently unsupported. */ (void)e; - return DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, "Using coherency to get a coherent data set is not being supported yet"); + DDS_ERROR("Using coherency to get a coherent data set is not being supported yet\n"); + return DDS_ERRNO(DDS_RETCODE_UNSUPPORTED); } diff --git a/src/core/ddsc/src/dds_qos.c b/src/core/ddsc/src/dds_qos.c index 281255a..30965f1 100644 --- a/src/core/ddsc/src/dds_qos.c +++ b/src/core/ddsc/src/dds_qos.c @@ -14,7 +14,6 @@ #include "dds__qos.h" #include "dds__err.h" #include "ddsi/q_config.h" -#include "dds__report.h" /* TODO: dd_duration_t is converted to nn_ddsi_time_t declared in q_time.h This structure contain seconds and fractions. @@ -135,25 +134,32 @@ dds_qos_validate_mutable_common ( /* TODO: Check whether immutable QoS are changed should actually incorporate change to current QoS */ if (qos->present & QP_DEADLINE) { - ret = DDS_ERRNO(DDS_RETCODE_IMMUTABLE_POLICY, "Deadline QoS policy caused immutable error"); + DDS_ERROR("Deadline QoS policy caused immutable error\n"); + ret = DDS_ERRNO(DDS_RETCODE_IMMUTABLE_POLICY); } if (qos->present & QP_OWNERSHIP) { - ret = DDS_ERRNO(DDS_RETCODE_IMMUTABLE_POLICY, "Ownership QoS policy caused immutable error"); + DDS_ERROR("Ownership QoS policy caused immutable error\n"); + ret = DDS_ERRNO(DDS_RETCODE_IMMUTABLE_POLICY); } if (qos->present & QP_LIVELINESS) { - ret = DDS_ERRNO(DDS_RETCODE_IMMUTABLE_POLICY, "Liveliness QoS policy caused immutable error"); + DDS_ERROR("Liveliness QoS policy caused immutable error\n"); + ret = DDS_ERRNO(DDS_RETCODE_IMMUTABLE_POLICY); } if (qos->present & QP_RELIABILITY) { - ret = DDS_ERRNO(DDS_RETCODE_IMMUTABLE_POLICY, "Reliability QoS policy caused immutable error"); + DDS_ERROR("Reliability QoS policy caused immutable error\n"); + ret = DDS_ERRNO(DDS_RETCODE_IMMUTABLE_POLICY); } if (qos->present & QP_DESTINATION_ORDER) { - ret = DDS_ERRNO(DDS_RETCODE_IMMUTABLE_POLICY, "Destination order QoS policy caused immutable error"); + DDS_ERROR("Destination order QoS policy caused immutable error\n"); + ret = DDS_ERRNO(DDS_RETCODE_IMMUTABLE_POLICY); } if (qos->present & QP_HISTORY) { - ret = DDS_ERRNO(DDS_RETCODE_IMMUTABLE_POLICY, "History QoS policy caused immutable error"); + DDS_ERROR("History QoS policy caused immutable error\n"); + ret = DDS_ERRNO(DDS_RETCODE_IMMUTABLE_POLICY); } if (qos->present & QP_RESOURCE_LIMITS) { - ret = DDS_ERRNO(DDS_RETCODE_IMMUTABLE_POLICY, "Resource limits QoS policy caused immutable error"); + DDS_ERROR("Resource limits QoS policy caused immutable error\n"); + ret = DDS_ERRNO(DDS_RETCODE_IMMUTABLE_POLICY); } return ret; @@ -215,7 +221,7 @@ dds_reset_qos( nn_xqos_fini (qos); dds_qos_init_defaults (qos); } else { - DDS_WARNING(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL"); + DDS_WARNING("Argument QoS is NULL\n"); } } @@ -249,10 +255,12 @@ dds_copy_qos ( _In_ const dds_qos_t * __restrict src) { if(!src){ - return DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument source(src) is NULL"); + DDS_ERROR("Argument source(src) is NULL\n"); + return DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); } if(!dst){ - return DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument destination(dst) is NULL"); + DDS_ERROR("Argument destination(dst) is NULL\n"); + return DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); } nn_xqos_copy (dst, src); return DDS_RETCODE_OK; @@ -271,11 +279,11 @@ void dds_merge_qos ( _In_ const dds_qos_t * __restrict src) { if(!src){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument source(src) is NULL"); + DDS_ERROR("Argument source(src) is NULL\n"); return; } if(!dst){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument destination(dst) is NULL"); + DDS_ERROR("Argument destination(dst) is NULL\n"); return; } /* Copy qos from source to destination unless already set */ @@ -309,7 +317,7 @@ void dds_qset_userdata( _In_ size_t sz) { if (!qos) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL"); + DDS_ERROR("Argument qos is NULL\n"); return ; } dds_qos_data_copy_in(&qos->user_data, value, sz); @@ -322,7 +330,7 @@ void dds_qset_topicdata( _In_ size_t sz) { if (!qos) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL"); + DDS_ERROR("Argument qos is NULL\n"); return ; } dds_qos_data_copy_in (&qos->topic_data, value, sz); @@ -335,7 +343,7 @@ void dds_qset_groupdata( _In_ size_t sz) { if (!qos) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL"); + DDS_ERROR("Argument qos is NULL\n"); return ; } dds_qos_data_copy_in (&qos->group_data, value, sz); @@ -352,7 +360,7 @@ void dds_qset_durability qos->durability.kind = (nn_durability_kind_t) kind; qos->present |= QP_DURABILITY; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL"); + DDS_ERROR("Argument QoS is NULL\n"); } } @@ -368,7 +376,7 @@ void dds_qset_history qos->history.depth = depth; qos->present |= QP_HISTORY; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL"); + DDS_ERROR("Argument QoS is NULL\n"); } } @@ -386,7 +394,7 @@ void dds_qset_resource_limits qos->resource_limits.max_samples_per_instance = max_samples_per_instance; qos->present |= QP_RESOURCE_LIMITS; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL"); + DDS_ERROR("Argument QoS is NULL\n"); } } @@ -404,7 +412,7 @@ void dds_qset_presentation qos->presentation.ordered_access = ordered_access; qos->present |= QP_PRESENTATION; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL"); + DDS_ERROR("Argument QoS is NULL\n"); } } @@ -418,7 +426,7 @@ void dds_qset_lifespan qos->lifespan.duration = nn_to_ddsi_duration (lifespan); qos->present |= QP_LIFESPAN; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL"); + DDS_ERROR("Argument QoS is NULL\n"); } } @@ -432,7 +440,7 @@ void dds_qset_deadline qos->deadline.deadline = nn_to_ddsi_duration (deadline); qos->present |= QP_DEADLINE; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL"); + DDS_ERROR("Argument QoS is NULL\n"); } } @@ -446,7 +454,7 @@ void dds_qset_latency_budget qos->latency_budget.duration = nn_to_ddsi_duration (duration); qos->present |= QP_LATENCY_BUDGET; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL"); + DDS_ERROR("Argument QoS is NULL\n"); } } @@ -460,7 +468,7 @@ void dds_qset_ownership qos->ownership.kind = (nn_ownership_kind_t) kind; qos->present |= QP_OWNERSHIP; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL"); + DDS_ERROR("Argument QoS is NULL\n"); } } @@ -474,7 +482,7 @@ void dds_qset_ownership_strength qos->ownership_strength.value = value; qos->present |= QP_OWNERSHIP_STRENGTH; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL"); + DDS_ERROR("Argument QoS is NULL\n"); } } @@ -490,7 +498,7 @@ void dds_qset_liveliness qos->liveliness.lease_duration = nn_to_ddsi_duration (lease_duration); qos->present |= QP_LIVELINESS; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL"); + DDS_ERROR("Argument QoS is NULL\n"); } } @@ -504,7 +512,7 @@ void dds_qset_time_based_filter qos->time_based_filter.minimum_separation = nn_to_ddsi_duration (minimum_separation); qos->present |= QP_TIME_BASED_FILTER; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL"); + DDS_ERROR("Argument QoS is NULL\n"); } } @@ -519,11 +527,11 @@ void dds_qset_partition size_t len; if(!qos) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos may not be NULL"); + DDS_ERROR("Argument qos may not be NULL\n"); return ; } if(n && !ps) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument ps is NULL, but n (%u) > 0", n); + DDS_ERROR("Argument ps is NULL, but n (%u) > 0", n); return ; } @@ -560,7 +568,7 @@ void dds_qset_reliability qos->reliability.max_blocking_time = nn_to_ddsi_duration (max_blocking_time); qos->present |= QP_RELIABILITY; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL"); + DDS_ERROR("Argument QoS is NULL\n"); } } @@ -574,7 +582,7 @@ void dds_qset_transport_priority qos->transport_priority.value = value; qos->present |= QP_TRANSPORT_PRIORITY; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL"); + DDS_ERROR("Argument QoS is NULL\n"); } } @@ -589,7 +597,7 @@ void dds_qset_destination_order qos->destination_order.kind = (nn_destination_order_kind_t) kind; qos->present |= QP_DESTINATION_ORDER; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL"); + DDS_ERROR("Argument QoS is NULL\n"); } } @@ -603,7 +611,7 @@ void dds_qset_writer_data_lifecycle qos->writer_data_lifecycle.autodispose_unregistered_instances = autodispose; qos->present |= QP_PRISMTECH_WRITER_DATA_LIFECYCLE; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL"); + DDS_ERROR("Argument QoS is NULL\n"); } } @@ -621,7 +629,7 @@ void dds_qset_reader_data_lifecycle nn_to_ddsi_duration (autopurge_disposed_samples_delay); qos->present |= QP_PRISMTECH_READER_DATA_LIFECYCLE; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL"); + DDS_ERROR("Argument QoS is NULL\n"); } } @@ -645,7 +653,7 @@ void dds_qset_durability_service qos->durability_service.resource_limits.max_samples_per_instance = max_samples_per_instance; qos->present |= QP_DURABILITY_SERVICE; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL"); + DDS_ERROR("Argument QoS is NULL\n"); } } @@ -657,15 +665,15 @@ void dds_qget_userdata ) { if(!qos) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL"); + DDS_ERROR("Argument QoS is NULL\n"); return ; } if(!value) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument value is NULL"); + DDS_ERROR("Argument value is NULL\n"); return ; } if(!sz) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument sz is NULL"); + DDS_ERROR("Argument sz is NULL\n"); return ; } dds_qos_data_copy_out (&qos->user_data, value, sz); @@ -679,15 +687,15 @@ void dds_qget_topicdata ) { if(!qos) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL"); + DDS_ERROR("Argument QoS is NULL\n"); return ; } if(!value) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument value is NULL"); + DDS_ERROR("Argument value is NULL\n"); return ; } if(!sz) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument sz is NULL"); + DDS_ERROR("Argument sz is NULL\n"); return ; } dds_qos_data_copy_out (&qos->topic_data, value, sz); @@ -701,15 +709,15 @@ void dds_qget_groupdata ) { if(!qos) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL"); + DDS_ERROR("Argument QoS is NULL\n"); return ; } if(!value) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument value is NULL"); + DDS_ERROR("Argument value is NULL\n"); return ; } if(!sz) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument sz is NULL"); + DDS_ERROR("Argument sz is NULL\n"); return ; } dds_qos_data_copy_out (&qos->group_data, value, sz); @@ -722,11 +730,11 @@ void dds_qget_durability ) { if(!qos) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL"); + DDS_ERROR("Argument QoS is NULL\n"); return ; } if(!kind) { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument kind is NULL"); + DDS_ERROR("Argument kind is NULL\n"); return ; } *kind = (dds_durability_kind_t) qos->durability.kind; @@ -743,7 +751,7 @@ void dds_qget_history if (kind) *kind = (dds_history_kind_t) qos->history.kind; if (depth) *depth = qos->history.depth; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL"); + DDS_ERROR("Argument qos is NULL\n"); } } @@ -762,7 +770,7 @@ void dds_qget_resource_limits *max_samples_per_instance = qos->resource_limits.max_samples_per_instance; } } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL"); + DDS_ERROR("Argument qos is NULL\n"); } } @@ -779,7 +787,7 @@ void dds_qget_presentation if (coherent_access) *coherent_access = qos->presentation.coherent_access; if (ordered_access) *ordered_access = qos->presentation.ordered_access; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL"); + DDS_ERROR("Argument qos is NULL\n"); } } @@ -790,11 +798,11 @@ void dds_qget_lifespan ) { if(!qos){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL"); + DDS_ERROR("Argument qos is NULL\n"); return ; } if(!lifespan){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument lifespan is NULL"); + DDS_ERROR("Argument lifespan is NULL\n"); return ; } *lifespan = nn_from_ddsi_duration (qos->lifespan.duration); @@ -807,11 +815,11 @@ void dds_qget_deadline ) { if(!qos){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL"); + DDS_ERROR("Argument qos is NULL\n"); return ; } if(!deadline){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument deadline is NULL"); + DDS_ERROR("Argument deadline is NULL\n"); return ; } *deadline = nn_from_ddsi_duration (qos->deadline.deadline); @@ -824,11 +832,11 @@ void dds_qget_latency_budget ) { if(!qos){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL"); + DDS_ERROR("Argument qos is NULL\n"); return ; } if(!duration){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument duration is NULL"); + DDS_ERROR("Argument duration is NULL\n"); return ; } *duration = nn_from_ddsi_duration (qos->latency_budget.duration); @@ -841,11 +849,11 @@ void dds_qget_ownership ) { if(!qos){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL"); + DDS_ERROR("Argument qos is NULL\n"); return ; } if(!kind){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument kind is NULL"); + DDS_ERROR("Argument kind is NULL\n"); return ; } *kind = (dds_ownership_kind_t) qos->ownership.kind; @@ -858,11 +866,11 @@ void dds_qget_ownership_strength ) { if(!qos){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL"); + DDS_ERROR("Argument qos is NULL\n"); return ; } if(!value){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument value is NULL"); + DDS_ERROR("Argument value is NULL\n"); return ; } *value = qos->ownership_strength.value; @@ -879,7 +887,7 @@ void dds_qget_liveliness if (kind) *kind = (dds_liveliness_kind_t) qos->liveliness.kind; if (lease_duration) *lease_duration = nn_from_ddsi_duration (qos->liveliness.lease_duration); } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL"); + DDS_ERROR("Argument qos is NULL\n"); } } @@ -890,11 +898,11 @@ void dds_qget_time_based_filter ) { if(!qos){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL"); + DDS_ERROR("Argument qos is NULL\n"); return ; } if(!minimum_separation){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument minimum_separation is NULL"); + DDS_ERROR("Argument minimum_separation is NULL\n"); return ; } *minimum_separation = nn_from_ddsi_duration (qos->time_based_filter.minimum_separation); @@ -911,11 +919,11 @@ void dds_qget_partition uint32_t i; if(!qos){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL"); + DDS_ERROR("Argument qos is NULL\n"); return ; } if(!n){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument n is NULL"); + DDS_ERROR("Argument n is NULL\n"); return ; } @@ -945,7 +953,7 @@ void dds_qget_reliability if (kind) *kind = (dds_reliability_kind_t) qos->reliability.kind; if (max_blocking_time) *max_blocking_time = nn_from_ddsi_duration (qos->reliability.max_blocking_time); } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL"); + DDS_ERROR("Argument qos is NULL\n"); } } @@ -956,11 +964,11 @@ void dds_qget_transport_priority ) { if(!qos){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL"); + DDS_ERROR("Argument qos is NULL\n"); return ; } if(!value){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument value is NULL"); + DDS_ERROR("Argument value is NULL\n"); return ; } *value = qos->transport_priority.value; @@ -973,11 +981,11 @@ void dds_qget_destination_order ) { if(!qos){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL"); + DDS_ERROR("Argument qos is NULL\n"); return ; } if(!kind){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument kind is NULL"); + DDS_ERROR("Argument kind is NULL\n"); return ; } *kind = (dds_destination_order_kind_t) qos->destination_order.kind; @@ -990,11 +998,11 @@ void dds_qget_writer_data_lifecycle ) { if(!qos){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL"); + DDS_ERROR("Argument qos is NULL\n"); return ; } if(!autodispose){ - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument autodispose is NULL"); + DDS_ERROR("Argument autodispose is NULL\n"); return ; } *autodispose = qos->writer_data_lifecycle.autodispose_unregistered_instances; @@ -1017,7 +1025,7 @@ void dds_qget_reader_data_lifecycle nn_from_ddsi_duration (qos->reader_data_lifecycle.autopurge_disposed_samples_delay); } } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL"); + DDS_ERROR("Argument qos is NULL\n"); } } @@ -1040,6 +1048,6 @@ void dds_qget_durability_service if (max_instances) *max_instances = qos->durability_service.resource_limits.max_instances; if (max_samples_per_instance) *max_samples_per_instance = qos->durability_service.resource_limits.max_samples_per_instance; } else { - DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL"); + DDS_ERROR("Argument qos is NULL\n"); } } diff --git a/src/core/ddsc/src/dds_querycond.c b/src/core/ddsc/src/dds_querycond.c index efc2d41..6748079 100644 --- a/src/core/ddsc/src/dds_querycond.c +++ b/src/core/ddsc/src/dds_querycond.c @@ -18,7 +18,6 @@ #include "dds__err.h" #include "ddsi/ddsi_serdata.h" #include "ddsi/ddsi_sertopic.h" -#include "dds__report.h" _Pre_satisfies_((reader & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER) DDS_EXPORT dds_entity_t @@ -31,8 +30,6 @@ dds_create_querycondition( dds__retcode_t rc; dds_reader *r; - DDS_REPORT_STACK(); - rc = dds_reader_lock(reader, &r); if (rc == DDS_RETCODE_OK) { dds_readcond *cond = dds_create_readcond(r, DDS_KIND_COND_QUERY, mask); @@ -41,8 +38,9 @@ dds_create_querycondition( cond->m_query.m_filter = filter; dds_reader_unlock(r); } else { - hdl = DDS_ERRNO(rc, "Error occurred on locking reader"); + DDS_ERROR("Error occurred on locking reader\n"); + hdl = DDS_ERRNO(rc); } - DDS_REPORT_FLUSH(hdl <= 0); + return hdl; } diff --git a/src/core/ddsc/src/dds_read.c b/src/core/ddsc/src/dds_read.c index 77eb516..6133dd7 100644 --- a/src/core/ddsc/src/dds_read.c +++ b/src/core/ddsc/src/dds_read.c @@ -19,7 +19,6 @@ #include "ddsi/q_thread.h" #include "ddsi/q_ephash.h" #include "ddsi/q_entity.h" -#include "dds__report.h" static _Check_return_ dds__retcode_t @@ -46,19 +45,19 @@ dds_read_lock( rc = dds_entity_lock(parent->m_hdl, DDS_KIND_READER, (dds_entity**)reader); if (rc != DDS_RETCODE_OK) { dds_entity_unlock((dds_entity*)*condition); - DDS_ERROR(rc, "Failed to lock condition reader."); + DDS_ERROR("Failed to lock condition reader\n"); } } else { - DDS_ERROR(rc, "Failed to lock condition."); + DDS_ERROR("Failed to lock condition\n"); } } else { - DDS_ERROR(rc, "Given entity is not a reader nor a condition."); + DDS_ERROR("Given entity is not a reader nor a condition\n"); } } else { - DDS_ERROR(rc, "Given entity is not a reader."); + DDS_ERROR("Given entity is not a reader\n"); } } else if (rc != DDS_RETCODE_OK) { - DDS_ERROR(rc, "Failed to lock reader."); + DDS_ERROR("Failed to lock reader\n"); } return rc; } @@ -106,34 +105,41 @@ dds_read_impl( thread_state_awake (thr); } if (buf == NULL) { - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "The provided buffer is NULL"); + DDS_ERROR("The provided buffer is NULL\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); goto fail; } if (si == NULL) { - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Provided pointer to an array of dds_sample_info_t is NULL"); + DDS_ERROR("Provided pointer to an array of dds_sample_info_t is NULL\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); goto fail; } if (maxs == 0) { - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "The maximum number of samples to read is zero"); + DDS_ERROR("The maximum number of samples to read is zero\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); goto fail; } if (bufsz == 0) { - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "The size of buffer is zero"); + DDS_ERROR("The size of buffer is zero\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); goto fail; } if (bufsz < maxs) { - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "The provided size of buffer is smaller than the maximum number of samples to read"); + DDS_ERROR("The provided size of buffer is smaller than the maximum number of samples to read\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); goto fail; } rc = dds_read_lock(reader_or_condition, &rd, &cond, only_reader); if (rc != DDS_RETCODE_OK) { - ret = DDS_ERRNO(rc, "Error occurred on locking entity"); + DDS_ERROR("Error occurred on locking entity\n"); + ret = DDS_ERRNO(rc); goto fail; } if (hand != DDS_HANDLE_NIL) { if (dds_tkmap_find_by_id(gv.m_tkmap, hand) == NULL) { - ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET, "Could not find instance"); + DDS_ERROR("Could not find instance\n"); + ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET); dds_read_unlock(rd, cond); goto fail; } @@ -235,7 +241,8 @@ dds_readcdr_impl( } dds_read_unlock(rd, cond); } else { - ret = DDS_ERRNO(rc, "Error occurred on locking entity"); + DDS_ERROR("Error occurred on locking entity\n"); + ret = DDS_ERRNO(rc); } if (asleep) @@ -258,18 +265,14 @@ dds_read( _In_ uint32_t maxs) { bool lock = true; - dds_return_t ret; - DDS_REPORT_STACK(); if (maxs == DDS_READ_WITHOUT_LOCK) { lock = false; /* Use a more sensible maxs, so use bufsz instead. * CHAM-306 will remove this ugly piece of code. */ maxs = (uint32_t)bufsz; } - ret = dds_read_impl (false, rd_or_cnd, buf, bufsz, maxs, si, NO_STATE_MASK_SET, DDS_HANDLE_NIL, lock, false); - DDS_REPORT_FLUSH(ret < 0); - return ret; + return dds_read_impl (false, rd_or_cnd, buf, bufsz, maxs, si, NO_STATE_MASK_SET, DDS_HANDLE_NIL, lock, false); } _Pre_satisfies_(((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) ||\ @@ -283,9 +286,6 @@ dds_read_wl( _In_ uint32_t maxs) { bool lock = true; - dds_return_t ret; - - DDS_REPORT_STACK(); if (maxs == DDS_READ_WITHOUT_LOCK) { lock = false; @@ -293,9 +293,7 @@ dds_read_wl( * CHAM-306 will remove this ugly piece of code. */ maxs = 100; } - ret = dds_read_impl (false, rd_or_cnd, buf, maxs, maxs, si, NO_STATE_MASK_SET, DDS_HANDLE_NIL, lock, false); - DDS_REPORT_FLUSH(ret < 0); - return ret; + return dds_read_impl (false, rd_or_cnd, buf, maxs, maxs, si, NO_STATE_MASK_SET, DDS_HANDLE_NIL, lock, false); } _Pre_satisfies_(((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) ||\ @@ -311,9 +309,6 @@ dds_read_mask( _In_ uint32_t mask) { bool lock = true; - dds_return_t ret; - - DDS_REPORT_STACK(); if (maxs == DDS_READ_WITHOUT_LOCK) { lock = false; @@ -321,9 +316,7 @@ dds_read_mask( * CHAM-306 will remove this ugly piece of code. */ maxs = (uint32_t)bufsz; } - ret = dds_read_impl (false, rd_or_cnd, buf, bufsz, maxs, si, mask, DDS_HANDLE_NIL, lock, false); - DDS_REPORT_FLUSH(ret < 0); - return ret; + return dds_read_impl (false, rd_or_cnd, buf, bufsz, maxs, si, mask, DDS_HANDLE_NIL, lock, false); } _Pre_satisfies_(((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) ||\ @@ -338,9 +331,6 @@ dds_read_mask_wl( _In_ uint32_t mask) { bool lock = true; - dds_return_t ret; - - DDS_REPORT_STACK(); if (maxs == DDS_READ_WITHOUT_LOCK) { lock = false; @@ -348,9 +338,7 @@ dds_read_mask_wl( * CHAM-306 will remove this ugly piece of code. */ maxs = 100; } - ret = dds_read_impl (false, rd_or_cnd, buf, maxs, maxs, si, mask, DDS_HANDLE_NIL, lock, false); - DDS_REPORT_FLUSH(ret < 0 ); - return ret; + return dds_read_impl (false, rd_or_cnd, buf, maxs, maxs, si, mask, DDS_HANDLE_NIL, lock, false); } _Pre_satisfies_(((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) ||\ @@ -367,10 +355,10 @@ dds_read_instance( { dds_return_t ret = DDS_RETCODE_OK; bool lock = true; - DDS_REPORT_STACK(); if (handle == DDS_HANDLE_NIL) { - ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET, "DDS_HANDLE_NIL was provided"); + DDS_ERROR("DDS_HANDLE_NIL was provided\n"); + ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET); goto fail; } @@ -382,7 +370,6 @@ dds_read_instance( } ret = dds_read_impl(false, rd_or_cnd, buf, bufsz, maxs, si, NO_STATE_MASK_SET, handle, lock, false); fail: - DDS_REPORT_FLUSH(ret < 0 ); return ret; } @@ -399,10 +386,10 @@ dds_read_instance_wl( { dds_return_t ret = DDS_RETCODE_OK; bool lock = true; - DDS_REPORT_STACK(); if (handle == DDS_HANDLE_NIL) { - ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET, "DDS_HANDLE_NIL was provided"); + DDS_ERROR("DDS_HANDLE_NIL was provided\n"); + ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET); goto fail; } @@ -414,7 +401,6 @@ dds_read_instance_wl( } ret = dds_read_impl(false, rd_or_cnd, buf, maxs, maxs, si, NO_STATE_MASK_SET, handle, lock, false); fail: - DDS_REPORT_FLUSH(ret < 0); return ret; } @@ -434,10 +420,10 @@ dds_read_instance_mask( { dds_return_t ret = DDS_RETCODE_OK; bool lock = true; - DDS_REPORT_STACK(); if (handle == DDS_HANDLE_NIL) { - ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET, "DDS_HANDLE_NIL was provided"); + DDS_ERROR("DDS_HANDLE_NIL was provided\n"); + ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET); goto fail; } @@ -449,7 +435,6 @@ dds_read_instance_mask( } ret = dds_read_impl(false, rd_or_cnd, buf, bufsz, maxs, si, mask, handle, lock, false); fail: - DDS_REPORT_FLUSH(ret < 0); return ret; } @@ -468,10 +453,10 @@ dds_read_instance_mask_wl( { dds_return_t ret = DDS_RETCODE_OK; bool lock = true; - DDS_REPORT_STACK(); if (handle == DDS_HANDLE_NIL) { - ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET, "DDS_HANDLE_NIL was provided"); + DDS_ERROR("DDS_HANDLE_NIL was provided\n"); + ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET); goto fail; } if (maxs == DDS_READ_WITHOUT_LOCK) { @@ -482,7 +467,6 @@ dds_read_instance_mask_wl( } ret = dds_read_impl(false, rd_or_cnd, buf, maxs, maxs, si, mask, handle, lock, false); fail: - DDS_REPORT_FLUSH(ret < 0); return ret; } @@ -494,13 +478,7 @@ dds_read_next( _Out_ dds_sample_info_t *si) { uint32_t mask = DDS_NOT_READ_SAMPLE_STATE | DDS_ANY_VIEW_STATE | DDS_ANY_INSTANCE_STATE; - dds_return_t ret; - - DDS_REPORT_STACK(); - - ret = dds_read_impl (false, reader, buf, 1u, 1u, si, mask, DDS_HANDLE_NIL, true, true); - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); - return ret; + return dds_read_impl (false, reader, buf, 1u, 1u, si, mask, DDS_HANDLE_NIL, true, true); } _Pre_satisfies_((reader & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) @@ -511,12 +489,7 @@ dds_read_next_wl( _Out_ dds_sample_info_t *si) { uint32_t mask = DDS_NOT_READ_SAMPLE_STATE | DDS_ANY_VIEW_STATE | DDS_ANY_INSTANCE_STATE; - dds_return_t ret; - - DDS_REPORT_STACK(); - ret = dds_read_impl (false, reader, buf, 1u, 1u, si, mask, DDS_HANDLE_NIL, true, true); - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); - return ret; + return dds_read_impl (false, reader, buf, 1u, 1u, si, mask, DDS_HANDLE_NIL, true, true); } _Pre_satisfies_(((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) ||\ @@ -531,9 +504,6 @@ dds_take( _In_ uint32_t maxs) { bool lock = true; - dds_return_t ret; - - DDS_REPORT_STACK(); if (maxs == DDS_READ_WITHOUT_LOCK) { lock = false; @@ -541,9 +511,7 @@ dds_take( * CHAM-306 will remove this ugly piece of code. */ maxs = (uint32_t)bufsz; } - ret = dds_read_impl (true, rd_or_cnd, buf, bufsz, maxs, si, NO_STATE_MASK_SET, DDS_HANDLE_NIL, lock, false); - DDS_REPORT_FLUSH(ret < 0); - return ret; + return dds_read_impl (true, rd_or_cnd, buf, bufsz, maxs, si, NO_STATE_MASK_SET, DDS_HANDLE_NIL, lock, false); } _Pre_satisfies_(((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) ||\ @@ -557,9 +525,6 @@ dds_take_wl( _In_ uint32_t maxs) { bool lock = true; - dds_return_t ret; - - DDS_REPORT_STACK(); if (maxs == DDS_READ_WITHOUT_LOCK) { lock = false; @@ -567,9 +532,7 @@ dds_take_wl( * CHAM-306 will remove this ugly piece of code. */ maxs = 100; } - ret = dds_read_impl (true, rd_or_cnd, buf, maxs, maxs, si, NO_STATE_MASK_SET, DDS_HANDLE_NIL, lock, false); - DDS_REPORT_FLUSH(ret < 0); - return ret; + return dds_read_impl (true, rd_or_cnd, buf, maxs, maxs, si, NO_STATE_MASK_SET, DDS_HANDLE_NIL, lock, false); } _Pre_satisfies_(((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) ||\ @@ -585,9 +548,6 @@ dds_take_mask( _In_ uint32_t mask) { bool lock = true; - dds_return_t ret; - - DDS_REPORT_STACK(); if (maxs == DDS_READ_WITHOUT_LOCK) { lock = false; @@ -595,9 +555,7 @@ dds_take_mask( * CHAM-306 will remove this ugly piece of code. */ maxs = (uint32_t)bufsz; } - ret = dds_read_impl (true, rd_or_cnd, buf, bufsz, maxs, si, mask, DDS_HANDLE_NIL, lock, false); - DDS_REPORT_FLUSH(ret < 0); - return ret; + return dds_read_impl (true, rd_or_cnd, buf, bufsz, maxs, si, mask, DDS_HANDLE_NIL, lock, false); } _Pre_satisfies_(((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) ||\ @@ -612,9 +570,6 @@ dds_take_mask_wl( _In_ uint32_t mask) { bool lock = true; - dds_return_t ret; - - DDS_REPORT_STACK(); if (maxs == DDS_READ_WITHOUT_LOCK) { lock = false; @@ -622,9 +577,7 @@ dds_take_mask_wl( * CHAM-306 will remove this ugly piece of code. */ maxs = 100; } - ret = dds_read_impl (true, rd_or_cnd, buf, maxs, maxs, si, mask, DDS_HANDLE_NIL, lock, false); - DDS_REPORT_FLUSH(ret < 0); - return ret; + return dds_read_impl (true, rd_or_cnd, buf, maxs, maxs, si, mask, DDS_HANDLE_NIL, lock, false); } int @@ -636,6 +589,7 @@ dds_takecdr( uint32_t mask) { bool lock = true; + if (maxs == DDS_READ_WITHOUT_LOCK) { lock = false; /* Use a more sensible maxs. Just an arbitrarily number. @@ -661,10 +615,9 @@ dds_take_instance( dds_return_t ret = DDS_RETCODE_OK; bool lock = true; - DDS_REPORT_STACK(); - if (handle == DDS_HANDLE_NIL) { - ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET, "DDS_HANDLE_NIL was provided"); + DDS_ERROR("DDS_HANDLE_NIL was provided\n"); + ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET); goto fail; } @@ -676,7 +629,6 @@ dds_take_instance( } ret = dds_read_impl(true, rd_or_cnd, buf, bufsz, maxs, si, NO_STATE_MASK_SET, handle, lock, false); fail: - DDS_REPORT_FLUSH(ret < 0); return ret; } @@ -694,10 +646,9 @@ dds_take_instance_wl( dds_return_t ret = DDS_RETCODE_OK; bool lock = true; - DDS_REPORT_STACK(); - if (handle == DDS_HANDLE_NIL) { - ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET, "DDS_HANDLE_NIL was provided"); + DDS_ERROR("DDS_HANDLE_NIL was provided\n"); + ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET); goto fail; } if (maxs == DDS_READ_WITHOUT_LOCK) { @@ -708,7 +659,6 @@ dds_take_instance_wl( } ret = dds_read_impl(true, rd_or_cnd, buf, maxs, maxs, si, NO_STATE_MASK_SET, handle, lock, false); fail: - DDS_REPORT_FLUSH(ret < 0); return ret; } @@ -729,10 +679,9 @@ dds_take_instance_mask( dds_return_t ret = DDS_RETCODE_OK; bool lock = true; - DDS_REPORT_STACK(); - if (handle == DDS_HANDLE_NIL) { - ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET, "DDS_HANDLE_NIL was provided"); + DDS_ERROR("DDS_HANDLE_NIL was provided\n"); + ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET); goto fail; } if (maxs == DDS_READ_WITHOUT_LOCK) { @@ -743,7 +692,6 @@ dds_take_instance_mask( } ret = dds_read_impl(true, rd_or_cnd, buf, bufsz, maxs, si, mask, handle, lock, false); fail: - DDS_REPORT_FLUSH(ret < 0); return ret; } @@ -763,10 +711,9 @@ dds_take_instance_mask_wl( dds_return_t ret = DDS_RETCODE_OK; bool lock = true; - DDS_REPORT_STACK(); - if (handle == DDS_HANDLE_NIL) { - ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET, "DDS_HANDLE_NIL was provided"); + DDS_ERROR("DDS_HANDLE_NIL was provided\n"); + ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET); goto fail; } if (maxs == DDS_READ_WITHOUT_LOCK) { @@ -777,7 +724,6 @@ dds_take_instance_mask_wl( } ret = dds_read_impl(true, rd_or_cnd, buf, maxs, maxs, si, mask, handle, lock, false); fail: - DDS_REPORT_FLUSH(ret < 0); return ret; } @@ -789,11 +735,7 @@ dds_take_next( _Out_ dds_sample_info_t *si) { uint32_t mask = DDS_NOT_READ_SAMPLE_STATE | DDS_ANY_VIEW_STATE | DDS_ANY_INSTANCE_STATE; - dds_return_t ret; - DDS_REPORT_STACK(); - ret = dds_read_impl (true, reader, buf, 1u, 1u, si, mask, DDS_HANDLE_NIL, true, true); - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); - return ret; + return dds_read_impl (true, reader, buf, 1u, 1u, si, mask, DDS_HANDLE_NIL, true, true); } _Pre_satisfies_((reader & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) @@ -804,11 +746,7 @@ dds_take_next_wl( _Out_ dds_sample_info_t *si) { uint32_t mask = DDS_NOT_READ_SAMPLE_STATE | DDS_ANY_VIEW_STATE | DDS_ANY_INSTANCE_STATE; - dds_return_t ret; - DDS_REPORT_STACK(); - ret = dds_read_impl (true, reader, buf, 1u, 1u, si, mask, DDS_HANDLE_NIL, true, true); - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); - return ret; + return dds_read_impl (true, reader, buf, 1u, 1u, si, mask, DDS_HANDLE_NIL, true, true); } _Pre_satisfies_(((reader_or_condition & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) ||\ @@ -826,20 +764,21 @@ dds_return_loan( dds_readcond *cond; dds_return_t ret = DDS_RETCODE_OK; - DDS_REPORT_STACK(); - if (!buf ) { - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument buf is NULL"); + DDS_ERROR("Argument buf is NULL\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); goto fail; } if(*buf == NULL && bufsz > 0){ - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument buf is NULL"); + DDS_ERROR("Argument buf is NULL\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); goto fail; } rc = dds_read_lock(reader_or_condition, &rd, &cond, false); if (rc != DDS_RETCODE_OK) { - ret = DDS_ERRNO(rc, "Error occurred on locking entity"); + DDS_ERROR("Error occurred on locking entity\n"); + ret = DDS_ERRNO(rc); goto fail; } desc = rd->m_topic->m_descriptor; @@ -861,6 +800,5 @@ dds_return_loan( dds_read_unlock(rd, cond); fail: - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); return ret; } diff --git a/src/core/ddsc/src/dds_readcond.c b/src/core/ddsc/src/dds_readcond.c index 5706d7e..f555a14 100644 --- a/src/core/ddsc/src/dds_readcond.c +++ b/src/core/ddsc/src/dds_readcond.c @@ -18,7 +18,6 @@ #include "ddsi/q_ephash.h" #include "ddsi/q_entity.h" #include "ddsi/q_thread.h" -#include "dds__report.h" static dds_return_t dds_readcond_delete( @@ -57,8 +56,6 @@ dds_create_readcondition( dds_reader * rd; dds__retcode_t rc; - DDS_REPORT_STACK(); - rc = dds_reader_lock(reader, &rd); if (rc == DDS_RETCODE_OK) { dds_readcond *cond = dds_create_readcond(rd, DDS_KIND_COND_READ, mask); @@ -66,9 +63,10 @@ dds_create_readcondition( hdl = cond->m_entity.m_hdl; dds_reader_unlock(rd); } else { - hdl = DDS_ERRNO(rc, "Error occurred on locking reader"); + DDS_ERROR("Error occurred on locking reader\n"); + hdl = DDS_ERRNO(rc); } - DDS_REPORT_FLUSH(hdl <= 0); + return hdl; } @@ -80,15 +78,15 @@ dds_get_datareader( { dds_entity_t hdl; - DDS_REPORT_STACK(); if (dds_entity_kind(condition) == DDS_KIND_COND_READ) { hdl = dds_get_parent(condition); } else if (dds_entity_kind(condition) == DDS_KIND_COND_QUERY) { hdl = dds_get_parent(condition); } else { - hdl = DDS_ERRNO(dds_valid_hdl(condition, DDS_KIND_COND_READ), "Argument condition is not valid"); + DDS_ERROR("Argument condition is not valid\n"); + hdl = DDS_ERRNO(dds_valid_hdl(condition, DDS_KIND_COND_READ)); } - DDS_REPORT_FLUSH(hdl <= 0); + return hdl; } @@ -104,8 +102,6 @@ dds_get_mask( dds_readcond *cond; dds__retcode_t rc; - DDS_REPORT_STACK(); - if (mask != NULL) { *mask = 0; if ((dds_entity_kind(condition) == DDS_KIND_COND_READ ) || @@ -116,14 +112,17 @@ dds_get_mask( dds_entity_unlock((dds_entity*)cond); ret = DDS_RETCODE_OK; } else{ - ret = DDS_ERRNO(rc, "Error occurred on locking condition"); + DDS_ERROR("Error occurred on locking condition\n"); + ret = DDS_ERRNO(rc); } } else { - ret = DDS_ERRNO(dds_valid_hdl(condition, DDS_KIND_COND_READ), "Argument condition is not valid"); + DDS_ERROR("Argument condition is not valid\n"); + ret = DDS_ERRNO(dds_valid_hdl(condition, DDS_KIND_COND_READ)); } } else { - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument mask is NULL"); + DDS_ERROR("Argument mask is NULL\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); } - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); + return ret; } diff --git a/src/core/ddsc/src/dds_reader.c b/src/core/ddsc/src/dds_reader.c index e281206..0c8e3e3 100644 --- a/src/core/ddsc/src/dds_reader.c +++ b/src/core/ddsc/src/dds_reader.c @@ -21,11 +21,9 @@ #include "dds__err.h" #include "ddsi/q_entity.h" #include "ddsi/q_thread.h" -#include "dds__report.h" #include "dds__builtin.h" #include "ddsc/ddsc_project.h" -#include #include "os/os.h" @@ -65,8 +63,9 @@ dds_reader_close( thread_state_awake(thr); } if (delete_reader(&e->m_guid) != 0) { + DDS_ERROR("Internal error"); rc = DDS_RETCODE_ERROR; - ret = DDS_ERRNO(rc, "Internal error"); + ret = DDS_ERRNO(rc); } if (asleep) { thread_state_asleep(thr); @@ -103,22 +102,28 @@ dds_reader_qos_validate( /* Check consistency. */ if(!dds_qos_validate_common(qos)) { - ret = DDS_ERRNO(DDS_RETCODE_ERROR, "Argument Qos is not valid"); + DDS_ERROR("Argument Qos is not valid\n"); + ret = DDS_ERRNO(DDS_RETCODE_ERROR); } if((qos->present & QP_USER_DATA) && !(validate_octetseq (&qos->user_data))) { - ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "User data policy is inconsistent and caused an error"); + DDS_ERROR("User data policy is inconsistent and caused an error\n"); + ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY); } if((qos->present & QP_PRISMTECH_READER_DATA_LIFECYCLE) && (validate_reader_data_lifecycle (&qos->reader_data_lifecycle) != 0)) { - ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "Prismtech reader data lifecycle policy is inconsistent and caused an error"); + DDS_ERROR("Prismtech reader data lifecycle policy is inconsistent and caused an error\n"); + ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY); } if((qos->present & QP_TIME_BASED_FILTER) && (validate_duration (&qos->time_based_filter.minimum_separation) != 0)) { - ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "Time based filter policy is inconsistent and caused an error"); + DDS_ERROR("Time based filter policy is inconsistent and caused an error\n"); + ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY); } if((qos->present & QP_HISTORY) && (qos->present & QP_RESOURCE_LIMITS) && (validate_history_and_resource_limits (&qos->history, &qos->resource_limits) != 0)) { - ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "History and resource limits policy is inconsistent and caused an error"); + DDS_ERROR("History and resource limits policy is inconsistent and caused an error\n"); + ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY); } if((qos->present & QP_TIME_BASED_FILTER) && (qos->present & QP_DEADLINE) && !(validate_deadline_and_timebased_filter (qos->deadline.deadline, qos->time_based_filter.minimum_separation))) { - ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "Time based filter and deadline policy is inconsistent and caused an error"); + DDS_ERROR("Time based filter and deadline policy is inconsistent and caused an error\n"); + ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY); } if(ret == DDS_RETCODE_OK && enabled) { ret = dds_qos_validate_mutable_common(qos); @@ -138,7 +143,8 @@ dds_reader_qos_set( if (ret == DDS_RETCODE_OK) { if (enabled) { /* TODO: CHAM-95: DDSI does not support changing QoS policies. */ - ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, DDSC_PROJECT_NAME" does not support changing QoS policies"); + DDS_ERROR(DDSC_PROJECT_NAME" does not support changing QoS policies\n"); + ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED); } } return ret; @@ -149,7 +155,7 @@ dds_reader_status_validate( uint32_t mask) { return (mask & ~(DDS_READER_STATUS_MASK)) ? - DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Invalid status mask") : + DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER) : DDS_RETCODE_OK; } @@ -162,8 +168,6 @@ dds_reader_status_cb( dds__retcode_t rc; void *metrics = NULL; - DDS_REPORT_STACK(); - /* When data is NULL, it means that the DDSI reader is deleted. */ if (data == NULL) { /* Release the initial claim that was done during the create. This @@ -173,8 +177,6 @@ dds_reader_status_cb( } if (dds_reader_lock(((dds_entity*)entity)->m_hdl, &rd) != DDS_RETCODE_OK) { - /* There's a deletion or closing going on. */ - DDS_REPORT_FLUSH(false); return; } assert(rd == entity); @@ -333,8 +335,6 @@ dds_reader_status_cb( } else { /* Something went wrong up the hierarchy. */ } - - DDS_REPORT_FLUSH(rc != DDS_RETCODE_OK); } @@ -362,8 +362,6 @@ dds_create_reader( const bool asleep = !vtime_awake_p (thr->vtime); dds_return_t ret = DDS_RETCODE_OK; - DDS_REPORT_STACK(); - if (dds_entity_kind(topic) != DDS_KIND_INTERNAL) { /* Try claiming a participant. If that's not working, then it could be a subscriber. */ if (dds_entity_kind(participant_or_subscriber) == DDS_KIND_PARTICIPANT) { @@ -380,7 +378,8 @@ dds_create_reader( rc = dds_entity_lock(subscriber, DDS_KIND_SUBSCRIBER, &sub); if (rc != DDS_RETCODE_OK) { - reader = DDS_ERRNO(rc, "Error occurred on locking subscriber"); + DDS_ERROR("Error occurred on locking subscriber\n"); + reader = DDS_ERRNO(rc); goto err_sub_lock; } @@ -392,7 +391,8 @@ dds_create_reader( rc = dds_entity_lock(t, DDS_KIND_TOPIC, &tp); if (rc != DDS_RETCODE_OK) { - reader = DDS_ERRNO(rc, "Error occurred on locking topic"); + DDS_ERROR("Error occurred on locking topic\n"); + reader = DDS_ERRNO(rc); goto err_tp_lock; } assert (((dds_topic*)tp)->m_stopic); @@ -472,7 +472,6 @@ dds_create_reader( dds_delete(t); } - DDS_REPORT_FLUSH(reader <= 0); return reader; err_bad_qos: @@ -483,7 +482,6 @@ err_tp_lock: (void)dds_delete(subscriber); } err_sub_lock: - DDS_REPORT_FLUSH(reader <= 0); return reader; } @@ -560,7 +558,6 @@ dds_reader_wait_for_historical_data( int ret; dds_reader *rd; - DDS_REPORT_STACK(); assert (reader); ret = dds_reader_lock(reader, &rd); @@ -568,13 +565,15 @@ dds_reader_wait_for_historical_data( if (((dds_entity*)rd)->m_qos->durability.kind > NN_TRANSIENT_LOCAL_DURABILITY_QOS) { ret = (dds_global.m_dur_wait) (rd, max_wait); } else { - ret = DDS_ERRNO(DDS_RETCODE_ERROR, "Can not wait for historical data on a reader with volatile durability"); + DDS_ERROR("Can not wait for historical data on a reader with volatile durability\n"); + ret = DDS_ERRNO(DDS_RETCODE_ERROR); } dds_reader_unlock(rd); } else { - ret = DDS_ERRNO(ret, "Error occurred on locking reader"); + DDS_ERROR("Error occurred on locking reader\n"); + ret = DDS_ERRNO(ret); } - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); + return ret; } @@ -587,8 +586,6 @@ dds_get_subscriber( { dds_entity_t hdl; - DDS_REPORT_STACK(); - if (dds_entity_kind(entity) == DDS_KIND_READER) { hdl = dds_get_parent(entity); } else if (dds_entity_kind(entity) == DDS_KIND_COND_READ || dds_entity_kind(entity) == DDS_KIND_COND_QUERY) { @@ -596,12 +593,13 @@ dds_get_subscriber( if(hdl > 0){ hdl = dds_get_subscriber(hdl); } else { - DDS_ERROR(hdl, "Reader of this condition is already deleted"); + DDS_ERROR("Reader of this condition is already deleted\n"); } } else { - hdl = DDS_ERRNO(dds_valid_hdl(entity, DDS_KIND_READER), "Provided entity is not a reader nor a condition"); + DDS_ERROR("Provided entity is not a reader nor a condition\n"); + hdl = DDS_ERRNO(dds_valid_hdl(entity, DDS_KIND_READER)); } - DDS_REPORT_FLUSH(hdl <= 0); + return hdl; } @@ -615,11 +613,10 @@ dds_get_subscription_matched_status ( dds_reader *rd; dds_return_t ret = DDS_RETCODE_OK; - DDS_REPORT_STACK(); - rc = dds_reader_lock(reader, &rd); if (rc != DDS_RETCODE_OK) { - ret = DDS_ERRNO(rc, "Error occurred on locking reader"); + DDS_ERROR("Error occurred on locking reader\n"); + ret = DDS_ERRNO(rc); goto fail; } /* status = NULL, application do not need the status, but reset the counter & triggered bit */ @@ -633,7 +630,6 @@ dds_get_subscription_matched_status ( } dds_reader_unlock(rd); fail: - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); return ret; } @@ -647,11 +643,10 @@ dds_get_liveliness_changed_status ( dds_reader *rd; dds_return_t ret = DDS_RETCODE_OK; - DDS_REPORT_STACK(); - rc = dds_reader_lock(reader, &rd); if (rc != DDS_RETCODE_OK) { - ret = DDS_ERRNO(rc, "Error occurred on locking reader"); + DDS_ERROR("Error occurred on locking reader\n"); + ret = DDS_ERRNO(rc); goto fail; } /* status = NULL, application do not need the status, but reset the counter & triggered bit */ @@ -665,7 +660,6 @@ dds_get_liveliness_changed_status ( } dds_reader_unlock(rd); fail: - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); return ret; } @@ -678,11 +672,10 @@ dds_return_t dds_get_sample_rejected_status ( dds_reader *rd; dds_return_t ret = DDS_RETCODE_OK; - DDS_REPORT_STACK(); - rc = dds_reader_lock(reader, &rd); if (rc != DDS_RETCODE_OK) { - ret = DDS_ERRNO(rc, "Error occurred on locking reader"); + DDS_ERROR("Error occurred on locking reader\n"); + ret = DDS_ERRNO(rc); goto fail; } /* status = NULL, application do not need the status, but reset the counter & triggered bit */ @@ -696,7 +689,6 @@ dds_return_t dds_get_sample_rejected_status ( } dds_reader_unlock(rd); fail: - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); return ret; } @@ -709,11 +701,10 @@ dds_return_t dds_get_sample_lost_status ( dds_reader *rd; dds_return_t ret = DDS_RETCODE_OK; - DDS_REPORT_STACK(); - rc = dds_reader_lock(reader, &rd); if (rc != DDS_RETCODE_OK) { - ret = DDS_ERRNO(rc, "Error occurred on locking reader"); + DDS_ERROR("Error occurred on locking reader\n"); + ret = DDS_ERRNO(rc); goto fail; } /* status = NULL, application do not need the status, but reset the counter & triggered bit */ @@ -726,7 +717,6 @@ dds_return_t dds_get_sample_lost_status ( } dds_reader_unlock(rd); fail: - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); return ret; } @@ -739,10 +729,10 @@ dds_return_t dds_get_requested_deadline_missed_status ( dds_reader *rd; dds_return_t ret = DDS_RETCODE_OK; - DDS_REPORT_STACK(); rc = dds_reader_lock(reader, &rd); if (rc != DDS_RETCODE_OK) { - ret = DDS_ERRNO(rc, "Error occurred on locking reader"); + DDS_ERROR("Error occurred on locking reader\n"); + ret = DDS_ERRNO(rc); goto fail; } /* status = NULL, application do not need the status, but reset the counter & triggered bit */ @@ -755,7 +745,6 @@ dds_return_t dds_get_requested_deadline_missed_status ( } dds_reader_unlock(rd); fail: - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); return ret; } @@ -768,11 +757,10 @@ dds_return_t dds_get_requested_incompatible_qos_status ( dds_reader *rd; dds_return_t ret = DDS_RETCODE_OK; - DDS_REPORT_STACK(); - rc = dds_reader_lock(reader, &rd); if (rc != DDS_RETCODE_OK) { - ret = DDS_ERRNO(rc, "Error occurred on locking reader"); + DDS_ERROR("Error occurred on locking reader\n"); + ret = DDS_ERRNO(rc); goto fail; } /* status = NULL, application do not need the status, but reset the counter & triggered bit */ @@ -785,6 +773,5 @@ dds_return_t dds_get_requested_incompatible_qos_status ( } dds_reader_unlock(rd); fail: - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); return ret; } diff --git a/src/core/ddsc/src/dds_report.c b/src/core/ddsc/src/dds_report.c deleted file mode 100644 index 13406a3..0000000 --- a/src/core/ddsc/src/dds_report.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright(c) 2006 to 2018 ADLINK Technology Limited and others - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License - * v. 1.0 which is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause - */ -#include "ddsc/dds.h" -#include "os/os.h" -#include "os/os_report.h" -#include -#include -#include "dds__report.h" - -void -dds_report( - os_reportType reportType, - const char *function, - int32_t line, - const char *file, - dds_return_t code, - const char *format, - ...) -{ - const char *retcode = NULL; - /* os_report truncates messages to bytes */ - char buffer[OS_REPORT_BUFLEN]; - size_t offset = 0; - va_list args; - - assert (function != NULL); - assert (file != NULL); - assert (format != NULL); - /* probably never happens, but you can never be to sure */ - assert (OS_REPORT_BUFLEN > 0); - - retcode = dds_err_str(code*-1); - offset = strlen(retcode); - assert (offset < OS_REPORT_BUFLEN); - (void)memcpy(buffer, retcode, offset); - buffer[offset] = ' '; - offset++; - - va_start (args, format); - (void)os_vsnprintf (buffer + offset, sizeof(buffer) - offset, format, args); - va_end (args); - os_report (reportType, function, file, line, code, "%s", buffer); -} - diff --git a/src/core/ddsc/src/dds_rhc.c b/src/core/ddsc/src/dds_rhc.c index 6f85b4d..72e4260 100644 --- a/src/core/ddsc/src/dds_rhc.c +++ b/src/core/ddsc/src/dds_rhc.c @@ -38,7 +38,6 @@ #include "ddsi/ddsi_serdata.h" #include "ddsi/ddsi_serdata_default.h" #include "ddsi/sysdeps.h" -#include "dds__report.h" /* INSTANCE MANAGEMENT =================== @@ -764,7 +763,7 @@ static void dds_rhc_register (struct rhc *rhc, struct rhc_instance *inst, uint64 { const uint64_t inst_wr_iid = inst->wr_iid_islive ? inst->wr_iid : 0; - TRACE ((" register:")); + DDS_TRACE(" register:"); /* Is an implicitly registering dispose semantically equivalent to register ; dispose? If so, both no_writers_gen and disposed_gen @@ -779,7 +778,7 @@ static void dds_rhc_register (struct rhc *rhc, struct rhc_instance *inst, uint64 /* Same writer as last time => we know it is registered already. This is the fast path -- we don't have to check anything else. */ - TRACE (("cached")); + DDS_TRACE("cached"); assert (inst->wrcount > 0); return; } @@ -797,7 +796,7 @@ static void dds_rhc_register (struct rhc *rhc, struct rhc_instance *inst, uint64 } inst->wrcount++; inst->no_writers_gen++; - TRACE (("new1")); + DDS_TRACE("new1"); if (!INST_IS_EMPTY (inst) && !inst->isdisposed) rhc->n_not_alive_no_writers--; @@ -822,14 +821,14 @@ static void dds_rhc_register (struct rhc *rhc, struct rhc_instance *inst, uint64 if (lwregs_add (&rhc->registrations, inst->iid, wr_iid)) { inst->wrcount++; - TRACE (("new2iidnull")); + DDS_TRACE("new2iidnull"); } else { int x = lwregs_delete (&rhc->registrations, inst->iid, wr_iid); assert (x); (void) x; - TRACE (("restore")); + DDS_TRACE("restore"); } /* to avoid wr_iid update when register is called for sample rejected */ if (iid_update) @@ -845,7 +844,7 @@ static void dds_rhc_register (struct rhc *rhc, struct rhc_instance *inst, uint64 if (inst->wrcount == 1) { /* 2nd writer => properly register the one we knew about */ - TRACE (("rescue1")); + DDS_TRACE("rescue1"); int x; x = lwregs_add (&rhc->registrations, inst->iid, inst_wr_iid); assert (x); @@ -856,12 +855,12 @@ static void dds_rhc_register (struct rhc *rhc, struct rhc_instance *inst, uint64 /* as soon as we reach at least two writers, we have to check the result of lwregs_add to know whether this sample registers a previously unknown writer or not */ - TRACE (("new3")); + DDS_TRACE("new3"); inst->wrcount++; } else { - TRACE (("known")); + DDS_TRACE("known"); } assert (inst->wrcount >= 2); /* the most recent writer gets the fast path */ @@ -890,7 +889,7 @@ static int rhc_unregister_isreg_w_sideeffects (struct rhc *rhc, const struct rhc /* Returns 1 if last registration just disappeared */ if (inst->wrcount == 0) { - TRACE (("unknown(#0)")); + DDS_TRACE("unknown(#0)"); return 0; } else if (inst->wrcount == 1 && inst->wr_iid_islive) @@ -898,23 +897,23 @@ static int rhc_unregister_isreg_w_sideeffects (struct rhc *rhc, const struct rhc assert(inst->wr_iid != 0); if (wr_iid != inst->wr_iid) { - TRACE (("unknown(cache)")); + DDS_TRACE("unknown(cache)"); return 0; } else { - TRACE (("last(cache)")); + DDS_TRACE("last(cache)"); return 1; } } else if (!lwregs_delete (&rhc->registrations, inst->iid, wr_iid)) { - TRACE (("unknown(regs)")); + DDS_TRACE("unknown(regs)"); return 0; } else { - TRACE (("delreg")); + DDS_TRACE("delreg"); /* If we transition from 2 to 1 writer, and we are deleting a writer other than the one cached in the instance, that means afterward there will be 1 writer, it will be cached, and its @@ -922,7 +921,7 @@ static int rhc_unregister_isreg_w_sideeffects (struct rhc *rhc, const struct rhc and wr_iid != 0 the wr_iid is not in "registrations") */ if (inst->wrcount == 2 && inst->wr_iid_islive && inst->wr_iid != wr_iid) { - TRACE ((",delreg(remain)")); + DDS_TRACE(",delreg(remain)"); lwregs_delete (&rhc->registrations, inst->iid, inst->wr_iid); } return 1; @@ -947,7 +946,7 @@ static int rhc_unregister_updateinst /* Reset the ownership strength to allow samples to be read from other writer(s) */ inst->strength = 0; - TRACE ((",clearcache")); + DDS_TRACE(",clearcache"); } return 0; } @@ -977,14 +976,14 @@ static int rhc_unregister_updateinst else if (inst->isdisposed) { /* No content left, no registrations left, so drop */ - TRACE ((",#0,empty,disposed,drop")); + DDS_TRACE(",#0,empty,disposed,drop"); drop_instance_noupdate_no_writers (rhc, inst); return 1; } else { /* Add invalid samples for transition to no-writers */ - TRACE ((",#0,empty,nowriters")); + DDS_TRACE(",#0,empty,nowriters"); assert (INST_IS_EMPTY (inst)); inst_set_invsample (rhc, inst); update_inst (rhc, inst, pwr_info, false, tstamp); @@ -1002,7 +1001,7 @@ static void dds_rhc_unregister ) { /* 'post' always gets set; instance may have been freed upon return. */ - TRACE ((" unregister:")); + DDS_TRACE(" unregister:"); if (!rhc_unregister_isreg_w_sideeffects (rhc, inst, pwr_info->iid)) { /* other registrations remain */ @@ -1141,13 +1140,13 @@ bool dds_rhc_store bool notify_data_available = true; bool delivered = true; - TRACE (("rhc_store(%"PRIx64",%"PRIx64" si %x has_data %d:", tk->m_iid, wr_iid, statusinfo, has_data)); + DDS_TRACE("rhc_store(%"PRIx64",%"PRIx64" si %x has_data %d:", tk->m_iid, wr_iid, statusinfo, has_data); if (!has_data && statusinfo == 0) { /* Write with nothing but a key -- I guess that would be a register, which we do implicitly. (Currently DDSI2 won't allow it through anyway.) */ - TRACE ((" ignore explicit register)\n")); + DDS_TRACE(" ignore explicit register)\n"); return delivered; } @@ -1166,12 +1165,12 @@ bool dds_rhc_store */ if (!has_data && !is_dispose) { - TRACE ((" disp/unreg on unknown instance")); + DDS_TRACE(" disp/unreg on unknown instance"); goto error_or_nochange; } else { - TRACE ((" new instance")); + DDS_TRACE(" new instance"); stored = rhc_store_new_instance (&post, rhc, pwr_info, sample, tk, has_data, &cb_data); if (stored != RHC_STORED) { @@ -1187,7 +1186,7 @@ bool dds_rhc_store will raise a SAMPLE_REJECTED, and indicate that the system should kill itself.) Not letting instances go to ALIVE or NEW based on a rejected sample - (no one knows, it seemed) */ - TRACE ((" instance rejects sample")); + DDS_TRACE(" instance rejects sample"); get_trigger_info (&pre, inst, true); @@ -1217,7 +1216,7 @@ bool dds_rhc_store { get_trigger_info (&pre, inst, true); - TRACE ((" wc %"PRIu32, inst->wrcount)); + DDS_TRACE(" wc %"PRIu32, inst->wrcount); if (has_data || is_dispose) { @@ -1245,7 +1244,7 @@ bool dds_rhc_store /* Sample arriving for a NOT_ALIVE instance => view state NEW */ if (has_data && not_alive) { - TRACE ((" notalive->alive")); + DDS_TRACE(" notalive->alive"); inst->isnew = 1; } @@ -1258,7 +1257,7 @@ bool dds_rhc_store and the operation is WD. */ if (has_data && inst->isdisposed) { - TRACE ((" disposed->notdisposed")); + DDS_TRACE(" disposed->notdisposed"); inst->isdisposed = 0; inst->disposed_gen++; } @@ -1266,17 +1265,17 @@ bool dds_rhc_store { inst->isdisposed = 1; inst_became_disposed = !old_isdisposed; - TRACE ((" dispose(%d)", inst_became_disposed)); + DDS_TRACE(" dispose(%d)", inst_became_disposed); } /* Only need to add a sample to the history if the input actually is a sample. */ if (has_data) { - TRACE ((" add_sample")); + DDS_TRACE(" add_sample"); if (! add_sample (rhc, inst, pwr_info, sample, &cb_data)) { - TRACE (("(reject)")); + DDS_TRACE("(reject)"); stored = RHC_REJECTED; goto error_or_nochange; } @@ -1338,7 +1337,7 @@ bool dds_rhc_store } } - TRACE ((")\n")); + DDS_TRACE(")\n"); /* do not send data available notification when an instance is dropped */ if ((post.qminst == ~0u) && (post.has_read == 0) && (post.has_not_read == 0) && (post.has_changed == false)) @@ -1377,7 +1376,7 @@ error_or_nochange: } os_mutexUnlock (&rhc->lock); - TRACE ((")\n")); + DDS_TRACE(")\n"); /* Make any reader status callback */ @@ -1411,7 +1410,7 @@ void dds_rhc_unregister_wr const int auto_dispose = pwr_info->auto_dispose; os_mutexLock (&rhc->lock); - TRACE (("rhc_unregister_wr_iid(%"PRIx64",%d:\n", wr_iid, auto_dispose)); + DDS_TRACE("rhc_unregister_wr_iid(%"PRIx64",%d:\n", wr_iid, auto_dispose); for (inst = ut_hhIterFirst (rhc->instances, &iter); inst; inst = ut_hhIterNext (&iter)) { if ((inst->wr_iid_islive && inst->wr_iid == wr_iid) || lwregs_contains (&rhc->registrations, inst->iid, wr_iid)) @@ -1419,7 +1418,7 @@ void dds_rhc_unregister_wr struct trigger_info pre, post; get_trigger_info (&pre, inst, true); - TRACE ((" %"PRIx64":", inst->iid)); + DDS_TRACE(" %"PRIx64":", inst->iid); assert (inst->wrcount > 0); if (auto_dispose && !inst->isdisposed) @@ -1445,7 +1444,7 @@ void dds_rhc_unregister_wr dds_rhc_unregister (&post, rhc, inst, pwr_info, inst->tstamp); - TRACE (("\n")); + DDS_TRACE("\n"); if (trigger_info_differs (&pre, &post)) { @@ -1458,7 +1457,7 @@ void dds_rhc_unregister_wr assert (rhc_check_counts_locked (rhc, true)); } } - TRACE ((")\n")); + DDS_TRACE(")\n"); os_mutexUnlock (&rhc->lock); if (trigger_waitsets) @@ -1472,7 +1471,7 @@ void dds_rhc_relinquish_ownership (struct rhc * __restrict rhc, const uint64_t w struct rhc_instance *inst; struct ut_hhIter iter; os_mutexLock (&rhc->lock); - TRACE (("rhc_relinquish_ownership(%"PRIx64":\n", wr_iid)); + DDS_TRACE("rhc_relinquish_ownership(%"PRIx64":\n", wr_iid); for (inst = ut_hhIterFirst (rhc->instances, &iter); inst; inst = ut_hhIterNext (&iter)) { if (inst->wr_iid_islive && inst->wr_iid == wr_iid) @@ -1480,7 +1479,7 @@ void dds_rhc_relinquish_ownership (struct rhc * __restrict rhc, const uint64_t w inst->wr_iid_islive = 0; } } - TRACE ((")\n")); + DDS_TRACE(")\n"); assert (rhc_check_counts_locked (rhc, true)); os_mutexUnlock (&rhc->lock); } @@ -1636,11 +1635,11 @@ static int dds_rhc_read_w_qminv os_mutexLock (&rhc->lock); } - TRACE (("read_w_qminv(%p,%p,%p,%u,%x) - inst %u nonempty %u disp %u nowr %u new %u samples %u+%u read %u+%u\n", + DDS_TRACE("read_w_qminv(%p,%p,%p,%u,%x) - inst %u nonempty %u disp %u nowr %u new %u samples %u+%u read %u+%u\n", (void *) rhc, (void *) values, (void *) info_seq, max_samples, qminv, rhc->n_instances, rhc->n_nonempty_instances, rhc->n_not_alive_disposed, rhc->n_not_alive_no_writers, rhc->n_new, rhc->n_vsamples, rhc->n_invsamples, - rhc->n_vread, rhc->n_invread)); + rhc->n_vread, rhc->n_invread); if (rhc->nonempty_instances) { @@ -1674,7 +1673,7 @@ static int dds_rhc_read_w_qminv { if (!sample->isread) { - TRACE (("s")); + DDS_TRACE("s"); sample->isread = true; inst->nvread++; rhc->n_vread++; @@ -1735,7 +1734,7 @@ static int dds_rhc_read_w_qminv } while (inst != end && n < max_samples); } - TRACE (("read: returning %u\n", n)); + DDS_TRACE("read: returning %u\n", n); assert (rhc_check_counts_locked (rhc, true)); os_mutexUnlock (&rhc->lock); @@ -1763,11 +1762,11 @@ static int dds_rhc_take_w_qminv os_mutexLock (&rhc->lock); } - TRACE (("take_w_qminv(%p,%p,%p,%u,%x) - inst %u nonempty %u disp %u nowr %u new %u samples %u+%u read %u+%u\n", + DDS_TRACE("take_w_qminv(%p,%p,%p,%u,%x) - inst %u nonempty %u disp %u nowr %u new %u samples %u+%u read %u+%u\n", (void*) rhc, (void*) values, (void*) info_seq, max_samples, qminv, rhc->n_instances, rhc->n_nonempty_instances, rhc->n_not_alive_disposed, rhc->n_not_alive_no_writers, rhc->n_new, rhc->n_vsamples, - rhc->n_invsamples, rhc->n_vread, rhc->n_invread)); + rhc->n_invsamples, rhc->n_vread, rhc->n_invread); if (rhc->nonempty_instances) { @@ -1877,7 +1876,7 @@ static int dds_rhc_take_w_qminv } if (inst->wrcount == 0) { - TRACE (("take: iid %"PRIx64" #0,empty,drop\n", iid)); + DDS_TRACE("take: iid %"PRIx64" #0,empty,drop\n", iid); if (!inst->isdisposed) { /* disposed has priority over no writers (why not just 2 bits?) */ @@ -1899,7 +1898,7 @@ static int dds_rhc_take_w_qminv inst = inst1; } } - TRACE (("take: returning %u\n", n)); + DDS_TRACE("take: returning %u\n", n); assert (rhc_check_counts_locked (rhc, true)); os_mutexUnlock (&rhc->lock); @@ -1928,11 +1927,11 @@ static int dds_rhc_takecdr_w_qminv os_mutexLock (&rhc->lock); } - TRACE (("take_w_qminv(%p,%p,%p,%u,%x) - inst %u nonempty %u disp %u nowr %u new %u samples %u+%u read %u+%u\n", + DDS_TRACE("take_w_qminv(%p,%p,%p,%u,%x) - inst %u nonempty %u disp %u nowr %u new %u samples %u+%u read %u+%u\n", (void*) rhc, (void*) values, (void*) info_seq, max_samples, qminv, rhc->n_instances, rhc->n_nonempty_instances, rhc->n_not_alive_disposed, rhc->n_not_alive_no_writers, rhc->n_new, rhc->n_vsamples, - rhc->n_invsamples, rhc->n_vread, rhc->n_invread)); + rhc->n_invsamples, rhc->n_vread, rhc->n_invread); if (rhc->nonempty_instances) { @@ -2028,7 +2027,7 @@ static int dds_rhc_takecdr_w_qminv } if (inst->wrcount == 0) { - TRACE (("take: iid %"PRIx64" #0,empty,drop\n", iid)); + DDS_TRACE("take: iid %"PRIx64" #0,empty,drop\n", iid); if (!inst->isdisposed) { /* disposed has priority over no writers (why not just 2 bits?) */ @@ -2050,7 +2049,7 @@ static int dds_rhc_takecdr_w_qminv inst = inst1; } } - TRACE (("take: returning %u\n", n)); + DDS_TRACE("take: returning %u\n", n); assert (rhc_check_counts_locked (rhc, true)); os_mutexUnlock (&rhc->lock); @@ -2084,7 +2083,7 @@ static uint32_t rhc_get_cond_trigger (struct rhc_instance * const inst, const dd m = m && !INST_IS_EMPTY (inst); break; default: - NN_FATAL ("update_readconditions: sample_states invalid: %x\n", c->m_sample_states); + DDS_FATAL("update_readconditions: sample_states invalid: %x\n", c->m_sample_states); } return m ? 1 : 0; } @@ -2118,9 +2117,9 @@ void dds_rhc_add_readcondition (dds_readcond * cond) rhc->nconds++; rhc->conds = cond; - TRACE (("add_readcondition(%p, %x, %x, %x) => %p qminv %x ; rhc %u conds\n", + DDS_TRACE("add_readcondition(%p, %x, %x, %x) => %p qminv %x ; rhc %u conds\n", (void *) rhc, cond->m_sample_states, cond->m_view_states, - cond->m_instance_states, cond, cond->m_qminv, rhc->nconds)); + cond->m_instance_states, cond, cond->m_qminv, rhc->nconds); os_mutexUnlock (&rhc->conds_lock); os_mutexUnlock (&rhc->lock); @@ -2172,9 +2171,9 @@ static bool update_conditions_locked const struct dds_topic_descriptor *desc = rhc->topic->status_cb_entity->m_descriptor; char *tmp = NULL; - TRACE (("update_conditions_locked(%p) - inst %u nonempty %u disp %u nowr %u new %u samples %u read %u\n", + DDS_TRACE("update_conditions_locked(%p) - inst %u nonempty %u disp %u nowr %u new %u samples %u read %u\n", (void *) rhc, rhc->n_instances, rhc->n_nonempty_instances, rhc->n_not_alive_disposed, - rhc->n_not_alive_no_writers, rhc->n_new, rhc->n_vsamples, rhc->n_vread)); + rhc->n_not_alive_no_writers, rhc->n_new, rhc->n_vsamples, rhc->n_vread); assert (rhc->n_nonempty_instances >= rhc->n_not_alive_disposed + rhc->n_not_alive_no_writers); assert (rhc->n_nonempty_instances >= rhc->n_new); @@ -2203,13 +2202,13 @@ static bool update_conditions_locked m_post = m_post && (post->has_read + post->has_not_read); break; default: - NN_FATAL ("update_readconditions: sample_states invalid: %x\n", iter->m_sample_states); + DDS_FATAL("update_readconditions: sample_states invalid: %x\n", iter->m_sample_states); } - TRACE ((" cond %p: ", (void *) iter)); + DDS_TRACE(" cond %p: ", (void *) iter); if (m_pre == m_post) { - TRACE (("no change")); + DDS_TRACE("no change"); } else if (m_pre < m_post) { @@ -2226,27 +2225,27 @@ static bool update_conditions_locked || (iter->m_query.m_filter != NULL && iter->m_query.m_filter (tmp)) ) { - TRACE (("now matches")); + DDS_TRACE("now matches"); if (iter->m_entity.m_trigger++ == 0) { - TRACE ((" (cond now triggers)")); + DDS_TRACE(" (cond now triggers)"); trigger = true; } } } else { - TRACE (("no longer matches")); + DDS_TRACE("no longer matches"); if (--iter->m_entity.m_trigger == 0) { - TRACE ((" (cond no longer triggers)")); + DDS_TRACE(" (cond no longer triggers)"); } } if (iter->m_entity.m_trigger) { dds_entity_status_signal(&(iter->m_entity)); } - TRACE (("\n")); + DDS_TRACE("\n"); iter = iter->m_rhc_next; } diff --git a/src/core/ddsc/src/dds_stream.c b/src/core/ddsc/src/dds_stream.c index d98d580..339a73b 100644 --- a/src/core/ddsc/src/dds_stream.c +++ b/src/core/ddsc/src/dds_stream.c @@ -165,7 +165,7 @@ size_t dds_stream_check_optimize (_In_ const dds_topic_descriptor_t * desc) dds_sample_free_contents (sample, desc->m_ops); dds_free (sample); dds_stream_fini (&os); - dds_log_info ("Marshalling for type: %s is%s optimised\n", desc->m_typename, size ? "" : " not"); + DDS_INFO("Marshalling for type: %s is%s optimised\n", desc->m_typename, size ? "" : " not"); return size; } @@ -490,7 +490,7 @@ static void dds_stream_write { type = DDS_OP_TYPE (op); #ifdef OP_DEBUG_WRITE - TRACE (("W-ADR: %s offset %d\n", stream_op_type[type], ops[1])); + DDS_TRACE("W-ADR: %s offset %d\n", stream_op_type[type], ops[1]); #endif addr = data + ops[1]; ops += 2; @@ -519,7 +519,7 @@ static void dds_stream_write case DDS_OP_VAL_STR: { #ifdef OP_DEBUG_WRITE - TRACE (("W-STR: %s\n", *((char**) addr))); + DDS_TRACE("W-STR: %s\n", *((char**) addr)); #endif dds_stream_write_string (os, *((char**) addr)); break; @@ -531,7 +531,7 @@ static void dds_stream_write num = seq->_length; #ifdef OP_DEBUG_WRITE - TRACE (("W-SEQ: %s <%d>\n", stream_op_type[subtype], num)); + DDS_TRACE("W-SEQ: %s <%d>\n", stream_op_type[subtype], num); #endif DDS_OS_PUT4 (os, num, uint32_t); if (num || (subtype > DDS_OP_VAL_STR)) @@ -558,7 +558,7 @@ static void dds_stream_write while (num--) { #ifdef OP_DEBUG_WRITE - TRACE (("W-SEQ STR: %s\n", *ptr)); + DDS_TRACE("W-SEQ STR: %s\n", *ptr); #endif dds_stream_write_string (os, *ptr); ptr++; @@ -572,7 +572,7 @@ static void dds_stream_write while (num--) { #ifdef OP_DEBUG_WRITE - TRACE (("W-SEQ BST[%d]: %s\n", align, ptr)); + DDS_TRACE("W-SEQ BST[%d]: %s\n", align, ptr); #endif dds_stream_write_string (os, ptr); ptr += align; @@ -603,7 +603,7 @@ static void dds_stream_write num = *ops++; #ifdef OP_DEBUG_WRITE - TRACE (("W-ARR: %s [%d]\n", stream_op_type[subtype], num)); + DDS_TRACE("W-ARR: %s [%d]\n", stream_op_type[subtype], num); #endif switch (subtype) { @@ -693,7 +693,7 @@ static void dds_stream_write default: assert (0); } #ifdef OP_DEBUG_WRITE - TRACE (("W-UNI: switch %s case %d/%d\n", stream_op_type[subtype], disc, num)); + DDS_TRACE("W-UNI: switch %s case %d/%d\n", stream_op_type[subtype], disc, num); #endif /* Write case matching discriminant */ @@ -710,7 +710,7 @@ static void dds_stream_write addr = data + jeq_op[2]; #ifdef OP_DEBUG_WRITE - TRACE (("W-UNI: case type %s\n", stream_op_type[subtype])); + DDS_TRACE("W-UNI: case type %s\n", stream_op_type[subtype]); #endif switch (subtype) { @@ -753,7 +753,7 @@ static void dds_stream_write case DDS_OP_VAL_BST: { #ifdef OP_DEBUG_WRITE - TRACE (("W-BST: %s\n", (char*) addr)); + DDS_TRACE("W-BST: %s\n", (char*) addr); #endif dds_stream_write_string (os, (char*) addr); ops++; @@ -766,7 +766,7 @@ static void dds_stream_write case DDS_OP_JSR: /* Implies nested type */ { #ifdef OP_DEBUG_WRITE - TRACE (("W-JSR: %d\n", DDS_OP_JUMP (op))); + DDS_TRACE("W-JSR: %d\n", DDS_OP_JUMP (op)); #endif dds_stream_write (os, data, ops + DDS_OP_JUMP (op)); ops++; @@ -776,7 +776,7 @@ static void dds_stream_write } } #ifdef OP_DEBUG_WRITE - TRACE (("W-RTS:\n")); + DDS_TRACE("W-RTS:\n"); #endif } @@ -797,7 +797,7 @@ static void dds_stream_read (dds_stream_t * is, char * data, const uint32_t * op { type = DDS_OP_TYPE (op); #ifdef OP_DEBUG_READ - TRACE (("R-ADR: %s offset %d\n", stream_op_type[type], ops[1])); + DDS_TRACE("R-ADR: %s offset %d\n", stream_op_type[type], ops[1]); #endif addr = data + ops[1]; ops += 2; @@ -826,7 +826,7 @@ static void dds_stream_read (dds_stream_t * is, char * data, const uint32_t * op case DDS_OP_VAL_STR: { #ifdef OP_DEBUG_READ - TRACE (("R-STR: @ %p\n", addr)); + DDS_TRACE("R-STR: @ %p\n", addr); #endif *(char**) addr = dds_stream_reuse_string (is, *((char**) addr), 0); break; @@ -838,7 +838,7 @@ static void dds_stream_read (dds_stream_t * is, char * data, const uint32_t * op num = dds_stream_read_uint32 (is); #ifdef OP_DEBUG_READ - TRACE (("R-SEQ: %s <%d>\n", stream_op_type[subtype], num)); + DDS_TRACE("R-SEQ: %s <%d>\n", stream_op_type[subtype], num); #endif /* Maintain max sequence length (may not have been set by caller) */ @@ -987,7 +987,7 @@ static void dds_stream_read (dds_stream_t * is, char * data, const uint32_t * op num = *ops++; #ifdef OP_DEBUG_READ - TRACE (("R-ARR: %s [%d]\n", stream_op_type[subtype], num)); + DDS_TRACE("R-ARR: %s [%d]\n", stream_op_type[subtype], num); #endif switch (subtype) { @@ -1080,7 +1080,7 @@ static void dds_stream_read (dds_stream_t * is, char * data, const uint32_t * op } #ifdef OP_DEBUG_READ - TRACE (("R-UNI: switch %s case %d/%d\n", stream_op_type[subtype], disc, num)); + DDS_TRACE("R-UNI: switch %s case %d/%d\n", stream_op_type[subtype], disc, num); #endif /* Read case matching discriminant */ @@ -1094,7 +1094,7 @@ static void dds_stream_read (dds_stream_t * is, char * data, const uint32_t * op addr = data + jeq_op[2]; #ifdef OP_DEBUG_READ - TRACE (("R-UNI: case type %s\n", stream_op_type[subtype])); + DDS_TRACE("R-UNI: case type %s\n", stream_op_type[subtype]); #endif switch (subtype) { @@ -1142,7 +1142,7 @@ static void dds_stream_read (dds_stream_t * is, char * data, const uint32_t * op case DDS_OP_VAL_BST: { #ifdef OP_DEBUG_READ - TRACE (("R-BST: @ %p\n", addr)); + DDS_TRACE("R-BST: @ %p\n", addr); #endif dds_stream_reuse_string (is, (char*) addr, *ops); ops++; @@ -1155,7 +1155,7 @@ static void dds_stream_read (dds_stream_t * is, char * data, const uint32_t * op case DDS_OP_JSR: /* Implies nested type */ { #ifdef OP_DEBUG_READ - TRACE (("R-JSR: %d\n", DDS_OP_JUMP (op))); + DDS_TRACE("R-JSR: %d\n", DDS_OP_JUMP (op)); #endif dds_stream_read (is, data, ops + DDS_OP_JUMP (op)); ops++; @@ -1165,7 +1165,7 @@ static void dds_stream_read (dds_stream_t * is, char * data, const uint32_t * op } } #ifdef OP_DEBUG_READ - TRACE (("R-RTS:\n")); + DDS_TRACE("R-RTS:\n"); #endif } @@ -1304,7 +1304,7 @@ uint32_t dds_stream_extract_key (dds_stream_t *is, dds_stream_t *os, const uint3 #ifdef OP_DEBUG_KEY if (is_key) { - TRACE (("K-ADR: %s\n", stream_op_type[type])); + DDS_TRACE("K-ADR: %s\n", stream_op_type[type]); } #endif switch (type) @@ -1347,7 +1347,7 @@ uint32_t dds_stream_extract_key (dds_stream_t *is, dds_stream_t *os, const uint3 DDS_OS_PUT4 (os, len, uint32_t); DDS_OS_PUT_BYTES(os, DDS_CDR_ADDRESS (is, void), len); #ifdef OP_DEBUG_KEY - TRACE (("K-ADR: String/BString (%d)\n", len)); + DDS_TRACE("K-ADR: String/BString (%d)\n", len); #endif } is->m_index += len; @@ -1417,7 +1417,7 @@ uint32_t dds_stream_extract_key (dds_stream_t *is, dds_stream_t *os, const uint3 #ifdef OP_DEBUG_KEY if (is_key) { - TRACE (("K-ADR: %s[%d]\n", stream_op_type[subtype], num)); + DDS_TRACE("K-ADR: %s[%d]\n", stream_op_type[subtype], num); } #endif switch (subtype) @@ -1479,7 +1479,7 @@ uint32_t dds_stream_extract_key (dds_stream_t *is, dds_stream_t *os, const uint3 assert (! is_key); #ifdef OP_DEBUG_KEY - TRACE (("K-UNI: switch %s cases %d\n", stream_op_type[subtype], num)); + DDS_TRACE("K-UNI: switch %s cases %d\n", stream_op_type[subtype], num); #endif /* Read discriminant */ diff --git a/src/core/ddsc/src/dds_subscriber.c b/src/core/ddsc/src/dds_subscriber.c index 8f313c1..b11ae58 100644 --- a/src/core/ddsc/src/dds_subscriber.c +++ b/src/core/ddsc/src/dds_subscriber.c @@ -14,7 +14,6 @@ #include "dds__qos.h" #include "dds__err.h" #include "ddsi/q_entity.h" -#include "dds__report.h" #include "ddsc/ddsc_project.h" #define DDS_SUBSCRIBER_STATUS_MASK \ @@ -28,7 +27,8 @@ dds_subscriber_instance_hdl( (void)e; (void)i; /* TODO: Get/generate proper handle. */ - return DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, "Generating subscriber instance handle is not supported"); + DDS_ERROR("Generating subscriber instance handle is not supported"); + return DDS_ERRNO(DDS_RETCODE_UNSUPPORTED); } static dds_return_t @@ -41,20 +41,25 @@ dds__subscriber_qos_validate( assert(qos); if((qos->present & QP_GROUP_DATA) && !validate_octetseq(&qos->group_data)) { - ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "Group data policy is inconsistent and caused an error"); + DDS_ERROR("Group data policy is inconsistent and caused an error\n"); + ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY); } if((qos->present & QP_PARTITION) && !validate_stringseq(&qos->partition)) { - ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "Partition policy is inconsistent and caused an error"); + DDS_ERROR("Partition policy is inconsistent and caused an error\n"); + ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY); } if((qos->present & QP_PRESENTATION) && validate_presentation_qospolicy(&qos->presentation)) { - ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "Presentation policy is inconsistent and caused an error"); + DDS_ERROR("Presentation policy is inconsistent and caused an error\n"); + ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY); } if((qos->present & QP_PRISMTECH_ENTITY_FACTORY) && !validate_entityfactory_qospolicy(&qos->entity_factory)) { - ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "Prismtech entity factory policy is inconsistent and caused an error"); + DDS_ERROR("Prismtech entity factory policy is inconsistent and caused an error\n"); + ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY); } if(ret == DDS_RETCODE_OK && enabled && (qos->present & QP_PRESENTATION)) { /* TODO: Improve/check immutable check. */ - ret = DDS_ERRNO(DDS_RETCODE_IMMUTABLE_POLICY, "Presentation QoS policy is immutable"); + DDS_ERROR("Presentation QoS policy is immutable\n"); + ret = DDS_ERRNO(DDS_RETCODE_IMMUTABLE_POLICY); } return ret; @@ -71,7 +76,8 @@ dds_subscriber_qos_set( if (ret == DDS_RETCODE_OK) { if (enabled) { /* TODO: CHAM-95: DDSI does not support changing QoS policies. */ - ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, DDSC_PROJECT_NAME" does not support changing QoS policies yet"); + DDS_ERROR(DDSC_PROJECT_NAME" does not support changing QoS policies yet\n"); + ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED); } } return ret; @@ -81,9 +87,14 @@ static dds_return_t dds_subscriber_status_validate( uint32_t mask) { - return (mask & ~(DDS_SUBSCRIBER_STATUS_MASK)) ? - DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Invalid status mask") : - DDS_RETCODE_OK; + dds_return_t ret = DDS_RETCODE_OK; + + if (mask & ~(DDS_SUBSCRIBER_STATUS_MASK)) { + DDS_ERROR("Invalid status mask\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); + } + + return ret; } /* @@ -159,18 +170,16 @@ dds_create_subscriber( dds_entity_t hdl; dds__retcode_t errnr; - DDS_REPORT_STACK(); - errnr = dds_entity_lock(participant, DDS_KIND_PARTICIPANT, &par); if (errnr != DDS_RETCODE_OK) { - hdl = DDS_ERRNO(errnr, "Error occurred on locking participant"); + DDS_ERROR("Error occurred on locking participant\n"); + hdl = DDS_ERRNO(errnr); return hdl; } hdl = dds__create_subscriber_l(par, qos, listener); dds_entity_unlock(par); - DDS_REPORT_FLUSH(hdl <= 0); return hdl; } @@ -184,12 +193,11 @@ dds_notify_readers( dds__retcode_t errnr; dds_return_t ret; - DDS_REPORT_STACK(); - errnr = dds_entity_lock(subscriber, DDS_KIND_SUBSCRIBER, &sub); if (errnr == DDS_RETCODE_OK) { errnr = DDS_RETCODE_UNSUPPORTED; - ret = DDS_ERRNO(errnr, "Unsupported operation"); + DDS_ERROR("Unsupported operation\n"); + ret = DDS_ERRNO(errnr); iter = sub->m_children; while (iter) { os_mutexLock(&iter->m_mutex); @@ -199,10 +207,10 @@ dds_notify_readers( } dds_entity_unlock(sub); } else { - ret = DDS_ERRNO(errnr, "Error occurred on locking subscriber"); + DDS_ERROR("Error occurred on locking subscriber\n"); + ret = DDS_ERRNO(errnr); } - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); return ret; } @@ -212,7 +220,8 @@ dds_subscriber_begin_coherent( { /* TODO: CHAM-124 Currently unsupported. */ (void)e; - return DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, "Using coherency to get a coherent data set is not currently being supported"); + DDS_ERROR("Using coherency to get a coherent data set is not currently being supported\n"); + return DDS_ERRNO(DDS_RETCODE_UNSUPPORTED); } dds_return_t @@ -221,6 +230,7 @@ dds_subscriber_end_coherent( { /* TODO: CHAM-124 Currently unsupported. */ (void)e; - return DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, "Using coherency to get a coherent data set is not currently being supported"); + DDS_ERROR("Using coherency to get a coherent data set is not currently being supported\n"); + return DDS_ERRNO(DDS_RETCODE_UNSUPPORTED); } diff --git a/src/core/ddsc/src/dds_tkmap.c b/src/core/ddsc/src/dds_tkmap.c index 6348226..951ede2 100644 --- a/src/core/ddsc/src/dds_tkmap.c +++ b/src/core/ddsc/src/dds_tkmap.c @@ -234,7 +234,7 @@ retry: if (tk && rd) { - TRACE (("tk=%p iid=%"PRIx64" ", &tk, tk->m_iid)); + DDS_TRACE("tk=%p iid=%"PRIx64" ", &tk, tk->m_iid); } return tk; } diff --git a/src/core/ddsc/src/dds_topic.c b/src/core/ddsc/src/dds_topic.c index 4d2d981..5e88b9d 100644 --- a/src/core/ddsc/src/dds_topic.c +++ b/src/core/ddsc/src/dds_topic.c @@ -24,7 +24,6 @@ #include "ddsi/ddsi_sertopic.h" #include "ddsi/q_ddsi_discovery.h" #include "os/os_atomics.h" -#include "dds__report.h" #include "dds__iid.h" #define DDS_TOPIC_STATUS_MASK \ @@ -82,9 +81,14 @@ static dds_return_t dds_topic_status_validate( uint32_t mask) { - return (mask & ~(DDS_TOPIC_STATUS_MASK)) ? - DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument mask is invalid") : - DDS_RETCODE_OK; + dds_return_t ret = DDS_RETCODE_OK; + + if (mask & ~(DDS_TOPIC_STATUS_MASK)) { + DDS_ERROR("Argument mask is invalid\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); + } + + return ret; } /* @@ -99,11 +103,7 @@ dds_topic_status_cb( dds_topic *topic; dds__retcode_t rc; - DDS_REPORT_STACK(); - if (dds_topic_lock(((dds_entity*)cb_t)->m_hdl, &topic) != DDS_RETCODE_OK) { - /* There's a deletion or closing going on. */ - DDS_REPORT_FLUSH(false); return; } assert(topic == cb_t); @@ -147,8 +147,6 @@ dds_topic_status_cb( } else { /* Something went wrong up the hierarchy. */ } - - DDS_REPORT_FLUSH(rc != DDS_RETCODE_OK); } struct ddsi_sertopic * @@ -225,8 +223,6 @@ dds_find_topic( struct ddsi_sertopic *st; dds__retcode_t rc; - DDS_REPORT_STACK(); - if (name) { rc = dds_entity_lock(participant, DDS_KIND_PARTICIPANT, &p); if (rc == DDS_RETCODE_OK) { @@ -236,17 +232,20 @@ dds_find_topic( dds_entity_add_ref (&st->status_cb_entity->m_entity); tp = st->status_cb_entity->m_entity.m_hdl; } else { - tp = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET, "Topic is not being created yet"); + DDS_ERROR("Topic is not being created yet\n"); + tp = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET); } os_mutexUnlock (&dds_global.m_mutex); dds_entity_unlock(p); } else { - tp = DDS_ERRNO(rc, "Error occurred on locking entity"); + DDS_ERROR("Error occurred on locking entity\n"); + tp = DDS_ERRNO(rc); } } else { - tp = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument name is not valid"); + DDS_ERROR("Argument name is not valid\n"); + tp = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); } - DDS_REPORT_FLUSH(tp <= 0); + return tp; } @@ -266,22 +265,26 @@ dds_topic_qos_validate( dds_return_t ret = DDS_RETCODE_OK; assert(qos); - /* Check consistency. */ if (!dds_qos_validate_common(qos)) { - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is not valid"); + DDS_ERROR("Argument QoS is not valid\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); } if ((qos->present & QP_GROUP_DATA) && !validate_octetseq (&qos->group_data)) { - ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "Group data QoS policy is inconsistent and caused an error"); + DDS_ERROR("Group data QoS policy is inconsistent and caused an error\n"); + ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY); } if ((qos->present & QP_DURABILITY_SERVICE) && (validate_durability_service_qospolicy(&qos->durability_service) != 0)) { - ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "Durability service QoS policy is inconsistent and caused an error"); + DDS_ERROR("Durability service QoS policy is inconsistent and caused an error\n"); + ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY); } if ((qos->present & QP_LIFESPAN) && (validate_duration(&qos->lifespan.duration) != 0)) { - ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "Lifespan QoS policy is inconsistent and caused an error"); + DDS_ERROR("Lifespan QoS policy is inconsistent and caused an error\n"); + ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY); } if (qos->present & QP_HISTORY && (qos->present & QP_RESOURCE_LIMITS) && (validate_history_and_resource_limits(&qos->history, &qos->resource_limits) != 0)) { - ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "Lifespan QoS policy is inconsistent and caused an error"); + DDS_ERROR("Lifespan QoS policy is inconsistent and caused an error\n"); + ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY); } if(ret == DDS_RETCODE_OK && enabled){ ret = dds_qos_validate_mutable_common(qos); @@ -301,7 +304,8 @@ dds_topic_qos_set( if (ret == DDS_RETCODE_OK) { if (enabled) { /* TODO: CHAM-95: DDSI does not support changing QoS policies. */ - ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, "Changing the topic QoS is not supported."); + DDS_ERROR("Changing the topic QoS is not supported\n"); + ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED); } } return ret; @@ -342,26 +346,28 @@ dds_create_topic( const bool asleep = !vtime_awake_p (thr->vtime); uint32_t index; - DDS_REPORT_STACK(); - if (desc == NULL){ - hdl = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Topic description is NULL"); + DDS_ERROR("Topic description is NULL\n"); + hdl = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); goto bad_param_err; } if (name == NULL) { - hdl = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Topic name is NULL"); + DDS_ERROR("Topic name is NULL\n"); + hdl = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); goto bad_param_err; } if (!is_valid_name(name)) { - hdl = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Topic name contains characters that are not allowed."); + DDS_ERROR("Topic name contains characters that are not allowed\n"); + hdl = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); goto bad_param_err; } rc = dds_entity_lock(participant, DDS_KIND_PARTICIPANT, &par); if (rc != DDS_RETCODE_OK) { - hdl = DDS_ERRNO(rc, "Error occurred on locking entity"); + DDS_ERROR("Error occurred on locking entity\n"); + hdl = DDS_ERRNO(rc); goto lock_err; } @@ -381,10 +387,12 @@ dds_create_topic( st = (struct ddsi_sertopic_default *)stgeneric; if (st->type != desc) { /* FIXME: should copy the type, perhaps? but then the pointers will no longer be the same */ - hdl = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET, "Create topic with mismatching type."); + DDS_ERROR("Create topic with mismatching type\n"); + hdl = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET); } else if (!dupdef_qos_ok(qos, stgeneric)) { /* FIXME: should copy the type, perhaps? but then the pointers will no longer be the same */ - hdl = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "Create topic with mismatching qos."); + DDS_ERROR("Create topic with mismatching qos\n"); + hdl = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY); } else { dds_entity_add_ref (&st->c.status_cb_entity->m_entity); hdl = st->c.status_cb_entity->m_entity.m_hdl; @@ -483,7 +491,6 @@ qos_err: dds_entity_unlock(par); lock_err: bad_param_err: - DDS_REPORT_FLUSH(hdl <= 0); return hdl; } @@ -571,14 +578,14 @@ dds_get_name( dds_return_t ret; dds__retcode_t rc; - DDS_REPORT_STACK(); - if(size <= 0){ - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument size is smaller than 0"); + DDS_ERROR("Argument size is smaller than 0\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); goto fail; } if(name == NULL){ - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument name is NULL"); + DDS_ERROR("Argument name is NULL\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); goto fail; } name[0] = '\0'; @@ -588,11 +595,11 @@ dds_get_name( dds_topic_unlock(t); ret = DDS_RETCODE_OK; } else { - ret = DDS_ERRNO(rc, "Error occurred on locking topic"); + DDS_ERROR("Error occurred on locking topic\n"); + ret = DDS_ERRNO(rc); goto fail; } fail: - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); return ret; } @@ -607,27 +614,27 @@ dds_get_type_name( dds__retcode_t rc; dds_return_t ret; - DDS_REPORT_STACK(); - if(size <= 0){ - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument size is smaller than 0"); + DDS_ERROR("Argument size is smaller than 0\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); goto fail; } if(name == NULL){ - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument name is NULL"); + DDS_ERROR("Argument name is NULL\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); goto fail; } name[0] = '\0'; rc = dds_topic_lock(topic, &t); if (rc != DDS_RETCODE_OK) { - ret = DDS_ERRNO(rc, "Error occurred on locking topic"); + DDS_ERROR("Error occurred on locking topic\n"); + ret = DDS_ERRNO(rc); goto fail; } (void)snprintf(name, size, "%s", t->m_stopic->typename); dds_topic_unlock(t); ret = DDS_RETCODE_OK; fail: - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); return ret; } _Pre_satisfies_((topic & DDS_ENTITY_KIND_MASK) == DDS_KIND_TOPIC) @@ -640,11 +647,10 @@ dds_get_inconsistent_topic_status( dds_topic *t; dds_return_t ret = DDS_RETCODE_OK; - DDS_REPORT_STACK(); - rc = dds_topic_lock(topic, &t); if (rc != DDS_RETCODE_OK) { - ret = DDS_ERRNO(rc, "Error occurred on locking topic"); + DDS_ERROR("Error occurred on locking topic\n"); + ret = DDS_ERRNO(rc); goto fail; } /* status = NULL, application do not need the status, but reset the counter & triggered bit */ @@ -657,6 +663,5 @@ dds_get_inconsistent_topic_status( } dds_topic_unlock(t); fail: - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); return ret; } diff --git a/src/core/ddsc/src/dds_waitset.c b/src/core/ddsc/src/dds_waitset.c index 35a7876..3d927c5 100644 --- a/src/core/ddsc/src/dds_waitset.c +++ b/src/core/ddsc/src/dds_waitset.c @@ -16,7 +16,6 @@ #include "dds__readcond.h" #include "dds__rhc.h" #include "dds__err.h" -#include "dds__report.h" #define dds_waitset_lock(hdl, obj) dds_entity_lock(hdl, DDS_KIND_WAITSET, (dds_entity**)obj) @@ -72,10 +71,12 @@ dds_waitset_wait_impl( dds_attachment *prev; if ((xs == NULL) && (nxs != 0)){ - return DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "A size was given, but no array."); + DDS_ERROR("A size was given, but no array\n"); + return DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); } if ((xs != NULL) && (nxs == 0)){ - return DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Array is given with an invalid size"); + DDS_ERROR("Array is given with an invalid size\n"); + return DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); } /* Locking the waitset here will delay a possible deletion until it is @@ -152,12 +153,14 @@ dds_waitset_wait_impl( } else if (rc == DDS_RETCODE_TIMEOUT) { ret = 0; } else { - ret = DDS_ERRNO(rc, "Internal error"); + DDS_ERROR("Internal error"); + ret = DDS_ERRNO(rc); } dds_waitset_unlock(ws); } else { - ret = DDS_ERRNO(rc, "Error occurred on locking waitset"); + DDS_ERROR("Error occurred on locking waitset\n"); + ret = DDS_ERRNO(rc); } return ret; @@ -229,8 +232,6 @@ dds_create_waitset( dds_entity *par; dds__retcode_t rc; - DDS_REPORT_STACK(); - rc = dds_entity_lock(participant, DDS_KIND_PARTICIPANT, &par); if (rc == DDS_RETCODE_OK) { dds_waitset *waitset = dds_alloc(sizeof(*waitset)); @@ -240,9 +241,10 @@ dds_create_waitset( waitset->triggered = NULL; dds_entity_unlock(par); } else { - hdl = DDS_ERRNO(rc, "Error occurred on locking entity"); + DDS_ERROR("Error occurred on locking entity\n"); + hdl = DDS_ERRNO(rc); } - DDS_REPORT_FLUSH(hdl <= 0); + return hdl; } @@ -258,8 +260,6 @@ dds_waitset_get_entities( dds__retcode_t rc; dds_waitset *ws; - DDS_REPORT_STACK(); - rc = dds_waitset_lock(waitset, &ws); if (rc == DDS_RETCODE_OK) { dds_attachment* iter; @@ -283,9 +283,10 @@ dds_waitset_get_entities( } dds_waitset_unlock(ws); } else { - ret = DDS_ERRNO(rc, "Error occurred on locking waitset"); + DDS_ERROR("Error occurred on locking waitset\n"); + ret = DDS_ERRNO(rc); } - DDS_REPORT_FLUSH(ret < 0); + return ret; } @@ -359,8 +360,6 @@ dds_waitset_attach( dds__retcode_t rc; dds_return_t ret; - DDS_REPORT_STACK(); - rc = dds_waitset_lock(waitset, &ws); if (rc == DDS_RETCODE_OK) { if (waitset != entity) { @@ -390,18 +389,21 @@ dds_waitset_attach( } ret = DDS_RETCODE_OK; } else if (rc != DDS_RETCODE_PRECONDITION_NOT_MET) { - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Entity is not valid"); + DDS_ERROR("Entity is not valid\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); } else { - ret = DDS_ERRNO(rc, "Entity is already attached."); + DDS_ERROR("Entity is already attached\n"); + ret = DDS_ERRNO(rc); } if ((e != NULL) && (waitset != entity)) { dds_entity_unlock(e); } dds_waitset_unlock(ws); } else { - ret = DDS_ERRNO(rc, "Error occurred on locking waitset"); + DDS_ERROR("Error occurred on locking waitset\n"); + ret = DDS_ERRNO(rc); } - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK ); + return ret; } @@ -415,8 +417,6 @@ dds_waitset_detach( dds__retcode_t rc; dds_return_t ret; - DDS_REPORT_STACK(); - rc = dds_waitset_lock(waitset, &ws); if (rc == DDS_RETCODE_OK) { /* Possibly fails when entity was not attached. */ @@ -429,15 +429,18 @@ dds_waitset_detach( dds_waitset_remove(ws, entity); ret = DDS_RETCODE_OK; } else if (rc != DDS_RETCODE_PRECONDITION_NOT_MET) { - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "The given entity to detach is invalid."); + DDS_ERROR("The given entity to detach is invalid\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); } else { - ret = DDS_ERRNO(rc, "The given entity to detach was not attached previously."); + DDS_ERROR("The given entity to detach was not attached previously\n"); + ret = DDS_ERRNO(rc); } dds_waitset_unlock(ws); } else { - ret = DDS_ERRNO(rc, "Error occurred on locking waitset"); + DDS_ERROR("Error occurred on locking waitset\n"); + ret = DDS_ERRNO(rc); } - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); + return ret; } @@ -449,11 +452,7 @@ dds_waitset_wait_until( _In_ size_t nxs, _In_ dds_time_t abstimeout) { - dds_return_t ret; - DDS_REPORT_STACK(); - ret = dds_waitset_wait_impl(waitset, xs, nxs, abstimeout, dds_time()); - DDS_REPORT_FLUSH(ret <0 ); - return ret; + return dds_waitset_wait_impl(waitset, xs, nxs, abstimeout, dds_time()); } _Pre_satisfies_((waitset & DDS_ENTITY_KIND_MASK) == DDS_KIND_WAITSET) @@ -465,16 +464,16 @@ dds_waitset_wait( _In_ dds_duration_t reltimeout) { dds_entity_t ret; - DDS_REPORT_STACK(); if (reltimeout >= 0) { dds_time_t tnow = dds_time(); dds_time_t abstimeout = (DDS_INFINITY - reltimeout <= tnow) ? DDS_NEVER : (tnow + reltimeout); ret = dds_waitset_wait_impl(waitset, xs, nxs, abstimeout, tnow); } else{ - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Negative timeout"); + DDS_ERROR("Negative timeout\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); } - DDS_REPORT_FLUSH(ret <0 ); + return ret; } @@ -488,14 +487,13 @@ dds_waitset_set_trigger( dds__retcode_t rc; dds_return_t ret = DDS_RETCODE_OK; - DDS_REPORT_STACK(); - /* Locking the waitset here will delay a possible deletion until it is * unlocked. Even when the related mutex is unlocked when we want to send * a signal. */ rc = dds_waitset_lock(waitset, &ws); if (rc != DDS_RETCODE_OK) { - ret = DDS_ERRNO(rc, "Error occurred on locking waitset"); + DDS_ERROR("Error occurred on locking waitset\n"); + ret = DDS_ERRNO(rc); goto fail; } if (trigger) { @@ -506,7 +504,6 @@ dds_waitset_set_trigger( dds_waitset_signal_entity(ws); dds_waitset_unlock(ws); fail: - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); return ret; } diff --git a/src/core/ddsc/src/dds_whc.c b/src/core/ddsc/src/dds_whc.c index 8e06b22..c1dca65 100644 --- a/src/core/ddsc/src/dds_whc.c +++ b/src/core/ddsc/src/dds_whc.c @@ -105,20 +105,6 @@ struct whc_sample_iter_sizecheck { char fits_in_generic_type[sizeof(struct whc_sample_iter_impl) <= sizeof(struct whc_sample_iter) ? 1 : -1]; }; -/* Avoiding all nn_log-related activities when LC_WHC is not set - (and it hardly ever is, as it is not even included in "trace") - saves a couple of % CPU on a high-rate publisher - that's worth - it. So we need a macro & a support function. */ -static int trace_whc (const char *fmt, ...) -{ - va_list ap; - va_start (ap, fmt); - nn_vlog (LC_WHC, fmt, ap); - va_end (ap); - return 0; -} -#define TRACE_WHC(args) ((config.enabled_logcats & LC_WHC) ? (trace_whc args) : 0) - /* Hash + interval tree adminitration of samples-by-sequence number * - by definition contains all samples in WHC (unchanged from older versions) * Circular array of samples per instance, inited to all 0 @@ -568,7 +554,7 @@ static void free_one_instance_from_idx (struct whc_impl *whc, seqno_t max_drop_s oldn->idxnode = NULL; if (oldn->seq <= max_drop_seq) { - TRACE_WHC((" prune tl whcn %p\n", (void *)oldn)); + DDS_LOG(DDS_LC_WHC, " prune tl whcn %p\n", (void *)oldn); assert(oldn != whc->maxseq_node); whc_delete_one (whc, oldn); } @@ -882,7 +868,7 @@ static unsigned whc_default_remove_acked_messages_full (struct whc_impl *whc, se if (whc->is_transient_local && whc->tldepth == 0) { /* KEEP_ALL on transient local, so we can never ever delete anything */ - TRACE_WHC((" KEEP_ALL transient-local: do nothing\n")); + DDS_LOG(DDS_LC_WHC, " KEEP_ALL transient-local: do nothing\n"); *deferred_free_list = NULL; return 0; } @@ -892,11 +878,11 @@ static unsigned whc_default_remove_acked_messages_full (struct whc_impl *whc, se prev_seq = whcn ? whcn->prev_seq : NULL; while (whcn && whcn->seq <= max_drop_seq) { - TRACE_WHC((" whcn %p %"PRId64, (void *) whcn, whcn->seq)); + DDS_LOG(DDS_LC_WHC, " whcn %p %"PRId64, (void *) whcn, whcn->seq); if (whcn_in_tlidx(whc, whcn->idxnode, whcn->idxnode_pos)) { /* quickly skip over samples in tlidx */ - TRACE_WHC((" tl:keep")); + DDS_LOG(DDS_LC_WHC, " tl:keep"); if (whcn->unacked) { assert (whc->unacked_bytes >= whcn->size); @@ -914,13 +900,13 @@ static unsigned whc_default_remove_acked_messages_full (struct whc_impl *whc, se } else { - TRACE_WHC((" delete")); + DDS_LOG(DDS_LC_WHC, " delete"); last_to_free->next_seq = whcn; last_to_free = last_to_free->next_seq; whc_delete_one_intv (whc, &intv, &whcn); ndropped++; } - TRACE_WHC(("\n")); + DDS_LOG(DDS_LC_WHC, "\n"); } if (prev_seq) prev_seq->next_seq = whcn; @@ -937,7 +923,7 @@ static unsigned whc_default_remove_acked_messages_full (struct whc_impl *whc, se if (whc->tldepth > 0 && whc->idxdepth > whc->tldepth) { assert(whc->hdepth == whc->idxdepth); - TRACE_WHC((" idxdepth %u > tldepth %u > 0 -- must prune\n", whc->idxdepth, whc->tldepth)); + DDS_LOG(DDS_LC_WHC, " idxdepth %u > tldepth %u > 0 -- must prune\n", whc->idxdepth, whc->tldepth); /* Do a second pass over the sequence number range we just processed: this time we only encounter samples that were retained because of the transient-local durability setting @@ -948,14 +934,14 @@ static unsigned whc_default_remove_acked_messages_full (struct whc_impl *whc, se struct whc_idxnode * const idxn = whcn->idxnode; unsigned cnt, idx; - TRACE_WHC((" whcn %p %"PRId64" idxn %p prune_seq %"PRId64":", (void *)whcn, whcn->seq, (void *)idxn, idxn->prune_seq)); + DDS_LOG(DDS_LC_WHC, " whcn %p %"PRId64" idxn %p prune_seq %"PRId64":", (void *)whcn, whcn->seq, (void *)idxn, idxn->prune_seq); assert(whcn_in_tlidx(whc, idxn, whcn->idxnode_pos)); assert (idxn->prune_seq <= max_drop_seq); if (idxn->prune_seq == max_drop_seq) { - TRACE_WHC((" already pruned\n")); + DDS_LOG(DDS_LC_WHC, " already pruned\n"); whcn = whcn->next_seq; continue; } @@ -983,7 +969,7 @@ static unsigned whc_default_remove_acked_messages_full (struct whc_impl *whc, se whcn_template.serdata = ddsi_serdata_ref(oldn->serdata); assert(oldn->seq < whcn->seq); #endif - TRACE_WHC((" del %p %"PRId64, (void *) oldn, oldn->seq)); + DDS_LOG(DDS_LC_WHC, " del %p %"PRId64, (void *) oldn, oldn->seq); whc_delete_one (whc, oldn); #ifndef NDEBUG assert(ut_hhLookup(whc->idx_hash, &template) == idxn); @@ -991,7 +977,7 @@ static unsigned whc_default_remove_acked_messages_full (struct whc_impl *whc, se #endif } } - TRACE_WHC(("\n")); + DDS_LOG(DDS_LC_WHC, "\n"); whcn = whcn->next_seq; } } @@ -1014,13 +1000,13 @@ static unsigned whc_default_remove_acked_messages (struct whc *whc_generic, seqn assert (max_drop_seq < MAX_SEQ_NUMBER); assert (max_drop_seq >= whc->max_drop_seq); - if (config.enabled_logcats & LC_WHC) + if (dds_get_log_mask() & DDS_LC_WHC) { struct whc_state tmp; get_state_locked(whc, &tmp); - TRACE_WHC(("whc_default_remove_acked_messages(%p max_drop_seq %"PRId64")\n", (void *)whc, max_drop_seq)); - TRACE_WHC((" whc: [%"PRId64",%"PRId64"] max_drop_seq %"PRId64" h %u tl %u\n", - tmp.min_seq, tmp.max_seq, whc->max_drop_seq, whc->hdepth, whc->tldepth)); + DDS_LOG(DDS_LC_WHC, "whc_default_remove_acked_messages(%p max_drop_seq %"PRId64")\n", (void *)whc, max_drop_seq); + DDS_LOG(DDS_LC_WHC, " whc: [%"PRId64",%"PRId64"] max_drop_seq %"PRId64" h %u tl %u\n", + tmp.min_seq, tmp.max_seq, whc->max_drop_seq, whc->hdepth, whc->tldepth); } check_whc (whc); @@ -1108,13 +1094,13 @@ static int whc_default_insert (struct whc *whc_generic, seqno_t max_drop_seq, se os_mutexLock (&whc->lock); check_whc (whc); - if (config.enabled_logcats & LC_WHC) + if (dds_get_log_mask() & DDS_LC_WHC) { struct whc_state whcst; get_state_locked(whc, &whcst); - TRACE_WHC(("whc_default_insert(%p max_drop_seq %"PRId64" seq %"PRId64" plist %p serdata %p:%"PRIx32")\n", (void *)whc, max_drop_seq, seq, (void*)plist, (void*)serdata, serdata->hash)); - TRACE_WHC((" whc: [%"PRId64",%"PRId64"] max_drop_seq %"PRId64" h %u tl %u\n", - whcst.min_seq, whcst.max_seq, whc->max_drop_seq, whc->hdepth, whc->tldepth)); + DDS_LOG(DDS_LC_WHC, "whc_default_insert(%p max_drop_seq %"PRId64" seq %"PRId64" plist %p serdata %p:%"PRIx32")\n", (void *)whc, max_drop_seq, seq, (void*)plist, (void*)serdata, serdata->hash); + DDS_LOG(DDS_LC_WHC, " whc: [%"PRId64",%"PRId64"] max_drop_seq %"PRId64" h %u tl %u\n", + whcst.min_seq, whcst.max_seq, whc->max_drop_seq, whc->hdepth, whc->tldepth); } assert (max_drop_seq < MAX_SEQ_NUMBER); @@ -1128,12 +1114,12 @@ static int whc_default_insert (struct whc *whc_generic, seqno_t max_drop_seq, se /* Always insert in seq admin */ newn = whc_default_insert_seq (whc, max_drop_seq, seq, plist, serdata); - TRACE_WHC((" whcn %p:", (void*)newn)); + DDS_LOG(DDS_LC_WHC, " whcn %p:", (void*)newn); /* Special case of empty data (such as commit messages) can't go into index, and if we're not maintaining an index, we're done, too */ if (serdata->kind == SDK_EMPTY || whc->idxdepth == 0) { - TRACE_WHC((" empty or no hist\n")); + DDS_LOG(DDS_LC_WHC, " empty or no hist\n"); os_mutexUnlock (&whc->lock); return 0; } @@ -1142,15 +1128,15 @@ static int whc_default_insert (struct whc *whc_generic, seqno_t max_drop_seq, se if ((idxn = ut_hhLookup (whc->idx_hash, &template)) != NULL) { /* Unregisters cause deleting of index entry, non-unregister of adding/overwriting in history */ - TRACE_WHC((" idxn %p", (void *)idxn)); + DDS_LOG(DDS_LC_WHC, " idxn %p", (void *)idxn); if (serdata->statusinfo & NN_STATUSINFO_UNREGISTER) { - TRACE_WHC((" unreg:delete\n")); + DDS_LOG(DDS_LC_WHC, " unreg:delete\n"); delete_one_instance_from_idx (whc, max_drop_seq, idxn); if (newn->seq <= max_drop_seq) { struct whc_node *prev_seq = newn->prev_seq; - TRACE_WHC((" unreg:seq <= max_drop_seq: delete newn\n")); + DDS_LOG(DDS_LC_WHC, " unreg:seq <= max_drop_seq: delete newn\n"); whc_delete_one (whc, newn); whc->maxseq_node = prev_seq; } @@ -1162,7 +1148,7 @@ static int whc_default_insert (struct whc *whc_generic, seqno_t max_drop_seq, se idxn->headidx = 0; if ((oldn = idxn->hist[idxn->headidx]) != NULL) { - TRACE_WHC((" overwrite whcn %p", (void *)oldn)); + DDS_LOG(DDS_LC_WHC, " overwrite whcn %p", (void *)oldn); oldn->idxnode = NULL; } idxn->hist[idxn->headidx] = newn; @@ -1171,7 +1157,7 @@ static int whc_default_insert (struct whc *whc_generic, seqno_t max_drop_seq, se if (oldn && (whc->hdepth > 0 || oldn->seq <= max_drop_seq)) { - TRACE_WHC((" prune whcn %p", (void *)oldn)); + DDS_LOG(DDS_LC_WHC, " prune whcn %p", (void *)oldn); assert(oldn != whc->maxseq_node); whc_delete_one (whc, oldn); } @@ -1187,23 +1173,23 @@ static int whc_default_insert (struct whc *whc_generic, seqno_t max_drop_seq, se pos -= whc->idxdepth; if ((oldn = idxn->hist[pos]) != NULL) { - TRACE_WHC((" prune tl whcn %p", (void *)oldn)); + DDS_LOG(DDS_LC_WHC, " prune tl whcn %p", (void *)oldn); assert(oldn != whc->maxseq_node); whc_delete_one (whc, oldn); } } - TRACE_WHC(("\n")); + DDS_LOG(DDS_LC_WHC, "\n"); } } else { - TRACE_WHC((" newkey")); + DDS_LOG(DDS_LC_WHC, " newkey"); /* Ignore unregisters, but insert everything else */ if (!(serdata->statusinfo & NN_STATUSINFO_UNREGISTER)) { unsigned i; idxn = os_malloc (sizeof (*idxn) + whc->idxdepth * sizeof (idxn->hist[0])); - TRACE_WHC((" idxn %p", (void *)idxn)); + DDS_LOG(DDS_LC_WHC, " idxn %p", (void *)idxn); dds_tkmap_instance_ref(tk); idxn->iid = tk->m_iid; idxn->tk = tk; @@ -1219,16 +1205,16 @@ static int whc_default_insert (struct whc *whc_generic, seqno_t max_drop_seq, se } else { - TRACE_WHC((" unreg:skip")); + DDS_LOG(DDS_LC_WHC, " unreg:skip"); if (newn->seq <= max_drop_seq) { struct whc_node *prev_seq = newn->prev_seq; - TRACE_WHC((" unreg:seq <= max_drop_seq: delete newn\n")); + DDS_LOG(DDS_LC_WHC, " unreg:seq <= max_drop_seq: delete newn\n"); whc_delete_one (whc, newn); whc->maxseq_node = prev_seq; } } - TRACE_WHC(("\n")); + DDS_LOG(DDS_LC_WHC, "\n"); } os_mutexUnlock (&whc->lock); return 0; diff --git a/src/core/ddsc/src/dds_write.c b/src/core/ddsc/src/dds_write.c index 50a8fd1..f0fe316 100644 --- a/src/core/ddsc/src/dds_write.c +++ b/src/core/ddsc/src/dds_write.c @@ -10,6 +10,7 @@ * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause */ #include +#include #include "dds__writer.h" #include "dds__write.h" #include "dds__tkmap.h" @@ -23,9 +24,7 @@ #include "ddsi/q_ephash.h" #include "ddsi/q_config.h" #include "ddsi/q_entity.h" -#include "dds__report.h" #include "ddsi/q_radmin.h" -#include _Pre_satisfies_((writer & DDS_ENTITY_KIND_MASK) == DDS_KIND_WRITER) dds_return_t @@ -37,20 +36,20 @@ dds_write( dds__retcode_t rc; dds_writer *wr; - DDS_REPORT_STACK(); - if (data != NULL) { rc = dds_writer_lock(writer, &wr); if (rc == DDS_RETCODE_OK) { ret = dds_write_impl(wr, data, dds_time(), 0); dds_writer_unlock(wr); } else { - ret = DDS_ERRNO(rc, "Error occurred on locking entity"); + DDS_ERROR("Error occurred on locking entity\n"); + ret = DDS_ERRNO(rc); } } else { - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "No data buffer provided"); + DDS_ERROR("No data buffer provided\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); } - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); + return ret; } @@ -69,10 +68,12 @@ dds_writecdr( ret = dds_writecdr_impl (wr, serdata, dds_time (), 0); dds_writer_unlock(wr); } else { - ret = DDS_ERRNO(rc, "Error occurred on locking writer"); + DDS_ERROR("Error occurred on locking writer\n"); + ret = DDS_ERRNO(rc); } } else{ - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Given cdr has NULL value"); + DDS_ERROR("Given cdr has NULL value\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); } return ret; } @@ -88,14 +89,14 @@ dds_write_ts( dds__retcode_t rc; dds_writer *wr; - DDS_REPORT_STACK(); - if(data == NULL){ - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument data has NULL value"); + DDS_ERROR("Argument data has NULL value\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); goto err; } if(timestamp < 0){ - ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument timestamp has negative value"); + DDS_ERROR("Argument timestamp has negative value\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); goto err; } rc = dds_writer_lock(writer, &wr); @@ -103,10 +104,10 @@ dds_write_ts( ret = dds_write_impl(wr, data, timestamp, 0); dds_writer_unlock(wr); } else { - ret = DDS_ERRNO(rc, "Error occurred on locking writer"); + DDS_ERROR("Error occurred on locking writer\n"); + ret = DDS_ERRNO(rc); } err: - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); return ret; } @@ -126,13 +127,14 @@ deliver_locally( make_proxy_writer_info(&pwr_info, &wr->e, wr->xqos); for (i = 0; rdary[i]; i++) { bool stored; - TRACE (("reader %x:%x:%x:%x\n", PGUID (rdary[i]->e.guid))); + DDS_TRACE("reader %x:%x:%x:%x\n", PGUID (rdary[i]->e.guid)); dds_duration_t max_block_ms = nn_from_ddsi_duration(wr->xqos->reliability.max_blocking_time) / DDS_NSECS_IN_MSEC; do { stored = (ddsi_plugin.rhc_plugin.rhc_store_fn) (rdary[i]->rhc, &pwr_info, payload, tk); if (!stored) { if (max_block_ms <= 0) { - ret = DDS_ERRNO(DDS_RETCODE_TIMEOUT, "The writer could not deliver data on time, probably due to a local reader resources being full."); + DDS_ERROR("The writer could not deliver data on time, probably due to a local reader resources being full\n"); + ret = DDS_ERRNO(DDS_RETCODE_TIMEOUT); } else { dds_sleepfor(DDS_MSECS(DDS_HEADBANG_TIMEOUT_MS)); } @@ -163,7 +165,7 @@ deliver_locally( for (m = ut_avlIterFirst (&wr_local_readers_treedef, &wr->local_readers, &it); m != NULL; m = ut_avlIterNext (&it)) { struct reader *rd; if ((rd = ephash_lookup_reader_guid (&m->rd_guid)) != NULL) { - TRACE (("reader-via-guid %x:%x:%x:%x\n", PGUID (rd->e.guid))); + DDS_TRACE("reader-via-guid %x:%x:%x:%x\n", PGUID (rd->e.guid)); /* Copied the return value ignore from DDSI deliver_user_data() function. */ (void)(ddsi_plugin.rhc_plugin.rhc_store_fn) (rd->rhc, &pwr_info, payload, tk); } @@ -195,7 +197,8 @@ dds_write_impl( struct ddsi_serdata *d; if (data == NULL) { - return DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "No data buffer provided"); + DDS_ERROR("No data buffer provided\n"); + return DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); } /* Check for topic filter */ @@ -227,11 +230,14 @@ dds_write_impl( } ret = DDS_RETCODE_OK; } else if (w_rc == ERR_TIMEOUT) { - ret = DDS_ERRNO(DDS_RETCODE_TIMEOUT, "The writer could not deliver data on time, probably due to a reader resources being full."); + DDS_ERROR("The writer could not deliver data on time, probably due to a reader resources being full\n"); + ret = DDS_ERRNO(DDS_RETCODE_TIMEOUT); } else if (w_rc == ERR_INVALID_DATA) { - ret = DDS_ERRNO(DDS_RETCODE_ERROR, "Invalid data provided"); + DDS_ERROR("Invalid data provided\n"); + ret = DDS_ERRNO(DDS_RETCODE_ERROR); } else { - ret = DDS_ERRNO(DDS_RETCODE_ERROR, "Internal error"); + DDS_ERROR("Internal error\n"); + ret = DDS_ERRNO(DDS_RETCODE_ERROR); } if (ret == DDS_RETCODE_OK) { ret = deliver_locally (ddsi_wr, d, tk); @@ -286,11 +292,14 @@ dds_writecdr_impl( } ret = DDS_RETCODE_OK; } else if (w_rc == ERR_TIMEOUT) { - ret = DDS_ERRNO(DDS_RETCODE_TIMEOUT, "The writer could not deliver data on time, probably due to a reader resources being full."); + DDS_ERROR("The writer could not deliver data on time, probably due to a reader resources being full\n"); + ret = DDS_ERRNO(DDS_RETCODE_TIMEOUT); } else if (w_rc == ERR_INVALID_DATA) { - ret = DDS_ERRNO(DDS_RETCODE_ERROR, "Invalid data provided"); + DDS_ERROR("Invalid data provided\n"); + ret = DDS_ERRNO(DDS_RETCODE_ERROR); } else { - ret = DDS_ERRNO(DDS_RETCODE_ERROR, "Internal error"); + DDS_ERROR("Internal error\n"); + ret = DDS_ERRNO(DDS_RETCODE_ERROR); } if (ret == DDS_RETCODE_OK) { @@ -318,9 +327,7 @@ void dds_write_flush( dds_entity_t writer) { - dds_return_t ret = DDS_RETCODE_OK; dds__retcode_t rc; - DDS_REPORT_STACK(); struct thread_state1 * const thr = lookup_thread_state (); const bool asleep = !vtime_awake_p (thr->vtime); @@ -333,14 +340,13 @@ dds_write_flush( if (rc == DDS_RETCODE_OK) { nn_xpack_send (wr->m_xp, true); dds_writer_unlock(wr); - ret = DDS_RETCODE_OK; } else{ - ret = DDS_ERRNO(rc, "Error occurred on locking writer"); + DDS_ERROR("Error occurred on locking writer\n"); } if (asleep) { thread_state_asleep (thr); } - DDS_REPORT_FLUSH(ret < 0); + return ; } diff --git a/src/core/ddsc/src/dds_writer.c b/src/core/ddsc/src/dds_writer.c index de3e143..3e9f1fe 100644 --- a/src/core/ddsc/src/dds_writer.c +++ b/src/core/ddsc/src/dds_writer.c @@ -22,7 +22,6 @@ #include "dds__init.h" #include "dds__tkmap.h" #include "dds__whc.h" -#include "dds__report.h" #include "ddsc/ddsc_project.h" #define DDS_WRITER_STATUS_MASK \ @@ -46,9 +45,14 @@ static dds_return_t dds_writer_status_validate( uint32_t mask) { - return (mask & ~(DDS_WRITER_STATUS_MASK)) ? - DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Invalid status mask") : - DDS_RETCODE_OK; + dds_return_t ret = DDS_RETCODE_OK; + + if (mask & ~(DDS_WRITER_STATUS_MASK)) { + DDS_ERROR("Invalid status mask\n"); + ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER); + } + + return ret; } /* @@ -75,11 +79,8 @@ dds_writer_status_cb( return; } - DDS_REPORT_STACK(); - if (dds_writer_lock(((dds_entity*)entity)->m_hdl, &wr) != DDS_RETCODE_OK) { /* There's a deletion or closing going on. */ - DDS_REPORT_FLUSH(false); return; } assert(wr == entity); @@ -180,8 +181,6 @@ dds_writer_status_cb( } else { /* Something went wrong up the hierarchy. */ } - - DDS_REPORT_FLUSH(rc != DDS_RETCODE_OK); } static uint32_t @@ -215,7 +214,8 @@ dds_writer_close( nn_xpack_send (wr->m_xp, false); } if (delete_writer (&e->m_guid) != 0) { - ret = DDS_ERRNO(DDS_RETCODE_ERROR, "Internal error"); + DDS_ERROR("Internal error"); + ret = DDS_ERRNO(DDS_RETCODE_ERROR); } if (asleep) { thread_state_asleep(thr); @@ -268,19 +268,24 @@ dds_writer_qos_validate( /* Check consistency. */ if(dds_qos_validate_common(qos) != true){ - ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "Provided inconsistent QoS policy"); + DDS_ERROR("Provided inconsistent QoS policy\n"); + ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY); } if((qos->present & QP_USER_DATA) && validate_octetseq(&qos->user_data) != true){ - ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "User Data QoS policy is inconsistent and caused an error"); + DDS_ERROR("User Data QoS policy is inconsistent and caused an error\n"); + ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY); } if ((qos->present & QP_DURABILITY_SERVICE) && validate_durability_service_qospolicy(&qos->durability_service) != 0){ - ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "Durability service QoS policy is inconsistent and caused an error"); + DDS_ERROR("Durability service QoS policy is inconsistent and caused an error\n"); + ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY); } if ((qos->present & QP_LIFESPAN) && validate_duration(&qos->lifespan.duration) != 0){ - ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "Lifespan QoS policy is inconsistent and caused an error"); + DDS_ERROR("Lifespan QoS policy is inconsistent and caused an error\n"); + ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY); } if ((qos->present & QP_HISTORY) && (qos->present & QP_RESOURCE_LIMITS) && (validate_history_and_resource_limits(&qos->history, &qos->resource_limits) != 0)){ - ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "Resource limits QoS policy is inconsistent and caused an error"); + DDS_ERROR("Resource limits QoS policy is inconsistent and caused an error\n"); + ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY); } if(ret == DDS_RETCODE_OK && enabled) { ret = dds_qos_validate_mutable_common(qos); @@ -330,11 +335,13 @@ dds_writer_qos_set( thread_state_asleep (thr); } } else { - ret = DDS_ERRNO(DDS_RETCODE_ERROR, "Setting ownership strength doesn't make sense when the ownership is shared."); + DDS_ERROR("Setting ownership strength doesn't make sense when the ownership is shared\n"); + ret = DDS_ERRNO(DDS_RETCODE_ERROR); } } else { if (enabled) { - ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, DDSC_PROJECT_NAME" does not support changing QoS policies yet"); + DDS_ERROR(DDSC_PROJECT_NAME" does not support changing QoS policies yet\n"); + ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED); } } } @@ -420,8 +427,6 @@ dds_create_writer( ddsi_tran_conn_t conn = gv.data_conn_uc; dds_return_t ret; - DDS_REPORT_STACK(); - /* Try claiming a participant. If that's not working, then it could be a subscriber. */ if(dds_entity_kind(participant_or_publisher) == DDS_KIND_PARTICIPANT){ publisher = dds_create_publisher(participant_or_publisher, qos, NULL); @@ -431,7 +436,8 @@ dds_create_writer( rc = dds_entity_lock(publisher, DDS_KIND_PUBLISHER, &pub); if (rc != DDS_RETCODE_OK) { - writer = DDS_ERRNO(rc, "Error occurred on locking publisher"); + DDS_ERROR("Error occurred on locking publisher\n"); + writer = DDS_ERRNO(rc); goto err_pub_lock; } @@ -441,7 +447,8 @@ dds_create_writer( rc = dds_entity_lock(topic, DDS_KIND_TOPIC, &tp); if (rc != DDS_RETCODE_OK) { - writer = DDS_ERRNO(rc, "Error occurred on locking topic"); + DDS_ERROR("Error occurred on locking topic\n"); + writer = DDS_ERRNO(rc); goto err_tp_lock; } assert(((dds_topic*)tp)->m_stopic); @@ -507,7 +514,6 @@ dds_create_writer( } dds_entity_unlock(tp); dds_entity_unlock(pub); - DDS_REPORT_FLUSH(writer <= 0); return writer; err_bad_qos: @@ -518,7 +524,6 @@ err_tp_lock: (void)dds_delete(publisher); } err_pub_lock: - DDS_REPORT_FLUSH(writer <= 0); return writer; } @@ -531,15 +536,14 @@ dds_get_publisher( { dds_entity_t hdl = DDS_RETCODE_OK; - DDS_REPORT_STACK(); - hdl = dds_valid_hdl(writer, DDS_KIND_WRITER); if(hdl != DDS_RETCODE_OK){ - hdl = DDS_ERRNO(hdl, "Provided handle is not writer kind, so it is not valid"); + DDS_ERROR("Provided handle is not writer kind, so it is not valid\n"); + hdl = DDS_ERRNO(hdl); } else{ hdl = dds_get_parent(writer); } - DDS_REPORT_FLUSH(hdl <= 0); + return hdl; } @@ -553,11 +557,10 @@ dds_get_publication_matched_status ( dds_writer *wr; dds_return_t ret = DDS_RETCODE_OK; - DDS_REPORT_STACK(); - rc = dds_writer_lock(writer, &wr); if (rc != DDS_RETCODE_OK) { - ret = DDS_ERRNO(rc, "Error occurred on locking writer"); + DDS_ERROR("Error occurred on locking writer\n"); + ret = DDS_ERRNO(rc); goto fail; } /* status = NULL, application do not need the status, but reset the counter & triggered bit */ @@ -571,7 +574,6 @@ dds_get_publication_matched_status ( } dds_writer_unlock(wr); fail: - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); return ret; } @@ -585,11 +587,10 @@ dds_get_liveliness_lost_status ( dds_writer *wr; dds_return_t ret = DDS_RETCODE_OK; - DDS_REPORT_STACK(); - rc = dds_writer_lock(writer, &wr); if (rc != DDS_RETCODE_OK) { - ret = DDS_ERRNO(rc, "Error occurred on locking writer"); + DDS_ERROR("Error occurred on locking writer\n"); + ret = DDS_ERRNO(rc); goto fail; } /* status = NULL, application do not need the status, but reset the counter & triggered bit */ @@ -602,7 +603,6 @@ dds_get_liveliness_lost_status ( } dds_writer_unlock(wr); fail: - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); return ret; } @@ -616,11 +616,10 @@ dds_get_offered_deadline_missed_status( dds_writer *wr; dds_return_t ret = DDS_RETCODE_OK; - DDS_REPORT_STACK(); - rc = dds_writer_lock(writer, &wr); if (rc != DDS_RETCODE_OK) { - ret = DDS_ERRNO(rc, "Error occurred on locking writer"); + DDS_ERROR("Error occurred on locking writer\n"); + ret = DDS_ERRNO(rc); goto fail; } /* status = NULL, application do not need the status, but reset the counter & triggered bit */ @@ -633,7 +632,6 @@ dds_get_offered_deadline_missed_status( } dds_writer_unlock(wr); fail: - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); return ret; } @@ -647,11 +645,10 @@ dds_get_offered_incompatible_qos_status ( dds_writer *wr; dds_return_t ret = DDS_RETCODE_OK; - DDS_REPORT_STACK(); - rc = dds_writer_lock(writer, &wr); if (rc != DDS_RETCODE_OK) { - ret = DDS_ERRNO(rc, "Error occurred on locking writer"); + DDS_ERROR("Error occurred on locking writer\n"); + ret = DDS_ERRNO(rc); goto fail; } /* status = NULL, application do not need the status, but reset the counter & triggered bit */ @@ -664,6 +661,5 @@ dds_get_offered_incompatible_qos_status ( } dds_writer_unlock(wr); fail: - DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK); return ret; } diff --git a/src/core/ddsi/.fileids b/src/core/ddsi/.fileids index 812b062..0fd013b 100644 --- a/src/core/ddsi/.fileids +++ b/src/core/ddsi/.fileids @@ -17,7 +17,6 @@ 16 src/q_init.c 17 src/q_lat_estim.c 18 src/q_lease.c -19 src/q_log.c 20 src/q_md5.c 21 src/q_misc.c 22 src/q_nwif.c diff --git a/src/core/ddsi/CMakeLists.txt b/src/core/ddsi/CMakeLists.txt index c8d062b..039c4a6 100644 --- a/src/core/ddsi/CMakeLists.txt +++ b/src/core/ddsi/CMakeLists.txt @@ -37,7 +37,6 @@ PREPEND(srcs_ddsi "${CMAKE_CURRENT_LIST_DIR}/src" q_init.c q_lat_estim.c q_lease.c - q_log.c q_md5.c q_misc.c q_nwif.c diff --git a/src/core/ddsi/include/ddsi/q_addrset.h b/src/core/ddsi/include/ddsi/q_addrset.h index 803f4b5..459fd7d 100644 --- a/src/core/ddsi/include/ddsi/q_addrset.h +++ b/src/core/ddsi/include/ddsi/q_addrset.h @@ -64,7 +64,7 @@ int addrset_any_mc (const struct addrset *as, nn_locator_t *dst); int addrset_forone (struct addrset *as, addrset_forone_fun_t f, void *arg); void addrset_forall (struct addrset *as, addrset_forall_fun_t f, void *arg); size_t addrset_forall_count (struct addrset *as, addrset_forall_fun_t f, void *arg); -void nn_log_addrset (logcat_t tf, const char *prefix, const struct addrset *as); +void nn_log_addrset (uint32_t tf, const char *prefix, const struct addrset *as); /* Tries to lock A then B for a decent check, returning false if trylock B fails */ diff --git a/src/core/ddsi/include/ddsi/q_config.h b/src/core/ddsi/include/ddsi/q_config.h index e4271cc..087b685 100644 --- a/src/core/ddsi/include/ddsi/q_config.h +++ b/src/core/ddsi/include/ddsi/q_config.h @@ -216,7 +216,7 @@ enum many_sockets_mode { struct config { int valid; - logcat_t enabled_logcats; + uint32_t enabled_logcats; char *servicename; char *pcap_file; diff --git a/src/core/ddsi/include/ddsi/q_globals.h b/src/core/ddsi/include/ddsi/q_globals.h index f8b6087..91a2123 100644 --- a/src/core/ddsi/include/ddsi/q_globals.h +++ b/src/core/ddsi/include/ddsi/q_globals.h @@ -308,13 +308,6 @@ struct q_globals { os_timePowerEvents powerEvents; struct nn_group_membership *mship; - - /* Static log buffer, for those rare cases a thread calls nn_vlogb - without having its own log buffer (happens during config file - processing and for listeners, &c. */ - int static_logbuf_lock_inited; - os_mutex static_logbuf_lock; - struct logbuf static_logbuf; }; extern struct q_globals OSAPI_EXPORT gv; diff --git a/src/core/ddsi/include/ddsi/q_lat_estim.h b/src/core/ddsi/include/ddsi/q_lat_estim.h index 42bd510..6878e5e 100644 --- a/src/core/ddsi/include/ddsi/q_lat_estim.h +++ b/src/core/ddsi/include/ddsi/q_lat_estim.h @@ -35,7 +35,7 @@ void nn_lat_estim_init (struct nn_lat_estim *le); void nn_lat_estim_fini (struct nn_lat_estim *le); void nn_lat_estim_update (struct nn_lat_estim *le, int64_t est); double nn_lat_estim_current (const struct nn_lat_estim *le); -int nn_lat_estim_log (logcat_t logcat, const char *tag, const struct nn_lat_estim *le); +int nn_lat_estim_log (uint32_t logcat, const char *tag, const struct nn_lat_estim *le); #if defined (__cplusplus) } diff --git a/src/core/ddsi/include/ddsi/q_log.h b/src/core/ddsi/include/ddsi/q_log.h index 229df22..7e24424 100644 --- a/src/core/ddsi/include/ddsi/q_log.h +++ b/src/core/ddsi/include/ddsi/q_log.h @@ -21,62 +21,21 @@ extern "C" { #endif -#define LC_FATAL 1u -#define LC_ERROR 2u -#define LC_WARNING 4u -#define LC_CONFIG 8u -#define LC_INFO 16u -#define LC_DISCOVERY 32u -#define LC_DATA 64u -#define LC_TRACE 128u -#define LC_RADMIN 256u -#define LC_TIMING 512u -#define LC_TRAFFIC 1024u -#define LC_TOPIC 2048u -#define LC_TCP 4096u -#define LC_PLIST 8192u -#define LC_WHC 16384u -#define LC_THROTTLE 32768u -#define LC_ALLCATS (LC_FATAL | LC_ERROR | LC_WARNING | LC_CONFIG | LC_INFO | LC_DISCOVERY | LC_DATA | LC_TRACE | LC_TIMING | LC_TRAFFIC | LC_TCP | LC_THROTTLE) - -typedef unsigned logcat_t; - -typedef struct logbuf { - char buf[2048]; - size_t bufsz; - size_t pos; - nn_wctime_t tstamp; -} *logbuf_t; - -logbuf_t logbuf_new (void); -void logbuf_init (logbuf_t lb); -void logbuf_free (logbuf_t lb); - -int nn_vlog (logcat_t cat, const char *fmt, va_list ap); -OSAPI_EXPORT int nn_log (_In_ logcat_t cat, _In_z_ _Printf_format_string_ const char *fmt, ...) __attribute_format__((printf,2,3)); -OSAPI_EXPORT int nn_trace (_In_z_ _Printf_format_string_ const char *fmt, ...) __attribute_format__((printf,1,2)); -void nn_log_set_tstamp (nn_wctime_t tnow); - -#define TRACE(args) ((config.enabled_logcats & LC_TRACE) ? (nn_trace args) : 0) - -#define LOG_THREAD_CPUTIME(guard) do { \ - if (config.enabled_logcats & LC_TIMING) \ - { \ - nn_mtime_t tnowlt = now_mt (); \ - if (tnowlt.v >= (guard).v) \ - { \ - int64_t ts = get_thread_cputime (); \ - nn_log (LC_TIMING, "thread_cputime %d.%09d\n", \ - (int) (ts / T_SECOND), (int) (ts % T_SECOND)); \ - (guard).v = tnowlt.v + T_SECOND; \ - } \ - } \ - } while (0) - - -#define NN_WARNING(fmt,...) nn_log (LC_WARNING, (" " fmt),##__VA_ARGS__) -#define NN_ERROR(fmt,...) nn_log (LC_ERROR, (" " fmt),##__VA_ARGS__) -#define NN_FATAL(fmt,...) nn_log (LC_FATAL, (" " fmt),##__VA_ARGS__) +/* LOG_THREAD_CPUTIME must be considered private. */ +#define LOG_THREAD_CPUTIME(guard) \ + do { \ + if (dds_get_log_mask() & DDS_LC_TIMING) { \ + nn_mtime_t tnowlt = now_mt(); \ + if (tnowlt.v >= (guard).v) { \ + const char fmt[] = "thread_cputime %d.%09d\n"; \ + int64_t ts = get_thread_cputime (); \ + dds_log( \ + DDS_LC_TIMING, __FILE__, __LINE__, OS_FUNCTION, \ + fmt, (int)(ts / T_SECOND), (int)(ts % T_SECOND)); \ + (guard).v = tnowlt.v + T_SECOND; \ + } \ + } \ + } while (0) #if defined (__cplusplus) } diff --git a/src/core/ddsi/include/ddsi/q_thread.h b/src/core/ddsi/include/ddsi/q_thread.h index 8643ceb..508d096 100644 --- a/src/core/ddsi/include/ddsi/q_thread.h +++ b/src/core/ddsi/include/ddsi/q_thread.h @@ -61,7 +61,6 @@ struct logbuf; os_threadId tid; \ os_threadId extTid; \ enum thread_state state; \ - struct logbuf *lb; \ char *name /* note: no semicolon! */ struct thread_state_base { diff --git a/src/core/ddsi/include/ddsi/q_xqos.h b/src/core/ddsi/include/ddsi/q_xqos.h index 05eecda..fd67be4 100644 --- a/src/core/ddsi/include/ddsi/q_xqos.h +++ b/src/core/ddsi/include/ddsi/q_xqos.h @@ -339,7 +339,7 @@ void nn_xqos_fini (nn_xqos_t *xqos); void nn_xqos_mergein_missing (nn_xqos_t *a, const nn_xqos_t *b); uint64_t nn_xqos_delta (const nn_xqos_t *a, const nn_xqos_t *b, uint64_t mask); void nn_xqos_addtomsg (struct nn_xmsg *m, const nn_xqos_t *xqos, uint64_t wanted); -void nn_log_xqos (logcat_t cat, const nn_xqos_t *xqos); +void nn_log_xqos (uint32_t cat, const nn_xqos_t *xqos); nn_xqos_t *nn_xqos_dup (const nn_xqos_t *src); #if defined (__cplusplus) diff --git a/src/core/ddsi/src/ddsi_ipaddr.c b/src/core/ddsi/src/ddsi_ipaddr.c index fb8a69e..0219d75 100644 --- a/src/core/ddsi/src/ddsi_ipaddr.c +++ b/src/core/ddsi/src/ddsi_ipaddr.c @@ -171,7 +171,7 @@ void ddsi_ipaddr_to_loc (nn_locator_t *dst, const os_sockaddr *src, int32_t kind } #endif default: - NN_FATAL ("nn_address_to_loc: family %d unsupported\n", (int) src->sa_family); + DDS_FATAL("nn_address_to_loc: family %d unsupported\n", (int) src->sa_family); } } diff --git a/src/core/ddsi/src/ddsi_mcgroup.c b/src/core/ddsi/src/ddsi_mcgroup.c index c3aad63..999494d 100644 --- a/src/core/ddsi/src/ddsi_mcgroup.c +++ b/src/core/ddsi/src/ddsi_mcgroup.c @@ -154,13 +154,13 @@ static int joinleave_mcgroup (ddsi_tran_conn_t conn, int join, const nn_locator_ { char buf[256]; int err; - TRACE (("%s\n", make_joinleave_msg (buf, sizeof(buf), conn, join, srcloc, mcloc, interf, 0))); + DDS_TRACE("%s\n", make_joinleave_msg (buf, sizeof(buf), conn, join, srcloc, mcloc, interf, 0)); if (join) err = ddsi_conn_join_mc(conn, srcloc, mcloc, interf); else err = ddsi_conn_leave_mc(conn, srcloc, mcloc, interf); if (err) - NN_WARNING ("%s\n", make_joinleave_msg (buf, sizeof(buf), conn, join, srcloc, mcloc, interf, err)); + DDS_WARNING("%s\n", make_joinleave_msg (buf, sizeof(buf), conn, join, srcloc, mcloc, interf, err)); return err ? -1 : 0; } @@ -211,7 +211,7 @@ static int joinleave_mcgroups (ddsi_tran_conn_t conn, int join, const nn_locator if (fails > 0) { if (oks > 0) - TRACE (("multicast join failed for some but not all interfaces, proceeding\n")); + DDS_TRACE("multicast join failed for some but not all interfaces, proceeding\n"); else return -2; } @@ -228,7 +228,7 @@ int ddsi_join_mc (ddsi_tran_conn_t conn, const nn_locator_t *srcloc, const nn_lo if (!reg_group_membership (gv.mship, conn, srcloc, mcloc)) { char buf[256]; - TRACE (("%s: already joined\n", make_joinleave_msg (buf, sizeof(buf), conn, 1, srcloc, mcloc, NULL, 0))); + DDS_TRACE("%s: already joined\n", make_joinleave_msg (buf, sizeof(buf), conn, 1, srcloc, mcloc, NULL, 0)); ret = 0; } else @@ -246,7 +246,7 @@ int ddsi_leave_mc (ddsi_tran_conn_t conn, const nn_locator_t *srcloc, const nn_l if (!unreg_group_membership (gv.mship, conn, srcloc, mcloc)) { char buf[256]; - TRACE (("%s: not leaving yet\n", make_joinleave_msg (buf, sizeof(buf), conn, 0, srcloc, mcloc, NULL, 0))); + DDS_TRACE("%s: not leaving yet\n", make_joinleave_msg (buf, sizeof(buf), conn, 0, srcloc, mcloc, NULL, 0)); ret = 0; } else diff --git a/src/core/ddsi/src/ddsi_raweth.c b/src/core/ddsi/src/ddsi_raweth.c index f35ae4d..a7494da 100644 --- a/src/core/ddsi/src/ddsi_raweth.c +++ b/src/core/ddsi/src/ddsi_raweth.c @@ -108,12 +108,12 @@ static ssize_t ddsi_raweth_conn_read (ddsi_tran_conn_t conn, unsigned char * buf snprintf(addrbuf, sizeof(addrbuf), "[%02x:%02x:%02x:%02x:%02x:%02x]:%u", src.sll_addr[0], src.sll_addr[1], src.sll_addr[2], src.sll_addr[3], src.sll_addr[4], src.sll_addr[5], ntohs(src.sll_protocol)); - NN_WARNING ("%s => %d truncated to %d\n", addrbuf, (int)ret, (int)len); + DDS_WARNING("%s => %d truncated to %d\n", addrbuf, (int)ret, (int)len); } } else if (err != os_sockENOTSOCK && err != os_sockECONNRESET) { - NN_ERROR ("UDP recvmsg sock %d: ret %d errno %d\n", (int) ((ddsi_raweth_conn_t) conn)->m_sock, (int) ret, err); + DDS_ERROR("UDP recvmsg sock %d: ret %d errno %d\n", (int) ((ddsi_raweth_conn_t) conn)->m_sock, (int) ret, err); } return ret; } @@ -162,7 +162,7 @@ static ssize_t ddsi_raweth_conn_write (ddsi_tran_conn_t conn, const nn_locator_t #endif break; default: - NN_ERROR("ddsi_raweth_conn_write failed with error code %d", err); + DDS_ERROR("ddsi_raweth_conn_write failed with error code %d", err); } } return ret; @@ -204,14 +204,14 @@ static ddsi_tran_conn_t ddsi_raweth_create_conn (uint32_t port, ddsi_tran_qos_t if (port == 0 || port > 65535) { - NN_ERROR("ddsi_raweth_create_conn %s port %u - using port number as ethernet type, %u won't do\n", mcast ? "multicast" : "unicast", port, port); + DDS_ERROR("ddsi_raweth_create_conn %s port %u - using port number as ethernet type, %u won't do\n", mcast ? "multicast" : "unicast", port, port); return NULL; } if ((sock = socket(PF_PACKET, SOCK_DGRAM, htons((uint16_t)port))) == -1) { rc = os_getErrno(); - NN_ERROR("ddsi_raweth_create_conn %s port %u failed ... errno = %d\n", mcast ? "multicast" : "unicast", port, rc); + DDS_ERROR("ddsi_raweth_create_conn %s port %u failed ... errno = %d\n", mcast ? "multicast" : "unicast", port, rc); return NULL; } @@ -224,7 +224,7 @@ static ddsi_tran_conn_t ddsi_raweth_create_conn (uint32_t port, ddsi_tran_qos_t { rc = os_getErrno(); close(sock); - NN_ERROR("ddsi_raweth_create_conn %s bind port %u failed ... errno = %d\n", mcast ? "multicast" : "unicast", port, rc); + DDS_ERROR("ddsi_raweth_create_conn %s bind port %u failed ... errno = %d\n", mcast ? "multicast" : "unicast", port, rc); return NULL; } @@ -242,7 +242,7 @@ static ddsi_tran_conn_t ddsi_raweth_create_conn (uint32_t port, ddsi_tran_qos_t uc->m_base.m_write_fn = ddsi_raweth_conn_write; uc->m_base.m_disable_multiplexing_fn = 0; - nn_log(LC_INFO, "ddsi_raweth_create_conn %s socket %d port %u\n", mcast ? "multicast" : "unicast", uc->m_sock, uc->m_base.m_base.m_port); + DDS_INFO("ddsi_raweth_create_conn %s socket %d port %u\n", mcast ? "multicast" : "unicast", uc->m_sock, uc->m_base.m_base.m_port); return uc ? &uc->m_base : NULL; } @@ -294,9 +294,8 @@ static int ddsi_raweth_leave_mc (ddsi_tran_conn_t conn, const nn_locator_t *srcl static void ddsi_raweth_release_conn (ddsi_tran_conn_t conn) { ddsi_raweth_conn_t uc = (ddsi_raweth_conn_t) conn; - nn_log + DDS_INFO ( - LC_INFO, "ddsi_raweth_release_conn %s socket %d port %d\n", conn->m_base.m_multicast ? "multicast" : "unicast", uc->m_sock, @@ -344,7 +343,7 @@ static void ddsi_raweth_deinit(void) if (os_atomic_dec32_nv(&init_g) == 0) { if (ddsi_raweth_config_g.mship) free_group_membership(ddsi_raweth_config_g.mship); - nn_log (LC_INFO | LC_CONFIG, "raweth de-initialized\n"); + DDS_LOG(DDS_LC_INFO | DDS_LC_CONFIG, "raweth de-initialized\n"); } } @@ -380,7 +379,7 @@ int ddsi_raweth_init (void) ddsi_raweth_config_g.mship = new_group_membership(); - nn_log (LC_INFO | LC_CONFIG, "raweth initialized\n"); + DDS_LOG(DDS_LC_INFO | DDS_LC_CONFIG, "raweth initialized\n"); } return 0; } diff --git a/src/core/ddsi/src/ddsi_serdata_default.c b/src/core/ddsi/src/ddsi_serdata_default.c index ea17fc3..548a92e 100644 --- a/src/core/ddsi/src/ddsi_serdata_default.c +++ b/src/core/ddsi/src/ddsi_serdata_default.c @@ -60,7 +60,7 @@ static void serdata_free_wrap (void *elem) void ddsi_serdatapool_free (struct serdatapool * pool) { - TRACE (("ddsi_serdatapool_free(%p)\n", pool)); + DDS_TRACE("ddsi_serdatapool_free(%p)\n", pool); nn_freelist_fini (&pool->freelist, serdata_free_wrap); os_free (pool); } diff --git a/src/core/ddsi/src/ddsi_ssl.c b/src/core/ddsi/src/ddsi_ssl.c index 4af1cd2..c420b0a 100644 --- a/src/core/ddsi/src/ddsi_ssl.c +++ b/src/core/ddsi/src/ddsi_ssl.c @@ -31,7 +31,7 @@ static void ddsi_ssl_error (SSL * ssl, const char * str, int err) { char buff [128]; ERR_error_string ((unsigned) SSL_get_error (ssl, err), buff); - nn_log (LC_ERROR, "tcp/ssl %s %s %d\n", str, buff, err); + DDS_ERROR("tcp/ssl %s %s %d\n", str, buff, err); } static int ddsi_ssl_verify (int ok, X509_STORE_CTX * store) @@ -56,9 +56,8 @@ static int ddsi_ssl_verify (int ok, X509_STORE_CTX * store) else { X509_NAME_oneline (X509_get_issuer_name (cert), issuer, sizeof (issuer)); - nn_log + DDS_ERROR ( - LC_ERROR, "tcp/ssl failed to verify certificate from %s : %s\n", issuer, X509_verify_cert_error_string (err) @@ -227,9 +226,9 @@ static SSL_CTX * ddsi_ssl_ctx_init (void) if (! SSL_CTX_use_certificate_file (ctx, config.ssl_keystore, SSL_FILETYPE_PEM)) { - nn_log + DDS_LOG ( - LC_ERROR | LC_CONFIG, + DDS_LC_ERROR | DDS_LC_CONFIG, "tcp/ssl failed to load certificate from file: %s\n", config.ssl_keystore ); @@ -244,9 +243,9 @@ static SSL_CTX * ddsi_ssl_ctx_init (void) if (! SSL_CTX_use_PrivateKey_file (ctx, config.ssl_keystore, SSL_FILETYPE_PEM)) { - nn_log + DDS_LOG ( - LC_ERROR | LC_CONFIG, + DDS_LC_ERROR | DDS_LC_CONFIG, "tcp/ssl failed to load private key from file: %s\n", config.ssl_keystore ); @@ -257,9 +256,9 @@ static SSL_CTX * ddsi_ssl_ctx_init (void) if (! SSL_CTX_load_verify_locations (ctx, config.ssl_keystore, 0)) { - nn_log + DDS_LOG ( - LC_ERROR | LC_CONFIG, + DDS_LC_ERROR | DDS_LC_CONFIG, "tcp/ssl failed to load CA from file: %s\n", config.ssl_keystore ); @@ -270,9 +269,9 @@ static SSL_CTX * ddsi_ssl_ctx_init (void) if (! SSL_CTX_set_cipher_list (ctx, config.ssl_ciphers)) { - nn_log + DDS_LOG ( - LC_ERROR | LC_CONFIG, + DDS_LC_ERROR | DDS_LC_CONFIG, "tcp/ssl failed to set ciphers: %s\n", config.ssl_ciphers ); @@ -285,9 +284,9 @@ static SSL_CTX * ddsi_ssl_ctx_init (void) { if (! RAND_load_file (config.ssl_rand_file, 4096)) { - nn_log + DDS_LOG ( - LC_ERROR | LC_CONFIG, + DDS_LC_ERROR | DDS_LC_CONFIG, "tcp/ssl failed to load random seed from file: %s\n", config.ssl_rand_file ); diff --git a/src/core/ddsi/src/ddsi_tcp.c b/src/core/ddsi/src/ddsi_tcp.c index 8205fc1..0ea5cab 100644 --- a/src/core/ddsi/src/ddsi_tcp.c +++ b/src/core/ddsi/src/ddsi_tcp.c @@ -73,16 +73,6 @@ typedef struct ddsi_tcp_listener } * ddsi_tcp_listener_t; -static void nn_trace_tcp (const char *fmt, ...) -{ - va_list ap; - va_start (ap, fmt); - nn_vlog (LC_TCP, fmt, ap); - va_end (ap); -} - -#define TRACE_TCP(args) ((config.enabled_logcats & LC_TCP) ? (nn_trace_tcp args) : (void) 0) - static int ddsi_tcp_cmp_conn (const ddsi_tcp_conn_t c1, const ddsi_tcp_conn_t c2) { const os_sockaddr *a1s = (os_sockaddr *)&c1->m_peer_addr; @@ -136,9 +126,9 @@ static void ddsi_tcp_cache_dump (void) while (n) { os_sockaddrAddressPortToString ((const os_sockaddr *) &n->m_conn->m_peer_addr, buff, sizeof (buff)); - nn_log + DDS_LOG ( - LC_INFO, + DDS_LC_INFO, "%s cache #%d: %s sock %d port %u peer %s\n", ddsi_name, i++, n->m_conn->m_base.m_server ? "server" : "client", n->m_conn->m_sock, n->m_conn->m_base.m_base.m_port, buff @@ -155,7 +145,7 @@ static unsigned short get_socket_port (os_socket socket) if (getsockname (socket, (os_sockaddr *) &addr, &addrlen) < 0) { int err = os_getErrno(); - NN_ERROR ("ddsi_tcp_get_socket_port: getsockname errno %d\n", err); + DDS_ERROR("ddsi_tcp_get_socket_port: getsockname errno %d\n", err); return 0; } return os_sockaddr_get_port((os_sockaddr *)&addr); @@ -173,7 +163,7 @@ static void ddsi_tcp_sock_free (os_socket sock, const char * msg) { if (msg) { - nn_log (LC_INFO, "%s %s free socket %"PRIsock"\n", ddsi_name, msg, sock); + DDS_INFO("%s %s free socket %"PRIsock"\n", ddsi_name, msg, sock); } os_sockFree (sock); } @@ -231,7 +221,7 @@ static void ddsi_tcp_conn_connect (ddsi_tcp_conn_t conn, const struct msghdr * m #endif sockaddr_to_string_with_port(buff, sizeof(buff), (os_sockaddr *) msg->msg_name); - nn_log (LC_INFO, "%s connect socket %"PRIsock" port %u to %s\n", ddsi_name, sock, get_socket_port (sock), buff); + DDS_INFO("%s connect socket %"PRIsock" port %u to %s\n", ddsi_name, sock, get_socket_port (sock), buff); /* Also may need to receive on connection so add to waitset */ @@ -279,7 +269,7 @@ static void ddsi_tcp_cache_add (ddsi_tcp_conn_t conn, ut_avlIPath_t * path) } sockaddr_to_string_with_port(buff, sizeof(buff), (os_sockaddr *)&conn->m_peer_addr); - nn_log (LC_INFO, "%s cache %s %s socket %"PRIsock" to %s\n", ddsi_name, action, conn->m_base.m_server ? "server" : "client", conn->m_sock, buff); + DDS_INFO("%s cache %s %s socket %"PRIsock" to %s\n", ddsi_name, action, conn->m_base.m_server ? "server" : "client", conn->m_sock, buff); } static void ddsi_tcp_cache_remove (ddsi_tcp_conn_t conn) @@ -293,7 +283,7 @@ static void ddsi_tcp_cache_remove (ddsi_tcp_conn_t conn) if (node) { sockaddr_to_string_with_port(buff, sizeof(buff), (os_sockaddr *)&conn->m_peer_addr); - nn_log (LC_INFO, "%s cache removed socket %"PRIsock" to %s\n", ddsi_name, conn->m_sock, buff); + DDS_INFO("%s cache removed socket %"PRIsock" to %s\n", ddsi_name, conn->m_sock, buff); ut_avlDeleteDPath (&ddsi_tcp_treedef, &ddsi_tcp_cache_g, node, &path); ddsi_tcp_node_free (node); } @@ -372,7 +362,7 @@ static bool ddsi_tcp_select (os_socket sock, bool read, size_t pos) timeout.tv_sec = (int) (tval / T_SECOND); timeout.tv_nsec = (int) (tval % T_SECOND); - TRACE_TCP (("%s blocked %s: sock %d\n", ddsi_name, read ? "read" : "write", (int) sock)); + DDS_LOG(DDS_LC_TCP, "%s blocked %s: sock %d\n", ddsi_name, read ? "read" : "write", (int) sock); do { ret = os_sockSelect ((int32_t)sock + 1, rdset, wrset, NULL, &timeout); /* The variable "sock" with os_socket type causes the possible loss of data. So type casting done */ @@ -381,9 +371,9 @@ static bool ddsi_tcp_select (os_socket sock, bool read, size_t pos) if (ret <= 0) { - nn_log + DDS_WARNING ( - LC_WARNING, "%s abandoning %s on blocking socket %d after %"PRIuSIZE" bytes\n", + "%s abandoning %s on blocking socket %d after %"PRIuSIZE" bytes\n", ddsi_name, read ? "read" : "write", (int) sock, pos ); } @@ -432,7 +422,7 @@ static ssize_t ddsi_tcp_conn_read (ddsi_tran_conn_t conn, unsigned char * buf, s } else if (n == 0) { - TRACE_TCP (("%s read: sock %"PRIsock" closed-by-peer\n", ddsi_name, tcp->m_sock)); + DDS_LOG(DDS_LC_TCP, "%s read: sock %"PRIsock" closed-by-peer\n", ddsi_name, tcp->m_sock); break; } else @@ -448,7 +438,7 @@ static ssize_t ddsi_tcp_conn_read (ddsi_tran_conn_t conn, unsigned char * buf, s } else { - TRACE_TCP (("%s read: sock %"PRIsock" error %d\n", ddsi_name, tcp->m_sock, err)); + DDS_LOG(DDS_LC_TCP, "%s read: sock %"PRIsock" error %d\n", ddsi_name, tcp->m_sock, err); break; } } @@ -516,7 +506,7 @@ static ssize_t ddsi_tcp_block_write } else { - TRACE_TCP (("%s write: sock %"PRIsock" error %d\n", ddsi_name, conn->m_sock, err)); + DDS_LOG(DDS_LC_TCP, "%s write: sock %"PRIsock" error %d\n", ddsi_name, conn->m_sock, err); break; } } @@ -591,7 +581,7 @@ static ssize_t ddsi_tcp_conn_write (ddsi_tran_conn_t base, const nn_locator_t *d if (!connect && ((flags & DDSI_TRAN_ON_CONNECT) != 0)) { - TRACE_TCP (("%s write: sock %"PRIsock" message filtered\n", ddsi_name, conn->m_sock)); + DDS_LOG(DDS_LC_TCP, "%s write: sock %"PRIsock" message filtered\n", ddsi_name, conn->m_sock); os_mutexUnlock (&conn->m_mutex); return (ssize_t) len; } @@ -651,16 +641,16 @@ static ssize_t ddsi_tcp_conn_write (ddsi_tran_conn_t base, const nn_locator_t *d { if (! conn->m_base.m_closed && (conn->m_sock != Q_INVALID_SOCKET)) { - nn_log + DDS_WARNING ( - LC_WARNING, "%s write failed on socket %"PRIsock" with errno %d\n", + "%s write failed on socket %"PRIsock" with errno %d\n", ddsi_name, conn->m_sock, err ); } } else { - TRACE_TCP (("%s write: sock %"PRIsock" ECONNRESET\n", ddsi_name, conn->m_sock)); + DDS_LOG(DDS_LC_TCP, "%s write: sock %"PRIsock" ECONNRESET\n", ddsi_name, conn->m_sock); } } } @@ -668,7 +658,7 @@ static ssize_t ddsi_tcp_conn_write (ddsi_tran_conn_t base, const nn_locator_t *d { if (ret == 0) { - TRACE_TCP (("%s write: sock %"PRIsock" eof\n", ddsi_name, conn->m_sock)); + DDS_LOG(DDS_LC_TCP, "%s write: sock %"PRIsock" eof\n", ddsi_name, conn->m_sock); } piecewise = (ret > 0 && (size_t) ret < len); } @@ -796,17 +786,17 @@ static ddsi_tran_conn_t ddsi_tcp_accept (ddsi_tran_listener_t listener) { getsockname (tl->m_sock, (struct sockaddr *) &addr, &addrlen); sockaddr_to_string_with_port(buff, sizeof(buff), (os_sockaddr *)&addr); - nn_log ((err == 0) ? LC_ERROR : LC_FATAL, "%s accept failed on socket %"PRIsock" at %s errno %d\n", ddsi_name, tl->m_sock, buff, err); + DDS_LOG((err == 0) ? DDS_LC_ERROR : DDS_LC_FATAL, "%s accept failed on socket %"PRIsock" at %s errno %d\n", ddsi_name, tl->m_sock, buff, err); } else if (getpeername (sock, (struct sockaddr *) &addr, &addrlen) == -1) { - nn_log (LC_WARNING, "%s accepted new socket %"PRIsock" on socket %"PRIsock" but no peer address, errno %d\n", ddsi_name, sock, tl->m_sock, os_getErrno()); + DDS_WARNING("%s accepted new socket %"PRIsock" on socket %"PRIsock" but no peer address, errno %d\n", ddsi_name, sock, tl->m_sock, os_getErrno()); os_sockFree (sock); } else { sockaddr_to_string_with_port(buff, sizeof(buff), (os_sockaddr *)&addr); - nn_log (LC_INFO, "%s accept new socket %"PRIsock" on socket %"PRIsock" from %s\n", ddsi_name, sock, tl->m_sock, buff); + DDS_INFO("%s accept new socket %"PRIsock" on socket %"PRIsock" from %s\n", ddsi_name, sock, tl->m_sock, buff); os_sockSetNonBlocking (sock, true); tcp = ddsi_tcp_new_conn (sock, true, (os_sockaddr *)&addr); @@ -844,7 +834,7 @@ static void ddsi_tcp_conn_peer_locator (ddsi_tran_conn_t conn, nn_locator_t * lo assert (tc->m_sock != Q_INVALID_SOCKET); ddsi_ipaddr_to_loc (loc, (os_sockaddr *)&tc->m_peer_addr, tc->m_peer_addr.ss_family == AF_INET ? NN_LOCATOR_KIND_TCPv4 : NN_LOCATOR_KIND_TCPv6); ddsi_locator_to_string(buff, sizeof(buff), loc); - TRACE (("(%s EP:%s)", ddsi_name, buff)); + DDS_LOG(DDS_LC_TCP, "(%s EP:%s)", ddsi_name, buff); } static void ddsi_tcp_base_init (struct ddsi_tran_conn * base) @@ -907,14 +897,14 @@ static ddsi_tran_listener_t ddsi_tcp_create_listener (int port, ddsi_tran_qos_t if (getsockname (sock, (os_sockaddr *) &addr, &addrlen) == -1) { int err = os_getErrno (); - NN_ERROR ("ddsi_tcp_create_listener: getsockname errno %d\n", err); + DDS_ERROR("ddsi_tcp_create_listener: getsockname errno %d\n", err); ddsi_tcp_sock_free (sock, NULL); os_free (tl); return NULL; } sockaddr_to_string_with_port(buff, sizeof(buff), (os_sockaddr *)&addr); - nn_log (LC_INFO, "%s create listener socket %"PRIsock" on %s\n", ddsi_name, sock, buff); + DDS_INFO("%s create listener socket %"PRIsock" on %s\n", ddsi_name, sock, buff); } return tl ? &tl->m_base : NULL; @@ -924,7 +914,7 @@ static void ddsi_tcp_conn_delete (ddsi_tcp_conn_t conn) { char buff[DDSI_LOCSTRLEN]; sockaddr_to_string_with_port(buff, sizeof(buff), (os_sockaddr *)&conn->m_peer_addr); - nn_log (LC_INFO, "%s free %s connnection on socket %"PRIsock" to %s\n", ddsi_name, conn->m_base.m_server ? "server" : "client", conn->m_sock, buff); + DDS_INFO("%s free %s connnection on socket %"PRIsock" to %s\n", ddsi_name, conn->m_base.m_server ? "server" : "client", conn->m_sock, buff); #ifdef DDSI_INCLUDE_SSL if (ddsi_tcp_ssl_plugin.ssl_free) @@ -948,7 +938,7 @@ static void ddsi_tcp_close_conn (ddsi_tran_conn_t tc) nn_locator_t loc; ddsi_tcp_conn_t conn = (ddsi_tcp_conn_t) tc; sockaddr_to_string_with_port(buff, sizeof(buff), (os_sockaddr *)&conn->m_peer_addr); - nn_log (LC_INFO, "%s close %s connnection on socket %"PRIsock" to %s\n", ddsi_name, conn->m_base.m_server ? "server" : "client", conn->m_sock, buff); + DDS_INFO("%s close %s connnection on socket %"PRIsock" to %s\n", ddsi_name, conn->m_base.m_server ? "server" : "client", conn->m_sock, buff); (void) shutdown (conn->m_sock, 2); ddsi_ipaddr_to_loc(&loc, (os_sockaddr *)&conn->m_peer_addr, conn->m_peer_addr.ss_family == AF_INET ? NN_LOCATOR_KIND_TCPv4 : NN_LOCATOR_KIND_TCPv6); loc.port = conn->m_peer_port; @@ -984,7 +974,7 @@ static void ddsi_tcp_unblock_listener (ddsi_tran_listener_t listener) os_sockaddr_storage addr; socklen_t addrlen = sizeof (addr); if (getsockname (tl->m_sock, (os_sockaddr *) &addr, &addrlen) == -1) - nn_log (LC_WARNING, "%s failed to get listener address error %d\n", ddsi_name, os_getErrno()); + DDS_WARNING("%s failed to get listener address error %d\n", ddsi_name, os_getErrno()); else { switch (addr.ss_family) { @@ -1016,7 +1006,7 @@ static void ddsi_tcp_unblock_listener (ddsi_tran_listener_t listener) { char buff[DDSI_LOCSTRLEN]; sockaddr_to_string_with_port(buff, sizeof(buff), (os_sockaddr *)&addr); - nn_log (LC_WARNING, "%s failed to connect to own listener (%s) error %d\n", ddsi_name, buff, os_getErrno()); + DDS_WARNING("%s failed to connect to own listener (%s) error %d\n", ddsi_name, buff, os_getErrno()); } } ddsi_tcp_sock_free (sock, NULL); @@ -1091,7 +1081,7 @@ int ddsi_tcp_init (void) ddsi_name = "tcp/ssl"; if (! (ddsi_tcp_ssl_plugin.init) ()) { - NN_ERROR ("Failed to initialize OpenSSL\n"); + DDS_ERROR("Failed to initialize OpenSSL\n"); return -1; } } @@ -1100,7 +1090,7 @@ int ddsi_tcp_init (void) ut_avlInit (&ddsi_tcp_treedef, &ddsi_tcp_cache_g); os_mutexInit (&ddsi_tcp_cache_lock_g); - nn_log (LC_INFO | LC_CONFIG, "%s initialized\n", ddsi_name); + DDS_LOG(DDS_LC_CONFIG, "%s initialized\n", ddsi_name); } return 0; } diff --git a/src/core/ddsi/src/ddsi_udp.c b/src/core/ddsi/src/ddsi_udp.c index 5ac3d39..ed09c58 100644 --- a/src/core/ddsi/src/ddsi_udp.c +++ b/src/core/ddsi/src/ddsi_udp.c @@ -93,12 +93,12 @@ static ssize_t ddsi_udp_conn_read (ddsi_tran_conn_t conn, unsigned char * buf, s nn_locator_t tmp; ddsi_ipaddr_to_loc(&tmp, (os_sockaddr *)&src, src.ss_family == AF_INET ? NN_LOCATOR_KIND_UDPv4 : NN_LOCATOR_KIND_UDPv6); ddsi_locator_to_string(addrbuf, sizeof(addrbuf), &tmp); - NN_WARNING ("%s => %d truncated to %d\n", addrbuf, (int)ret, (int)len); + DDS_WARNING("%s => %d truncated to %d\n", addrbuf, (int)ret, (int)len); } } else if (err != os_sockENOTSOCK && err != os_sockECONNRESET) { - NN_ERROR ("UDP recvmsg sock %d: ret %d errno %d\n", (int) ((ddsi_udp_conn_t) conn)->m_sock, (int) ret, err); + DDS_ERROR("UDP recvmsg sock %d: ret %d errno %d\n", (int) ((ddsi_udp_conn_t) conn)->m_sock, (int) ret, err); } return ret; } @@ -169,7 +169,7 @@ static ssize_t ddsi_udp_conn_write (ddsi_tran_conn_t conn, const nn_locator_t *d #endif break; default: - NN_ERROR("ddsi_udp_conn_write failed with error code %d", err); + DDS_ERROR("ddsi_udp_conn_write failed with error code %d", err); } } return ret; @@ -220,7 +220,7 @@ static unsigned short get_socket_port (os_socket socket) if (getsockname (socket, (os_sockaddr *) &addr, &addrlen) < 0) { int err = os_getErrno(); - NN_ERROR ("ddsi_udp_get_socket_port: getsockname errno %d\n", err); + DDS_ERROR("ddsi_udp_get_socket_port: getsockname errno %d\n", err); return 0; } @@ -271,9 +271,8 @@ static ddsi_tran_conn_t ddsi_udp_create_conn uc->m_base.m_write_fn = ddsi_udp_conn_write; uc->m_base.m_disable_multiplexing_fn = ddsi_udp_disable_multiplexing; - nn_log + DDS_INFO ( - LC_INFO, "ddsi_udp_create_conn %s socket %"PRIsock" port %u\n", mcast ? "multicast" : "unicast", uc->m_sock, @@ -285,7 +284,7 @@ static ddsi_tran_conn_t ddsi_udp_create_conn if (os_sockSetsockopt (sock, IPPROTO_IP, IP_TOS, (char*) &uc->m_diffserv, sizeof (uc->m_diffserv)) != os_resultSuccess) { int err = os_getErrno(); - NN_ERROR("ddsi_udp_create_conn: set diffserv error %d\n", err); + DDS_ERROR("ddsi_udp_create_conn: set diffserv error %d\n", err); } } #endif @@ -294,7 +293,7 @@ static ddsi_tran_conn_t ddsi_udp_create_conn { if (config.participantIndex != PARTICIPANT_INDEX_AUTO) { - NN_ERROR + DDS_ERROR ( "UDP make_socket failed for %s port %u\n", mcast ? "multicast" : "unicast", @@ -395,9 +394,8 @@ static int ddsi_udp_leave_mc (ddsi_tran_conn_t conn, const nn_locator_t *srcloc, static void ddsi_udp_release_conn (ddsi_tran_conn_t conn) { ddsi_udp_conn_t uc = (ddsi_udp_conn_t) conn; - nn_log + DDS_INFO ( - LC_INFO, "ddsi_udp_release_conn %s socket %"PRIsock" port %u\n", conn->m_base.m_multicast ? "multicast" : "unicast", uc->m_sock, @@ -415,7 +413,7 @@ void ddsi_udp_fini (void) if(os_atomic_dec32_nv (&ddsi_udp_init_g) == 0) { free_group_membership(ddsi_udp_config_g.mship); memset (&ddsi_udp_factory_g, 0, sizeof (ddsi_udp_factory_g)); - nn_log (LC_INFO | LC_CONFIG, "udp finalized\n"); + DDS_LOG(DDS_LC_INFO | DDS_LC_CONFIG, "udp finalized\n"); } } @@ -505,7 +503,7 @@ static void ddsi_udp_deinit(void) if (os_atomic_dec32_nv(&ddsi_udp_init_g) == 0) { if (ddsi_udp_config_g.mship) free_group_membership(ddsi_udp_config_g.mship); - nn_log (LC_INFO | LC_CONFIG, "udp de-initialized\n"); + DDS_LOG(DDS_LC_INFO | DDS_LC_CONFIG, "udp de-initialized\n"); } } @@ -550,7 +548,7 @@ int ddsi_udp_init (void) ddsi_factory_add (&ddsi_udp_factory_g); - nn_log (LC_INFO | LC_CONFIG, "udp initialized\n"); + DDS_LOG(DDS_LC_INFO | DDS_LC_CONFIG, "udp initialized\n"); } return 0; } diff --git a/src/core/ddsi/src/q_addrset.c b/src/core/ddsi/src/q_addrset.c index d4f0176..2c03269 100644 --- a/src/core/ddsi/src/q_addrset.c +++ b/src/core/ddsi/src/q_addrset.c @@ -50,19 +50,19 @@ static int add_addresses_to_addrset_1 (struct addrset *as, const char *ip, int p case AFSR_OK: break; case AFSR_INVALID: - NN_ERROR ("%s: %s: not a valid address\n", msgtag, ip); + DDS_ERROR("%s: %s: not a valid address\n", msgtag, ip); return -1; case AFSR_UNKNOWN: - NN_ERROR ("%s: %s: unknown address\n", msgtag, ip); + DDS_ERROR("%s: %s: unknown address\n", msgtag, ip); return -1; case AFSR_MISMATCH: - NN_ERROR ("%s: %s: address family mismatch\n", msgtag, ip); + DDS_ERROR("%s: %s: address family mismatch\n", msgtag, ip); return -1; } if (req_mc && !ddsi_is_mcaddr (&loc)) { - NN_ERROR ("%s: %s: not a multicast address\n", msgtag, ip); + DDS_ERROR ("%s: %s: not a multicast address\n", msgtag, ip); return -1; } @@ -82,20 +82,20 @@ static int add_addresses_to_addrset_1 (struct addrset *as, const char *ip, int p } else { - NN_ERROR ("%s: %s,%d,%d,%d: IPv4 multicast address generator invalid or out of place\n", - msgtag, ip, mcgen_base, mcgen_count, mcgen_idx); + DDS_ERROR("%s: %s,%d,%d,%d: IPv4 multicast address generator invalid or out of place\n", + msgtag, ip, mcgen_base, mcgen_count, mcgen_idx); return -1; } if (port_mode >= 0) { loc.port = (unsigned) port_mode; - nn_log (LC_CONFIG, "%s: add %s", msgtag, ddsi_locator_to_string(buf, sizeof(buf), &loc)); + DDS_LOG(DDS_LC_CONFIG, "%s: add %s", msgtag, ddsi_locator_to_string(buf, sizeof(buf), &loc)); add_to_addrset (as, &loc); } else { - nn_log (LC_CONFIG, "%s: add ", msgtag); + DDS_LOG(DDS_LC_CONFIG, "%s: add ", msgtag); if (!ddsi_is_mcaddr (&loc)) { int i; @@ -104,9 +104,9 @@ static int add_addresses_to_addrset_1 (struct addrset *as, const char *ip, int p int port = config.port_base + config.port_dg * config.domainId.value + i * config.port_pg + config.port_d1; loc.port = (unsigned) port; if (i == 0) - nn_log (LC_CONFIG, "%s", ddsi_locator_to_string(buf, sizeof(buf), &loc)); + DDS_LOG(DDS_LC_CONFIG, "%s", ddsi_locator_to_string(buf, sizeof(buf), &loc)); else - nn_log (LC_CONFIG, ", :%d", port); + DDS_LOG(DDS_LC_CONFIG, ", :%d", port); add_to_addrset (as, &loc); } } @@ -116,12 +116,12 @@ static int add_addresses_to_addrset_1 (struct addrset *as, const char *ip, int p if (port == -1) port = config.port_base + config.port_dg * config.domainId.value + config.port_d0; loc.port = (unsigned) port; - nn_log (LC_CONFIG, "%s", ddsi_locator_to_string(buf, sizeof(buf), &loc)); + DDS_LOG(DDS_LC_CONFIG, "%s", ddsi_locator_to_string(buf, sizeof(buf), &loc)); add_to_addrset (as, &loc); } } - nn_log (LC_CONFIG, "\n"); + DDS_LOG(DDS_LC_CONFIG, "\n"); return 0; } @@ -168,7 +168,7 @@ int add_addresses_to_addrset (struct addrset *as, const char *addrs, int port_mo if (add_addresses_to_addrset_1 (as, ip, port, msgtag, req_mc, mcgen_base, mcgen_count, mcgen_idx) < 0) goto error; } else { - NN_ERROR ("%s: %s: port %d invalid\n", msgtag, a, port); + DDS_ERROR("%s: %s: port %d invalid\n", msgtag, a, port); } } retval = 0; @@ -562,24 +562,24 @@ int addrset_forone (struct addrset *as, addrset_forone_fun_t f, void *arg) struct log_addrset_helper_arg { - logcat_t tf; + uint32_t tf; }; static void log_addrset_helper (const nn_locator_t *n, void *varg) { const struct log_addrset_helper_arg *arg = varg; char buf[DDSI_LOCSTRLEN]; - if (config.enabled_logcats & arg->tf) - nn_log (arg->tf, " %s", ddsi_locator_to_string(buf, sizeof(buf), n)); + if (dds_get_log_mask() & arg->tf) + DDS_LOG(arg->tf, " %s", ddsi_locator_to_string(buf, sizeof(buf), n)); } -void nn_log_addrset (logcat_t tf, const char *prefix, const struct addrset *as) +void nn_log_addrset (uint32_t tf, const char *prefix, const struct addrset *as) { - if (config.enabled_logcats & tf) + if (dds_get_log_mask() & tf) { struct log_addrset_helper_arg arg; arg.tf = tf; - nn_log (tf, "%s", prefix); + DDS_LOG(tf, "%s", prefix); addrset_forall ((struct addrset *) as, log_addrset_helper, &arg); /* drop const, we know it is */ } } diff --git a/src/core/ddsi/src/q_config.c b/src/core/ddsi/src/q_config.c index 278aab0..ca7d13c 100644 --- a/src/core/ddsi/src/q_config.c +++ b/src/core/ddsi/src/q_config.c @@ -98,10 +98,10 @@ struct cfgst { /* "trace" is special: it enables (nearly) everything */ static const char *logcat_names[] = { - "fatal", "error", "warning", "config", "info", "discovery", "data", "radmin", "timing", "traffic", "topic", "tcp", "plist", "whc", "throttle", "trace", NULL + "fatal", "error", "warning", "info", "config", "discovery", "data", "radmin", "timing", "traffic", "topic", "tcp", "plist", "whc", "throttle", "trace", NULL }; -static const logcat_t logcat_codes[] = { - LC_FATAL, LC_ERROR, LC_WARNING, LC_CONFIG, LC_INFO, LC_DISCOVERY, LC_DATA, LC_RADMIN, LC_TIMING, LC_TRAFFIC, LC_TOPIC, LC_TCP, LC_PLIST, LC_WHC, LC_THROTTLE, LC_ALLCATS +static const uint32_t logcat_codes[] = { + DDS_LC_FATAL, DDS_LC_ERROR, DDS_LC_WARNING, DDS_LC_INFO, DDS_LC_CONFIG, DDS_LC_DISCOVERY, DDS_LC_DATA, DDS_LC_RADMIN, DDS_LC_TIMING, DDS_LC_TRAFFIC, DDS_LC_TOPIC, DDS_LC_TCP, DDS_LC_PLIST, DDS_LC_WHC, DDS_LC_THROTTLE, DDS_LC_ALL }; /* We want the tracing/verbosity settings to be fixed while parsing @@ -785,7 +785,7 @@ static const struct cfgelem tracing_cfgelems[] = {
  • finest: finer + trace
  • \n\

    While none prevents any message from being written to a DDSI2 log file.

    \n\

    The categorisation of tracing output is incomplete and hence most of the verbosity levels and categories are not of much use in the current release. This is an ongoing process and here we describe the target situation rather than the current situation. Currently, the most useful verbosity levels are config, fine and finest.

    " }, -{ LEAF("OutputFile"), 1, DDSC_PROJECT_NAME_NOSPACE_SMALL"-trace.log", ABSOFF(tracingOutputFileName), 0, uf_tracingOutputFileName, ff_free, pf_string, +{ LEAF("OutputFile"), 1, DDSC_PROJECT_NAME_NOSPACE_SMALL".log", ABSOFF(tracingOutputFileName), 0, uf_tracingOutputFileName, ff_free, pf_string, "

    This option specifies where the logging is printed to. Note that stdout and stderr are treated as special values, representing \"standard out\" and \"standard error\" respectively. No file is created unless logging categories are enabled using the Tracing/Verbosity or Tracing/EnabledCategory settings.

    " }, { LEAF_W_ATTRS("Timestamps", timestamp_cfgattrs), 1, "true", ABSOFF(tracingTimestamps), 0, uf_boolean, 0, pf_boolean, "

    This option has no effect.

    " }, @@ -1015,7 +1015,7 @@ static size_t cfg_note_vsnprintf(struct cfg_note_buf *bb, const char *fmt, va_li return nbufsize; } if ( x < 0 ) - NN_FATAL("cfg_note_vsnprintf: os_vsnprintf failed\n"); + DDS_FATAL("cfg_note_vsnprintf: os_vsnprintf failed\n"); else bb->bufpos += (size_t) x; return 0; @@ -1036,13 +1036,13 @@ static void cfg_note_snprintf(struct cfg_note_buf *bb, const char *fmt, ...) va_start(ap, fmt); s = os_vsnprintf(bb->buf + bb->bufpos, bb->bufsize - bb->bufpos, fmt, ap); if ( s < 0 || (size_t) s >= bb->bufsize - bb->bufpos ) - NN_FATAL("cfg_note_snprintf: os_vsnprintf failed\n"); + DDS_FATAL("cfg_note_snprintf: os_vsnprintf failed\n"); va_end(ap); bb->bufpos += (size_t) s; } } -static size_t cfg_note(struct cfgst *cfgst, logcat_t cat, size_t bsz, const char *fmt, va_list ap) +static size_t cfg_note(struct cfgst *cfgst, uint32_t cat, size_t bsz, const char *fmt, va_list ap) { /* Have to snprintf our way to a single string so we can OS_REPORT as well as nn_log. Otherwise configuration errors will be lost @@ -1053,14 +1053,14 @@ static size_t cfg_note(struct cfgst *cfgst, logcat_t cat, size_t bsz, const char int i, sidx; size_t r; - if (cat & LC_ERROR) { + if (cat & DDS_LC_ERROR) { cfgst->error = 1; } bb.bufpos = 0; bb.bufsize = (bsz == 0) ? 1024 : bsz; if ( (bb.buf = os_malloc(bb.bufsize)) == NULL ) - NN_FATAL("cfg_note: out of memory\n"); + DDS_FATAL("cfg_note: out of memory\n"); cfg_note_snprintf(&bb, "config: "); @@ -1093,17 +1093,17 @@ static size_t cfg_note(struct cfgst *cfgst, logcat_t cat, size_t bsz, const char } switch ( cat ) { - case LC_CONFIG: - nn_log(cat, "%s\n", bb.buf); + case DDS_LC_CONFIG: + DDS_LOG(cat, "%s\n", bb.buf); break; - case LC_WARNING: - NN_WARNING("%s\n", bb.buf); + case DDS_LC_WARNING: + DDS_WARNING("%s\n", bb.buf); break; - case LC_ERROR: - NN_ERROR("%s\n", bb.buf); + case DDS_LC_ERROR: + DDS_ERROR("%s\n", bb.buf); break; default: - NN_FATAL("cfg_note unhandled category %u for message %s\n", (unsigned) cat, bb.buf); + DDS_FATAL("cfg_note unhandled category %u for message %s\n", (unsigned) cat, bb.buf); break; } @@ -1118,7 +1118,7 @@ static void cfg_warning(struct cfgst *cfgst, const char *fmt, ...) size_t bsz = 0; do { va_start(ap, fmt); - bsz = cfg_note(cfgst, LC_WARNING, bsz, fmt, ap); + bsz = cfg_note(cfgst, DDS_LC_WARNING, bsz, fmt, ap); va_end(ap); } while ( bsz > 0 ); } @@ -1130,7 +1130,7 @@ static int cfg_error(struct cfgst *cfgst, const char *fmt, ...) size_t bsz = 0; do { va_start(ap, fmt); - bsz = cfg_note(cfgst, LC_ERROR, bsz, fmt, ap); + bsz = cfg_note(cfgst, DDS_LC_ERROR, bsz, fmt, ap); va_end(ap); } while ( bsz > 0 ); return 0; @@ -1142,7 +1142,7 @@ static int cfg_log(struct cfgst *cfgst, const char *fmt, ...) size_t bsz = 0; do { va_start(ap, fmt); - bsz = cfg_note(cfgst, LC_CONFIG, bsz, fmt, ap); + bsz = cfg_note(cfgst, DDS_LC_CONFIG, bsz, fmt, ap); va_end(ap); } while ( bsz > 0 ); return 0; @@ -1345,7 +1345,7 @@ static void pf_boolean_default (struct cfgst *cfgst, void *parent, struct cfgele static int uf_logcat(struct cfgst *cfgst, UNUSED_ARG(void *parent), UNUSED_ARG(struct cfgelem const * const cfgelem), UNUSED_ARG(int first), const char *value) { static const char **vs = logcat_names; - static const logcat_t *lc = logcat_codes; + static const uint32_t *lc = logcat_codes; char *copy = os_strdup(value), *cursor = copy, *tok; while ( (tok = os_strsep(&cursor, ",")) != NULL ) { int idx = list_index(vs, tok); @@ -1365,8 +1365,8 @@ static int uf_verbosity(struct cfgst *cfgst, UNUSED_ARG(void *parent), UNUSED_AR static const char *vs[] = { "finest", "finer", "fine", "config", "info", "warning", "severe", "none", NULL }; - static const logcat_t lc[] = { - LC_ALLCATS, LC_TRAFFIC | LC_TIMING, LC_DISCOVERY | LC_THROTTLE, LC_CONFIG, LC_INFO, LC_WARNING, LC_ERROR | LC_FATAL, 0, 0 + static const uint32_t lc[] = { + DDS_LC_ALL, DDS_LC_TRAFFIC | DDS_LC_TIMING, DDS_LC_DISCOVERY | DDS_LC_THROTTLE, DDS_LC_CONFIG, DDS_LC_INFO, DDS_LC_WARNING, DDS_LC_ERROR | DDS_LC_FATAL, 0, 0 }; int idx = list_index(vs, value); assert(sizeof(vs) / sizeof(*vs) == sizeof(lc) / sizeof(*lc)); @@ -2270,7 +2270,7 @@ static int uf_standards_conformance(struct cfgst *cfgst, void *parent, struct cf static const char *vs[] = { "pedantic", "strict", "lax", NULL }; - static const logcat_t lc[] = { + static const uint32_t lc[] = { NN_SC_PEDANTIC, NN_SC_STRICT, NN_SC_LAX, 0 }; enum nn_standards_conformance *elem = cfg_address(cfgst, parent, cfgelem); @@ -2298,7 +2298,7 @@ static void pf_standards_conformance(struct cfgst *cfgst, void *parent, struct c static void pf_logcat(struct cfgst *cfgst, UNUSED_ARG(void *parent), UNUSED_ARG(struct cfgelem const * const cfgelem), UNUSED_ARG(int is_default)) { - logcat_t remaining = config.enabled_logcats; + uint32_t remaining = config.enabled_logcats; char res[256] = "", *resp = res; const char *prefix = ""; size_t i; @@ -2313,9 +2313,9 @@ static void pf_logcat(struct cfgst *cfgst, UNUSED_ARG(void *parent), UNUSED_ARG( } #endif /* TRACE enables ALLCATS, all the others just one */ - if ( (remaining & LC_ALLCATS) == LC_ALLCATS ) { + if ( (remaining & DDS_LC_ALL) == DDS_LC_ALL ) { resp += snprintf(resp, 256, "%strace", prefix); - remaining &= ~LC_ALLCATS; + remaining &= ~DDS_LC_ALL; prefix = ","; } for ( i = 0; i < sizeof(logcat_codes) / sizeof(*logcat_codes); i++ ) { @@ -2692,7 +2692,7 @@ static int sort_channels_check_nodups(struct config *cfg) result = 0; for ( i = 0; i < n - 1; i++ ) { if ( ary[i]->priority == ary[i + 1]->priority ) { - NN_ERROR("config: duplicate channel definition for priority %u: channels %s and %s\n", + DDS_ERROR("config: duplicate channel definition for priority %u: channels %s and %s\n", ary[i]->priority, ary[i]->name, ary[i + 1]->name); result = ERR_ENTITY_EXISTS; } @@ -2722,7 +2722,7 @@ struct cfgst * config_init memset(&config, 0, sizeof(config)); config.tracingOutputFile = stderr; - config.enabled_logcats = LC_ERROR | LC_WARNING; + config.enabled_logcats = DDS_LC_ERROR | DDS_LC_WARNING; /* eventually, we domainId.value will be the real domain id selected, even if it was configured to the default of "any" and has "isdefault" set; initializing it to the default-default @@ -2747,7 +2747,7 @@ struct cfgst * config_init if ( (fp = fopen(tok, "r")) == NULL ) { if ( strncmp(tok, "file://", 7) != 0 || (fp = fopen(tok + 7, "r")) == NULL ) { - NN_ERROR("can't open configuration file %s\n", tok); + DDS_ERROR("can't open configuration file %s\n", tok); os_free(copy); os_free(cfgst); return NULL; @@ -2816,7 +2816,7 @@ struct cfgst * config_init break; } if (!ok1) - NN_ERROR ("config: invalid combination of Transport, IPv6, TCP\n"); + DDS_ERROR("config: invalid combination of Transport, IPv6, TCP\n"); ok = ok && ok1; cfgst->cfg->compat_use_ipv6 = (cfgst->cfg->transport_selector == TRANS_UDP6 || cfgst->cfg->transport_selector == TRANS_TCP6) ? BOOLDEF_TRUE : BOOLDEF_FALSE; cfgst->cfg->compat_tcp_enable = (cfgst->cfg->transport_selector == TRANS_TCP || cfgst->cfg->transport_selector == TRANS_TCP6) ? BOOLDEF_TRUE : BOOLDEF_FALSE; @@ -2844,17 +2844,17 @@ struct cfgst * config_init case Q_CIPHER_NULL: /* nop */ if ( s->key && strlen(s->key) > 0 ) { - NN_ERROR("config: DDSI2Service/Security/SecurityProfile[@cipherkey]: %s: cipher key not required\n", s->key); + DDS_ERROR("config: DDSI2Service/Security/SecurityProfile[@cipherkey]: %s: cipher key not required\n", s->key); } break; default: /* read the cipherkey if present */ if ( !s->key || strlen(s->key) == 0 ) { - NN_ERROR("config: DDSI2Service/Security/SecurityProfile[@cipherkey]: cipher key missing\n"); + DDS_ERROR("config: DDSI2Service/Security/SecurityProfile[@cipherkey]: cipher key missing\n"); ok = 0; } else if ( q_security_plugin.valid_uri && !(q_security_plugin.valid_uri) (s->cipher, s->key) ) { - NN_ERROR("config: DDSI2Service/Security/SecurityProfile[@cipherkey]: %s : incorrect key\n", s->key); + DDS_ERROR("config: DDSI2Service/Security/SecurityProfile[@cipherkey]: %s : incorrect key\n", s->key); ok = 0; } } @@ -2883,7 +2883,7 @@ struct cfgst * config_init if ( s ) p->securityProfile = s; else { - NN_ERROR("config: DDSI2Service/Partitioning/NetworkPartitions/NetworkPartition[@securityprofile]: %s: unknown securityprofile\n", p->profileName); + DDS_ERROR("config: DDSI2Service/Partitioning/NetworkPartitions/NetworkPartition[@securityprofile]: %s: unknown securityprofile\n", p->profileName); ok = 0; } } @@ -2911,7 +2911,7 @@ struct cfgst * config_init if ( p ) { m->partition = p; } else { - NN_ERROR("config: DDSI2Service/Partitioning/PartitionMappings/PartitionMapping[@networkpartition]: %s: unknown partition\n", m->networkPartition); + DDS_ERROR("config: DDSI2Service/Partitioning/PartitionMappings/PartitionMapping[@networkpartition]: %s: unknown partition\n", m->networkPartition); ok = 0; } m = m->next; @@ -2950,7 +2950,9 @@ void config_fini(_In_ struct cfgst *cfgst) assert(config.valid); free_all_elements(cfgst, cfgst->cfg, root_cfgelems); - if ( config.tracingOutputFile && config.tracingOutputFile != stdout && config.tracingOutputFile != stderr) { + dds_set_log_file(stderr); + dds_set_trace_file(stderr); + if (config.tracingOutputFile && config.tracingOutputFile != stdout && config.tracingOutputFile != stderr) { fclose(config.tracingOutputFile); } memset(&config, 0, sizeof(config)); diff --git a/src/core/ddsi/src/q_ddsi_discovery.c b/src/core/ddsi/src/q_ddsi_discovery.c index 3655ee9..c6fe9f7 100644 --- a/src/core/ddsi/src/q_ddsi_discovery.c +++ b/src/core/ddsi/src/q_ddsi_discovery.c @@ -202,11 +202,11 @@ int spdp_write (struct participant *pp) propagate_builtin_topic_participant(&(pp->e), pp->plist, now(), true); - TRACE (("spdp_write(%x:%x:%x:%x)\n", PGUID (pp->e.guid))); + DDS_TRACE("spdp_write(%x:%x:%x:%x)\n", PGUID (pp->e.guid)); if ((wr = get_builtin_writer (pp, NN_ENTITYID_SPDP_BUILTIN_PARTICIPANT_WRITER)) == NULL) { - TRACE (("spdp_write(%x:%x:%x:%x) - builtin participant writer not found\n", PGUID (pp->e.guid))); + DDS_TRACE("spdp_write(%x:%x:%x:%x) - builtin participant writer not found\n", PGUID (pp->e.guid)); return 0; } @@ -311,7 +311,7 @@ int spdp_write (struct participant *pp) size = strlen(node) + strlen(OSPL_VERSION_STR) + strlen(OSPL_HOST_STR) + strlen(OSPL_TARGET_STR) + 4; /* + ///'\0' */ ps.prismtech_participant_version_info.internals = os_malloc(size); (void) snprintf(ps.prismtech_participant_version_info.internals, size, "%s/%s/%s/%s", node, OSPL_VERSION_STR, OSPL_HOST_STR, OSPL_TARGET_STR); - TRACE (("spdp_write(%x:%x:%x:%x) - internals: %s\n", PGUID (pp->e.guid), ps.prismtech_participant_version_info.internals)); + DDS_TRACE("spdp_write(%x:%x:%x:%x) - internals: %s\n", PGUID (pp->e.guid), ps.prismtech_participant_version_info.internals); } /* Participant QoS's insofar as they are set, different from the default, and mapped to the SPDP data, rather than to the PrismTech-specific CMParticipant endpoint. Currently, that means just USER_DATA. */ @@ -339,7 +339,7 @@ int spdp_dispose_unregister (struct participant *pp) if ((wr = get_builtin_writer (pp, NN_ENTITYID_SPDP_BUILTIN_PARTICIPANT_WRITER)) == NULL) { - TRACE (("spdp_dispose_unregister(%x:%x:%x:%x) - builtin participant writer not found\n", PGUID (pp->e.guid))); + DDS_TRACE("spdp_dispose_unregister(%x:%x:%x:%x) - builtin participant writer not found\n", PGUID (pp->e.guid)); return 0; } @@ -400,7 +400,7 @@ static void respond_to_spdp (const nn_guid_t *dest_proxypp_guid) int64_t delay_max_ms = config.spdp_response_delay_max / 1000000; int64_t delay = (int64_t) delay_norm * delay_max_ms / 1000; nn_mtime_t tsched = add_duration_to_mtime (tnow, delay); - TRACE ((" %"PRId64, delay)); + DDS_TRACE(" %"PRId64, delay); if (!config.unicast_response_to_spdp_messages) /* pp can't reach gc_delete_participant => can safely reschedule */ resched_xevent_if_earlier (pp->spdp_xevent, tsched); @@ -414,26 +414,26 @@ static int handle_SPDP_dead (const struct receiver_state *rst, nn_wctime_t times { nn_guid_t guid; - if (!(config.enabled_logcats & LC_TRACE)) - nn_log (LC_DISCOVERY, "SPDP ST%x", statusinfo); + if (!(dds_get_log_mask() & DDS_LC_DISCOVERY)) + DDS_LOG(DDS_LC_DISCOVERY, "SPDP ST%x", statusinfo); if (datap->present & PP_PARTICIPANT_GUID) { guid = datap->participant_guid; - nn_log (LC_DISCOVERY, " %x:%x:%x:%x", PGUID (guid)); + DDS_LOG(DDS_LC_DISCOVERY, " %x:%x:%x:%x", PGUID (guid)); assert (guid.entityid.u == NN_ENTITYID_PARTICIPANT); if (delete_proxy_participant_by_guid (&guid, timestamp, 0) < 0) { - nn_log (LC_DISCOVERY, " unknown"); + DDS_LOG(DDS_LC_DISCOVERY, " unknown"); } else { - nn_log (LC_DISCOVERY, " delete"); + DDS_LOG(DDS_LC_DISCOVERY, " delete"); } } else { - NN_WARNING ("data (SPDP, vendor %u.%u): no/invalid payload\n", rst->vendor.id[0], rst->vendor.id[1]); + DDS_WARNING("data (SPDP, vendor %u.%u): no/invalid payload\n", rst->vendor.id[0], rst->vendor.id[1]); } return 1; } @@ -485,12 +485,12 @@ static void make_participants_dependent_on_ddsi2 (const nn_guid_t *ddsi2guid, nn { if (vendor_is_opensplice (pp->vendor) && pp->e.guid.prefix.u[0] == ddsi2guid->prefix.u[0] && !pp->is_ddsi2_pp) { - TRACE (("proxy participant %x:%x:%x:%x depends on ddsi2 %x:%x:%x:%x", PGUID (pp->e.guid), PGUID (*ddsi2guid))); + DDS_TRACE("proxy participant %x:%x:%x:%x depends on ddsi2 %x:%x:%x:%x", PGUID (pp->e.guid), PGUID (*ddsi2guid)); os_mutexLock (&pp->e.lock); pp->privileged_pp_guid = *ddsi2guid; os_mutexUnlock (&pp->e.lock); proxy_participant_reassign_lease (pp, d2pp_lease); - TRACE (("\n")); + DDS_TRACE("\n"); if (ephash_lookup_proxy_participant_guid (ddsi2guid) == NULL) { @@ -505,7 +505,7 @@ static void make_participants_dependent_on_ddsi2 (const nn_guid_t *ddsi2guid, nn if (pp != NULL) { - TRACE (("make_participants_dependent_on_ddsi2: ddsi2 %x:%x:%x:%x is no more, delete %x:%x:%x:%x\n", PGUID (*ddsi2guid), PGUID (pp->e.guid))); + DDS_TRACE("make_participants_dependent_on_ddsi2: ddsi2 %x:%x:%x:%x is no more, delete %x:%x:%x:%x\n", PGUID (*ddsi2guid), PGUID (pp->e.guid)); delete_proxy_participant_by_guid (&pp->e.guid, timestamp, 1); } } @@ -523,12 +523,12 @@ static int handle_SPDP_alive (const struct receiver_state *rst, nn_wctime_t time nn_duration_t lease_duration; unsigned custom_flags = 0; - if (!(config.enabled_logcats & LC_TRACE)) - nn_log (LC_DISCOVERY, "SPDP ST0"); + if (!(dds_get_log_mask() & DDS_LC_DISCOVERY)) + DDS_LOG(DDS_LC_DISCOVERY, "SPDP ST0"); if (!(datap->present & PP_PARTICIPANT_GUID) || !(datap->present & PP_BUILTIN_ENDPOINT_SET)) { - NN_WARNING ("data (SPDP, vendor %u.%u): no/invalid payload\n", rst->vendor.id[0], rst->vendor.id[1]); + DDS_WARNING("data (SPDP, vendor %u.%u): no/invalid payload\n", rst->vendor.id[0], rst->vendor.id[1]); return 1; } @@ -546,7 +546,7 @@ static int handle_SPDP_alive (const struct receiver_state *rst, nn_wctime_t time NN_BUILTIN_ENDPOINT_PARTICIPANT_MESSAGE_DATA_WRITER)) && config.assume_rti_has_pmd_endpoints) { - NN_WARNING ("data (SPDP, vendor %u.%u): assuming unadvertised PMD endpoints do exist\n", + DDS_WARNING("data (SPDP, vendor %u.%u): assuming unadvertised PMD endpoints do exist\n", rst->vendor.id[0], rst->vendor.id[1]); builtin_endpoint_set |= NN_BUILTIN_ENDPOINT_PARTICIPANT_MESSAGE_DATA_READER | @@ -561,14 +561,14 @@ static int handle_SPDP_alive (const struct receiver_state *rst, nn_wctime_t time but it would cause problems with cases where we would be happy with only (say) CM participant. Have to do a backwards-compatible fix because it has already been released with the flags all aliased to bits 0 and 1 ... */ - nn_log (LC_DISCOVERY, " (ptbes_fixed_0 %x)", prismtech_builtin_endpoint_set); + DDS_LOG(DDS_LC_DISCOVERY, " (ptbes_fixed_0 %x)", prismtech_builtin_endpoint_set); if (prismtech_builtin_endpoint_set & NN_DISC_BUILTIN_ENDPOINT_CM_PARTICIPANT_READER) prismtech_builtin_endpoint_set |= NN_DISC_BUILTIN_ENDPOINT_CM_PUBLISHER_READER | NN_DISC_BUILTIN_ENDPOINT_CM_SUBSCRIBER_READER; if (prismtech_builtin_endpoint_set & NN_DISC_BUILTIN_ENDPOINT_CM_PARTICIPANT_WRITER) prismtech_builtin_endpoint_set |= NN_DISC_BUILTIN_ENDPOINT_CM_PUBLISHER_WRITER | NN_DISC_BUILTIN_ENDPOINT_CM_SUBSCRIBER_WRITER; } - nn_log (LC_DISCOVERY, " %x:%x:%x:%x", PGUID (datap->participant_guid)); + DDS_LOG(DDS_LC_DISCOVERY, " %x:%x:%x:%x", PGUID (datap->participant_guid)); /* Local SPDP packets may be looped back, and that may include ones currently being deleted. The first thing that happens when @@ -578,7 +578,7 @@ static int handle_SPDP_alive (const struct receiver_state *rst, nn_wctime_t time if (is_deleted_participant_guid (&datap->participant_guid, DPG_REMOTE)) { - nn_log (LC_DISCOVERY, " (recently deleted)"); + DDS_LOG(DDS_LC_DISCOVERY, " (recently deleted)"); return 1; } @@ -588,7 +588,7 @@ static int handle_SPDP_alive (const struct receiver_state *rst, nn_wctime_t time islocal = 1; if (islocal) { - nn_log (LC_DISCOVERY, " (local %d)", islocal); + DDS_LOG(DDS_LC_DISCOVERY, " (local %d)", islocal); return 0; } } @@ -599,12 +599,12 @@ static int handle_SPDP_alive (const struct receiver_state *rst, nn_wctime_t time are even skipping the automatic lease renewal. Therefore do it regardless of config.arrival_of_data_asserts_pp_and_ep_liveliness. */ - nn_log (LC_DISCOVERY, " (known)"); + DDS_LOG(DDS_LC_DISCOVERY, " (known)"); lease_renew (os_atomic_ldvoidp (&proxypp->lease), now_et ()); os_mutexLock (&proxypp->e.lock); if (proxypp->implicitly_created) { - nn_log (LC_DISCOVERY, " (NEW was-implicitly-created)"); + DDS_LOG(DDS_LC_DISCOVERY, " (NEW was-implicitly-created)"); proxypp->implicitly_created = 0; update_proxy_participant_plist_locked (proxypp, datap, UPD_PROXYPP_SPDP, timestamp); } @@ -612,7 +612,7 @@ static int handle_SPDP_alive (const struct receiver_state *rst, nn_wctime_t time return 0; } - nn_log (LC_DISCOVERY, " bes %x ptbes %x NEW", builtin_endpoint_set, prismtech_builtin_endpoint_set); + DDS_LOG(DDS_LC_DISCOVERY, " bes %x ptbes %x NEW", builtin_endpoint_set, prismtech_builtin_endpoint_set); if (datap->present & PP_PARTICIPANT_LEASE_DURATION) { @@ -620,7 +620,7 @@ static int handle_SPDP_alive (const struct receiver_state *rst, nn_wctime_t time } else { - nn_log (LC_DISCOVERY, " (PARTICIPANT_LEASE_DURATION defaulting to 100s)"); + DDS_LOG(DDS_LC_DISCOVERY, " (PARTICIPANT_LEASE_DURATION defaulting to 100s)"); lease_duration = nn_to_ddsi_duration (100 * T_SECOND); } @@ -632,7 +632,7 @@ static int handle_SPDP_alive (const struct receiver_state *rst, nn_wctime_t time (datap->prismtech_participant_version_info.flags & NN_PRISMTECH_FL_PARTICIPANT_IS_DDSI2)) custom_flags |= CF_PARTICIPANT_IS_DDSI2; - nn_log (LC_DISCOVERY, " (0x%08x-0x%08x-0x%08x-0x%08x-0x%08x %s)", + DDS_LOG(DDS_LC_DISCOVERY, " (0x%08x-0x%08x-0x%08x-0x%08x-0x%08x %s)", datap->prismtech_participant_version_info.version, datap->prismtech_participant_version_info.flags, datap->prismtech_participant_version_info.unused[0], @@ -652,7 +652,7 @@ static int handle_SPDP_alive (const struct receiver_state *rst, nn_wctime_t time if ((builtin_endpoint_set & bes_sedp_announcer_mask) != bes_sedp_announcer_mask && memcmp (&privileged_pp_guid, &datap->participant_guid, sizeof (nn_guid_t)) != 0) { - nn_log (LC_DISCOVERY, " (depends on %x:%x:%x:%x)", PGUID (privileged_pp_guid)); + DDS_LOG(DDS_LC_DISCOVERY, " (depends on %x:%x:%x:%x)", PGUID (privileged_pp_guid)); /* never expire lease for this proxy: it won't actually expire until the "privileged" one expires anyway */ lease_duration = nn_to_ddsi_duration (T_NEVER); @@ -668,7 +668,7 @@ static int handle_SPDP_alive (const struct receiver_state *rst, nn_wctime_t time { privileged_pp_guid.prefix = ddsi2->e.guid.prefix; lease_duration = nn_to_ddsi_duration (T_NEVER); - nn_log (LC_DISCOVERY, " (depends on %x:%x:%x:%x)", PGUID (privileged_pp_guid)); + DDS_LOG(DDS_LC_DISCOVERY, " (depends on %x:%x:%x:%x)", PGUID (privileged_pp_guid)); } } else @@ -699,40 +699,40 @@ static int handle_SPDP_alive (const struct receiver_state *rst, nn_wctime_t time else { uc_same_subnet = 1; - nn_log (LC_DISCOVERY, " subnet-filter"); + DDS_LOG(DDS_LC_DISCOVERY, " subnet-filter"); } /* If unicast locators not present, then try to obtain from connection */ if (!config.tcp_use_peeraddr_for_unicast && (datap->present & PP_DEFAULT_UNICAST_LOCATOR) && (get_locator (&loc, &datap->default_unicast_locators, uc_same_subnet))) add_to_addrset (as_default, &loc); else { - nn_log (LC_DISCOVERY, " (srclocD)"); + DDS_LOG(DDS_LC_DISCOVERY, " (srclocD)"); add_to_addrset (as_default, &rst->srcloc); } if (!config.tcp_use_peeraddr_for_unicast && (datap->present & PP_METATRAFFIC_UNICAST_LOCATOR) && (get_locator (&loc, &datap->metatraffic_unicast_locators, uc_same_subnet))) add_to_addrset (as_meta, &loc); else { - nn_log (LC_DISCOVERY, " (srclocM)"); + DDS_LOG(DDS_LC_DISCOVERY, " (srclocM)"); add_to_addrset (as_meta, &rst->srcloc); } - nn_log_addrset (LC_DISCOVERY, " (data", as_default); - nn_log_addrset (LC_DISCOVERY, " meta", as_meta); - nn_log (LC_DISCOVERY, ")"); + nn_log_addrset(DDS_LC_DISCOVERY, " (data", as_default); + nn_log_addrset(DDS_LC_DISCOVERY, " meta", as_meta); + DDS_LOG(DDS_LC_DISCOVERY, ")"); } if (addrset_empty_uc (as_default) || addrset_empty_uc (as_meta)) { - nn_log (LC_DISCOVERY, " (no unicast address"); + DDS_LOG(DDS_LC_DISCOVERY, " (no unicast address"); unref_addrset (as_default); unref_addrset (as_meta); return 1; } - nn_log (LC_DISCOVERY, " QOS={"); - nn_log_xqos (LC_DISCOVERY, &datap->qos); - nn_log (LC_DISCOVERY, "}\n"); + DDS_LOG(DDS_LC_DISCOVERY, " QOS={"); + nn_log_xqos(DDS_LC_DISCOVERY, &datap->qos); + DDS_LOG(DDS_LC_DISCOVERY, "}\n"); maybe_add_pp_as_meta_to_as_disc (as_meta); @@ -759,12 +759,12 @@ static int handle_SPDP_alive (const struct receiver_state *rst, nn_wctime_t time (rst->dst_guid_prefix.u[0] != 0 || rst->dst_guid_prefix.u[1] != 0 || rst->dst_guid_prefix.u[2] != 0); if (!have_dst) { - nn_log (LC_DISCOVERY, "broadcasted SPDP packet -> answering"); + DDS_LOG(DDS_LC_DISCOVERY, "broadcasted SPDP packet -> answering"); respond_to_spdp (&datap->participant_guid); } else { - nn_log (LC_DISCOVERY, "directed SPDP packet -> not responding\n"); + DDS_LOG(DDS_LC_DISCOVERY, "directed SPDP packet -> not responding\n"); } } @@ -781,7 +781,7 @@ static int handle_SPDP_alive (const struct receiver_state *rst, nn_wctime_t time of DDSI2. */ if (ephash_lookup_proxy_participant_guid (&privileged_pp_guid) == NULL) { - nn_log (LC_DISCOVERY, "make_participants_dependent_on_ddsi2: ddsi2 %x:%x:%x:%x is no more, delete %x:%x:%x:%x\n", PGUID (privileged_pp_guid), PGUID (datap->participant_guid)); + DDS_LOG(DDS_LC_DISCOVERY, "make_participants_dependent_on_ddsi2: ddsi2 %x:%x:%x:%x is no more, delete %x:%x:%x:%x\n", PGUID (privileged_pp_guid), PGUID (datap->participant_guid)); delete_proxy_participant_by_guid (&datap->participant_guid, timestamp, 1); } } @@ -791,10 +791,10 @@ static int handle_SPDP_alive (const struct receiver_state *rst, nn_wctime_t time static void handle_SPDP (const struct receiver_state *rst, nn_wctime_t timestamp, unsigned statusinfo, const void *vdata, unsigned len) { const struct CDRHeader *data = vdata; /* built-ins not deserialized (yet) */ - TRACE (("SPDP ST%x", statusinfo)); + DDS_TRACE("SPDP ST%x", statusinfo); if (data == NULL) { - TRACE ((" no payload?\n")); + DDS_TRACE(" no payload?\n"); return; } else @@ -809,7 +809,7 @@ static void handle_SPDP (const struct receiver_state *rst, nn_wctime_t timestamp src.bufsz = len - 4; if (nn_plist_init_frommsg (&decoded_data, NULL, ~(uint64_t)0, ~(uint64_t)0, &src) < 0) { - NN_WARNING ("SPDP (vendor %u.%u): invalid qos/parameters\n", src.vendorid.id[0], src.vendorid.id[1]); + DDS_WARNING("SPDP (vendor %u.%u): invalid qos/parameters\n", src.vendorid.id[0], src.vendorid.id[1]); return; } @@ -827,7 +827,7 @@ static void handle_SPDP (const struct receiver_state *rst, nn_wctime_t timestamp } nn_plist_fini (&decoded_data); - nn_log (interesting ? LC_DISCOVERY : LC_TRACE, "\n"); + DDS_LOG(interesting ? DDS_LC_DISCOVERY : DDS_LC_TRACE, "\n"); } } @@ -951,7 +951,7 @@ static int sedp_write_endpoint nn_xmsg_addpar_sentinel (mpayload); nn_plist_fini (&ps); - TRACE (("sedp: write for %x:%x:%x:%x via %x:%x:%x:%x\n", PGUID (*epguid), PGUID (wr->e.guid))); + DDS_LOG(DDS_LC_DISCOVERY, "sedp: write for %x:%x:%x:%x via %x:%x:%x:%x\n", PGUID (*epguid), PGUID (wr->e.guid)); ret = write_mpayload (wr, alive, PID_ENDPOINT_GUID, mpayload); nn_xmsg_free (mpayload); return ret; @@ -961,7 +961,7 @@ static struct writer *get_sedp_writer (const struct participant *pp, unsigned en { struct writer *sedp_wr = get_builtin_writer (pp, entityid); if (sedp_wr == NULL) - NN_FATAL ("sedp_write_writer: no SEDP builtin writer %x for %x:%x:%x:%x\n", entityid, PGUID (pp->e.guid)); + DDS_FATAL("sedp_write_writer: no SEDP builtin writer %x for %x:%x:%x:%x\n", entityid, PGUID (pp->e.guid)); return sedp_wr; } @@ -1044,14 +1044,14 @@ static struct proxy_participant *implicitly_create_proxypp (const nn_guid_t *ppg { nn_vendorid_t actual_vendorid; /* Some endpoint that we discovered through the DS, but then it must have at least some locators */ - TRACE ((" from-DS %x:%x:%x:%x", PGUID (privguid))); + DDS_TRACE(" from-DS %x:%x:%x:%x", PGUID (privguid)); /* avoid "no address" case, so we never create the proxy participant for nothing (FIXME: rework some of this) */ if (!(datap->present & (PP_UNICAST_LOCATOR | PP_MULTICAST_LOCATOR))) { - TRACE ((" data locator absent\n")); + DDS_TRACE(" data locator absent\n"); goto err; } - nn_log (LC_DISCOVERY, " new-proxypp %x:%x:%x:%x\n", PGUID (*ppguid)); + DDS_TRACE(" new-proxypp %x:%x:%x:%x\n", PGUID (*ppguid)); /* We need to handle any source of entities, but we really want to try to keep the GIDs (and certainly the systemId component) unchanged for OSPL. The new proxy participant will take the GID from the GUID if it is from a "modern" OSPL that advertises it includes all GIDs in @@ -1073,18 +1073,18 @@ static struct proxy_participant *implicitly_create_proxypp (const nn_guid_t *ppg with a minimal built-in endpoint set */ struct proxy_participant *privpp; if ((privpp = ephash_lookup_proxy_participant_guid (&privguid)) == NULL) { - TRACE ((" unknown-src-proxypp?\n")); + DDS_TRACE(" unknown-src-proxypp?\n"); goto err; } else if (!privpp->is_ddsi2_pp) { - TRACE ((" src-proxypp-not-ddsi2?\n")); + DDS_TRACE(" src-proxypp-not-ddsi2?\n"); goto err; } else if (!privpp->minimal_bes_mode) { - TRACE ((" src-ddsi2-not-minimal-bes-mode?\n")); + DDS_TRACE(" src-ddsi2-not-minimal-bes-mode?\n"); goto err; } else { struct addrset *as_default, *as_meta; nn_plist_t tmp_plist; - TRACE ((" from-ddsi2 %x:%x:%x:%x", PGUID (privguid))); + DDS_TRACE(" from-ddsi2 %x:%x:%x:%x", PGUID (privguid)); nn_plist_init_empty (&pp_plist); os_mutexLock (&privpp->e.lock); @@ -1109,7 +1109,7 @@ static struct proxy_participant *implicitly_create_proxypp (const nn_guid_t *ppg static void handle_SEDP_alive (const struct receiver_state *rst, nn_plist_t *datap /* note: potentially modifies datap */, const nn_guid_prefix_t *src_guid_prefix, nn_vendorid_t vendorid, nn_wctime_t timestamp) { -#define E(msg, lbl) do { nn_log (LC_DISCOVERY, (msg)); goto lbl; } while (0) +#define E(msg, lbl) do { DDS_LOG(DDS_LC_DISCOVERY, msg); goto lbl; } while (0) struct proxy_participant *pp; struct proxy_writer * pwr = NULL; struct proxy_reader * prd = NULL; @@ -1126,7 +1126,7 @@ static void handle_SEDP_alive (const struct receiver_state *rst, nn_plist_t *dat if (!(datap->present & PP_ENDPOINT_GUID)) E (" no guid?\n", err); - nn_log (LC_DISCOVERY, " %x:%x:%x:%x", PGUID (datap->endpoint_guid)); + DDS_LOG(DDS_LC_DISCOVERY, " %x:%x:%x:%x", PGUID (datap->endpoint_guid)); ppguid.prefix = datap->endpoint_guid.prefix; ppguid.entityid.u = NN_ENTITYID_PARTICIPANT; @@ -1145,11 +1145,11 @@ static void handle_SEDP_alive (const struct receiver_state *rst, nn_plist_t *dat if ((pp = ephash_lookup_proxy_participant_guid (&ppguid)) == NULL) { - nn_log (LC_DISCOVERY, " unknown-proxypp"); + DDS_LOG(DDS_LC_DISCOVERY, " unknown-proxypp"); if ((pp = implicitly_create_proxypp (&ppguid, datap, src_guid_prefix, vendorid, timestamp)) == NULL) E ("?\n", err); /* Repeat regular SEDP trace for convenience */ - nn_log (LC_DISCOVERY, "SEDP ST0 %x:%x:%x:%x (cont)", PGUID (datap->endpoint_guid)); + DDS_LOG(DDS_LC_DISCOVERY, "SEDP ST0 %x:%x:%x:%x (cont)", PGUID (datap->endpoint_guid)); } xqos = &datap->qos; @@ -1169,7 +1169,7 @@ static void handle_SEDP_alive (const struct receiver_state *rst, nn_plist_t *dat assert (xqos->present & QP_DURABILITY); reliable = (xqos->reliability.kind == NN_RELIABLE_RELIABILITY_QOS); - nn_log (LC_DISCOVERY, " %s %s %s: %s%s.%s/%s", + DDS_LOG(DDS_LC_DISCOVERY, " %s %s %s: %s%s.%s/%s", reliable ? "reliable" : "best-effort", durability_to_string (xqos->durability.kind), is_writer ? "writer" : "reader", @@ -1197,28 +1197,28 @@ static void handle_SEDP_alive (const struct receiver_state *rst, nn_plist_t *dat if (! vendor_is_cloud (vendorid)) { - nn_log (LC_DISCOVERY, " known\n"); + DDS_LOG(DDS_LC_DISCOVERY, " known\n"); goto err; } /* Re-bind the proxy participant to the discovery service - and do this if it is currently bound to another DS instance, because that other DS instance may have already failed and with a new one taking over, without our noticing it. */ - nn_log (LC_DISCOVERY, " known-DS"); + DDS_LOG(DDS_LC_DISCOVERY, " known-DS"); if (vendor_is_cloud (vendorid) && pp->implicitly_created && memcmp(&pp->privileged_pp_guid.prefix, src_guid_prefix, sizeof(pp->privileged_pp_guid.prefix)) != 0) { nn_etime_t never = { T_NEVER }; - nn_log (LC_DISCOVERY, " %x:%x:%x:%x attach-to-DS %x:%x:%x:%x", PGUID(pp->e.guid), PGUIDPREFIX(*src_guid_prefix), pp->privileged_pp_guid.entityid.u); + DDS_LOG(DDS_LC_DISCOVERY, " %x:%x:%x:%x attach-to-DS %x:%x:%x:%x", PGUID(pp->e.guid), PGUIDPREFIX(*src_guid_prefix), pp->privileged_pp_guid.entityid.u); os_mutexLock (&pp->e.lock); pp->privileged_pp_guid.prefix = *src_guid_prefix; lease_set_expiry(os_atomic_ldvoidp(&pp->lease), never); os_mutexUnlock (&pp->e.lock); } - nn_log (LC_DISCOVERY, "\n"); + DDS_LOG(DDS_LC_DISCOVERY, "\n"); } else { - nn_log (LC_DISCOVERY, " NEW"); + DDS_LOG(DDS_LC_DISCOVERY, " NEW"); } { @@ -1228,7 +1228,7 @@ static void handle_SEDP_alive (const struct receiver_state *rst, nn_plist_t *dat add_to_addrset (as, &loc); else if (config.tcp_use_peeraddr_for_unicast) { - nn_log (LC_DISCOVERY, " (srcloc)"); + DDS_LOG(DDS_LC_DISCOVERY, " (srcloc)"); add_to_addrset (as, &rst->srcloc); } else @@ -1246,22 +1246,22 @@ static void handle_SEDP_alive (const struct receiver_state *rst, nn_plist_t *dat E (" no address", err); } - nn_log_addrset (LC_DISCOVERY, " (as", as); + nn_log_addrset(DDS_LC_DISCOVERY, " (as", as); #ifdef DDSI_INCLUDE_SSM ssm = 0; if (is_writer) ssm = addrset_contains_ssm (as); else if (datap->present & PP_READER_FAVOURS_SSM) ssm = (datap->reader_favours_ssm.state != 0); - nn_log (LC_DISCOVERY, " ssm=%u", ssm); + DDS_LOG(DDS_LC_DISCOVERY, " ssm=%u", ssm); #endif - nn_log (LC_DISCOVERY, ") QOS={"); - nn_log_xqos (LC_DISCOVERY, xqos); - nn_log (LC_DISCOVERY, "}\n"); + DDS_LOG(DDS_LC_DISCOVERY, ") QOS={"); + nn_log_xqos(DDS_LC_DISCOVERY, xqos); + DDS_LOG(DDS_LC_DISCOVERY, "}\n"); if ((datap->endpoint_guid.entityid.u & NN_ENTITYID_SOURCE_MASK) == NN_ENTITYID_SOURCE_VENDOR && !vendor_is_prismtech (vendorid)) { - nn_log (LC_DISCOVERY, "ignoring vendor-specific endpoint %x:%x:%x:%x\n", PGUID (datap->endpoint_guid)); + DDS_LOG(DDS_LC_DISCOVERY, "ignoring vendor-specific endpoint %x:%x:%x:%x\n", PGUID (datap->endpoint_guid)); } else { @@ -1315,10 +1315,10 @@ static void handle_SEDP_dead (nn_plist_t *datap, nn_wctime_t timestamp) int res; if (!(datap->present & PP_ENDPOINT_GUID)) { - nn_log (LC_DISCOVERY, " no guid?\n"); + DDS_LOG(DDS_LC_DISCOVERY, " no guid?\n"); return; } - nn_log (LC_DISCOVERY, " %x:%x:%x:%x", PGUID (datap->endpoint_guid)); + DDS_LOG(DDS_LC_DISCOVERY, " %x:%x:%x:%x", PGUID (datap->endpoint_guid)); if (is_writer_entityid (datap->endpoint_guid.entityid)) { res = delete_proxy_writer (&datap->endpoint_guid, timestamp, 0); @@ -1327,16 +1327,16 @@ static void handle_SEDP_dead (nn_plist_t *datap, nn_wctime_t timestamp) { res = delete_proxy_reader (&datap->endpoint_guid, timestamp, 0); } - nn_log (LC_DISCOVERY, " %s\n", (res < 0) ? " unknown" : " delete"); + DDS_LOG(DDS_LC_DISCOVERY, " %s\n", (res < 0) ? " unknown" : " delete"); } static void handle_SEDP (const struct receiver_state *rst, nn_wctime_t timestamp, unsigned statusinfo, const void *vdata, unsigned len) { const struct CDRHeader *data = vdata; /* built-ins not deserialized (yet) */ - nn_log (LC_DISCOVERY, "SEDP ST%x", statusinfo); + DDS_LOG(DDS_LC_DISCOVERY, "SEDP ST%x", statusinfo); if (data == NULL) { - nn_log (LC_DISCOVERY, " no payload?\n"); + DDS_LOG(DDS_LC_DISCOVERY, " no payload?\n"); return; } else @@ -1350,7 +1350,7 @@ static void handle_SEDP (const struct receiver_state *rst, nn_wctime_t timestamp src.bufsz = len - 4; if (nn_plist_init_frommsg (&decoded_data, NULL, ~(uint64_t)0, ~(uint64_t)0, &src) < 0) { - NN_WARNING ("SEDP (vendor %u.%u): invalid qos/parameters\n", src.vendorid.id[0], src.vendorid.id[1]); + DDS_WARNING("SEDP (vendor %u.%u): invalid qos/parameters\n", src.vendorid.id[0], src.vendorid.id[1]); return; } @@ -1400,7 +1400,7 @@ int sedp_write_topic (struct participant *pp, const struct nn_plist *datap) nn_plist_addtomsg (mpayload, datap, ~(uint64_t)0, delta); nn_xmsg_addpar_sentinel (mpayload); - TRACE (("sedp: write topic %s via %x:%x:%x:%x\n", datap->qos.topic_name, PGUID (sedp_wr->e.guid))); + DDS_TRACE("sedp: write topic %s via %x:%x:%x:%x\n", datap->qos.topic_name, PGUID (sedp_wr->e.guid)); ret = write_mpayload (sedp_wr, 1, PID_TOPIC_NAME, mpayload); nn_xmsg_free (mpayload); return ret; @@ -1449,8 +1449,8 @@ int sedp_write_cm_participant (struct participant *pp, int alive) } nn_xmsg_addpar_sentinel (mpayload); - TRACE (("sedp: write CMParticipant ST%x for %x:%x:%x:%x via %x:%x:%x:%x\n", - alive ? 0 : NN_STATUSINFO_DISPOSE | NN_STATUSINFO_UNREGISTER, PGUID (pp->e.guid), PGUID (sedp_wr->e.guid))); + DDS_TRACE("sedp: write CMParticipant ST%x for %x:%x:%x:%x via %x:%x:%x:%x\n", + alive ? 0 : NN_STATUSINFO_DISPOSE | NN_STATUSINFO_UNREGISTER, PGUID (pp->e.guid), PGUID (sedp_wr->e.guid)); ret = write_mpayload (sedp_wr, alive, PID_PARTICIPANT_GUID, mpayload); nn_xmsg_free (mpayload); return ret; @@ -1459,12 +1459,12 @@ int sedp_write_cm_participant (struct participant *pp, int alive) static void handle_SEDP_CM (const struct receiver_state *rst, nn_entityid_t wr_entity_id, nn_wctime_t timestamp, unsigned statusinfo, const void *vdata, unsigned len) { const struct CDRHeader *data = vdata; /* built-ins not deserialized (yet) */ - nn_log (LC_DISCOVERY, "SEDP_CM ST%x", statusinfo); + DDS_LOG(DDS_LC_DISCOVERY, "SEDP_CM ST%x", statusinfo); assert (wr_entity_id.u == NN_ENTITYID_SEDP_BUILTIN_CM_PARTICIPANT_WRITER); (void) wr_entity_id; if (data == NULL) { - nn_log (LC_DISCOVERY, " no payload?\n"); + DDS_LOG(DDS_LC_DISCOVERY, " no payload?\n"); return; } else @@ -1478,7 +1478,7 @@ static void handle_SEDP_CM (const struct receiver_state *rst, nn_entityid_t wr_e src.bufsz = len - 4; if (nn_plist_init_frommsg (&decoded_data, NULL, ~(uint64_t)0, ~(uint64_t)0, &src) < 0) { - NN_WARNING ("SEDP_CM (vendor %u.%u): invalid qos/parameters\n", src.vendorid.id[0], src.vendorid.id[1]); + DDS_WARNING("SEDP_CM (vendor %u.%u): invalid qos/parameters\n", src.vendorid.id[0], src.vendorid.id[1]); return; } @@ -1487,7 +1487,7 @@ static void handle_SEDP_CM (const struct receiver_state *rst, nn_entityid_t wr_e { struct proxy_participant *proxypp; if (!(decoded_data.present & PP_PARTICIPANT_GUID)) - NN_WARNING ("SEDP_CM (vendor %u.%u): missing participant GUID\n", src.vendorid.id[0], src.vendorid.id[1]); + DDS_WARNING("SEDP_CM (vendor %u.%u): missing participant GUID\n", src.vendorid.id[0], src.vendorid.id[1]); else { if ((proxypp = ephash_lookup_proxy_participant_guid (&decoded_data.participant_guid)) == NULL) @@ -1499,7 +1499,7 @@ static void handle_SEDP_CM (const struct receiver_state *rst, nn_entityid_t wr_e nn_plist_fini (&decoded_data); } - nn_log (LC_DISCOVERY, "\n"); + DDS_LOG(DDS_LC_DISCOVERY, "\n"); } static struct participant *group_guid_to_participant (const nn_guid_t *group_guid) @@ -1520,8 +1520,8 @@ int sedp_write_cm_publisher (const struct nn_plist *datap, int alive) if ((pp = group_guid_to_participant (&datap->group_guid)) == NULL) { - TRACE (("sedp: write CMPublisher alive:%d for %x:%x:%x:%x dropped: no participant\n", - alive, PGUID (datap->group_guid))); + DDS_TRACE("sedp: write CMPublisher alive:%d for %x:%x:%x:%x dropped: no participant\n", + alive, PGUID (datap->group_guid)); return 0; } sedp_wr = get_sedp_writer (pp, NN_ENTITYID_SEDP_BUILTIN_CM_PUBLISHER_WRITER); @@ -1556,8 +1556,8 @@ int sedp_write_cm_subscriber (const struct nn_plist *datap, int alive) if ((pp = group_guid_to_participant (&datap->group_guid)) == NULL) { - TRACE (("sedp: write CMSubscriber alive:%d for %x:%x:%x:%x dropped: no participant\n", - alive, PGUID (datap->group_guid))); + DDS_LOG(DDS_LC_DISCOVERY, "sedp: write CMSubscriber alive:%d for %x:%x:%x:%x dropped: no participant\n", + alive, PGUID (datap->group_guid)); return 0; } sedp_wr = get_sedp_writer (pp, NN_ENTITYID_SEDP_BUILTIN_CM_SUBSCRIBER_WRITER); @@ -1584,19 +1584,19 @@ int sedp_write_cm_subscriber (const struct nn_plist *datap, int alive) static void handle_SEDP_GROUP_alive (nn_plist_t *datap /* note: potentially modifies datap */, nn_wctime_t timestamp) { -#define E(msg, lbl) do { nn_log (LC_DISCOVERY, (msg)); goto lbl; } while (0) +#define E(msg, lbl) do { DDS_LOG(DDS_LC_DISCOVERY, msg); goto lbl; } while (0) nn_guid_t ppguid; if (!(datap->present & PP_GROUP_GUID)) E (" no guid?\n", err); - nn_log (LC_DISCOVERY, " %x:%x:%x:%x", PGUID (datap->group_guid)); + DDS_LOG(DDS_LC_DISCOVERY, " %x:%x:%x:%x", PGUID (datap->group_guid)); ppguid.prefix = datap->group_guid.prefix; ppguid.entityid.u = NN_ENTITYID_PARTICIPANT; if (ephash_lookup_proxy_participant_guid (&ppguid) == NULL) E (" unknown proxy pp?\n", err); - nn_log (LC_DISCOVERY, " alive\n"); + DDS_LOG(DDS_LC_DISCOVERY, " alive\n"); { char *name = (datap->present & PP_ENTITY_NAME) ? datap->entity_name : ""; @@ -1611,20 +1611,20 @@ static void handle_SEDP_GROUP_dead (nn_plist_t *datap, nn_wctime_t timestamp) { if (!(datap->present & PP_GROUP_GUID)) { - nn_log (LC_DISCOVERY, " no guid?\n"); + DDS_LOG(DDS_LC_DISCOVERY, " no guid?\n"); return; } - nn_log (LC_DISCOVERY, " %x:%x:%x:%x\n", PGUID (datap->group_guid)); + DDS_LOG(DDS_LC_DISCOVERY, " %x:%x:%x:%x\n", PGUID (datap->group_guid)); delete_proxy_group (&datap->group_guid, timestamp, 0); } static void handle_SEDP_GROUP (const struct receiver_state *rst, nn_wctime_t timestamp, unsigned statusinfo, const void *vdata, unsigned len) { const struct CDRHeader *data = vdata; /* built-ins not deserialized (yet) */ - nn_log (LC_DISCOVERY, "SEDP_GROUP ST%x", statusinfo); + DDS_LOG(DDS_LC_DISCOVERY, "SEDP_GROUP ST%x", statusinfo); if (data == NULL) { - nn_log (LC_DISCOVERY, " no payload?\n"); + DDS_LOG(DDS_LC_DISCOVERY, " no payload?\n"); return; } else @@ -1638,7 +1638,7 @@ static void handle_SEDP_GROUP (const struct receiver_state *rst, nn_wctime_t tim src.bufsz = len - 4; if (nn_plist_init_frommsg (&decoded_data, NULL, ~(uint64_t)0, ~(uint64_t)0, &src) < 0) { - NN_WARNING ("SEDP_GROUP (vendor %u.%u): invalid qos/parameters\n", src.vendorid.id[0], src.vendorid.id[1]); + DDS_WARNING("SEDP_GROUP (vendor %u.%u): invalid qos/parameters\n", src.vendorid.id[0], src.vendorid.id[1]); return; } @@ -1759,7 +1759,7 @@ int builtins_dqueue_handler (const struct nn_rsample_info *sampleinfo, const str src.bufsz = NN_RDATA_PAYLOAD_OFF (fragchain) - qos_offset; if (nn_plist_init_frommsg (&qos, NULL, PP_STATUSINFO | PP_KEYHASH, 0, &src) < 0) { - NN_WARNING ("data(builtin, vendor %u.%u): %x:%x:%x:%x #%"PRId64": invalid inline qos\n", + DDS_WARNING("data(builtin, vendor %u.%u): %x:%x:%x:%x #%"PRId64": invalid inline qos\n", src.vendorid.id[0], src.vendorid.id[1], PGUID (srcguid), sampleinfo->seq); goto done_upd_deliv; } @@ -1783,7 +1783,7 @@ int builtins_dqueue_handler (const struct nn_rsample_info *sampleinfo, const str { if (datasz == 0 || !(data_smhdr_flags & DATA_FLAG_DATAFLAG)) { - NN_WARNING ("data(builtin, vendor %u.%u): %x:%x:%x:%x #%"PRId64": " + DDS_WARNING("data(builtin, vendor %u.%u): %x:%x:%x:%x #%"PRId64": " "built-in data but no payload\n", sampleinfo->rst->vendor.id[0], sampleinfo->rst->vendor.id[1], PGUID (srcguid), sampleinfo->seq); @@ -1797,7 +1797,7 @@ int builtins_dqueue_handler (const struct nn_rsample_info *sampleinfo, const str hasn't been checked fully yet. */ if (!(data_smhdr_flags & DATA_FLAG_KEYFLAG)) { - NN_WARNING ("data(builtin, vendor %u.%u): %x:%x:%x:%x #%"PRId64": " + DDS_WARNING("data(builtin, vendor %u.%u): %x:%x:%x:%x #%"PRId64": " "dispose/unregister of built-in data but payload not just key\n", sampleinfo->rst->vendor.id[0], sampleinfo->rst->vendor.id[1], PGUID (srcguid), sampleinfo->seq); @@ -1839,7 +1839,7 @@ int builtins_dqueue_handler (const struct nn_rsample_info *sampleinfo, const str pid = PID_ENDPOINT_GUID; break; default: - NN_WARNING ("data(builtin, vendor %u.%u): %x:%x:%x:%x #%"PRId64": mapping keyhash to ENDPOINT_GUID", + DDS_WARNING("data(builtin, vendor %u.%u): %x:%x:%x:%x #%"PRId64": mapping keyhash to ENDPOINT_GUID", sampleinfo->rst->vendor.id[0], sampleinfo->rst->vendor.id[1], PGUID (srcguid), sampleinfo->seq); pid = PID_ENDPOINT_GUID; @@ -1856,7 +1856,7 @@ int builtins_dqueue_handler (const struct nn_rsample_info *sampleinfo, const str } else { - NN_WARNING ("data(builtin, vendor %u.%u): %x:%x:%x:%x #%"PRId64": " + DDS_WARNING("data(builtin, vendor %u.%u): %x:%x:%x:%x #%"PRId64": " "dispose/unregister with no content\n", sampleinfo->rst->vendor.id[0], sampleinfo->rst->vendor.id[1], PGUID (srcguid), sampleinfo->seq); @@ -1884,7 +1884,7 @@ int builtins_dqueue_handler (const struct nn_rsample_info *sampleinfo, const str handle_SEDP_GROUP (sampleinfo->rst, timestamp, statusinfo, datap, datasz); break; default: - NN_WARNING ("data(builtin, vendor %u.%u): %x:%x:%x:%x #%"PRId64": not handled\n", + DDS_WARNING ("data(builtin, vendor %u.%u): %x:%x:%x:%x #%"PRId64": not handled\n", sampleinfo->rst->vendor.id[0], sampleinfo->rst->vendor.id[1], PGUID (srcguid), sampleinfo->seq); break; diff --git a/src/core/ddsi/src/q_debmon.c b/src/core/ddsi/src/q_debmon.c index 6671cac..a0a27b0 100644 --- a/src/core/ddsi/src/q_debmon.c +++ b/src/core/ddsi/src/q_debmon.c @@ -352,7 +352,7 @@ struct debug_monitor *new_debug_monitor (int port) dm->servsock = ddsi_factory_create_listener (dm->tran_factory, port, NULL); if (dm->servsock == NULL) { - NN_WARNING ("debmon: can't create socket\n"); + DDS_WARNING("debmon: can't create socket\n"); goto err_servsock; } @@ -360,7 +360,7 @@ struct debug_monitor *new_debug_monitor (int port) nn_locator_t loc; char buf[DDSI_LOCSTRLEN]; (void) ddsi_listener_locator(dm->servsock, &loc); - nn_log (LC_CONFIG, "debmon at %s\n", ddsi_locator_to_string (buf, sizeof(buf), &loc)); + DDS_LOG(DDS_LC_CONFIG, "debmon at %s\n", ddsi_locator_to_string (buf, sizeof(buf), &loc)); } os_mutexInit (&dm->lock); diff --git a/src/core/ddsi/src/q_entity.c b/src/core/ddsi/src/q_entity.c index d9d6de9..ae487e1 100644 --- a/src/core/ddsi/src/q_entity.c +++ b/src/core/ddsi/src/q_entity.c @@ -297,7 +297,7 @@ int is_deleted_participant_guid (const struct nn_guid *guid, unsigned for_what) static void remove_deleted_participant_guid (const struct nn_guid *guid, unsigned for_what) { struct deleted_participant *n; - nn_log (LC_DISCOVERY, "remove_deleted_participant_guid(%x:%x:%x:%x for_what=%x)\n", PGUID (*guid), for_what); + DDS_LOG(DDS_LC_DISCOVERY, "remove_deleted_participant_guid(%x:%x:%x:%x for_what=%x)\n", PGUID (*guid), for_what); os_mutexLock (&deleted_participants_lock); if ((n = ut_avlLookup (&deleted_participants_treedef, &deleted_participants, guid)) != NULL) { @@ -339,7 +339,7 @@ int pp_allocate_entityid(nn_entityid_t *id, unsigned kind, struct participant *p } else { - NN_ERROR("pp_allocate_entityid(%x:%x:%x:%x): all ids in use\n", PGUID(pp->e.guid)); + DDS_ERROR("pp_allocate_entityid(%x:%x:%x:%x): all ids in use\n", PGUID(pp->e.guid)); ret = ERR_OUT_OF_IDS; } os_mutexUnlock (&pp->e.lock); @@ -390,12 +390,12 @@ int new_participant_guid (const nn_guid_t *ppguid, unsigned flags, const nn_plis else { os_mutexUnlock (&gv.participant_set_lock); - NN_ERROR ("new_participant(%x:%x:%x:%x, %x) failed: max participants reached\n", PGUID (*ppguid), flags); + DDS_ERROR("new_participant(%x:%x:%x:%x, %x) failed: max participants reached\n", PGUID (*ppguid), flags); return ERR_OUT_OF_IDS; } } - nn_log (LC_DISCOVERY, "new_participant(%x:%x:%x:%x, %x)\n", PGUID (*ppguid), flags); + DDS_LOG(DDS_LC_DISCOVERY, "new_participant(%x:%x:%x:%x, %x)\n", PGUID (*ppguid), flags); pp = os_malloc (sizeof (*pp)); @@ -411,11 +411,11 @@ int new_participant_guid (const nn_guid_t *ppguid, unsigned flags, const nn_plis nn_plist_copy (pp->plist, plist); nn_plist_mergein_missing (pp->plist, &gv.default_plist_pp); - if (config.enabled_logcats & LC_DISCOVERY) + if (dds_get_log_mask() & DDS_LC_DISCOVERY) { - nn_log (LC_DISCOVERY, "PARTICIPANT %x:%x:%x:%x QOS={", PGUID (pp->e.guid)); - nn_log_xqos (LC_DISCOVERY, &pp->plist->qos); - nn_log (LC_DISCOVERY, "}\n"); + DDS_LOG(DDS_LC_DISCOVERY, "PARTICIPANT %x:%x:%x:%x QOS={", PGUID (pp->e.guid)); + nn_log_xqos(DDS_LC_DISCOVERY, &pp->plist->qos); + DDS_LOG(DDS_LC_DISCOVERY, "}\n"); } if (config.many_sockets_mode == MSM_MANY_UNICAST) @@ -650,7 +650,7 @@ static struct participant *ref_participant (struct participant *pp, const struct stguid = *guid_of_refing_entity; else memset (&stguid, 0, sizeof (stguid)); - nn_log (LC_DISCOVERY, "ref_participant(%x:%x:%x:%x @ %p <- %x:%x:%x:%x @ %p) user %d builtin %d\n", + DDS_LOG(DDS_LC_DISCOVERY, "ref_participant(%x:%x:%x:%x @ %p <- %x:%x:%x:%x @ %p) user %d builtin %d\n", PGUID (pp->e.guid), (void*)pp, PGUID (stguid), (void*)guid_of_refing_entity, pp->user_refc, pp->builtin_refc); os_mutexUnlock (&pp->refc_lock); return pp; @@ -691,7 +691,7 @@ static void unref_participant (struct participant *pp, const struct nn_guid *gui stguid = *guid_of_refing_entity; else memset (&stguid, 0, sizeof (stguid)); - nn_log (LC_DISCOVERY, "unref_participant(%x:%x:%x:%x @ %p <- %x:%x:%x:%x @ %p) user %d builtin %d\n", + DDS_LOG(DDS_LC_DISCOVERY, "unref_participant(%x:%x:%x:%x @ %p <- %x:%x:%x:%x @ %p) user %d builtin %d\n", PGUID (pp->e.guid), (void*)pp, PGUID (stguid), (void*)guid_of_refing_entity, pp->user_refc, pp->builtin_refc); if (pp->user_refc == 0 && (pp->bes != 0 || pp->prismtech_bes != 0) && !pp->builtins_deleted) @@ -803,7 +803,7 @@ static void unref_participant (struct participant *pp, const struct nn_guid *gui static void gc_delete_participant (struct gcreq *gcreq) { struct participant *pp = gcreq->arg; - nn_log (LC_DISCOVERY, "gc_delete_participant(%p, %x:%x:%x:%x)\n", (void *) gcreq, PGUID (pp->e.guid)); + DDS_LOG(DDS_LC_DISCOVERY, "gc_delete_participant(%p, %x:%x:%x:%x)\n", (void *) gcreq, PGUID (pp->e.guid)); gcreq_free (gcreq); unref_participant (pp, NULL); } @@ -863,7 +863,7 @@ struct writer *get_builtin_writer (const struct participant *pp, unsigned entity bes_mask = NN_DISC_BUILTIN_ENDPOINT_TOPIC_ANNOUNCER; break; default: - NN_FATAL ("get_builtin_writer called with entityid %x\n", entityid); + DDS_FATAL ("get_builtin_writer called with entityid %x\n", entityid); return NULL; } @@ -983,7 +983,7 @@ static void rebuild_make_locs(int *p_nlocs, nn_locator_t **p_locs, struct addrse j++; } nlocs = i+1; - nn_log(LC_DISCOVERY, "reduced nlocs=%d\n", nlocs); + DDS_LOG(DDS_LC_DISCOVERY, "reduced nlocs=%d\n", nlocs); *p_nlocs = nlocs; *p_locs = locs; } @@ -1069,13 +1069,13 @@ static void rebuild_trace_covered(int nreaders, int nlocs, const nn_locator_t *l { char buf[INET6_ADDRSTRLEN_EXTENDED]; ddsi_locator_to_string(buf, sizeof(buf), &locs[i]); - nn_log(LC_DISCOVERY, " loc %2d = %-20s %2d {", i, buf, locs_nrds[i]); + DDS_LOG(DDS_LC_DISCOVERY, " loc %2d = %-20s %2d {", i, buf, locs_nrds[i]); for (j = 0; j < nreaders; j++) if (covered[j * nlocs + i] >= 0) - nn_log(LC_DISCOVERY, " %d", covered[j * nlocs + i]); + DDS_LOG(DDS_LC_DISCOVERY, " %d", covered[j * nlocs + i]); else - nn_log(LC_DISCOVERY, " ."); - nn_log(LC_DISCOVERY, " }\n"); + DDS_LOG(DDS_LC_DISCOVERY, " ."); + DDS_LOG(DDS_LC_DISCOVERY, " }\n"); } } @@ -1106,7 +1106,7 @@ static void rebuild_add(struct addrset *newas, int locidx, int nreaders, int nlo if (locs[locidx].kind != NN_LOCATOR_KIND_UDPv4MCGEN) { ddsi_locator_to_string(str, sizeof(str), &locs[locidx]); - nn_log(LC_DISCOVERY, " simple %s\n", str); + DDS_LOG(DDS_LC_DISCOVERY, " simple %s\n", str); add_to_addrset(newas, &locs[locidx]); } else /* convert MC gen to the correct multicast address */ @@ -1125,7 +1125,7 @@ static void rebuild_add(struct addrset *newas, int locidx, int nreaders, int nlo ipn = htonl(iph); memcpy(l.address + 12, &ipn, 4); ddsi_locator_to_string(str, sizeof(str), &l); - nn_log(LC_DISCOVERY, " mcgen %s\n", str); + DDS_LOG(DDS_LC_DISCOVERY, " mcgen %s\n", str); add_to_addrset(newas, &l); } } @@ -1158,7 +1158,8 @@ static void rebuild_writer_addrset_setcover(struct addrset *newas, struct writer int best; if ((all_addrs = rebuild_make_all_addrs(&nreaders, wr)) == NULL) return; - nn_log_addrset(LC_DISCOVERY, "setcover: all_addrs", all_addrs); nn_log(LC_DISCOVERY, "\n"); + nn_log_addrset(DDS_LC_DISCOVERY, "setcover: all_addrs", all_addrs); + DDS_LOG(DDS_LC_DISCOVERY, "\n"); rebuild_make_locs(&nlocs, &locs, all_addrs); unref_addrset(all_addrs); rebuild_make_covered(&covered, wr, &nreaders, nlocs, locs); @@ -1168,7 +1169,7 @@ static void rebuild_writer_addrset_setcover(struct addrset *newas, struct writer while ((best = rebuild_select(nlocs, locs, locs_nrds)) >= 0) { rebuild_trace_covered(nreaders, nlocs, locs, locs_nrds, covered); - nn_log(LC_DISCOVERY, " best = %d\n", best); + DDS_LOG(DDS_LC_DISCOVERY, " best = %d\n", best); rebuild_add(newas, best, nreaders, nlocs, locs, covered); rebuild_drop(best, nreaders, nlocs, locs_nrds, covered); assert (locs_nrds[best] == 0); @@ -1196,9 +1197,9 @@ static void rebuild_writer_addrset (struct writer *wr) wr->as = newas; unref_addrset (oldas); - nn_log (LC_DISCOVERY, "rebuild_writer_addrset(%x:%x:%x:%x):", PGUID (wr->e.guid)); - nn_log_addrset (LC_DISCOVERY, "", wr->as); - nn_log (LC_DISCOVERY, "\n"); + DDS_LOG(DDS_LC_DISCOVERY, "rebuild_writer_addrset(%x:%x:%x:%x):", PGUID (wr->e.guid)); + nn_log_addrset(DDS_LC_DISCOVERY, "", wr->as); + DDS_LOG(DDS_LC_DISCOVERY, "\n"); } void rebuild_or_clear_writer_addrsets(int rebuild) @@ -1206,7 +1207,7 @@ void rebuild_or_clear_writer_addrsets(int rebuild) struct ephash_enum_writer est; struct writer *wr; struct addrset *empty = rebuild ? NULL : new_addrset(); - nn_log (LC_DISCOVERY, "rebuild_or_delete_writer_addrsets(%d)\n", rebuild); + DDS_LOG(DDS_LC_DISCOVERY, "rebuild_or_delete_writer_addrsets(%d)\n", rebuild); ephash_enum_writer_init (&est); os_rwlockRead (&gv.qoslock); while ((wr = ephash_enum_writer_next (&est)) != NULL) @@ -1234,7 +1235,7 @@ void rebuild_or_clear_writer_addrsets(int rebuild) } os_rwlockUnlock (&gv.qoslock); ephash_enum_writer_fini (&est); - nn_log (LC_DISCOVERY, "rebuild_or_delete_writer_addrsets(%d) done\n", rebuild); + DDS_LOG(DDS_LC_DISCOVERY, "rebuild_or_delete_writer_addrsets(%d) done\n", rebuild); } static void free_wr_prd_match (struct wr_prd_match *m) @@ -1256,7 +1257,7 @@ static void free_rd_pwr_match (struct rd_pwr_match *m) assert (ddsi_is_mcaddr (&m->ssm_mc_loc)); assert (!is_unspec_locator (&m->ssm_src_loc)); if (ddsi_leave_mc (gv.data_conn_mc, &m->ssm_src_loc, &m->ssm_mc_loc) < 0) - nn_log (LC_WARNING, "failed to leave network partition ssm group\n"); + DDS_WARNING("failed to leave network partition ssm group\n"); } #endif os_free (m); @@ -1421,19 +1422,19 @@ static void update_reader_init_acknack_count (const struct nn_guid *rd_guid, nn_ /* Update the initial acknack sequence number for the reader. See also reader_add_connection(). */ - nn_log (LC_DISCOVERY, "update_reader_init_acknack_count (%x:%x:%x:%x, %d): ", PGUID (*rd_guid), count); + DDS_LOG(DDS_LC_DISCOVERY, "update_reader_init_acknack_count (%x:%x:%x:%x, %d): ", PGUID (*rd_guid), count); if ((rd = ephash_lookup_reader_guid (rd_guid)) != NULL) { os_mutexLock (&rd->e.lock); - nn_log (LC_DISCOVERY, "%d -> ", rd->init_acknack_count); + DDS_LOG(DDS_LC_DISCOVERY, "%d -> ", rd->init_acknack_count); if (count > rd->init_acknack_count) rd->init_acknack_count = count; - nn_log (LC_DISCOVERY, "%d\n", count); + DDS_LOG(DDS_LC_DISCOVERY, "%d\n", count); os_mutexUnlock (&rd->e.lock); } else { - nn_log (LC_DISCOVERY, "reader no longer exists\n"); + DDS_LOG(DDS_LC_DISCOVERY, "reader no longer exists\n"); } } @@ -1502,7 +1503,7 @@ static void writer_add_connection (struct writer *wr, struct proxy_reader *prd) os_mutexLock (&prd->e.lock); if (prd->deleting) { - nn_log (LC_DISCOVERY, " writer_add_connection(wr %x:%x:%x:%x prd %x:%x:%x:%x) - prd is being deleted\n", + DDS_LOG(DDS_LC_DISCOVERY, " writer_add_connection(wr %x:%x:%x:%x prd %x:%x:%x:%x) - prd is being deleted\n", PGUID (wr->e.guid), PGUID (prd->e.guid)); pretend_everything_acked = 1; } @@ -1530,14 +1531,14 @@ static void writer_add_connection (struct writer *wr, struct proxy_reader *prd) m->seq = wr->seq; if (ut_avlLookupIPath (&wr_readers_treedef, &wr->readers, &prd->e.guid, &path)) { - nn_log(LC_DISCOVERY, " writer_add_connection(wr %x:%x:%x:%x prd %x:%x:%x:%x) - already connected\n", PGUID (wr->e.guid), PGUID (prd->e.guid)); + DDS_LOG(DDS_LC_DISCOVERY, " writer_add_connection(wr %x:%x:%x:%x prd %x:%x:%x:%x) - already connected\n", PGUID (wr->e.guid), PGUID (prd->e.guid)); os_mutexUnlock (&wr->e.lock); nn_lat_estim_fini (&m->hb_to_ack_latency); os_free (m); } else { - nn_log(LC_DISCOVERY, " writer_add_connection(wr %x:%x:%x:%x prd %x:%x:%x:%x) - ack seq %"PRId64"\n", PGUID (wr->e.guid), PGUID (prd->e.guid), m->seq); + DDS_LOG(DDS_LC_DISCOVERY, " writer_add_connection(wr %x:%x:%x:%x prd %x:%x:%x:%x) - ack seq %"PRId64"\n", PGUID (wr->e.guid), PGUID (prd->e.guid), m->seq); ut_avlInsertIPath (&wr_readers_treedef, &wr->readers, m, &path); rebuild_writer_addrset (wr); wr->num_reliable_readers += m->is_reliable; @@ -1587,13 +1588,13 @@ static void writer_add_local_connection (struct writer *wr, struct reader *rd) os_mutexLock (&wr->e.lock); if (ut_avlLookupIPath (&wr_local_readers_treedef, &wr->local_readers, &rd->e.guid, &path)) { - nn_log(LC_DISCOVERY, " writer_add_local_connection(wr %x:%x:%x:%x rd %x:%x:%x:%x) - already connected\n", PGUID (wr->e.guid), PGUID (rd->e.guid)); + DDS_LOG(DDS_LC_DISCOVERY, " writer_add_local_connection(wr %x:%x:%x:%x rd %x:%x:%x:%x) - already connected\n", PGUID (wr->e.guid), PGUID (rd->e.guid)); os_mutexUnlock (&wr->e.lock); os_free (m); return; } - nn_log(LC_DISCOVERY, " writer_add_local_connection(wr %x:%x:%x:%x rd %x:%x:%x:%x)", PGUID (wr->e.guid), PGUID (rd->e.guid)); + DDS_LOG(DDS_LC_DISCOVERY, " writer_add_local_connection(wr %x:%x:%x:%x rd %x:%x:%x:%x)", PGUID (wr->e.guid), PGUID (rd->e.guid)); m->rd_guid = rd->e.guid; ut_avlInsertIPath (&wr_local_readers_treedef, &wr->local_readers, m, &path); local_reader_ary_insert (&wr->rdary, rd); @@ -1620,7 +1621,7 @@ static void writer_add_local_connection (struct writer *wr, struct reader *rd) os_mutexUnlock (&wr->e.lock); - nn_log(LC_DISCOVERY, "\n"); + DDS_LOG(DDS_LC_DISCOVERY, "\n"); if (wr->status_cb) { @@ -1647,19 +1648,19 @@ static void reader_add_connection (struct reader *rd, struct proxy_writer *pwr, writer will always see monotonically increasing sequence numbers from one particular reader. This is then used for the pwr_rd_match initialization */ - nn_log (LC_DISCOVERY, " reader %x:%x:%x:%x init_acknack_count = %d\n", PGUID (rd->e.guid), rd->init_acknack_count); + DDS_LOG(DDS_LC_DISCOVERY, " reader %x:%x:%x:%x init_acknack_count = %d\n", PGUID (rd->e.guid), rd->init_acknack_count); *init_count = rd->init_acknack_count; if (ut_avlLookupIPath (&rd_writers_treedef, &rd->writers, &pwr->e.guid, &path)) { - nn_log (LC_DISCOVERY, " reader_add_connection(pwr %x:%x:%x:%x rd %x:%x:%x:%x) - already connected\n", + DDS_LOG(DDS_LC_DISCOVERY, " reader_add_connection(pwr %x:%x:%x:%x rd %x:%x:%x:%x) - already connected\n", PGUID (pwr->e.guid), PGUID (rd->e.guid)); os_mutexUnlock (&rd->e.lock); os_free (m); } else { - nn_log (LC_DISCOVERY, " reader_add_connection(pwr %x:%x:%x:%x rd %x:%x:%x:%x)\n", + DDS_LOG(DDS_LC_DISCOVERY, " reader_add_connection(pwr %x:%x:%x:%x rd %x:%x:%x:%x)\n", PGUID (pwr->e.guid), PGUID (rd->e.guid)); ut_avlInsertIPath (&rd_writers_treedef, &rd->writers, m, &path); os_mutexUnlock (&rd->e.lock); @@ -1707,13 +1708,13 @@ static void reader_add_local_connection (struct reader *rd, struct writer *wr) if (ut_avlLookupIPath (&rd_local_writers_treedef, &rd->local_writers, &wr->e.guid, &path)) { - nn_log(LC_DISCOVERY, " reader_add_local_connection(wr %x:%x:%x:%x rd %x:%x:%x:%x) - already connected\n", PGUID (wr->e.guid), PGUID (rd->e.guid)); + DDS_LOG(DDS_LC_DISCOVERY, " reader_add_local_connection(wr %x:%x:%x:%x rd %x:%x:%x:%x) - already connected\n", PGUID (wr->e.guid), PGUID (rd->e.guid)); os_mutexUnlock (&rd->e.lock); os_free (m); } else { - nn_log(LC_DISCOVERY, " reader_add_local_connection(wr %x:%x:%x:%x rd %x:%x:%x:%x)\n", PGUID (wr->e.guid), PGUID (rd->e.guid)); + DDS_LOG(DDS_LC_DISCOVERY, " reader_add_local_connection(wr %x:%x:%x:%x rd %x:%x:%x:%x)\n", PGUID (wr->e.guid), PGUID (rd->e.guid)); ut_avlInsertIPath (&rd_local_writers_treedef, &rd->local_writers, m, &path); os_mutexUnlock (&rd->e.lock); @@ -1750,7 +1751,7 @@ static void proxy_writer_add_connection (struct proxy_writer *pwr, struct reader pwr->ddsi2direct_cbarg = rd->ddsi2direct_cbarg; } - nn_log (LC_DISCOVERY, " proxy_writer_add_connection(pwr %x:%x:%x:%x rd %x:%x:%x:%x)", + DDS_LOG(DDS_LC_DISCOVERY, " proxy_writer_add_connection(pwr %x:%x:%x:%x rd %x:%x:%x:%x)", PGUID (pwr->e.guid), PGUID (rd->e.guid)); m->rd_guid = rd->e.guid; m->tcreate = now_mt (); @@ -1785,7 +1786,7 @@ static void proxy_writer_add_connection (struct proxy_writer *pwr, struct reader m->in_sync = PRMSS_TLCATCHUP; m->u.not_in_sync.end_of_tl_seq = MAX_SEQ_NUMBER; if (m->in_sync != PRMSS_SYNC) - nn_log (LC_DISCOVERY, " - tlcatchup"); + DDS_LOG(DDS_LC_DISCOVERY, " - tlcatchup"); } else if (!config.conservative_builtin_reader_startup && is_builtin_entityid (rd->e.guid.entityid, ownvendorid) && !ut_avlIsEmpty (&pwr->readers)) { @@ -1798,7 +1799,7 @@ static void proxy_writer_add_connection (struct proxy_writer *pwr, struct reader m->in_sync = PRMSS_OUT_OF_SYNC; m->u.not_in_sync.end_of_tl_seq = pwr->last_seq; m->u.not_in_sync.end_of_out_of_sync_seq = last_deliv_seq; - nn_log(LC_DISCOVERY, " - out-of-sync %"PRId64, m->u.not_in_sync.end_of_out_of_sync_seq); + DDS_LOG(DDS_LC_DISCOVERY, " - out-of-sync %"PRId64, m->u.not_in_sync.end_of_out_of_sync_seq); } if (m->in_sync != PRMSS_SYNC) pwr->n_readers_out_of_sync++; @@ -1828,7 +1829,7 @@ static void proxy_writer_add_connection (struct proxy_writer *pwr, struct reader os_mutexUnlock (&pwr->e.lock); qxev_pwr_entityid (pwr, &rd->e.guid.prefix); - nn_log (LC_DISCOVERY, "\n"); + DDS_LOG(DDS_LC_DISCOVERY, "\n"); if (rd->status_cb) { @@ -1843,7 +1844,7 @@ static void proxy_writer_add_connection (struct proxy_writer *pwr, struct reader already_matched: assert (is_builtin_entityid (pwr->e.guid.entityid, pwr->c.vendor) ? (pwr->c.topic == NULL) : (pwr->c.topic != NULL)); - nn_log (LC_DISCOVERY, " proxy_writer_add_connection(pwr %x:%x:%x:%x rd %x:%x:%x:%x) - already connected\n", + DDS_LOG(DDS_LC_DISCOVERY, " proxy_writer_add_connection(pwr %x:%x:%x:%x rd %x:%x:%x:%x) - already connected\n", PGUID (pwr->e.guid), PGUID (rd->e.guid)); os_mutexUnlock (&pwr->e.lock); os_free (m); @@ -1861,14 +1862,14 @@ static void proxy_reader_add_connection (struct proxy_reader *prd, struct writer prd->c.topic = wr->topic; if (ut_avlLookupIPath (&prd_writers_treedef, &prd->writers, &wr->e.guid, &path)) { - nn_log (LC_DISCOVERY, " proxy_reader_add_connection(wr %x:%x:%x:%x prd %x:%x:%x:%x) - already connected\n", + DDS_LOG(DDS_LC_DISCOVERY, " proxy_reader_add_connection(wr %x:%x:%x:%x prd %x:%x:%x:%x) - already connected\n", PGUID (wr->e.guid), PGUID (prd->e.guid)); os_mutexUnlock (&prd->e.lock); os_free (m); } else { - nn_log (LC_DISCOVERY, " proxy_reader_add_connection(wr %x:%x:%x:%x prd %x:%x:%x:%x)\n", + DDS_LOG(DDS_LC_DISCOVERY, " proxy_reader_add_connection(wr %x:%x:%x:%x prd %x:%x:%x:%x)\n", PGUID (wr->e.guid), PGUID (prd->e.guid)); ut_avlInsertIPath (&prd_writers_treedef, &prd->writers, m, &path); os_mutexUnlock (&prd->e.lock); @@ -2195,7 +2196,7 @@ static void generic_do_match (struct entity_common *e, nn_mtime_t tnow) enum entity_kind mkind = generic_do_match_mkind(e->kind); if (!is_builtin_entityid (e->guid.entityid, ownvendorid)) { - nn_log(LC_DISCOVERY, "match_%s_with_%ss(%s %x:%x:%x:%x) scanning all %ss\n", + DDS_LOG(DDS_LC_DISCOVERY, "match_%s_with_%ss(%s %x:%x:%x:%x) scanning all %ss\n", generic_do_match_kindstr_us (e->kind), generic_do_match_kindstr_us (mkind), generic_do_match_kindabbrev (e->kind), PGUID (e->guid), generic_do_match_kindstr(mkind)); @@ -2216,7 +2217,7 @@ static void generic_do_match (struct entity_common *e, nn_mtime_t tnow) /* Built-ins have fixed QoS */ nn_entityid_t tgt_ent = builtin_entityid_match (e->guid.entityid); enum entity_kind pkind = generic_do_match_isproxy (e) ? EK_PARTICIPANT : EK_PROXY_PARTICIPANT; - nn_log(LC_DISCOVERY, "match_%s_with_%ss(%s %x:%x:%x:%x) scanning %sparticipants tgt=%x\n", + DDS_LOG(DDS_LC_DISCOVERY, "match_%s_with_%ss(%s %x:%x:%x:%x) scanning %sparticipants tgt=%x\n", generic_do_match_kindstr_us (e->kind), generic_do_match_kindstr_us (mkind), generic_do_match_kindabbrev (e->kind), PGUID (e->guid), generic_do_match_isproxy (e) ? "" : "proxy ", @@ -2247,7 +2248,7 @@ static void generic_do_local_match (struct entity_common *e, nn_mtime_t tnow) /* never a need for local matches on discovery endpoints */ return; mkind = generic_do_local_match_mkind(e->kind); - nn_log(LC_DISCOVERY, "match_%s_with_%ss(%s %x:%x:%x:%x) scanning all %ss\n", + DDS_LOG(DDS_LC_DISCOVERY, "match_%s_with_%ss(%s %x:%x:%x:%x) scanning all %ss\n", generic_do_match_kindstr_us (e->kind), generic_do_match_kindstr_us (mkind), generic_do_match_kindabbrev (e->kind), PGUID (e->guid), generic_do_match_kindstr(mkind)); @@ -2314,7 +2315,7 @@ static void new_reader_writer_common (const struct nn_guid *guid, const struct d if (xqos->partition.n > 1) partition_suffix = "+"; } - nn_log (LC_DISCOVERY, "new_%s(guid %x:%x:%x:%x, %s%s.%s/%s)\n", + DDS_LOG(DDS_LC_DISCOVERY, "new_%s(guid %x:%x:%x:%x, %s%s.%s/%s)\n", is_writer_entityid (guid->entityid) ? "writer" : "reader", PGUID (*guid), partition, partition_suffix, @@ -2377,7 +2378,7 @@ static uint32_t get_partitionid_from_mapping (const char *partition, const char return 0; else { - nn_log (LC_DISCOVERY, "matched writer for topic \"%s\" in partition \"%s\" to networkPartition \"%s\"\n", topic, partition, pm->networkPartition); + DDS_LOG(DDS_LC_DISCOVERY, "matched writer for topic \"%s\" in partition \"%s\" to networkPartition \"%s\"\n", topic, partition, pm->networkPartition); return pm->partition->partitionId; } } @@ -2549,7 +2550,7 @@ unsigned remove_acked_messages (struct writer *wr, struct whc_state *whcst, stru writer_clear_retransmitting (wr); if (wr->state == WRST_LINGERING && whcst->unacked_bytes == 0) { - nn_log (LC_DISCOVERY, "remove_acked_messages: deleting lingering writer %x:%x:%x:%x\n", PGUID (wr->e.guid)); + DDS_LOG(DDS_LC_DISCOVERY, "remove_acked_messages: deleting lingering writer %x:%x:%x:%x\n", PGUID (wr->e.guid)); delete_writer_nolinger_locked (wr); } return n; @@ -2604,11 +2605,11 @@ static struct writer * new_writer_guid (const struct nn_guid *guid, const struct assert (wr->xqos->aliased == 0); set_topic_type_name (wr->xqos, topic); - if (config.enabled_logcats & LC_DISCOVERY) + if (dds_get_log_mask() & DDS_LC_DISCOVERY) { - nn_log (LC_DISCOVERY, "WRITER %x:%x:%x:%x QOS={", PGUID (wr->e.guid)); - nn_log_xqos (LC_DISCOVERY, wr->xqos); - nn_log (LC_DISCOVERY, "}\n"); + DDS_LOG(DDS_LC_DISCOVERY, "WRITER %x:%x:%x:%x QOS={", PGUID (wr->e.guid)); + nn_log_xqos (DDS_LC_DISCOVERY, wr->xqos); + DDS_LOG(DDS_LC_DISCOVERY, "}\n"); } assert (wr->xqos->present & QP_RELIABILITY); wr->reliable = (wr->xqos->reliability.kind != NN_BEST_EFFORT_RELIABILITY_QOS); @@ -2698,9 +2699,9 @@ static struct writer * new_writer_guid (const struct nn_guid *guid, const struct wr->supports_ssm = 1; wr->ssm_as = new_addrset (); add_to_addrset (wr->ssm_as, &loc); - nn_log (LC_DISCOVERY, "writer %x:%x:%x:%x: ssm=%d", PGUID (wr->e.guid), wr->supports_ssm); - nn_log_addrset (LC_DISCOVERY, "", wr->ssm_as); - nn_log (LC_DISCOVERY, "\n"); + DDS_LOG(DDS_LC_DISCOVERY, "writer %x:%x:%x:%x: ssm=%d", PGUID (wr->e.guid), wr->supports_ssm); + nn_log_addrset (DDS_LC_DISCOVERY, "", wr->ssm_as); + DDS_LOG(DDS_LC_DISCOVERY, "\n"); } } #endif @@ -2711,7 +2712,7 @@ static struct writer * new_writer_guid (const struct nn_guid *guid, const struct if (!is_builtin_entityid (wr->e.guid.entityid, ownvendorid)) { struct config_channel_listelem *channel = find_channel (wr->xqos->transport_priority); - nn_log (LC_DISCOVERY, "writer %x:%x:%x:%x: transport priority %d => channel '%s' priority %d\n", + DDS_LOG(DDS_LC_DISCOVERY, "writer %x:%x:%x:%x: transport priority %d => channel '%s' priority %d\n", PGUID (wr->e.guid), wr->xqos->transport_priority.value, channel->name, channel->priority); wr->evq = channel->evq ? channel->evq : gv.xevents; } @@ -2739,7 +2740,7 @@ static struct writer * new_writer_guid (const struct nn_guid *guid, const struct if (wr->xqos->liveliness.kind != NN_AUTOMATIC_LIVELINESS_QOS || nn_from_ddsi_duration (wr->xqos->liveliness.lease_duration) != T_NEVER) { - nn_log (LC_INFO | LC_DISCOVERY, "writer %x:%x:%x:%x: incorrectly treating it as of automatic liveliness kind with lease duration = inf (%d, %"PRId64")\n", PGUID (wr->e.guid), (int) wr->xqos->liveliness.kind, nn_from_ddsi_duration (wr->xqos->liveliness.lease_duration)); + DDS_LOG(DDS_LC_INFO | DDS_LC_DISCOVERY, "writer %x:%x:%x:%x: incorrectly treating it as of automatic liveliness kind with lease duration = inf (%d, %"PRId64")\n", PGUID (wr->e.guid), (int) wr->xqos->liveliness.kind, nn_from_ddsi_duration (wr->xqos->liveliness.lease_duration)); } wr->lease_duration = T_NEVER; /* FIXME */ @@ -2798,7 +2799,7 @@ struct writer * new_writer (struct nn_guid *wrguid, const struct nn_guid *group_ if ((pp = ephash_lookup_participant_guid (ppguid)) == NULL) { - nn_log (LC_DISCOVERY, "new_writer - participant %x:%x:%x:%x not found\n", PGUID (*ppguid)); + DDS_LOG(DDS_LC_DISCOVERY, "new_writer - participant %x:%x:%x:%x not found\n", PGUID (*ppguid)); return NULL; } /* participant can't be freed while we're mucking around cos we are @@ -2814,7 +2815,7 @@ struct writer * new_writer (struct nn_guid *wrguid, const struct nn_guid *group_ static void gc_delete_writer (struct gcreq *gcreq) { struct writer *wr = gcreq->arg; - nn_log (LC_DISCOVERY, "gc_delete_writer(%p, %x:%x:%x:%x)\n", (void *) gcreq, PGUID (wr->e.guid)); + DDS_LOG(DDS_LC_DISCOVERY, "gc_delete_writer(%p, %x:%x:%x:%x)\n", (void *) gcreq, PGUID (wr->e.guid)); gcreq_free (gcreq); /* We now allow GC while blocked on a full WHC, but we still don't allow deleting a writer while blocked on it. The writer's state must be DELETING by the time we get here, and that means the transmit path is no longer blocked. It doesn't imply that the write thread is no longer in throttle_writer(), just that if it is, it will soon return from there. Therefore, block until it isn't throttling anymore. We can safely lock the writer, as we're on the separate GC thread. */ @@ -2873,7 +2874,7 @@ static void gc_delete_writer (struct gcreq *gcreq) static void gc_delete_writer_throttlewait (struct gcreq *gcreq) { struct writer *wr = gcreq->arg; - nn_log (LC_DISCOVERY, "gc_delete_writer_throttlewait(%p, %x:%x:%x:%x)\n", (void *) gcreq, PGUID (wr->e.guid)); + DDS_LOG(DDS_LC_DISCOVERY, "gc_delete_writer_throttlewait(%p, %x:%x:%x:%x)\n", (void *) gcreq, PGUID (wr->e.guid)); /* We now allow GC while blocked on a full WHC, but we still don't allow deleting a writer while blocked on it. The writer's state must be DELETING by the time we get here, and that means the transmit path is no longer blocked. It doesn't imply that the write thread is no longer in throttle_writer(), just that if it is, it will soon return from there. Therefore, block until it isn't throttling anymore. We can safely lock the writer, as we're on the separate GC thread. */ assert (wr->state == WRST_DELETING); os_mutexLock (&wr->e.lock); @@ -2886,7 +2887,7 @@ static void gc_delete_writer_throttlewait (struct gcreq *gcreq) static void writer_set_state (struct writer *wr, enum writer_state newstate) { ASSERT_MUTEX_HELD (&wr->e.lock); - nn_log (LC_DISCOVERY, "writer_set_state(%x:%x:%x:%x) state transition %d -> %d\n", PGUID (wr->e.guid), wr->state, newstate); + DDS_LOG(DDS_LC_DISCOVERY, "writer_set_state(%x:%x:%x:%x) state transition %d -> %d\n", PGUID (wr->e.guid), wr->state, newstate); assert (newstate > wr->state); if (wr->state == WRST_OPERATIONAL) { @@ -2903,7 +2904,7 @@ static void writer_set_state (struct writer *wr, enum writer_state newstate) int delete_writer_nolinger_locked (struct writer *wr) { - nn_log (LC_DISCOVERY, "delete_writer_nolinger(guid %x:%x:%x:%x) ...\n", PGUID (wr->e.guid)); + DDS_LOG(DDS_LC_DISCOVERY, "delete_writer_nolinger(guid %x:%x:%x:%x) ...\n", PGUID (wr->e.guid)); ASSERT_MUTEX_HELD (&wr->e.lock); local_reader_ary_setinvalid (&wr->rdary); ephash_remove_writer_guid (wr); @@ -2924,10 +2925,10 @@ int delete_writer_nolinger (const struct nn_guid *guid) assert (is_writer_entityid (guid->entityid)); if ((wr = ephash_lookup_writer_guid (guid)) == NULL) { - nn_log (LC_DISCOVERY, "delete_writer_nolinger(guid %x:%x:%x:%x) - unknown guid\n", PGUID (*guid)); + DDS_LOG(DDS_LC_DISCOVERY, "delete_writer_nolinger(guid %x:%x:%x:%x) - unknown guid\n", PGUID (*guid)); return ERR_UNKNOWN_ENTITY; } - nn_log (LC_DISCOVERY, "delete_writer_nolinger(guid %x:%x:%x:%x) ...\n", PGUID (*guid)); + DDS_LOG(DDS_LC_DISCOVERY, "delete_writer_nolinger(guid %x:%x:%x:%x) ...\n", PGUID (*guid)); os_mutexLock (&wr->e.lock); delete_writer_nolinger_locked (wr); os_mutexUnlock (&wr->e.lock); @@ -2940,10 +2941,10 @@ int delete_writer (const struct nn_guid *guid) struct whc_state whcst; if ((wr = ephash_lookup_writer_guid (guid)) == NULL) { - nn_log (LC_DISCOVERY, "delete_writer(guid %x:%x:%x:%x) - unknown guid\n", PGUID (*guid)); + DDS_LOG(DDS_LC_DISCOVERY, "delete_writer(guid %x:%x:%x:%x) - unknown guid\n", PGUID (*guid)); return ERR_UNKNOWN_ENTITY; } - nn_log (LC_DISCOVERY, "delete_writer(guid %x:%x:%x:%x) ...\n", PGUID (*guid)); + DDS_LOG(DDS_LC_DISCOVERY, "delete_writer(guid %x:%x:%x:%x) ...\n", PGUID (*guid)); os_mutexLock (&wr->e.lock); /* If no unack'ed data, don't waste time or resources (expected to @@ -2953,7 +2954,7 @@ int delete_writer (const struct nn_guid *guid) whc_get_state(wr->whc, &whcst); if (whcst.unacked_bytes == 0) { - nn_log (LC_DISCOVERY, "delete_writer(guid %x:%x:%x:%x) - no unack'ed samples\n", PGUID (*guid)); + DDS_LOG(DDS_LC_DISCOVERY, "delete_writer(guid %x:%x:%x:%x) - no unack'ed samples\n", PGUID (*guid)); delete_writer_nolinger_locked (wr); os_mutexUnlock (&wr->e.lock); } @@ -2965,7 +2966,7 @@ int delete_writer (const struct nn_guid *guid) os_mutexUnlock (&wr->e.lock); tsched = add_duration_to_mtime (now_mt (), config.writer_linger_duration); mtime_to_sec_usec (&tsec, &tusec, tsched); - nn_log (LC_DISCOVERY, "delete_writer(guid %x:%x:%x:%x) - unack'ed samples, will delete when ack'd or at t = %d.%06d\n", + DDS_LOG(DDS_LC_DISCOVERY, "delete_writer(guid %x:%x:%x:%x) - unack'ed samples, will delete when ack'd or at t = %d.%06d\n", PGUID (*guid), tsec, tusec); qxev_delete_writer (tsched, &wr->e.guid); } @@ -2984,7 +2985,7 @@ void writer_exit_startup_mode (struct writer *wr) cnt += remove_acked_messages (wr, &whcst, &deferred_free_list); cnt += whc_downgrade_to_volatile (wr->whc, &whcst); writer_clear_retransmitting (wr); - nn_log (LC_DISCOVERY, " %x:%x:%x:%x: dropped %u samples\n", PGUID(wr->e.guid), cnt); + DDS_LOG(DDS_LC_DISCOVERY, " %x:%x:%x:%x: dropped %u samples\n", PGUID(wr->e.guid), cnt); } os_mutexUnlock (&wr->e.lock); whc_free_deferred_free_list (wr->whc, deferred_free_list); @@ -3013,7 +3014,7 @@ static struct addrset * get_as_from_mapping (const char *partition, const char * struct addrset *as = new_addrset (); if ((pm = find_partitionmapping (partition, topic)) != NULL) { - nn_log (LC_DISCOVERY, "matched reader for topic \"%s\" in partition \"%s\" to networkPartition \"%s\"\n", topic, partition, pm->networkPartition); + DDS_LOG(DDS_LC_DISCOVERY, "matched reader for topic \"%s\" in partition \"%s\" to networkPartition \"%s\"\n", topic, partition, pm->networkPartition); assert (pm->partition->as); copy_addrset_into_addrset (as, pm->partition->as); } @@ -3029,7 +3030,7 @@ static void join_mcast_helper (const nn_locator_t *n, void * varg) { if (ddsi_join_mc (conn, NULL, n) < 0) { - nn_log (LC_WARNING, "failed to join network partition multicast group\n"); + DDS_LOG(DDS_LC_WARNING, "failed to join network partition multicast group\n"); } } else /* join all addresses that include this node */ @@ -3053,7 +3054,7 @@ static void join_mcast_helper (const nn_locator_t *n, void * varg) memcpy(l.address + 12, &ipn, 4); if (ddsi_join_mc (conn, NULL, &l) < 0) { - nn_log (LC_WARNING, "failed to join network partition multicast group\n"); + DDS_LOG(DDS_LC_WARNING, "failed to join network partition multicast group\n"); } } } @@ -3071,7 +3072,7 @@ static void leave_mcast_helper (const nn_locator_t *n, void * varg) { if (ddsi_leave_mc (conn, NULL, n) < 0) { - nn_log (LC_WARNING, "failed to leave network partition multicast group\n"); + DDS_LOG(DDS_LC_WARNING, "failed to leave network partition multicast group\n"); } } else /* join all addresses that include this node */ @@ -3095,7 +3096,7 @@ static void leave_mcast_helper (const nn_locator_t *n, void * varg) memcpy(l.address + 12, &ipn, 4); if (ddsi_leave_mc (conn, NULL, &l) < 0) { - nn_log (LC_WARNING, "failed to leave network partition multicast group\n"); + DDS_LOG(DDS_LC_WARNING, "failed to leave network partition multicast group\n"); } } } @@ -3138,11 +3139,11 @@ static struct reader * new_reader_guid assert (rd->xqos->aliased == 0); set_topic_type_name (rd->xqos, topic); - if (config.enabled_logcats & LC_DISCOVERY) + if (dds_get_log_mask() & DDS_LC_DISCOVERY) { - nn_log (LC_DISCOVERY, "READER %x:%x:%x:%x QOS={", PGUID (rd->e.guid)); - nn_log_xqos (LC_DISCOVERY, rd->xqos); - nn_log (LC_DISCOVERY, "}\n"); + DDS_LOG(DDS_LC_DISCOVERY, "READER %x:%x:%x:%x QOS={", PGUID (rd->e.guid)); + nn_log_xqos (DDS_LC_DISCOVERY, rd->xqos); + DDS_LOG(DDS_LC_DISCOVERY, "}\n"); } assert (rd->xqos->present & QP_RELIABILITY); rd->reliable = (rd->xqos->reliability.kind != NN_BEST_EFFORT_RELIABILITY_QOS); @@ -3171,7 +3172,7 @@ static struct reader * new_reader_guid if (rd->xqos->liveliness.kind != NN_AUTOMATIC_LIVELINESS_QOS || nn_from_ddsi_duration (rd->xqos->liveliness.lease_duration) != T_NEVER) { - nn_log (LC_INFO | LC_DISCOVERY, "reader %x:%x:%x:%x: incorrectly treating it as of automatic liveliness kind with lease duration = inf (%d, %"PRId64")\n", PGUID (rd->e.guid), (int) rd->xqos->liveliness.kind, nn_from_ddsi_duration (rd->xqos->liveliness.lease_duration)); + DDS_LOG(DDS_LC_INFO | DDS_LC_DISCOVERY, "reader %x:%x:%x:%x: incorrectly treating it as of automatic liveliness kind with lease duration = inf (%d, %"PRId64")\n", PGUID (rd->e.guid), (int) rd->xqos->liveliness.kind, nn_from_ddsi_duration (rd->xqos->liveliness.lease_duration)); } #ifdef DDSI_INCLUDE_NETWORK_PARTITIONS @@ -3203,11 +3204,11 @@ static struct reader * new_reader_guid * - Join the socket if a multicast address */ addrset_forall (rd->as, join_mcast_helper, gv.data_conn_mc); - if (config.enabled_logcats & LC_DISCOVERY) + if (dds_get_log_mask() & DDS_LC_DISCOVERY) { - nn_log (LC_DISCOVERY, "READER %x:%x:%x:%x locators={", PGUID (rd->e.guid)); - nn_log_addrset (LC_DISCOVERY, "", rd->as); - nn_log (LC_DISCOVERY, "}\n"); + DDS_LOG(DDS_LC_DISCOVERY, "READER %x:%x:%x:%x locators={", PGUID (rd->e.guid)); + nn_log_addrset(DDS_LC_DISCOVERY, "", rd->as); + DDS_LOG(DDS_LC_DISCOVERY, "}\n"); } } #ifdef DDSI_INCLUDE_SSM @@ -3223,7 +3224,7 @@ static struct reader * new_reader_guid } #ifdef DDSI_INCLUDE_SSM if (rd->favours_ssm) - nn_log (LC_DISCOVERY, "READER %x:%x:%x:%x ssm=%d\n", PGUID (rd->e.guid), rd->favours_ssm); + DDS_LOG(DDS_LC_DISCOVERY, "READER %x:%x:%x:%x ssm=%d\n", PGUID (rd->e.guid), rd->favours_ssm); #endif #endif @@ -3254,7 +3255,7 @@ struct reader * new_reader if ((pp = ephash_lookup_participant_guid (ppguid)) == NULL) { - nn_log (LC_DISCOVERY, "new_reader - participant %x:%x:%x:%x not found\n", PGUID (*ppguid)); + DDS_LOG(DDS_LC_DISCOVERY, "new_reader - participant %x:%x:%x:%x not found\n", PGUID (*ppguid)); return NULL; } rdguid->prefix = pp->e.guid.prefix; @@ -3268,7 +3269,7 @@ static void gc_delete_reader (struct gcreq *gcreq) { /* see gc_delete_writer for comments */ struct reader *rd = gcreq->arg; - nn_log (LC_DISCOVERY, "gc_delete_reader(%p, %x:%x:%x:%x)\n", (void *) gcreq, PGUID (rd->e.guid)); + DDS_LOG(DDS_LC_DISCOVERY, "gc_delete_reader(%p, %x:%x:%x:%x)\n", (void *) gcreq, PGUID (rd->e.guid)); gcreq_free (gcreq); while (!ut_avlIsEmpty (&rd->writers)) @@ -3317,14 +3318,14 @@ int delete_reader (const struct nn_guid *guid) assert (!is_writer_entityid (guid->entityid)); if ((rd = ephash_lookup_reader_guid (guid)) == NULL) { - nn_log (LC_DISCOVERY, "delete_reader_guid(guid %x:%x:%x:%x) - unknown guid\n", PGUID (*guid)); + DDS_LOG(DDS_LC_DISCOVERY, "delete_reader_guid(guid %x:%x:%x:%x) - unknown guid\n", PGUID (*guid)); return ERR_UNKNOWN_ENTITY; } if (rd->rhc) { (ddsi_plugin.rhc_plugin.rhc_fini_fn) (rd->rhc); } - nn_log (LC_DISCOVERY, "delete_reader_guid(guid %x:%x:%x:%x) ...\n", PGUID (*guid)); + DDS_LOG(DDS_LC_DISCOVERY, "delete_reader_guid(guid %x:%x:%x:%x) ...\n", PGUID (*guid)); ephash_remove_reader_guid (rd); gcreq_reader (rd); return 0; @@ -3669,7 +3670,7 @@ static void unref_proxy_participant (struct proxy_participant *proxypp, struct p { assert (proxypp->endpoints == NULL); os_mutexUnlock (&proxypp->e.lock); - nn_log (LC_DISCOVERY, "unref_proxy_participant(%x:%x:%x:%x): refc=0, freeing\n", PGUID (proxypp->e.guid)); + DDS_LOG(DDS_LC_DISCOVERY, "unref_proxy_participant(%x:%x:%x:%x): refc=0, freeing\n", PGUID (proxypp->e.guid)); unref_addrset (proxypp->as_default); @@ -3686,7 +3687,7 @@ static void unref_proxy_participant (struct proxy_participant *proxypp, struct p { assert (refc == 1); os_mutexUnlock (&proxypp->e.lock); - nn_log (LC_DISCOVERY, "unref_proxy_participant(%x:%x:%x:%x): refc=%u, no endpoints, implicitly created, deleting\n", PGUID (proxypp->e.guid), (unsigned) refc); + DDS_LOG(DDS_LC_DISCOVERY, "unref_proxy_participant(%x:%x:%x:%x): refc=%u, no endpoints, implicitly created, deleting\n", PGUID (proxypp->e.guid), (unsigned) refc); delete_proxy_participant_by_guid(&proxypp->e.guid, tnow, 1); /* Deletion is still (and has to be) asynchronous. A parallel endpoint creation may or may not succeed, and if it succeeds it will be deleted along with the proxy participant. So "your @@ -3695,14 +3696,14 @@ static void unref_proxy_participant (struct proxy_participant *proxypp, struct p else { os_mutexUnlock (&proxypp->e.lock); - nn_log (LC_DISCOVERY, "unref_proxy_participant(%x:%x:%x:%x): refc=%u\n", PGUID (proxypp->e.guid), (unsigned) refc); + DDS_LOG(DDS_LC_DISCOVERY, "unref_proxy_participant(%x:%x:%x:%x): refc=%u\n", PGUID (proxypp->e.guid), (unsigned) refc); } } static void gc_delete_proxy_participant (struct gcreq *gcreq) { struct proxy_participant *proxypp = gcreq->arg; - nn_log (LC_DISCOVERY, "gc_delete_proxy_participant(%p, %x:%x:%x:%x)\n", (void *) gcreq, PGUID (proxypp->e.guid)); + DDS_LOG(DDS_LC_DISCOVERY, "gc_delete_proxy_participant(%p, %x:%x:%x:%x)\n", (void *) gcreq, PGUID (proxypp->e.guid)); gcreq_free (gcreq); unref_proxy_participant (proxypp, NULL); } @@ -3735,7 +3736,7 @@ static void delete_or_detach_dependent_pp (struct proxy_participant *p, struct p { nn_etime_t texp = add_duration_to_etime (now_et(), config.ds_grace_period); /* Clear dependency (but don't touch entity id, which must be 0x1c1) and set the lease ticking */ - nn_log (LC_DISCOVERY, "%x:%x:%x:%x detach-from-DS %x:%x:%x:%x\n", PGUID(p->e.guid), PGUID(proxypp->e.guid)); + DDS_LOG(DDS_LC_DISCOVERY, "%x:%x:%x:%x detach-from-DS %x:%x:%x:%x\n", PGUID(p->e.guid), PGUID(proxypp->e.guid)); memset (&p->privileged_pp_guid.prefix, 0, sizeof (p->privileged_pp_guid.prefix)); lease_set_expiry (os_atomic_ldvoidp (&p->lease), texp); os_mutexUnlock (&p->e.lock); @@ -3748,7 +3749,7 @@ static void delete_ppt (struct proxy_participant * proxypp, nn_wctime_t timestam int ret; /* if any proxy participants depend on this participant, delete them */ - nn_log (LC_DISCOVERY, "delete_ppt(%x:%x:%x:%x) - deleting dependent proxy participants\n", PGUID (proxypp->e.guid)); + DDS_LOG(DDS_LC_DISCOVERY, "delete_ppt(%x:%x:%x:%x) - deleting dependent proxy participants\n", PGUID (proxypp->e.guid)); { struct ephash_enum_proxy_participant est; struct proxy_participant *p; @@ -3765,11 +3766,11 @@ static void delete_ppt (struct proxy_participant * proxypp, nn_wctime_t timestam if (isimplicit) proxypp->lease_expired = 1; - nn_log (LC_DISCOVERY, "delete_ppt(%x:%x:%x:%x) - deleting groups\n", PGUID (proxypp->e.guid)); + DDS_LOG(DDS_LC_DISCOVERY, "delete_ppt(%x:%x:%x:%x) - deleting groups\n", PGUID (proxypp->e.guid)); while (!ut_avlIsEmpty (&proxypp->groups)) delete_proxy_group_locked (ut_avlRoot (&proxypp_groups_treedef, &proxypp->groups), timestamp, isimplicit); - nn_log (LC_DISCOVERY, "delete_ppt(%x:%x:%x:%x) - deleting endpoints\n", PGUID (proxypp->e.guid)); + DDS_LOG(DDS_LC_DISCOVERY, "delete_ppt(%x:%x:%x:%x) - deleting endpoints\n", PGUID (proxypp->e.guid)); c = proxypp->endpoints; while (c) { @@ -3834,16 +3835,16 @@ int delete_proxy_participant_by_guid (const struct nn_guid * guid, nn_wctime_t t { struct proxy_participant * ppt; - nn_log (LC_DISCOVERY, "delete_proxy_participant_by_guid(%x:%x:%x:%x) ", PGUID (*guid)); + DDS_LOG(DDS_LC_DISCOVERY, "delete_proxy_participant_by_guid(%x:%x:%x:%x) ", PGUID (*guid)); os_mutexLock (&gv.lock); ppt = ephash_lookup_proxy_participant_guid (guid); if (ppt == NULL) { os_mutexUnlock (&gv.lock); - nn_log (LC_DISCOVERY, "- unknown\n"); + DDS_LOG(DDS_LC_DISCOVERY, "- unknown\n"); return ERR_UNKNOWN_ENTITY; } - nn_log (LC_DISCOVERY, "- deleting\n"); + DDS_LOG(DDS_LC_DISCOVERY, "- deleting\n"); propagate_builtin_topic_cmparticipant(&(ppt->e), ppt->plist, timestamp, false); propagate_builtin_topic_participant(&(ppt->e), ppt->plist, timestamp, false); remember_deleted_participant_guid (&ppt->e.guid); @@ -3879,7 +3880,7 @@ int new_proxy_group (const struct nn_guid *guid, const char *name, const struct ppguid.entityid.u = NN_ENTITYID_PARTICIPANT; if ((proxypp = ephash_lookup_proxy_participant_guid (&ppguid)) == NULL) { - nn_log (LC_DISCOVERY, "new_proxy_group(%x:%x:%x:%x) - unknown participant\n", PGUID (*guid)); + DDS_LOG(DDS_LC_DISCOVERY, "new_proxy_group(%x:%x:%x:%x) - unknown participant\n", PGUID (*guid)); return 0; } else @@ -3896,7 +3897,7 @@ int new_proxy_group (const struct nn_guid *guid, const char *name, const struct is_sub = 1; break; default: - NN_WARNING ("new_proxy_group: unrecognised entityid: %x\n", guid->entityid.u); + DDS_WARNING("new_proxy_group: unrecognised entityid: %x\n", guid->entityid.u); return ERR_INVALID_DATA; } os_mutexLock (&proxypp->e.lock); @@ -3911,7 +3912,7 @@ int new_proxy_group (const struct nn_guid *guid, const char *name, const struct else { /* Always have a guid, may not have a gid */ - nn_log (LC_DISCOVERY, "new_proxy_group(%x:%x:%x:%x): new\n", PGUID (*guid)); + DDS_LOG(DDS_LC_DISCOVERY, "new_proxy_group(%x:%x:%x:%x): new\n", PGUID (*guid)); pgroup = os_malloc (sizeof (*pgroup)); pgroup->guid = *guid; pgroup->proxypp = proxypp; @@ -3922,14 +3923,14 @@ int new_proxy_group (const struct nn_guid *guid, const char *name, const struct if (name) { assert (xqos != NULL); - nn_log (LC_DISCOVERY, "new_proxy_group(%x:%x:%x:%x): setting name (%s) and qos\n", PGUID (*guid), name); + DDS_LOG(DDS_LC_DISCOVERY, "new_proxy_group(%x:%x:%x:%x): setting name (%s) and qos\n", PGUID (*guid), name); pgroup->name = os_strdup (name); pgroup->xqos = nn_xqos_dup (xqos); nn_xqos_mergein_missing (pgroup->xqos, is_sub ? &gv.default_xqos_sub : &gv.default_xqos_pub); } out: os_mutexUnlock (&proxypp->e.lock); - nn_log (LC_DISCOVERY, "\n"); + DDS_LOG(DDS_LC_DISCOVERY, "\n"); return 0; } } @@ -3940,7 +3941,7 @@ static void delete_proxy_group_locked (struct proxy_group *pgroup, nn_wctime_t t (void)timestamp; (void)isimplicit; assert ((pgroup->xqos != NULL) == (pgroup->name != NULL)); - nn_log (LC_DISCOVERY, "delete_proxy_group_locked %x:%x:%x:%x\n", PGUID (pgroup->guid)); + DDS_LOG(DDS_LC_DISCOVERY, "delete_proxy_group_locked %x:%x:%x:%x\n", PGUID (pgroup->guid)); ut_avlDelete (&proxypp_groups_treedef, &proxypp->groups, pgroup); /* Publish corresponding built-in topic only if it is not a place holder: in that case we haven't announced its presence and @@ -4029,7 +4030,7 @@ int new_proxy_writer (const struct nn_guid *ppguid, const struct nn_guid *guid, if ((proxypp = ephash_lookup_proxy_participant_guid (ppguid)) == NULL) { - NN_WARNING ("new_proxy_writer(%x:%x:%x:%x): proxy participant unknown\n", PGUID (*guid)); + DDS_WARNING("new_proxy_writer(%x:%x:%x:%x): proxy participant unknown\n", PGUID (*guid)); return ERR_UNKNOWN_ENTITY; } @@ -4071,12 +4072,12 @@ int new_proxy_writer (const struct nn_guid *ppguid, const struct nn_guid *guid, assert (pwr->c.xqos->present & QP_LIVELINESS); if (pwr->c.xqos->liveliness.kind != NN_AUTOMATIC_LIVELINESS_QOS) - nn_log (LC_DISCOVERY, " FIXME: only AUTOMATIC liveliness supported"); + DDS_LOG(DDS_LC_DISCOVERY, " FIXME: only AUTOMATIC liveliness supported"); #if 0 pwr->tlease_dur = nn_from_ddsi_duration (pwr->c.xqos->liveliness.lease_duration); if (pwr->tlease_dur == 0) { - nn_log (LC_DISCOVERY, " FIXME: treating lease_duration=0 as inf"); + DDS_LOG(DDS_LC_DISCOVERY, " FIXME: treating lease_duration=0 as inf"); pwr->tlease_dur = T_NEVER; } pwr->tlease_end = add_duration_to_wctime (tnow, pwr->tlease_dur); @@ -4194,7 +4195,7 @@ void update_proxy_reader (struct proxy_reader * prd, struct addrset * as) static void gc_delete_proxy_writer (struct gcreq *gcreq) { struct proxy_writer *pwr = gcreq->arg; - nn_log (LC_DISCOVERY, "gc_delete_proxy_writer(%p, %x:%x:%x:%x)\n", (void *) gcreq, PGUID (pwr->e.guid)); + DDS_LOG(DDS_LC_DISCOVERY, "gc_delete_proxy_writer(%p, %x:%x:%x:%x)\n", (void *) gcreq, PGUID (pwr->e.guid)); gcreq_free (gcreq); while (!ut_avlIsEmpty (&pwr->readers)) @@ -4217,12 +4218,12 @@ int delete_proxy_writer (const struct nn_guid *guid, nn_wctime_t timestamp, int struct proxy_writer *pwr; (void)timestamp; (void)isimplicit; - nn_log (LC_DISCOVERY, "delete_proxy_writer (%x:%x:%x:%x) ", PGUID (*guid)); + DDS_LOG(DDS_LC_DISCOVERY, "delete_proxy_writer (%x:%x:%x:%x) ", PGUID (*guid)); os_mutexLock (&gv.lock); if ((pwr = ephash_lookup_proxy_writer_guid (guid)) == NULL) { os_mutexUnlock (&gv.lock); - nn_log (LC_DISCOVERY, "- unknown\n"); + DDS_LOG(DDS_LC_DISCOVERY, "- unknown\n"); return ERR_UNKNOWN_ENTITY; } /* Set "deleting" flag in particular for Lite, to signal to the receive path it can't @@ -4230,7 +4231,7 @@ int delete_proxy_writer (const struct nn_guid *guid, nn_wctime_t timestamp, int table will prevent the readers from looking up the proxy writer, and consequently from removing themselves from the proxy writer's rdary[]. */ local_reader_ary_setinvalid (&pwr->rdary); - nn_log(LC_DISCOVERY, "- deleting\n"); + DDS_LOG(DDS_LC_DISCOVERY, "- deleting\n"); ephash_remove_proxy_writer_guid (pwr); os_mutexUnlock (&gv.lock); gcreq_proxy_writer (pwr); @@ -4255,7 +4256,7 @@ int new_proxy_reader (const struct nn_guid *ppguid, const struct nn_guid *guid, if ((proxypp = ephash_lookup_proxy_participant_guid (ppguid)) == NULL) { - NN_WARNING ("new_proxy_reader(%x:%x:%x:%x): proxy participant unknown\n", PGUID (*guid)); + DDS_WARNING("new_proxy_reader(%x:%x:%x:%x): proxy participant unknown\n", PGUID (*guid)); return ERR_UNKNOWN_ENTITY; } @@ -4328,7 +4329,7 @@ static void proxy_reader_set_delete_and_ack_all_messages (struct proxy_reader *p static void gc_delete_proxy_reader (struct gcreq *gcreq) { struct proxy_reader *prd = gcreq->arg; - nn_log (LC_DISCOVERY, "gc_delete_proxy_reader(%p, %x:%x:%x:%x)\n", (void *) gcreq, PGUID (prd->e.guid)); + DDS_LOG(DDS_LC_DISCOVERY, "gc_delete_proxy_reader(%p, %x:%x:%x:%x)\n", (void *) gcreq, PGUID (prd->e.guid)); gcreq_free (gcreq); while (!ut_avlIsEmpty (&prd->writers)) @@ -4348,17 +4349,17 @@ int delete_proxy_reader (const struct nn_guid *guid, nn_wctime_t timestamp, int struct proxy_reader *prd; (void)timestamp; (void)isimplicit; - nn_log (LC_DISCOVERY, "delete_proxy_reader (%x:%x:%x:%x) ", PGUID (*guid)); + DDS_LOG(DDS_LC_DISCOVERY, "delete_proxy_reader (%x:%x:%x:%x) ", PGUID (*guid)); os_mutexLock (&gv.lock); if ((prd = ephash_lookup_proxy_reader_guid (guid)) == NULL) { os_mutexUnlock (&gv.lock); - nn_log (LC_DISCOVERY, "- unknown\n"); + DDS_LOG(DDS_LC_DISCOVERY, "- unknown\n"); return ERR_UNKNOWN_ENTITY; } ephash_remove_proxy_reader_guid (prd); os_mutexUnlock (&gv.lock); - nn_log (LC_DISCOVERY, "- deleting\n"); + DDS_LOG(DDS_LC_DISCOVERY, "- deleting\n"); /* If the proxy reader is reliable, pretend it has just acked all messages: this allows a throttled writer to once again make @@ -4408,7 +4409,7 @@ static void gc_delete_proxy_writer_dqueue_bubble_cb (struct gcreq *gcreq) { /* delete proxy_writer, phase 3 */ struct proxy_writer *pwr = gcreq->arg; - nn_log (LC_DISCOVERY, "gc_delete_proxy_writer_dqueue_bubble(%p, %x:%x:%x:%x)\n", (void *) gcreq, PGUID (pwr->e.guid)); + DDS_LOG(DDS_LC_DISCOVERY, "gc_delete_proxy_writer_dqueue_bubble(%p, %x:%x:%x:%x)\n", (void *) gcreq, PGUID (pwr->e.guid)); gcreq_requeue (gcreq, gc_delete_proxy_writer); } @@ -4417,7 +4418,7 @@ static void gc_delete_proxy_writer_dqueue (struct gcreq *gcreq) /* delete proxy_writer, phase 2 */ struct proxy_writer *pwr = gcreq->arg; struct nn_dqueue *dqueue = pwr->dqueue; - nn_log (LC_DISCOVERY, "gc_delete_proxy_writer_dqueue(%p, %x:%x:%x:%x)\n", (void *) gcreq, PGUID (pwr->e.guid)); + DDS_LOG(DDS_LC_DISCOVERY, "gc_delete_proxy_writer_dqueue(%p, %x:%x:%x:%x)\n", (void *) gcreq, PGUID (pwr->e.guid)); nn_dqueue_enqueue_callback (dqueue, (void (*) (void *)) gc_delete_proxy_writer_dqueue_bubble_cb, gcreq); } diff --git a/src/core/ddsi/src/q_gc.c b/src/core/ddsi/src/q_gc.c index 3428b8c..fdec90e 100644 --- a/src/core/ddsi/src/q_gc.c +++ b/src/core/ddsi/src/q_gc.c @@ -134,24 +134,24 @@ static uint32_t gcreq_queue_thread (struct gcreq_queue *q) if (!threads_vtime_check (&gcreq->nvtimes, gcreq->vtimes)) { /* Not all threads made enough progress => gcreq is not ready - yet => sleep for a bit and rety. Note that we can't even + yet => sleep for a bit and retry. Note that we can't even terminate while this gcreq is waiting and that there is no condition on which to wait, so a plain sleep is quite reasonable. */ if (trace_shortsleep) { - TRACE (("gc %p: not yet, shortsleep\n", (void*)gcreq)); + DDS_TRACE("gc %p: not yet, shortsleep\n", (void*)gcreq); trace_shortsleep = 0; } os_nanoSleep (shortsleep); } else { - /* Sufficent progress has been made: may now continue deleting + /* Sufficient progress has been made: may now continue deleting it; the callback is responsible for requeueing (if complex multi-phase delete) or freeing the delete request. Reset the current gcreq as this one obviously is no more. */ - TRACE (("gc %p: deleting\n", (void*)gcreq)); + DDS_TRACE("gc %p: deleting\n", (void*)gcreq); thread_state_awake (self); gcreq->cb (gcreq); thread_state_asleep (self); diff --git a/src/core/ddsi/src/q_init.c b/src/core/ddsi/src/q_init.c index 2690b57..037d794 100644 --- a/src/core/ddsi/src/q_init.c +++ b/src/core/ddsi/src/q_init.c @@ -96,7 +96,7 @@ static int make_uc_sockets (uint32_t * pdisc, uint32_t * pdata, int ppid) } else { - NN_FATAL ("make_uc_sockets: invalid participant index %d\n", ppid); + DDS_FATAL("make_uc_sockets: invalid participant index %d\n", ppid); return -1; } @@ -149,7 +149,7 @@ static int set_recvips (void) #if OS_SOCKET_HAS_IPV6 if (gv.ipv6_link_local) { - NN_WARNING ("DDSI2EService/General/MulticastRecvNetworkInterfaceAddresses: using 'preferred' instead of 'all' because of IPv6 link-local address\n"); + DDS_WARNING("DDSI2EService/General/MulticastRecvNetworkInterfaceAddresses: using 'preferred' instead of 'all' because of IPv6 link-local address\n"); gv.recvips_mode = RECVIPS_MODE_PREFERRED; } else @@ -163,7 +163,7 @@ static int set_recvips (void) #if OS_SOCKET_HAS_IPV6 if (gv.ipv6_link_local) { - NN_ERROR ("DDSI2EService/General/MulticastRecvNetworkInterfaceAddresses: 'any' is unsupported in combination with an IPv6 link-local address\n"); + DDS_ERROR("DDSI2EService/General/MulticastRecvNetworkInterfaceAddresses: 'any' is unsupported in combination with an IPv6 link-local address\n"); return -1; } #endif @@ -189,7 +189,7 @@ static int set_recvips (void) nn_locator_t loc; if (ddsi_locator_from_string(&loc, config.networkRecvAddressStrings[i]) != AFSR_OK) { - NN_ERROR ("%s: not a valid address in DDSI2EService/General/MulticastRecvNetworkInterfaceAddresses\n", config.networkRecvAddressStrings[i]); + DDS_ERROR("%s: not a valid address in DDSI2EService/General/MulticastRecvNetworkInterfaceAddresses\n", config.networkRecvAddressStrings[i]); return -1; } if (compare_locators(&loc, &gv.interfaces[gv.selected_interface].loc) == 0) @@ -200,7 +200,7 @@ static int set_recvips (void) gv.recvips_mode = have_selected ? RECVIPS_MODE_PREFERRED : RECVIPS_MODE_NONE; if (have_others) { - NN_WARNING ("DDSI2EService/General/MulticastRecvNetworkInterfaceAddresses: using 'preferred' because of IPv6 local address\n"); + DDS_WARNING("DDSI2EService/General/MulticastRecvNetworkInterfaceAddresses: using 'preferred' because of IPv6 local address\n"); } } #endif @@ -214,7 +214,7 @@ static int set_recvips (void) nn_locator_t loc; if (ddsi_locator_from_string(&loc, config.networkRecvAddressStrings[i]) != AFSR_OK) { - NN_ERROR ("%s: not a valid address in DDSI2EService/General/MulticastRecvNetworkInterfaceAddresses\n", config.networkRecvAddressStrings[i]); + DDS_ERROR("%s: not a valid address in DDSI2EService/General/MulticastRecvNetworkInterfaceAddresses\n", config.networkRecvAddressStrings[i]); return -1; } for (j = 0; j < gv.n_interfaces; j++) @@ -224,7 +224,7 @@ static int set_recvips (void) } if (j == gv.n_interfaces) { - NN_ERROR ("No interface bound to requested address '%s'\n", config.networkRecvAddressStrings[i]); + DDS_ERROR("No interface bound to requested address '%s'\n", config.networkRecvAddressStrings[i]); return -1; } *recvnode = os_malloc (sizeof (struct ospl_in_addr_node)); @@ -255,13 +255,13 @@ static int string_to_default_locator (nn_locator_t *loc, const char *string, uin case AFSR_OK: break; case AFSR_INVALID: - NN_ERROR ("%s: not a valid address (%s)\n", string, tag); + DDS_ERROR("%s: not a valid address (%s)\n", string, tag); return -1; case AFSR_UNKNOWN: - NN_ERROR ("%s: address name resolution failure (%s)\n", string, tag); + DDS_ERROR("%s: address name resolution failure (%s)\n", string, tag); return -1; case AFSR_MISMATCH: - NN_ERROR ("%s: invalid address kind (%s)\n", string, tag); + DDS_ERROR("%s: invalid address kind (%s)\n", string, tag); return -1; } if (port != 0 && !is_unspec_locator(loc)) @@ -275,7 +275,7 @@ static int string_to_default_locator (nn_locator_t *loc, const char *string, uin const int ismc = is_unspec_locator (loc) || ddsi_is_mcaddr (loc); if (mc != ismc) { - NN_ERROR ("%s: %s %s be the unspecified address or a multicast address\n", string, tag, rel); + DDS_ERROR("%s: %s %s be the unspecified address or a multicast address\n", string, tag, rel); return -1; } } @@ -307,7 +307,7 @@ static int set_spdp_address (void) #ifdef DDSI_INCLUDE_SSM if (gv.loc_spdp_mc.kind != NN_LOCATOR_KIND_INVALID && ddsi_is_ssm_mcaddr (&gv.loc_spdp_mc)) { - NN_ERROR ("%s: SPDP address may not be an SSM address\n", config.spdpMulticastAddressString); + DDS_ERROR("%s: SPDP address may not be an SSM address\n", config.spdpMulticastAddressString); return -1; } #endif @@ -348,7 +348,7 @@ static int set_ext_address_and_mask (void) else if ((rc = string_to_default_locator (&loc, config.externalAddressString, 0, 0, "external address")) < 0) return rc; else if (rc == 0) { - NN_WARNING ("Ignoring ExternalNetworkAddress %s\n", config.externalAddressString); + DDS_WARNING("Ignoring ExternalNetworkAddress %s\n", config.externalAddressString); gv.extloc = gv.ownloc; } else { gv.extloc = loc; @@ -362,7 +362,7 @@ static int set_ext_address_and_mask (void) } else if (config.transport_selector != TRANS_UDP) { - NN_ERROR ("external network masks only supported in IPv4 mode\n"); + DDS_ERROR("external network masks only supported in IPv4 mode\n"); return -1; } else @@ -412,11 +412,11 @@ static int check_thread_properties (void) } if (chanprefix[i] == NULL) { - NN_ERROR ("config: DDSI2Service/Threads/Thread[@name=\"%s\"]: unknown thread\n", e->name); + DDS_ERROR("config: DDSI2Service/Threads/Thread[@name=\"%s\"]: unknown thread\n", e->name); ok = 0; } #else - NN_ERROR ("config: DDSI2Service/Threads/Thread[@name=\"%s\"]: unknown thread\n", e->name); + DDS_ERROR("config: DDSI2Service/Threads/Thread[@name=\"%s\"]: unknown thread\n", e->name); ok = 0; #endif /* DDSI_INCLUDE_NETWORK_CHANNELS */ } @@ -446,7 +446,7 @@ int rtps_config_open (void) } else if ((config.tracingOutputFile = fopen (config.tracingOutputFileName, config.tracingAppendToFile ? "a" : "w")) == NULL) { - NN_ERROR ("%s: cannot open for writing\n", config.tracingOutputFileName); + DDS_ERROR("%s: cannot open for writing\n", config.tracingOutputFileName); status = 0; } else @@ -454,6 +454,10 @@ int rtps_config_open (void) status = 1; } + dds_set_log_mask(config.enabled_logcats); + dds_set_log_file(config.tracingOutputFile); + dds_set_trace_file(config.tracingOutputFile); + return status; } @@ -471,7 +475,7 @@ int rtps_config_prep (struct cfgst *cfgst) config.whc_init_highwater_mark.value < config.whc_lowwater_mark || config.whc_init_highwater_mark.value > config.whc_highwater_mark) { - NN_ERROR ("Invalid watermark settings\n"); + DDS_ERROR("Invalid watermark settings\n"); goto err_config_late_error; } @@ -483,7 +487,7 @@ int rtps_config_prep (struct cfgst *cfgst) inherited by readers/writers), but in many sockets mode each participant has its own socket, and therefore unique address set */ - NN_ERROR ("Minimal built-in endpoint set mode and ManySocketsMode are incompatible\n"); + DDS_ERROR("Minimal built-in endpoint set mode and ManySocketsMode are incompatible\n"); goto err_config_late_error; } @@ -509,7 +513,7 @@ int rtps_config_prep (struct cfgst *cfgst) { double max = (double) config.auxiliary_bandwidth_limit * ((double) config.nack_delay / 1e9); if (max < 0) - NN_FATAL ("AuxiliaryBandwidthLimit * NackDelay = %g bytes is insane\n", max); + DDS_FATAL("AuxiliaryBandwidthLimit * NackDelay = %g bytes is insane\n", max); if (max > 2147483647.0) config.max_queued_rexmit_bytes = 2147483647u; else @@ -523,7 +527,7 @@ int rtps_config_prep (struct cfgst *cfgst) /* Verify thread properties refer to defined threads */ if (!check_thread_properties ()) { - NN_ERROR ("Could not initialise configuration\n"); + DDS_ERROR("Could not initialise configuration\n"); goto err_config_late_error; } @@ -534,7 +538,7 @@ int rtps_config_prep (struct cfgst *cfgst) have chosen the latter. */ if (config.useIpv6) { - NN_ERROR ("IPv6 addressing requested but not supported on this platform\n"); + DDS_ERROR("IPv6 addressing requested but not supported on this platform\n"); goto err_config_late_error; } #endif @@ -559,7 +563,7 @@ int rtps_config_prep (struct cfgst *cfgst) if (config.transport_selector != TRANS_UDP && chptr->diffserv_field != 0) { - NN_ERROR ("channel %s specifies IPv4 DiffServ settings which is incompatible with IPv6 use\n", + DDS_ERROR("channel %s specifies IPv4 DiffServ settings which is incompatible with IPv6 use\n", chptr->name); error = 1; } @@ -583,7 +587,7 @@ int rtps_config_prep (struct cfgst *cfgst) printed */ if (! rtps_config_open ()) { - NN_ERROR ("Could not initialise configuration\n"); + DDS_ERROR("Could not initialise configuration\n"); goto err_config_late_error; } @@ -654,7 +658,7 @@ int joinleave_spdp_defmcip (int dojoin) unref_addrset (as); if (arg.errcount) { - NN_ERROR ("rtps_init: failed to join multicast groups for domain %d participant %d\n", config.domainId.value, config.participantIndex); + DDS_ERROR("rtps_init: failed to join multicast groups for domain %d participant %d\n", config.domainId.value, config.participantIndex); return -1; } return 0; @@ -686,8 +690,8 @@ int create_multicast_sockets(void) gv.disc_conn_mc = disc; gv.data_conn_mc = data; - TRACE (("Multicast Ports: discovery %d data %d \n", - ddsi_tran_port (gv.disc_conn_mc), ddsi_tran_port (gv.data_conn_mc))); + DDS_TRACE("Multicast Ports: discovery %d data %d \n", + ddsi_tran_port (gv.disc_conn_mc), ddsi_tran_port (gv.data_conn_mc)); return 1; err_data: @@ -735,7 +739,7 @@ static void wait_for_receive_threads (void) /* retrying is to deal a packet geting lost because the socket buffer is full or because the macOS firewall (and perhaps others) likes to ask if the process is allowed to receive data, dropping the packets until the user approves. */ - NN_WARNING ("wait_for_receive_threads: failed to schedule periodic triggering of the receive threads to deal with packet loss\n"); + DDS_WARNING("wait_for_receive_threads: failed to schedule periodic triggering of the receive threads to deal with packet loss\n"); } for (i = 0; i < gv.n_recv_threads; i++) { @@ -835,20 +839,20 @@ static int setup_and_start_recv_threads (void) it before it does anything with it. */ if ((gv.recv_threads[i].arg.rbpool = nn_rbufpool_new (config.rbuf_size, config.rmsg_chunk_size)) == NULL) { - NN_ERROR ("rtps_init: can't allocate receive buffer pool for thread %s\n", gv.recv_threads[i].name); + DDS_ERROR("rtps_init: can't allocate receive buffer pool for thread %s\n", gv.recv_threads[i].name); goto fail; } if (gv.recv_threads[i].arg.mode == RTM_MANY) { if ((gv.recv_threads[i].arg.u.many.ws = os_sockWaitsetNew ()) == NULL) { - NN_ERROR ("rtps_init: can't allocate sock waitset for thread %s\n", gv.recv_threads[i].name); + DDS_ERROR("rtps_init: can't allocate sock waitset for thread %s\n", gv.recv_threads[i].name); goto fail; } } if ((gv.recv_threads[i].ts = create_thread (gv.recv_threads[i].name, recv_thread, &gv.recv_threads[i].arg)) == NULL) { - NN_ERROR ("rtps_init: failed to start thread %s\n", gv.recv_threads[i].name); + DDS_ERROR("rtps_init: failed to start thread %s\n", gv.recv_threads[i].name); goto fail; } } @@ -889,7 +893,7 @@ int rtps_init (void) gv.debmon = NULL; /* Print start time for referencing relative times in the remainder - of the nn_log. */ + of the DDS_LOG. */ { int sec = (int) (gv.tstart.v / 1000000000); int usec = (int) (gv.tstart.v % 1000000000) / 1000; @@ -898,7 +902,7 @@ int rtps_init (void) tv.tv_sec = sec; tv.tv_nsec = usec * 1000; os_ctime_r (&tv, str, sizeof(str)); - nn_log (LC_INFO | LC_CONFIG, "started at %d.06%d -- %s\n", sec, usec, str); + DDS_LOG(DDS_LC_INFO | DDS_LC_CONFIG, "started at %d.06%d -- %s\n", sec, usec, str); } /* Initialize thread pool */ @@ -947,14 +951,14 @@ int rtps_init (void) if (!find_own_ip (config.networkAddressString)) { - NN_ERROR ("No network interface selected\n"); + DDS_ERROR("No network interface selected\n"); goto err_find_own_ip; } if (config.allowMulticast) { if (!gv.interfaces[gv.selected_interface].mc_capable) { - NN_WARNING ("selected interface is not multicast-capable: disabling multicast\n"); + DDS_WARNING("selected interface is not multicast-capable: disabling multicast\n"); config.suppress_spdp_multicast = 1; config.allowMulticast = AMC_FALSE; } @@ -971,19 +975,19 @@ int rtps_init (void) { char buf[DDSI_LOCSTRLEN]; /* the "ownip", "extip" labels in the trace have been there for so long, that it seems worthwhile to retain them even though they need not be IP any longer */ - nn_log (LC_CONFIG, "ownip: %s\n", ddsi_locator_to_string_no_port (buf, sizeof(buf), &gv.ownloc)); - nn_log (LC_CONFIG, "extip: %s\n", ddsi_locator_to_string_no_port (buf, sizeof(buf), &gv.extloc)); - nn_log (LC_CONFIG, "extmask: %s%s\n", ddsi_locator_to_string_no_port (buf, sizeof(buf), &gv.extmask), gv.m_factory->m_kind != NN_LOCATOR_KIND_UDPv4 ? " (not applicable)" : ""); - nn_log (LC_CONFIG, "networkid: 0x%lx\n", (unsigned long) gv.myNetworkId); - nn_log (LC_CONFIG, "SPDP MC: %s\n", ddsi_locator_to_string_no_port (buf, sizeof(buf), &gv.loc_spdp_mc)); - nn_log (LC_CONFIG, "default MC: %s\n", ddsi_locator_to_string_no_port (buf, sizeof(buf), &gv.loc_default_mc)); + DDS_LOG(DDS_LC_CONFIG, "ownip: %s\n", ddsi_locator_to_string_no_port (buf, sizeof(buf), &gv.ownloc)); + DDS_LOG(DDS_LC_CONFIG, "extip: %s\n", ddsi_locator_to_string_no_port (buf, sizeof(buf), &gv.extloc)); + DDS_LOG(DDS_LC_CONFIG, "extmask: %s%s\n", ddsi_locator_to_string_no_port (buf, sizeof(buf), &gv.extmask), gv.m_factory->m_kind != NN_LOCATOR_KIND_UDPv4 ? " (not applicable)" : ""); + DDS_LOG(DDS_LC_CONFIG, "networkid: 0x%lx\n", (unsigned long) gv.myNetworkId); + DDS_LOG(DDS_LC_CONFIG, "SPDP MC: %s\n", ddsi_locator_to_string_no_port (buf, sizeof(buf), &gv.loc_spdp_mc)); + DDS_LOG(DDS_LC_CONFIG, "default MC: %s\n", ddsi_locator_to_string_no_port (buf, sizeof(buf), &gv.loc_default_mc)); #ifdef DDSI_INCLUDE_SSM - nn_log (LC_CONFIG, "SSM support included\n"); + DDS_LOG(DDS_LC_CONFIG, "SSM support included\n"); #endif } if (gv.ownloc.kind != gv.extloc.kind) - NN_FATAL ("mismatch between network address kinds\n"); + DDS_FATAL("mismatch between network address kinds\n"); #ifdef DDSI_INCLUDE_NETWORK_PARTITIONS /* Convert address sets in partition mappings from string to address sets */ @@ -1007,7 +1011,7 @@ int rtps_init (void) #endif gv.startup_mode = (config.startup_mode_duration > 0) ? 1 : 0; - nn_log (LC_CONFIG, "startup-mode: %s\n", gv.startup_mode ? "enabled" : "disabled"); + DDS_LOG(DDS_LC_CONFIG, "startup-mode: %s\n", gv.startup_mode ? "enabled" : "disabled"); (ddsi_plugin.init_fn) (); @@ -1018,7 +1022,7 @@ int rtps_init (void) if (q_security_plugin.new_decoder) { gv.recvSecurityCodec = (q_security_plugin.new_decoder) (); - nn_log (LC_CONFIG, "decoderset created\n"); + DDS_LOG(DDS_LC_CONFIG, "decoderset created\n"); } #endif @@ -1064,7 +1068,7 @@ int rtps_init (void) { if (make_uc_sockets (&port_disc_uc, &port_data_uc, config.participantIndex) < 0) { - NN_ERROR ("rtps_init: failed to create unicast sockets for domain %d participant %d\n", config.domainId.value, config.participantIndex); + DDS_ERROR("rtps_init: failed to create unicast sockets for domain %d participant %d\n", config.domainId.value, config.participantIndex); goto err_unicast_sockets; } } @@ -1072,7 +1076,7 @@ int rtps_init (void) { /* try to find a free one, and update config.participantIndex */ int ppid; - nn_log (LC_CONFIG, "rtps_init: trying to find a free participant index\n"); + DDS_LOG(DDS_LC_CONFIG, "rtps_init: trying to find a free participant index\n"); for (ppid = 0; ppid <= config.maxAutoParticipantIndex; ppid++) { int r = make_uc_sockets (&port_disc_uc, &port_data_uc, ppid); @@ -1082,13 +1086,13 @@ int rtps_init (void) continue; else /* Oops! */ { - NN_ERROR ("rtps_init: failed to create unicast sockets for domain %d participant %d\n", config.domainId.value, ppid); + DDS_ERROR("rtps_init: failed to create unicast sockets for domain %d participant %d\n", config.domainId.value, ppid); goto err_unicast_sockets; } } if (ppid > config.maxAutoParticipantIndex) { - NN_ERROR ("rtps_init: failed to find a free participant index for domain %d\n", config.domainId.value); + DDS_ERROR("rtps_init: failed to find a free participant index for domain %d\n", config.domainId.value); goto err_unicast_sockets; } config.participantIndex = ppid; @@ -1097,9 +1101,9 @@ int rtps_init (void) { assert(0); } - nn_log (LC_CONFIG, "rtps_init: uc ports: disc %u data %u\n", port_disc_uc, port_data_uc); + DDS_LOG(DDS_LC_CONFIG, "rtps_init: uc ports: disc %u data %u\n", port_disc_uc, port_data_uc); } - nn_log (LC_CONFIG, "rtps_init: domainid %d participantid %d\n", config.domainId.value, config.participantIndex); + DDS_LOG(DDS_LC_CONFIG, "rtps_init: domainid %d participantid %d\n", config.domainId.value, config.participantIndex); if (config.pcap_file && *config.pcap_file) { @@ -1119,7 +1123,7 @@ int rtps_init (void) if (gv.m_factory->m_connless) { if (!(config.many_sockets_mode == MSM_NO_UNICAST && config.allowMulticast)) - TRACE (("Unicast Ports: discovery %d data %d\n", ddsi_tran_port (gv.disc_conn_uc), ddsi_tran_port (gv.data_conn_uc))); + DDS_TRACE("Unicast Ports: discovery %d data %d\n", ddsi_tran_port (gv.disc_conn_uc), ddsi_tran_port (gv.data_conn_uc)); if (config.allowMulticast) { @@ -1154,7 +1158,7 @@ int rtps_init (void) gv.listener = ddsi_factory_create_listener (gv.m_factory, config.tcp_port, NULL); if (gv.listener == NULL || ddsi_listener_listen (gv.listener) != 0) { - NN_ERROR ("Failed to create %s listener\n", gv.m_factory->m_typename); + DDS_ERROR("Failed to create %s listener\n", gv.m_factory->m_typename); if (gv.listener) ddsi_listener_free(gv.listener); goto err_mc_conn; @@ -1173,7 +1177,7 @@ int rtps_init (void) /* Create shared transmit connection */ gv.tev_conn = gv.data_conn_uc; - TRACE (("Timed event transmit port: %d\n", (int) ddsi_tran_port (gv.tev_conn))); + DDS_TRACE("Timed event transmit port: %d\n", (int) ddsi_tran_port (gv.tev_conn)); #ifdef DDSI_INCLUDE_NETWORK_CHANNELS { @@ -1194,14 +1198,14 @@ int rtps_init (void) ddsi_tran_free_qos (qos); if (chptr->transmit_conn == NULL) { - NN_FATAL ("failed to create transmit connection for channel %s\n", chptr->name); + DDS_FATAL("failed to create transmit connection for channel %s\n", chptr->name); } } else { chptr->transmit_conn = gv.data_conn_uc; } - TRACE (("channel %s: transmit port %d\n", chptr->name, (int) ddsi_tran_port (chptr->transmit_conn))); + DDS_TRACE("channel %s: transmit port %d\n", chptr->name, (int) ddsi_tran_port (chptr->transmit_conn)); #ifdef DDSI_INCLUDE_BANDWIDTH_LIMITING if (chptr->auxiliary_bandwidth_limit > 0 || lookup_thread_properties (tname)) @@ -1270,7 +1274,7 @@ int rtps_init (void) gv.builtins_dqueue = nn_dqueue_new ("builtins", config.delivery_queue_maxsamples, builtins_dqueue_handler, NULL); if ((r = xeventq_start (gv.xevents, NULL)) < 0) { - NN_FATAL ("failed to start global event processing thread (%d)\n", r); + DDS_FATAL("failed to start global event processing thread (%d)\n", r); } } @@ -1291,7 +1295,7 @@ int rtps_init (void) { int r; if ((r = xeventq_start (chptr->evq, chptr->name)) < 0) - NN_FATAL ("failed to start event processing thread for channel '%s' (%d)\n", chptr->name, r); + DDS_FATAL("failed to start event processing thread for channel '%s' (%d)\n", chptr->name, r); } chptr = chptr->next; } @@ -1302,7 +1306,7 @@ int rtps_init (void) if (setup_and_start_recv_threads () < 0) { - NN_FATAL ("failed to start receive threads\n"); + DDS_FATAL("failed to start receive threads\n"); } if (gv.listener) @@ -1660,5 +1664,5 @@ OS_WARNING_MSVC_ON(6001); ddsi_serdatapool_free (gv.serpool); nn_xmsgpool_free (gv.xmsgpool); (ddsi_plugin.fini_fn) (); - nn_log (LC_CONFIG, "Finis.\n"); + DDS_LOG(DDS_LC_CONFIG, "Finis.\n"); } diff --git a/src/core/ddsi/src/q_lat_estim.c b/src/core/ddsi/src/q_lat_estim.c index f3c684d..c56a482 100644 --- a/src/core/ddsi/src/q_lat_estim.c +++ b/src/core/ddsi/src/q_lat_estim.c @@ -56,7 +56,7 @@ void nn_lat_estim_update (struct nn_lat_estim *le, int64_t est) le->smoothed = (1.0f - alpha) * le->smoothed + alpha * med; } -int nn_lat_estim_log (logcat_t logcat, const char *tag, const struct nn_lat_estim *le) +int nn_lat_estim_log (uint32_t logcat, const char *tag, const struct nn_lat_estim *le) { if (le->smoothed == 0.0f) return 0; @@ -67,12 +67,12 @@ int nn_lat_estim_log (logcat_t logcat, const char *tag, const struct nn_lat_esti memcpy (tmp, le->window, sizeof (tmp)); qsort (tmp, NN_LAT_ESTIM_MEDIAN_WINSZ, sizeof (tmp[0]), (int (*) (const void *, const void *)) cmpfloat); if (tag) - nn_log (logcat, " LAT(%s: %e {", tag, le->smoothed); + DDS_LOG(logcat, " LAT(%s: %e {", tag, le->smoothed); else - nn_log (logcat, " LAT(%e {", le->smoothed); + DDS_LOG(logcat, " LAT(%e {", le->smoothed); for (i = 0; i < NN_LAT_ESTIM_MEDIAN_WINSZ; i++) - nn_log (logcat, "%s%e", (i > 0) ? "," : "", tmp[i]); - nn_log (logcat, "})"); + DDS_LOG(logcat, "%s%e", (i > 0) ? "," : "", tmp[i]); + DDS_LOG(logcat, "})"); return 1; } } diff --git a/src/core/ddsi/src/q_lease.c b/src/core/ddsi/src/q_lease.c index ce6ed57..0c1f26e 100644 --- a/src/core/ddsi/src/q_lease.c +++ b/src/core/ddsi/src/q_lease.c @@ -109,7 +109,7 @@ struct lease *lease_new (nn_etime_t texpire, int64_t tdur, struct entity_common struct lease *l; if ((l = os_malloc (sizeof (*l))) == NULL) return NULL; - TRACE (("lease_new(tdur %"PRId64" guid %x:%x:%x:%x) @ %p\n", tdur, PGUID (e->guid), (void *) l)); + DDS_TRACE("lease_new(tdur %"PRId64" guid %x:%x:%x:%x) @ %p\n", tdur, PGUID (e->guid), (void *) l); l->tdur = tdur; l->tend = texpire; l->tsched.v = TSCHED_NOT_ON_HEAP; @@ -119,7 +119,7 @@ struct lease *lease_new (nn_etime_t texpire, int64_t tdur, struct entity_common void lease_register (struct lease *l) { - TRACE (("lease_register(l %p guid %x:%x:%x:%x)\n", (void *) l, PGUID (l->entity->guid))); + DDS_TRACE("lease_register(l %p guid %x:%x:%x:%x)\n", (void *) l, PGUID (l->entity->guid)); os_mutexLock (&gv.leaseheap_lock); lock_lease (l); assert (l->tsched.v == TSCHED_NOT_ON_HEAP); @@ -137,7 +137,7 @@ void lease_register (struct lease *l) void lease_free (struct lease *l) { - TRACE (("lease_free(l %p guid %x:%x:%x:%x)\n", (void *) l, PGUID (l->entity->guid))); + DDS_TRACE("lease_free(l %p guid %x:%x:%x:%x)\n", (void *) l, PGUID (l->entity->guid)); os_mutexLock (&gv.leaseheap_lock); if (l->tsched.v != TSCHED_NOT_ON_HEAP) ut_fibheapDelete (&lease_fhdef, &gv.leaseheap, l); @@ -163,16 +163,16 @@ void lease_renew (struct lease *l, nn_etime_t tnowE) } unlock_lease (l); - if (did_update && (config.enabled_logcats & LC_TRACE)) + if (did_update && (dds_get_log_mask() & DDS_LC_TRACE)) { int tsec, tusec; - TRACE ((" L(")); + DDS_TRACE(" L("); if (l->entity->guid.entityid.u == NN_ENTITYID_PARTICIPANT) - TRACE ((":%x", l->entity->guid.entityid.u)); + DDS_TRACE(":%x", l->entity->guid.entityid.u); else - TRACE (("%x:%x:%x:%x", PGUID (l->entity->guid))); + DDS_TRACE("%x:%x:%x:%x", PGUID (l->entity->guid)); etime_to_sec_usec (&tsec, &tusec, tend_new); - TRACE ((" %d.%06d)", tsec, tusec)); + DDS_TRACE(" %d.%06d)", tsec, tusec); } } @@ -234,7 +234,7 @@ int64_t check_and_handle_lease_expiration (UNUSED_ARG (struct thread_state1 *sel continue; } - nn_log (LC_DISCOVERY, "lease expired: l %p guid %x:%x:%x:%x tend %"PRId64" < now %"PRId64"\n", (void *) l, PGUID (g), l->tend.v, tnowE.v); + DDS_LOG(DDS_LC_DISCOVERY, "lease expired: l %p guid %x:%x:%x:%x tend %"PRId64" < now %"PRId64"\n", (void *) l, PGUID (g), l->tend.v, tnowE.v); /* If the proxy participant is relying on another participant for writing its discovery data (on the privileged participant, @@ -267,7 +267,7 @@ int64_t check_and_handle_lease_expiration (UNUSED_ARG (struct thread_state1 *sel if ((proxypp = ephash_lookup_proxy_participant_guid (&g)) != NULL && ephash_lookup_proxy_participant_guid (&proxypp->privileged_pp_guid) != NULL) { - nn_log (LC_DISCOVERY, "but postponing because privileged pp %x:%x:%x:%x is still live\n", + DDS_LOG(DDS_LC_DISCOVERY, "but postponing because privileged pp %x:%x:%x:%x is still live\n", PGUID (proxypp->privileged_pp_guid)); l->tsched = l->tend = add_duration_to_etime (tnowE, 200 * T_MILLISECOND); unlock_lease (l); @@ -317,15 +317,15 @@ static void debug_print_rawdata (const char *msg, const void *data, size_t len) { const unsigned char *c = data; size_t i; - TRACE (("%s<", msg)); + DDS_TRACE("%s<", msg); for (i = 0; i < len; i++) { if (32 < c[i] && c[i] <= 127) - TRACE (("%s%c", (i > 0 && (i%4) == 0) ? " " : "", c[i])); + DDS_TRACE("%s%c", (i > 0 && (i%4) == 0) ? " " : "", c[i]); else - TRACE (("%s\\x%02x", (i > 0 && (i%4) == 0) ? " " : "", c[i])); + DDS_TRACE("%s\\x%02x", (i > 0 && (i%4) == 0) ? " " : "", c[i]); } - TRACE ((">")); + DDS_TRACE(">"); } void handle_PMD (UNUSED_ARG (const struct receiver_state *rst), nn_wctime_t timestamp, unsigned statusinfo, const void *vdata, unsigned len) @@ -334,10 +334,10 @@ void handle_PMD (UNUSED_ARG (const struct receiver_state *rst), nn_wctime_t time const int bswap = (data->identifier == CDR_LE) ^ PLATFORM_IS_LITTLE_ENDIAN; struct proxy_participant *pp; nn_guid_t ppguid; - TRACE ((" PMD ST%x", statusinfo)); + DDS_TRACE(" PMD ST%x", statusinfo); if (data->identifier != CDR_LE && data->identifier != CDR_BE) { - TRACE ((" PMD data->identifier %u !?\n", ntohs (data->identifier))); + DDS_TRACE(" PMD data->identifier %u !?\n", ntohs (data->identifier)); return; } switch (statusinfo & (NN_STATUSINFO_DISPOSE | NN_STATUSINFO_UNREGISTER)) @@ -351,7 +351,7 @@ void handle_PMD (UNUSED_ARG (const struct receiver_state *rst), nn_wctime_t time nn_guid_prefix_t p = nn_ntoh_guid_prefix (pmd->participantGuidPrefix); unsigned kind = ntohl (pmd->kind); unsigned length = bswap ? bswap4u (pmd->length) : pmd->length; - TRACE ((" pp %x:%x:%x kind %u data %u", p.u[0], p.u[1], p.u[2], kind, length)); + DDS_TRACE(" pp %x:%x:%x kind %u data %u", p.u[0], p.u[1], p.u[2], kind, length); if (len - sizeof (struct CDRHeader) - offsetof (ParticipantMessageData_t, value) < length) debug_print_rawdata (" SHORT2", pmd->value, len - sizeof (struct CDRHeader) - offsetof (ParticipantMessageData_t, value)); else @@ -359,7 +359,7 @@ void handle_PMD (UNUSED_ARG (const struct receiver_state *rst), nn_wctime_t time ppguid.prefix = p; ppguid.entityid.u = NN_ENTITYID_PARTICIPANT; if ((pp = ephash_lookup_proxy_participant_guid (&ppguid)) == NULL) - TRACE ((" PPunknown")); + DDS_TRACE(" PPunknown"); else { /* Renew lease if arrival of this message didn't already do so, also renew the lease @@ -382,11 +382,11 @@ void handle_PMD (UNUSED_ARG (const struct receiver_state *rst), nn_wctime_t time ppguid.prefix = nn_ntoh_guid_prefix (*((nn_guid_prefix_t *) (data + 1))); ppguid.entityid.u = NN_ENTITYID_PARTICIPANT; if (delete_proxy_participant_by_guid (&ppguid, timestamp, 0) < 0) - TRACE ((" unknown")); + DDS_TRACE(" unknown"); else - TRACE ((" delete")); + DDS_TRACE(" delete"); } break; } - TRACE (("\n")); + DDS_TRACE("\n"); } diff --git a/src/core/ddsi/src/q_log.c b/src/core/ddsi/src/q_log.c deleted file mode 100644 index 10808cf..0000000 --- a/src/core/ddsi/src/q_log.c +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright(c) 2006 to 2018 ADLINK Technology Limited and others - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License - * v. 1.0 which is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause - */ -#include -#include -#include -#include -#include -#include - -#include "os/os.h" - -#include "ddsi/q_config.h" -#include "ddsi/q_globals.h" -#include "ddsi/q_thread.h" -#include "ddsi/q_time.h" -#include "ddsi/q_log.h" - -#define MAX_TIMESTAMP_LENGTH (10 + 1 + 6) -#define MAX_TID_LENGTH 10 -#define MAX_HDR_LENGTH (MAX_TIMESTAMP_LENGTH + 1 + MAX_TID_LENGTH + + 2) - -#define BUF_OFFSET MAX_HDR_LENGTH - -static void logbuf_flush_real (struct thread_state1 *self, logbuf_t lb) -{ - if (config.tracingOutputFile != NULL) - { - const char *tname = self ? self->name : "(anon)"; - char hdr[MAX_HDR_LENGTH + 1]; - int n, tsec, tusec; - if (lb->tstamp.v < 0) - lb->tstamp = now (); - wctime_to_sec_usec (&tsec, &tusec, lb->tstamp); - lb->tstamp.v = -1; - n = snprintf (hdr, sizeof (hdr), "%d.%06d/%*.*s: ", tsec, tusec, MAX_TID_LENGTH, MAX_TID_LENGTH, tname); - assert (0 < n && n <= BUF_OFFSET); - memcpy (lb->buf + BUF_OFFSET - n, hdr, (size_t) n); - fwrite (lb->buf + BUF_OFFSET - n, 1, lb->pos - BUF_OFFSET + (size_t) n, config.tracingOutputFile); - fflush (config.tracingOutputFile); - } - lb->pos = BUF_OFFSET; - lb->buf[lb->pos] = 0; -} - -static void logbuf_flush (struct thread_state1 *self, logbuf_t lb) -{ - if (lb->pos > BUF_OFFSET) - { - if (lb->pos < (int) sizeof (lb->buf)) - lb->buf[lb->pos++] = '\n'; - else - lb->buf[sizeof (lb->buf) - 1] = '\n'; - logbuf_flush_real (self, lb); - } -} - -void logbuf_init (logbuf_t lb) -{ - lb->bufsz = sizeof (lb->buf); - lb->pos = BUF_OFFSET; - lb->tstamp.v = -1; - lb->buf[lb->pos] = 0; -} - -logbuf_t logbuf_new (void) -{ - logbuf_t lb = os_malloc (sizeof (*lb)); - logbuf_init (lb); - return lb; -} - -void logbuf_free (logbuf_t lb) -{ - logbuf_flush (lookup_thread_state (), lb); - os_free (lb); -} - -/* LOGGING ROUTINES */ - -static void nn_vlogb (struct thread_state1 *self, const char *fmt, va_list ap) -{ - int n, trunc = 0; - size_t nrem; - logbuf_t lb; - if (*fmt == 0) - return; - if (self->lb) - lb = self->lb; - else - { - lb = &gv.static_logbuf; - if (gv.static_logbuf_lock_inited) - { - /* not supposed to be multi-threaded when mutex not - initialized */ - os_mutexLock (&gv.static_logbuf_lock); - } - } - - nrem = lb->bufsz - lb->pos; - if (nrem > 0) - { - n = os_vsnprintf (lb->buf + lb->pos, nrem, fmt, ap); - if (n >= 0 && (size_t) n < nrem) - lb->pos += (size_t) n; - else - { - lb->pos += nrem; - trunc = 1; - } - if (trunc) - { - static const char msg[] = "(trunc)\n"; - const size_t msglen = sizeof (msg) - 1; - assert (lb->pos <= lb->bufsz); - assert (lb->pos >= msglen); - memcpy (lb->buf + lb->pos - msglen, msg, msglen); - } - } - if (fmt[strlen (fmt) - 1] == '\n') - { - logbuf_flush_real (self, lb); - } - - if (lb == &gv.static_logbuf && gv.static_logbuf_lock_inited) - { - os_mutexUnlock (&gv.static_logbuf_lock); - } -} - -int nn_vlog (logcat_t cat, const char *fmt, va_list ap) -{ - if (config.enabled_logcats & cat) - { - struct thread_state1 *self = lookup_thread_state (); - nn_vlogb (self, fmt, ap); - } - return 0; -} - -int nn_log (_In_ logcat_t cat, _In_z_ _Printf_format_string_ const char *fmt, ...) -{ - if (config.enabled_logcats & cat) - { - struct thread_state1 *self = lookup_thread_state (); - va_list ap; - va_start (ap, fmt); - nn_vlogb (self, fmt, ap); - va_end (ap); - } - if (cat == LC_FATAL) - { - abort (); - } - return 0; -} - -int nn_trace (_In_z_ _Printf_format_string_ const char *fmt, ...) -{ - if (config.enabled_logcats & LC_TRACE) - { - struct thread_state1 *self = lookup_thread_state (); - va_list ap; - va_start (ap, fmt); - nn_vlogb (self, fmt, ap); - va_end (ap); - } - return 0; -} - -void nn_log_set_tstamp (nn_wctime_t tnow) -{ - struct thread_state1 *self = lookup_thread_state (); - if (self && self->lb) - self->lb->tstamp = tnow; -} diff --git a/src/core/ddsi/src/q_nwif.c b/src/core/ddsi/src/q_nwif.c index 876e34c..f6303b9 100644 --- a/src/core/ddsi/src/q_nwif.c +++ b/src/core/ddsi/src/q_nwif.c @@ -36,7 +36,7 @@ static void print_sockerror (const char *msg) { int err = os_getErrno (); - NN_ERROR ("SOCKET %s errno %d\n", msg, err); + DDS_ERROR("SOCKET %s errno %d\n", msg, err); } unsigned locator_to_hopefully_unique_uint32 (const nn_locator_t *src) @@ -141,15 +141,15 @@ static int set_rcvbuf (os_socket socket) } if (ReceiveBufferSize < socket_min_rcvbuf_size) { - /* NN_ERROR does more than just nn_log(LC_ERROR), hence the duplication */ + /* NN_ERROR does more than just DDS_ERROR(), hence the duplication */ if (config.socket_min_rcvbuf_size.isdefault) - nn_log (LC_CONFIG, "failed to increase socket receive buffer size to %u bytes, continuing with %u bytes\n", socket_min_rcvbuf_size, ReceiveBufferSize); + DDS_LOG(DDS_LC_CONFIG, "failed to increase socket receive buffer size to %u bytes, continuing with %u bytes\n", socket_min_rcvbuf_size, ReceiveBufferSize); else - NN_ERROR ("failed to increase socket receive buffer size to %u bytes, continuing with %u bytes\n", socket_min_rcvbuf_size, ReceiveBufferSize); + DDS_ERROR("failed to increase socket receive buffer size to %u bytes, continuing with %u bytes\n", socket_min_rcvbuf_size, ReceiveBufferSize); } else { - nn_log (LC_CONFIG, "socket receive buffer size set to %u bytes\n", ReceiveBufferSize); + DDS_LOG(DDS_LC_CONFIG, "socket receive buffer size set to %u bytes\n", ReceiveBufferSize); } } return 0; @@ -463,13 +463,13 @@ int find_own_ip (const char *requested_address) int selected_idx = -1; char addrbuf[DDSI_LOCSTRLEN]; - nn_log (LC_CONFIG, "interfaces:"); + DDS_LOG(DDS_LC_CONFIG, "interfaces:"); { int ret; ret = ddsi_enumerate_interfaces(gv.m_factory, &ifa_root); if (ret < 0) { - NN_ERROR("ddsi_enumerate_interfaces(%s): %d\n", gv.m_factory->m_typename, ret); + DDS_ERROR("ddsi_enumerate_interfaces(%s): %d\n", gv.m_factory->m_typename, ret); return 0; } } @@ -485,15 +485,15 @@ int find_own_ip (const char *requested_address) if_name[sizeof (if_name) - 1] = 0; if (strcmp (if_name, last_if_name)) - nn_log (LC_CONFIG, "%s%s", sep, if_name); + DDS_LOG(DDS_LC_CONFIG, "%s%s", sep, if_name); strcpy (last_if_name, if_name); /* interface must be up */ if ((ifa->flags & IFF_UP) == 0) { - nn_log (LC_CONFIG, " (interface down)"); + DDS_LOG(DDS_LC_CONFIG, " (interface down)"); continue; } else if (os_sockaddr_is_unspecified(ifa->addr)) { - nn_log (LC_CONFIG, " (address unspecified)"); + DDS_LOG(DDS_LC_CONFIG, " (address unspecified)"); continue; } @@ -513,11 +513,11 @@ int find_own_ip (const char *requested_address) ddsi_ipaddr_to_loc(&gv.interfaces[gv.n_interfaces].loc, ifa->addr, gv.m_factory->m_kind); } ddsi_locator_to_string_no_port(addrbuf, sizeof(addrbuf), &gv.interfaces[gv.n_interfaces].loc); - nn_log (LC_CONFIG, " %s(", addrbuf); + DDS_LOG(DDS_LC_CONFIG, " %s(", addrbuf); if (!(ifa->flags & IFF_MULTICAST) && multicast_override (if_name)) { - nn_log (LC_CONFIG, "assume-mc:"); + DDS_LOG(DDS_LC_CONFIG, "assume-mc:"); ifa->flags |= IFF_MULTICAST; } @@ -560,7 +560,7 @@ int find_own_ip (const char *requested_address) q += 2; } - nn_log (LC_CONFIG, "q%d)", q); + DDS_LOG(DDS_LC_CONFIG, "q%d)", q); if (q == quality) { maxq_list[maxq_count] = gv.n_interfaces; maxq_strlen += 2 + strlen (if_name); @@ -590,7 +590,7 @@ int find_own_ip (const char *requested_address) gv.interfaces[gv.n_interfaces].name = os_strdup (if_name); gv.n_interfaces++; } - nn_log (LC_CONFIG, "\n"); + DDS_LOG(DDS_LC_CONFIG, "\n"); os_freeifaddrs (ifa_root); if (requested_address == NULL) @@ -605,7 +605,7 @@ int find_own_ip (const char *requested_address) p = 0; for (i = 0; i < maxq_count && (size_t) p < maxq_strlen; i++) p += snprintf (names + p, maxq_strlen - (size_t) p, ", %s", gv.interfaces[maxq_list[i]].name); - NN_WARNING ("using network interface %s (%s) selected arbitrarily from: %s\n", + DDS_WARNING("using network interface %s (%s) selected arbitrarily from: %s\n", gv.interfaces[idx].name, addrbuf, names + 2); os_free (names); } @@ -613,7 +613,7 @@ int find_own_ip (const char *requested_address) if (maxq_count > 0) selected_idx = maxq_list[0]; else - NN_ERROR ("failed to determine default own IP address\n"); + DDS_ERROR("failed to determine default own IP address\n"); } else { @@ -660,7 +660,7 @@ int find_own_ip (const char *requested_address) if (i < gv.n_interfaces) selected_idx = i; else - NN_ERROR ("%s: does not match an available interface\n", config.networkAddressString); + DDS_ERROR("%s: does not match an available interface\n", config.networkAddressString); } if (selected_idx < 0) @@ -682,7 +682,7 @@ int find_own_ip (const char *requested_address) gv.ipv6_link_local = 0; } #endif - nn_log (LC_CONFIG, "selected interface: %s (index %u)\n", + DDS_LOG(DDS_LC_CONFIG, "selected interface: %s (index %u)\n", gv.interfaces[selected_idx].name, gv.interfaceNo); return 1; diff --git a/src/core/ddsi/src/q_pcap.c b/src/core/ddsi/src/q_pcap.c index 4aa9f03..5ca71c2 100644 --- a/src/core/ddsi/src/q_pcap.c +++ b/src/core/ddsi/src/q_pcap.c @@ -86,7 +86,7 @@ FILE *new_pcap_file (const char *name) if ((fp = fopen (name, "wb")) == NULL) { - NN_WARNING ("packet capture disabled: file %s could not be opened for writing\n", name); + DDS_WARNING ("packet capture disabled: file %s could not be opened for writing\n", name); return NULL; } diff --git a/src/core/ddsi/src/q_plist.c b/src/core/ddsi/src/q_plist.c index 2623754..9863a16 100644 --- a/src/core/ddsi/src/q_plist.c +++ b/src/core/ddsi/src/q_plist.c @@ -74,21 +74,7 @@ struct cdroctetseq { unsigned char value[1]; }; -/* Avoiding all nn_log-related activities when LC_PLIST is not set - (and it hardly ever is, as it is not even included in "trace") - saves a couple of % CPU on a high-rate subscriber - that's worth - it. So we need a macro & a support function. */ -static int trace_plist (const char *fmt, ...) -{ - va_list ap; - va_start (ap, fmt); - nn_vlog (LC_PLIST, fmt, ap); - va_end (ap); - return 0; -} -#define TRACE_PLIST(args) ((config.enabled_logcats & LC_PLIST) ? (trace_plist args) : 0) - -static void log_octetseq (logcat_t cat, unsigned n, const unsigned char *xs); +static void log_octetseq (uint32_t cat, unsigned n, const unsigned char *xs); static size_t align4u (size_t x) { @@ -106,18 +92,18 @@ static int validate_string (const struct dd *dd, size_t *len) const struct cdrstring *x = (const struct cdrstring *) dd->buf; if (dd->bufsz < sizeof (struct cdrstring)) { - TRACE (("plist/validate_string: buffer too small (header)\n")); + DDS_TRACE("plist/validate_string: buffer too small (header)\n"); return ERR_INVALID; } *len = dd->bswap ? bswap4u (x->length) : x->length; if (*len < 1 || *len > dd->bufsz - offsetof (struct cdrstring, contents)) { - TRACE (("plist/validate_string: length %" PRIuSIZE " out of range\n", *len)); + DDS_TRACE("plist/validate_string: length %" PRIuSIZE " out of range\n", *len); return ERR_INVALID; } if (x->contents[*len-1] != 0) { - TRACE (("plist/validate_string: terminator missing\n")); + DDS_TRACE("plist/validate_string: terminator missing\n"); return ERR_INVALID; } return 0; @@ -207,7 +193,7 @@ static int validate_stringseq (const struct dd *dd) int i, n; if (dd->bufsz < sizeof (int)) { - TRACE (("plist/validate_stringseq: buffer too small (header)\n")); + DDS_TRACE("plist/validate_stringseq: buffer too small (header)\n"); return ERR_INVALID; } memcpy (&n, seq, sizeof (n)); @@ -216,7 +202,7 @@ static int validate_stringseq (const struct dd *dd) seq += sizeof (int); if (n < 0) { - TRACE (("plist/validate_stringseq: length %d out of range\n", n)); + DDS_TRACE("plist/validate_stringseq: length %d out of range\n", n); return ERR_INVALID; } else if (n == 0) @@ -233,14 +219,14 @@ static int validate_stringseq (const struct dd *dd) dd1.bufsz = (size_t) (seqend - seq); if ((rc = validate_string (&dd1, &len1)) < 0) { - TRACE (("plist/validate_stringseq: invalid string\n")); + DDS_TRACE("plist/validate_stringseq: invalid string\n"); return rc; } seq += sizeof (uint32_t) + align4u (len1); } if (i < n) { - TRACE (("plist/validate_stringseq: buffer too small (contents)\n")); + DDS_TRACE("plist/validate_stringseq: buffer too small (contents)\n"); return ERR_INVALID; } } @@ -262,7 +248,7 @@ static int alias_stringseq (nn_stringseq_t *strseq, const struct dd *dd) int result; if (dd->bufsz < sizeof (int)) { - TRACE (("plist/alias_stringseq: buffer too small (header)\n")); + DDS_TRACE("plist/alias_stringseq: buffer too small (header)\n"); return ERR_INVALID; } memcpy (&strseq->n, seq, sizeof (strseq->n)); @@ -271,7 +257,7 @@ static int alias_stringseq (nn_stringseq_t *strseq, const struct dd *dd) seq += sizeof (uint32_t); if (strseq->n >= UINT_MAX / sizeof(*strs)) { - TRACE (("plist/alias_stringseq: length %u out of range\n", strseq->n)); + DDS_TRACE("plist/alias_stringseq: length %u out of range\n", strseq->n); return ERR_INVALID; } else if (strseq->n == 0) @@ -291,14 +277,14 @@ static int alias_stringseq (nn_stringseq_t *strseq, const struct dd *dd) and a non-const version of it. */ if ((result = alias_string ((const unsigned char **) &strs[i], &dd1, &len1)) < 0) { - TRACE (("plist/alias_stringseq: invalid string\n")); + DDS_TRACE("plist/alias_stringseq: invalid string\n"); goto fail; } seq += sizeof (uint32_t) + align4u (len1); } if (i != strseq->n) { - TRACE (("plist/validate_stringseq: buffer too small (contents)\n")); + DDS_TRACE("plist/validate_stringseq: buffer too small (contents)\n"); result = ERR_INVALID; goto fail; } @@ -371,7 +357,7 @@ static int validate_property (_In_ const struct dd *dd, _Out_ size_t *len) rc = validate_string(dd, &lenN); if (rc != 0) { - TRACE (("plist/validate_property: name validation failed\n")); + DDS_TRACE("plist/validate_property: name validation failed\n"); return rc; } lenN = sizeof(uint32_t) + /* cdr string len arg + */ @@ -384,7 +370,7 @@ static int validate_property (_In_ const struct dd *dd, _Out_ size_t *len) rc = validate_string(&ddV, &lenV); if (rc != 0) { - TRACE (("plist/validate_property: value validation failed\n")); + DDS_TRACE("plist/validate_property: value validation failed\n"); return rc; } lenV = sizeof(uint32_t) + /* cdr string len arg + */ @@ -407,7 +393,7 @@ static int alias_property (_Out_ nn_property_t *prop, _In_ const struct dd *dd, rc = alias_string((const unsigned char **)&(prop->name), dd, &lenN); if (rc != 0) { - TRACE (("plist/alias_property: invalid name buffer\n")); + DDS_TRACE("plist/alias_property: invalid name buffer\n"); return rc; } lenN = sizeof(uint32_t) + /* cdr string len arg + */ @@ -419,7 +405,7 @@ static int alias_property (_Out_ nn_property_t *prop, _In_ const struct dd *dd, rc = alias_string((const unsigned char **)&(prop->value), &ddV, &lenV); if (rc != 0) { - TRACE (("plist/validate_property: invalid value buffer\n")); + DDS_TRACE("plist/validate_property: invalid value buffer\n"); return rc; } lenV = sizeof(uint32_t) + /* cdr string len arg + */ @@ -463,7 +449,7 @@ static int validate_propertyseq (_In_ const struct dd *dd, _Out_ size_t *len) int i, n; if (dd->bufsz < sizeof (int)) { - TRACE (("plist/validate_propertyseq: buffer too small (header)\n")); + DDS_TRACE("plist/validate_propertyseq: buffer too small (header)\n"); return ERR_INVALID; } memcpy (&n, seq, sizeof (n)); @@ -472,7 +458,7 @@ static int validate_propertyseq (_In_ const struct dd *dd, _Out_ size_t *len) seq += sizeof (int); if (n < 0) { - TRACE (("plist/validate_propertyseq: length %d out of range\n", n)); + DDS_TRACE("plist/validate_propertyseq: length %d out of range\n", n); return ERR_INVALID; } else if (n == 0) @@ -489,14 +475,14 @@ static int validate_propertyseq (_In_ const struct dd *dd, _Out_ size_t *len) dd1.bufsz = (size_t) (seqend - seq); if ((rc = validate_property (&dd1, &len1)) != 0) { - TRACE (("plist/validate_propertyseq: invalid property\n")); + DDS_TRACE("plist/validate_propertyseq: invalid property\n"); return rc; } seq += len1; } if (i < n) { - TRACE (("plist/validate_propertyseq: buffer too small (contents)\n")); + DDS_TRACE("plist/validate_propertyseq: buffer too small (contents)\n"); return ERR_INVALID; } } @@ -517,7 +503,7 @@ static int alias_propertyseq (_Out_ nn_propertyseq_t *pseq, _In_ const struct dd int result; if (dd->bufsz < sizeof (int)) { - TRACE (("plist/alias_propertyseq: buffer too small (header)\n")); + DDS_TRACE("plist/alias_propertyseq: buffer too small (header)\n"); return ERR_INVALID; } @@ -527,7 +513,7 @@ static int alias_propertyseq (_Out_ nn_propertyseq_t *pseq, _In_ const struct dd seq += sizeof (uint32_t); if (pseq->n >= UINT_MAX / sizeof(*props)) { - TRACE (("plist/alias_propertyseq: length %u out of range\n", pseq->n)); + DDS_TRACE("plist/alias_propertyseq: length %u out of range\n", pseq->n); return ERR_INVALID; } else if (pseq->n == 0) @@ -544,14 +530,14 @@ static int alias_propertyseq (_Out_ nn_propertyseq_t *pseq, _In_ const struct dd dd1.bufsz = (size_t) (seqend - seq); if ((result = alias_property (&props[i], &dd1, &len1)) != 0) { - TRACE (("plist/alias_propertyseq: invalid property\n")); + DDS_TRACE("plist/alias_propertyseq: invalid property\n"); goto fail; } seq += len1; } if (i != pseq->n) { - TRACE (("plist/alias_propertyseq: buffer too small (contents)\n")); + DDS_TRACE("plist/alias_propertyseq: buffer too small (contents)\n"); result = ERR_INVALID; goto fail; } @@ -621,7 +607,7 @@ static int validate_binaryproperty (_In_ const struct dd *dd, _Out_ size_t *len) rc = validate_string(dd, &lenN); if (rc != 0) { - TRACE (("plist/validate_property: name validation failed\n")); + DDS_TRACE("plist/validate_property: name validation failed\n"); return rc; } lenN = sizeof(uint32_t) + /* cdr string len arg + */ @@ -633,7 +619,7 @@ static int validate_binaryproperty (_In_ const struct dd *dd, _Out_ size_t *len) rc = validate_octetseq(&ddV, &lenV); if (rc != 0) { - TRACE (("plist/validate_property: value validation failed\n")); + DDS_TRACE("plist/validate_property: value validation failed\n"); return rc; } lenV = sizeof(uint32_t) + /* cdr sequence len arg + */ @@ -656,7 +642,7 @@ static int alias_binaryproperty (_Out_ nn_binaryproperty_t *prop, _In_ const str rc = alias_string((const unsigned char **)&(prop->name), dd, &lenN); if (rc != 0) { - TRACE (("plist/alias_property: invalid name buffer\n")); + DDS_TRACE("plist/alias_property: invalid name buffer\n"); return rc; } lenN = sizeof(uint32_t) + /* cdr string len arg + */ @@ -668,7 +654,7 @@ static int alias_binaryproperty (_Out_ nn_binaryproperty_t *prop, _In_ const str rc = alias_octetseq(&(prop->value), &ddV); if (rc != 0) { - TRACE (("plist/validate_property: invalid value buffer\n")); + DDS_TRACE("plist/validate_property: invalid value buffer\n"); return rc; } lenV = sizeof(uint32_t) + /* cdr sequence len arg + */ @@ -713,7 +699,7 @@ static int validate_binarypropertyseq (_In_ const struct dd *dd, _Out_ size_t *l int i, n; if (dd->bufsz < sizeof (int)) { - TRACE (("plist/validate_binarypropertyseq: buffer too small (header)\n")); + DDS_TRACE("plist/validate_binarypropertyseq: buffer too small (header)\n"); return ERR_INVALID; } memcpy (&n, seq, sizeof (n)); @@ -722,7 +708,7 @@ static int validate_binarypropertyseq (_In_ const struct dd *dd, _Out_ size_t *l seq += sizeof (int); if (n < 0) { - TRACE (("plist/validate_binarypropertyseq: length %d out of range\n", n)); + DDS_TRACE("plist/validate_binarypropertyseq: length %d out of range\n", n); return ERR_INVALID; } else if (n == 0) @@ -739,14 +725,14 @@ static int validate_binarypropertyseq (_In_ const struct dd *dd, _Out_ size_t *l dd1.bufsz = (size_t) (seqend - seq); if ((rc = validate_binaryproperty (&dd1, &len1)) != 0) { - TRACE (("plist/validate_binarypropertyseq: invalid property\n")); + DDS_TRACE("plist/validate_binarypropertyseq: invalid property\n"); return rc; } seq += len1; } if (i < n) { - TRACE (("plist/validate_binarypropertyseq: buffer too small (contents)\n")); + DDS_TRACE("plist/validate_binarypropertyseq: buffer too small (contents)\n"); return ERR_INVALID; } } @@ -767,7 +753,7 @@ static int alias_binarypropertyseq (_Out_ nn_binarypropertyseq_t *pseq, _In_ con int result; if (dd->bufsz < sizeof (int)) { - TRACE (("plist/alias_binarypropertyseq: buffer too small (header)\n")); + DDS_TRACE("plist/alias_binarypropertyseq: buffer too small (header)\n"); return ERR_INVALID; } @@ -777,7 +763,7 @@ static int alias_binarypropertyseq (_Out_ nn_binarypropertyseq_t *pseq, _In_ con seq += sizeof (uint32_t); if (pseq->n >= UINT_MAX / sizeof(*props)) { - TRACE (("plist/alias_binarypropertyseq: length %u out of range\n", pseq->n)); + DDS_TRACE("plist/alias_binarypropertyseq: length %u out of range\n", pseq->n); return ERR_INVALID; } else if (pseq->n == 0) @@ -794,14 +780,14 @@ static int alias_binarypropertyseq (_Out_ nn_binarypropertyseq_t *pseq, _In_ con dd1.bufsz = (size_t) (seqend - seq); if ((result = alias_binaryproperty (&props[i], &dd1, &len1)) != 0) { - TRACE (("plist/alias_binarypropertyseq: invalid property\n")); + DDS_TRACE("plist/alias_binarypropertyseq: invalid property\n"); goto fail; } seq += len1; } if (i != pseq->n) { - TRACE (("plist/alias_binarypropertyseq: buffer too small (contents)\n")); + DDS_TRACE("plist/alias_binarypropertyseq: buffer too small (contents)\n"); result = ERR_INVALID; goto fail; } @@ -1081,7 +1067,7 @@ static int validate_time (const nn_ddsi_time_t *t) return 0; else { - TRACE (("plist/validate_time: invalid timestamp (%08x.%08x)\n", t->seconds, t->fraction)); + DDS_TRACE("plist/validate_time: invalid timestamp (%08x.%08x)\n", t->seconds, t->fraction); return ERR_INVALID; } } @@ -1108,7 +1094,7 @@ int validate_duration (const nn_duration_t *d) return 0; else { - TRACE (("plist/validate_time: invalid duration (%08x.%08x)\n", d->sec, d->nanosec)); + DDS_TRACE("plist/validate_time: invalid duration (%08x.%08x)\n", d->sec, d->nanosec); return ERR_INVALID; } } @@ -1129,7 +1115,7 @@ static int do_duration (nn_duration_t *q, uint64_t *present, uint64_t fl, const int res; if (dd->bufsz < sizeof (*q)) { - TRACE (("plist/do_duration: buffer too small\n")); + DDS_TRACE("plist/do_duration: buffer too small\n"); return ERR_INVALID; } memcpy (q, dd->buf, sizeof (*q)); @@ -1156,7 +1142,7 @@ int validate_durability_qospolicy (const nn_durability_qospolicy_t *q) case NN_PERSISTENT_DURABILITY_QOS: break; default: - TRACE (("plist/validate_durability_qospolicy: invalid kind (%d)\n", (int) q->kind)); + DDS_TRACE("plist/validate_durability_qospolicy: invalid kind (%d)\n", (int) q->kind); return ERR_INVALID; } return 0; @@ -1183,7 +1169,7 @@ int validate_history_qospolicy (const nn_history_qospolicy_t *q) case NN_KEEP_ALL_HISTORY_QOS: break; default: - TRACE (("plist/validate_history_qospolicy: invalid kind (%d)\n", (int) q->kind)); + DDS_TRACE("plist/validate_history_qospolicy: invalid kind (%d)\n", (int) q->kind); return ERR_INVALID; } /* Accept all values for depth if kind = ALL */ @@ -1191,7 +1177,7 @@ int validate_history_qospolicy (const nn_history_qospolicy_t *q) { if (q->depth < 1) { - TRACE (("plist/validate_history_qospolicy: invalid depth (%d)\n", (int) q->depth)); + DDS_TRACE("plist/validate_history_qospolicy: invalid depth (%d)\n", (int) q->depth); return ERR_INVALID; } } @@ -1213,17 +1199,17 @@ int validate_resource_limits_qospolicy (const nn_resource_limits_qospolicy_t *q) consistency of the resource limits. */ if (q->max_samples < 1 && q->max_samples != unlimited) { - TRACE (("plist/validate_resource_limits_qospolicy: max_samples invalid (%d)\n", (int) q->max_samples)); + DDS_TRACE("plist/validate_resource_limits_qospolicy: max_samples invalid (%d)\n", (int) q->max_samples); return ERR_INVALID; } if (q->max_instances < 1 && q->max_instances != unlimited) { - TRACE (("plist/validate_resource_limits_qospolicy: max_instances invalid (%d)\n", (int) q->max_instances)); + DDS_TRACE("plist/validate_resource_limits_qospolicy: max_instances invalid (%d)\n", (int) q->max_instances); return ERR_INVALID; } if (q->max_samples_per_instance < 1 && q->max_samples_per_instance != unlimited) { - TRACE (("plist/validate_resource_limits_qospolicy: max_samples_per_instance invalid (%d)\n", (int) q->max_samples_per_instance)); + DDS_TRACE("plist/validate_resource_limits_qospolicy: max_samples_per_instance invalid (%d)\n", (int) q->max_samples_per_instance); return ERR_INVALID; } if (q->max_samples != unlimited && q->max_samples_per_instance != unlimited) @@ -1232,7 +1218,7 @@ int validate_resource_limits_qospolicy (const nn_resource_limits_qospolicy_t *q) care" and any conditions related to it must be ignored. */ if (q->max_samples < q->max_samples_per_instance) { - TRACE (("plist/validate_resource_limits_qospolicy: max_samples (%d) and max_samples_per_instance (%d) incompatible\n", (int) q->max_samples, (int) q->max_samples_per_instance)); + DDS_TRACE("plist/validate_resource_limits_qospolicy: max_samples (%d) and max_samples_per_instance (%d) incompatible\n", (int) q->max_samples, (int) q->max_samples_per_instance); return ERR_INVALID; } } @@ -1245,12 +1231,12 @@ int validate_history_and_resource_limits (const nn_history_qospolicy_t *qh, cons int res; if ((res = validate_history_qospolicy (qh)) < 0) { - TRACE (("plist/validate_history_and_resource_limits: history policy invalid\n")); + DDS_TRACE("plist/validate_history_and_resource_limits: history policy invalid\n"); return res; } if ((res = validate_resource_limits_qospolicy (qr)) < 0) { - TRACE (("plist/validate_history_and_resource_limits: resource_limits policy invalid\n")); + DDS_TRACE("plist/validate_history_and_resource_limits: resource_limits policy invalid\n"); return res; } switch (qh->kind) @@ -1259,7 +1245,7 @@ int validate_history_and_resource_limits (const nn_history_qospolicy_t *qh, cons #if 0 /* See comment in validate_resource_limits, ref'ing 7.1.3.19 */ if (qr->max_samples_per_instance != unlimited) { - TRACE (("plist/validate_history_and_resource_limits: max_samples_per_instance (%d) incompatible with KEEP_ALL policy\n", (int) qr->max_samples_per_instance)); + DDS_TRACE("plist/validate_history_and_resource_limits: max_samples_per_instance (%d) incompatible with KEEP_ALL policy\n", (int) qr->max_samples_per_instance); return ERR_INVALID; } #endif @@ -1267,7 +1253,7 @@ int validate_history_and_resource_limits (const nn_history_qospolicy_t *qh, cons case NN_KEEP_LAST_HISTORY_QOS: if (qr->max_samples_per_instance != unlimited && qh->depth > qr->max_samples_per_instance) { - TRACE (("plist/validate_history_and_resource_limits: depth (%d) and max_samples_per_instance (%d) incompatible with KEEP_LAST policy\n", (int) qh->depth, (int) qr->max_samples_per_instance)); + DDS_TRACE("plist/validate_history_and_resource_limits: depth (%d) and max_samples_per_instance (%d) incompatible with KEEP_LAST policy\n", (int) qh->depth, (int) qr->max_samples_per_instance); return ERR_INVALID; } break; @@ -1287,12 +1273,12 @@ int validate_durability_service_qospolicy (const nn_durability_service_qospolicy int res; if ((res = validate_duration (&q->service_cleanup_delay)) < 0) { - TRACE (("plist/validate_durability_service_qospolicy: duration invalid\n")); + DDS_TRACE("plist/validate_durability_service_qospolicy: duration invalid\n"); return res; } if ((res = validate_history_and_resource_limits (&q->history, &q->resource_limits)) < 0) { - TRACE (("plist/validate_durability_service_qospolicy: invalid history and/or resource limits\n")); + DDS_TRACE("plist/validate_durability_service_qospolicy: invalid history and/or resource limits\n"); return res; } return 0; @@ -1313,10 +1299,10 @@ int validate_liveliness_qospolicy (const nn_liveliness_qospolicy_t *q) case NN_MANUAL_BY_PARTICIPANT_LIVELINESS_QOS: case NN_MANUAL_BY_TOPIC_LIVELINESS_QOS: if ((res = validate_duration (&q->lease_duration)) < 0) - TRACE (("plist/validate_liveliness_qospolicy: invalid lease duration\n")); + DDS_TRACE("plist/validate_liveliness_qospolicy: invalid lease duration\n"); return res; default: - TRACE (("plist/validate_liveliness_qospolicy: invalid kind (%d)\n", (int) q->kind)); + DDS_TRACE("plist/validate_liveliness_qospolicy: invalid kind (%d)\n", (int) q->kind); return ERR_INVALID; } } @@ -1341,10 +1327,10 @@ static int validate_xform_reliability_qospolicy (nn_reliability_qospolicy_t *qds case NN_PEDANTIC_RELIABLE_RELIABILITY_QOS: qdst->kind = NN_RELIABLE_RELIABILITY_QOS; if ((res = validate_duration (&qdst->max_blocking_time)) < 0) - TRACE (("plist/validate_xform_reliability_qospolicy[pedantic]: max_blocking_time invalid\n")); + DDS_TRACE("plist/validate_xform_reliability_qospolicy[pedantic]: max_blocking_time invalid\n"); return res; default: - TRACE (("plist/validate_xform_reliability_qospolicy[pedantic]: invalid kind (%d)\n", (int) qext->kind)); + DDS_TRACE("plist/validate_xform_reliability_qospolicy[pedantic]: invalid kind (%d)\n", (int) qext->kind); return ERR_INVALID; } } @@ -1358,10 +1344,10 @@ static int validate_xform_reliability_qospolicy (nn_reliability_qospolicy_t *qds case NN_INTEROP_RELIABLE_RELIABILITY_QOS: qdst->kind = NN_RELIABLE_RELIABILITY_QOS; if ((res = validate_duration (&qdst->max_blocking_time)) < 0) - TRACE (("plist/validate_xform_reliability_qospolicy[!pedantic]: max_blocking time invalid\n")); + DDS_TRACE("plist/validate_xform_reliability_qospolicy[!pedantic]: max_blocking time invalid\n"); return res; default: - TRACE (("plist/validate_xform_reliability_qospolicy[!pedantic]: invalid kind (%d)\n", (int) qext->kind)); + DDS_TRACE("plist/validate_xform_reliability_qospolicy[!pedantic]: invalid kind (%d)\n", (int) qext->kind); return ERR_INVALID; } } @@ -1380,7 +1366,7 @@ int validate_destination_order_qospolicy (const nn_destination_order_qospolicy_t case NN_BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS: return 0; default: - TRACE (("plist/validate_destination_order_qospolicy: invalid kind (%d)\n", (int) q->kind)); + DDS_TRACE("plist/validate_destination_order_qospolicy: invalid kind (%d)\n", (int) q->kind); return ERR_INVALID; } } @@ -1398,7 +1384,7 @@ int validate_ownership_qospolicy (const nn_ownership_qospolicy_t *q) case NN_EXCLUSIVE_OWNERSHIP_QOS: return 0; default: - TRACE (("plist/validate_ownership_qospolicy: invalid kind (%d)\n", (int) q->kind)); + DDS_TRACE("plist/validate_ownership_qospolicy: invalid kind (%d)\n", (int) q->kind); return ERR_INVALID; } } @@ -1427,18 +1413,18 @@ int validate_presentation_qospolicy (const nn_presentation_qospolicy_t *q) case NN_GROUP_PRESENTATION_QOS: break; default: - TRACE (("plist/validate_presentation_qospolicy: invalid access_scope (%d)\n", (int) q->access_scope)); + DDS_TRACE("plist/validate_presentation_qospolicy: invalid access_scope (%d)\n", (int) q->access_scope); return ERR_INVALID; } /* Bools must be 0 or 1, i.e., only the lsb may be set */ if (q->coherent_access & ~1) { - TRACE (("plist/validate_presentation_qospolicy: coherent_access invalid (%d)\n", (int) q->coherent_access)); + DDS_TRACE("plist/validate_presentation_qospolicy: coherent_access invalid (%d)\n", (int) q->coherent_access); return ERR_INVALID; } if (q->ordered_access & ~1) { - TRACE (("plist/validate_presentation_qospolicy: ordered_access invalid (%d)\n", (int) q->ordered_access)); + DDS_TRACE("plist/validate_presentation_qospolicy: ordered_access invalid (%d)\n", (int) q->ordered_access); return ERR_INVALID; } /* coherent_access & ordered_access are a bit irrelevant for @@ -1514,7 +1500,7 @@ static int do_locator if (dd->bufsz < sizeof (loc)) { - TRACE (("plist/do_locator: buffer too small\n")); + DDS_TRACE("plist/do_locator: buffer too small\n"); return ERR_INVALID; } memcpy (&loc, dd->buf, sizeof (loc)); @@ -1529,12 +1515,12 @@ static int do_locator case NN_LOCATOR_KIND_TCPv4: if (loc.port <= 0 || loc.port > 65535) { - TRACE (("plist/do_locator[kind=IPv4]: invalid port (%d)\n", (int) loc.port)); + DDS_TRACE("plist/do_locator[kind=IPv4]: invalid port (%d)\n", (int) loc.port); return ERR_INVALID; } if (!locator_address_prefix12_zero (&loc)) { - TRACE (("plist/do_locator[kind=IPv4]: junk in address prefix\n")); + DDS_TRACE("plist/do_locator[kind=IPv4]: junk in address prefix\n"); return ERR_INVALID; } break; @@ -1542,7 +1528,7 @@ static int do_locator case NN_LOCATOR_KIND_TCPv6: if (loc.port <= 0 || loc.port > 65535) { - TRACE (("plist/do_locator[kind=IPv6]: invalid port (%d)\n", (int) loc.port)); + DDS_TRACE("plist/do_locator[kind=IPv6]: invalid port (%d)\n", (int) loc.port); return ERR_INVALID; } break; @@ -1552,12 +1538,12 @@ static int do_locator return 0; if (loc.port <= 0 || loc.port > 65536) { - TRACE (("plist/do_locator[kind=IPv4MCGEN]: invalid port (%d)\n", (int) loc.port)); + DDS_TRACE("plist/do_locator[kind=IPv4MCGEN]: invalid port (%d)\n", (int) loc.port); return ERR_INVALID; } if ((int)x->base + x->count >= 28 || x->count == 0 || x->idx >= x->count) { - TRACE (("plist/do_locator[kind=IPv4MCGEN]: invalid base/count/idx (%u,%u,%u)\n", x->base, x->count, x->idx)); + DDS_TRACE("plist/do_locator[kind=IPv4MCGEN]: invalid base/count/idx (%u,%u,%u)\n", x->base, x->count, x->idx); return ERR_INVALID; } break; @@ -1565,12 +1551,12 @@ static int do_locator case NN_LOCATOR_KIND_INVALID: if (!locator_address_zero (&loc)) { - TRACE (("plist/do_locator[kind=INVALID]: junk in address\n")); + DDS_TRACE("plist/do_locator[kind=INVALID]: junk in address\n"); return ERR_INVALID; } if (loc.port != 0) { - TRACE (("plist/do_locator[kind=INVALID]: junk in port\n")); + DDS_TRACE("plist/do_locator[kind=INVALID]: junk in port\n"); return ERR_INVALID; } /* silently dropped correctly formatted "invalid" locators. */ @@ -1579,7 +1565,7 @@ static int do_locator /* silently dropped "reserved" locators. */ return 0; default: - TRACE (("plist/do_locator: invalid kind (%d)\n", (int) loc.kind)); + DDS_TRACE("plist/do_locator: invalid kind (%d)\n", (int) loc.kind); return NN_PEDANTIC_P ? ERR_INVALID : 0; } return add_locator (ls, present, wanted, fl, &loc); @@ -1602,7 +1588,7 @@ static int do_ipv4address (nn_plist_t *dest, nn_ipaddress_params_tmp_t *dest_tmp uint64_t fldest; if (dd->bufsz < sizeof (*a)) { - TRACE (("plist/do_ipv4address: buffer too small\n")); + DDS_TRACE("plist/do_ipv4address: buffer too small\n"); return ERR_INVALID; } switch (fl_tmp) @@ -1672,7 +1658,7 @@ static int do_port (nn_plist_t *dest, nn_ipaddress_params_tmp_t *dest_tmp, uint6 unsigned fl1_tmp; if (dd->bufsz < sizeof (*p)) { - TRACE (("plist/do_port: buffer too small\n")); + DDS_TRACE("plist/do_port: buffer too small\n"); return ERR_INVALID; } switch (fl_tmp) @@ -1706,7 +1692,7 @@ static int do_port (nn_plist_t *dest, nn_ipaddress_params_tmp_t *dest_tmp, uint6 *p = bswap4u (*p); if (*p <= 0 || *p > 65535) { - TRACE (("plist/do_port: invalid port (%d)\n", (int) *p)); + DDS_TRACE("plist/do_port: invalid port (%d)\n", (int) *p); return ERR_INVALID; } dest_tmp->present |= fl_tmp; @@ -1735,7 +1721,7 @@ static int valid_participant_guid (const nn_guid_t *g, UNUSED_ARG (const struct return 0; else { - TRACE (("plist/valid_participant_guid: prefix is 0 but entityid is not (%u)\n", g->entityid.u)); + DDS_TRACE("plist/valid_participant_guid: prefix is 0 but entityid is not (%u)\n", g->entityid.u); return ERR_INVALID; } } @@ -1745,7 +1731,7 @@ static int valid_participant_guid (const nn_guid_t *g, UNUSED_ARG (const struct } else { - TRACE (("plist/valid_participant_guid: entityid not a participant entityid (%u)\n", g->entityid.u)); + DDS_TRACE("plist/valid_participant_guid: entityid not a participant entityid (%u)\n", g->entityid.u); return ERR_INVALID; } } @@ -1759,7 +1745,7 @@ static int valid_group_guid (const nn_guid_t *g, UNUSED_ARG (const struct dd *dd return 0; else { - TRACE (("plist/valid_group_guid: prefix is 0 but entityid is not (%u)\n", g->entityid.u)); + DDS_TRACE("plist/valid_group_guid: prefix is 0 but entityid is not (%u)\n", g->entityid.u); return ERR_INVALID; } } @@ -1770,7 +1756,7 @@ static int valid_group_guid (const nn_guid_t *g, UNUSED_ARG (const struct dd *dd } else { - TRACE (("plist/valid_group_guid: entityid is 0\n")); + DDS_TRACE("plist/valid_group_guid: entityid is 0\n"); return ERR_INVALID; } } @@ -1784,7 +1770,7 @@ static int valid_endpoint_guid (const nn_guid_t *g, const struct dd *dd) return 0; else { - TRACE (("plist/valid_endpoint_guid: prefix is 0 but entityid is not (%x)\n", g->entityid.u)); + DDS_TRACE("plist/valid_endpoint_guid: prefix is 0 but entityid is not (%x)\n", g->entityid.u); return ERR_INVALID; } } @@ -1803,9 +1789,9 @@ static int valid_endpoint_guid (const nn_guid_t *g, const struct dd *dd) return 0; else { - TRACE (("plist/valid_endpoint_guid[src=USER,proto=%u.%u]: invalid kind (%x)\n", + DDS_TRACE("plist/valid_endpoint_guid[src=USER,proto=%u.%u]: invalid kind (%x)\n", dd->protocol_version.major, dd->protocol_version.minor, - g->entityid.u & NN_ENTITYID_KIND_MASK)); + g->entityid.u & NN_ENTITYID_KIND_MASK); return ERR_INVALID; } } @@ -1828,8 +1814,8 @@ static int valid_endpoint_guid (const nn_guid_t *g, const struct dd *dd) return 0; else { - TRACE (("plist/valid_endpoint_guid[src=BUILTIN,proto=%u.%u]: invalid entityid (%x)\n", - dd->protocol_version.major, dd->protocol_version.minor, g->entityid.u)); + DDS_TRACE("plist/valid_endpoint_guid[src=BUILTIN,proto=%u.%u]: invalid entityid (%x)\n", + dd->protocol_version.major, dd->protocol_version.minor, g->entityid.u); return ERR_INVALID; } } @@ -1855,14 +1841,14 @@ static int valid_endpoint_guid (const nn_guid_t *g, const struct dd *dd) return 0; else { - TRACE (("plist/valid_endpoint_guid[src=VENDOR,proto=%u.%u]: invalid entityid (%x)\n", - dd->protocol_version.major, dd->protocol_version.minor, g->entityid.u)); + DDS_TRACE("plist/valid_endpoint_guid[src=VENDOR,proto=%u.%u]: invalid entityid (%x)\n", + dd->protocol_version.major, dd->protocol_version.minor, g->entityid.u); return 0; } } } default: - TRACE (("plist/valid_endpoint_guid: invalid source (%x)\n", g->entityid.u)); + DDS_TRACE("plist/valid_endpoint_guid: invalid source (%x)\n", g->entityid.u); return ERR_INVALID; } } @@ -1871,7 +1857,7 @@ static int do_guid (nn_guid_t *dst, uint64_t *present, uint64_t fl, int (*valid) { if (dd->bufsz < sizeof (*dst)) { - TRACE (("plist/do_guid: buffer too small\n")); + DDS_TRACE("plist/do_guid: buffer too small\n"); return ERR_INVALID; } memcpy (dst, dd->buf, sizeof (*dst)); @@ -1881,9 +1867,9 @@ static int do_guid (nn_guid_t *dst, uint64_t *present, uint64_t fl, int (*valid) if (fl == PP_PARTICIPANT_GUID && vendor_is_twinoaks (dd->vendorid) && dst->entityid.u == 0 && ! NN_STRICT_P) { - NN_WARNING ("plist(vendor %u.%u): rewriting invalid participant guid %x:%x:%x:%x\n", - dd->vendorid.id[0], dd->vendorid.id[1], - dst->prefix.u[0], dst->prefix.u[1], dst->prefix.u[2], dst->entityid.u); + DDS_WARNING("plist(vendor %u.%u): rewriting invalid participant guid %x:%x:%x:%x\n", + dd->vendorid.id[0], dd->vendorid.id[1], + dst->prefix.u[0], dst->prefix.u[1], dst->prefix.u[2], dst->entityid.u); dst->entityid.u = NN_ENTITYID_PARTICIPANT; } else @@ -1911,7 +1897,7 @@ static int do_prismtech_participant_version_info (nn_prismtech_participant_versi return 0; else if (dd->bufsz < NN_PRISMTECH_PARTICIPANT_VERSION_INFO_FIXED_CDRSIZE) { - TRACE (("plist/do_prismtech_participant_version_info[pid=PRISMTECH_PARTICIPANT_VERSION_INFO]: buffer too small\n")); + DDS_TRACE("plist/do_prismtech_participant_version_info[pid=PRISMTECH_PARTICIPANT_VERSION_INFO]: buffer too small\n"); return ERR_INVALID; } else @@ -1946,13 +1932,13 @@ static int do_subscription_keys_qospolicy (nn_subscription_keys_qospolicy_t *q, int res; if (dd->bufsz < 4) { - TRACE (("plist/do_subscription_keys: buffer too small\n")); + DDS_TRACE("plist/do_subscription_keys: buffer too small\n"); return ERR_INVALID; } q->use_key_list = (unsigned char) dd->buf[0]; if (q->use_key_list != 0 && q->use_key_list != 1) { - TRACE (("plist/do_subscription_keys: invalid use_key_list (%d)\n", (int) q->use_key_list)); + DDS_TRACE("plist/do_subscription_keys: invalid use_key_list (%d)\n", (int) q->use_key_list); return ERR_INVALID; } dd1 = *dd; @@ -1976,7 +1962,7 @@ static int do_reader_lifespan_qospolicy (nn_reader_lifespan_qospolicy_t *q, uint int res; if (dd->bufsz < sizeof (*q)) { - TRACE (("plist/do_reader_lifespan: buffer too small\n")); + DDS_TRACE("plist/do_reader_lifespan: buffer too small\n"); return ERR_INVALID; } *q = *((nn_reader_lifespan_qospolicy_t *) dd->buf); @@ -1984,7 +1970,7 @@ static int do_reader_lifespan_qospolicy (nn_reader_lifespan_qospolicy_t *q, uint bswap_duration (&q->duration); if (q->use_lifespan != 0 && q->use_lifespan != 1) { - TRACE (("plist/do_reader_lifespan: invalid use_lifespan (%d)\n", (int) q->use_lifespan)); + DDS_TRACE("plist/do_reader_lifespan: invalid use_lifespan (%d)\n", (int) q->use_lifespan); return ERR_INVALID; } if ((res = validate_duration (&q->duration)) >= 0) @@ -1996,13 +1982,13 @@ static int do_entity_factory_qospolicy (nn_entity_factory_qospolicy_t *q, uint64 { if (dd->bufsz < sizeof (*q)) { - TRACE (("plist/do_entity_factory: buffer too small\n")); + DDS_TRACE("plist/do_entity_factory: buffer too small\n"); return ERR_INVALID; } q->autoenable_created_entities = dd->buf[0]; if (q->autoenable_created_entities != 0 && q->autoenable_created_entities != 1) { - TRACE (("plist/do_entity_factory: invalid autoenable_created_entities (%d)\n", (int) q->autoenable_created_entities)); + DDS_TRACE("plist/do_entity_factory: invalid autoenable_created_entities (%d)\n", (int) q->autoenable_created_entities); return ERR_INVALID; } *present |= fl; @@ -2014,17 +2000,17 @@ int validate_reader_data_lifecycle (const nn_reader_data_lifecycle_qospolicy_t * if (validate_duration (&q->autopurge_nowriter_samples_delay) < 0 || validate_duration (&q->autopurge_disposed_samples_delay) < 0) { - TRACE (("plist/init_one_parameter[pid=PRISMTECH_READER_DATA_LIFECYCLE]: invalid autopurge_nowriter_sample_delay or autopurge_disposed_samples_delay\n")); + DDS_TRACE("plist/init_one_parameter[pid=PRISMTECH_READER_DATA_LIFECYCLE]: invalid autopurge_nowriter_sample_delay or autopurge_disposed_samples_delay\n"); return ERR_INVALID; } if (q->autopurge_dispose_all != 0 && q->autopurge_dispose_all != 1) { - TRACE (("plist/init_one_parameter[pid=PRISMTECH_READER_DATA_LIFECYCLE]: invalid autopurge_dispose_all\n")); + DDS_TRACE("plist/init_one_parameter[pid=PRISMTECH_READER_DATA_LIFECYCLE]: invalid autopurge_dispose_all\n"); return ERR_INVALID; } if (q->enable_invalid_samples != 0 && q->enable_invalid_samples != 1) { - TRACE (("plist/init_one_parameter[pid=PRISMTECH_READER_DATA_LIFECYCLE]: invalid enable_invalid_samples\n")); + DDS_TRACE("plist/init_one_parameter[pid=PRISMTECH_READER_DATA_LIFECYCLE]: invalid enable_invalid_samples\n"); return ERR_INVALID; } /* Don't check consistency between enable_invalid_samples and invalid_samples_mode (yet) */ @@ -2035,7 +2021,7 @@ int validate_reader_data_lifecycle (const nn_reader_data_lifecycle_qospolicy_t * case NN_ALL_INVALID_SAMPLE_VISIBILITY_QOS: break; default: - TRACE (("plist/init_one_parameter[pid=PRISMTECH_READER_DATA_LIFECYCLE]: invalid invalid_sample_visibility\n")); + DDS_TRACE("plist/init_one_parameter[pid=PRISMTECH_READER_DATA_LIFECYCLE]: invalid invalid_sample_visibility\n"); return ERR_INVALID; } return 0; @@ -2096,17 +2082,17 @@ static int do_dataholder (_Out_ nn_dataholder_t *dh, _Inout_ uint64_t *present, ddtmp.bufsz = ddtmp.bufsz - len; if ((res = validate_binarypropertyseq (&ddtmp, &len)) != 0) { - TRACE (("plist/do_dataholder: invalid binary_property_seq\n")); + DDS_TRACE("plist/do_dataholder: invalid binary_property_seq\n"); } } else { - TRACE (("plist/do_dataholder: invalid property_seq\n")); + DDS_TRACE("plist/do_dataholder: invalid property_seq\n"); } } else { - TRACE (("plist/do_dataholder: invalid class_id\n")); + DDS_TRACE("plist/do_dataholder: invalid class_id\n"); } } return res; @@ -2116,7 +2102,7 @@ static int do_dataholder (_Out_ nn_dataholder_t *dh, _Inout_ uint64_t *present, res = alias_string((const unsigned char **)&(dh->class_id), dd, &len /* strlen */); if (res != 0) { - TRACE (("plist/do_dataholder: invalid class_id\n")); + DDS_TRACE("plist/do_dataholder: invalid class_id\n"); return res; } len = sizeof(uint32_t) + /* cdr string len arg + */ @@ -2128,7 +2114,7 @@ static int do_dataholder (_Out_ nn_dataholder_t *dh, _Inout_ uint64_t *present, res = alias_propertyseq(&(dh->properties), &ddtmp, &len /* complete length */); if (res != 0) { - TRACE (("plist/do_dataholder: invalid property_seq\n")); + DDS_TRACE("plist/do_dataholder: invalid property_seq\n"); return res; } @@ -2138,7 +2124,7 @@ static int do_dataholder (_Out_ nn_dataholder_t *dh, _Inout_ uint64_t *present, res = alias_binarypropertyseq(&(dh->binary_properties), &ddtmp, &len /* complete length */); if (res != 0) { - TRACE (("plist/do_dataholder: invalid binary_property_seq\n")); + DDS_TRACE("plist/do_dataholder: invalid binary_property_seq\n"); return res; } @@ -2169,7 +2155,7 @@ static int init_one_parameter #define Q(NAME_, name_) case PID_##NAME_: \ if (dd->bufsz < sizeof (nn_##name_##_qospolicy_t)) \ { \ - TRACE (("plist/init_one_parameter[pid=%s]: buffer too small\n", #NAME_)); \ + DDS_TRACE("plist/init_one_parameter[pid=%s]: buffer too small\n", #NAME_); \ return ERR_INVALID; \ } \ else \ @@ -2203,7 +2189,7 @@ static int init_one_parameter case PID_RELIABILITY: if (dd->bufsz < sizeof (nn_external_reliability_qospolicy_t)) { - TRACE (("plist/init_one_parameter[pid=RELIABILITY]: buffer too small\n")); + DDS_TRACE("plist/init_one_parameter[pid=RELIABILITY]: buffer too small\n"); return ERR_INVALID; } else @@ -2254,7 +2240,7 @@ static int init_one_parameter ret = do_reader_data_lifecycle_v0 (&dest->qos.reader_data_lifecycle, dd); else { - TRACE (("plist/init_one_parameter[pid=PRISMTECH_READER_DATA_LIFECYCLE]: buffer too small\n")); + DDS_TRACE("plist/init_one_parameter[pid=PRISMTECH_READER_DATA_LIFECYCLE]: buffer too small\n"); ret = ERR_INVALID; } if (ret >= 0) @@ -2269,7 +2255,7 @@ static int init_one_parameter nn_writer_data_lifecycle_qospolicy_t *q = &dest->qos.writer_data_lifecycle; if (dd->bufsz < 1) { - TRACE (("plist/init_one_parameter[pid=PRISMTECH_WRITER_DATA_LIFECYCLE]: buffer too small\n")); + DDS_TRACE("plist/init_one_parameter[pid=PRISMTECH_WRITER_DATA_LIFECYCLE]: buffer too small\n"); return ERR_INVALID; } else if (dd->bufsz < sizeof (*q)) @@ -2290,13 +2276,13 @@ static int init_one_parameter } if (q->autodispose_unregistered_instances & ~1) { - TRACE (("plist/init_one_parameter[pid=PRISMTECH_WRITER_DATA_LIFECYCLE]: invalid autodispose_unregistered_instances (%d)\n", (int) q->autodispose_unregistered_instances)); + DDS_TRACE("plist/init_one_parameter[pid=PRISMTECH_WRITER_DATA_LIFECYCLE]: invalid autodispose_unregistered_instances (%d)\n", (int) q->autodispose_unregistered_instances); return ERR_INVALID; } if (validate_duration (&q->autounregister_instance_delay) < 0 || validate_duration (&q->autopurge_suspended_samples_delay) < 0) { - TRACE (("plist/init_one_parameter[pid=PRISMTECH_WRITER_DATA_LIFECYCLE]: invalid autounregister_instance_delay or autopurge_suspended_samples_delay\n")); + DDS_TRACE("plist/init_one_parameter[pid=PRISMTECH_WRITER_DATA_LIFECYCLE]: invalid autounregister_instance_delay or autopurge_suspended_samples_delay\n"); return ERR_INVALID; } dest->qos.present |= QP_PRISMTECH_WRITER_DATA_LIFECYCLE; @@ -2308,7 +2294,7 @@ static int init_one_parameter return 0; else if (dd->bufsz < sizeof (dest->qos.relaxed_qos_matching)) { - TRACE (("plist/init_one_parameter[pid=PRISMTECH_RELAXED_QOS_MATCHING]: buffer too small\n")); + DDS_TRACE("plist/init_one_parameter[pid=PRISMTECH_RELAXED_QOS_MATCHING]: buffer too small\n"); return ERR_INVALID; } else @@ -2317,7 +2303,7 @@ static int init_one_parameter memcpy (rqm, dd->buf, sizeof (*rqm)); if (rqm->value != 0 && rqm->value != 1) { - TRACE (("plist/init_one_parameter[pid=PRISMTECH_RELAXED_QOS_MATCHING]: invalid\n")); + DDS_TRACE("plist/init_one_parameter[pid=PRISMTECH_RELAXED_QOS_MATCHING]: invalid\n"); return ERR_INVALID; } dest->qos.present |= QP_PRISMTECH_RELAXED_QOS_MATCHING; @@ -2329,7 +2315,7 @@ static int init_one_parameter return 0; else if (dd->bufsz < sizeof (dest->qos.synchronous_endpoint)) { - TRACE (("plist/init_one_parameter[pid=PRISMTECH_SYNCHRONOUS_ENDPOINT]: buffer too small\n")); + DDS_TRACE("plist/init_one_parameter[pid=PRISMTECH_SYNCHRONOUS_ENDPOINT]: buffer too small\n"); return ERR_INVALID; } else @@ -2338,7 +2324,7 @@ static int init_one_parameter memcpy (q, dd->buf, sizeof (*q)); if (q->value != 0 && q->value != 1) { - TRACE (("plist/init_one_parameter[pid=PRISMTECH_SYNCHRONOUS_ENDPOINT]: invalid value for synchronous flag\n")); + DDS_TRACE("plist/init_one_parameter[pid=PRISMTECH_SYNCHRONOUS_ENDPOINT]: invalid value for synchronous flag\n"); return ERR_INVALID; } dest->qos.present |= QP_PRISMTECH_SYNCHRONOUS_ENDPOINT; @@ -2349,7 +2335,7 @@ static int init_one_parameter case PID_PROTOCOL_VERSION: if (dd->bufsz < sizeof (nn_protocol_version_t)) { - TRACE (("plist/init_one_parameter[pid=PROTOCOL_VERSION]: buffer too small\n")); + DDS_TRACE("plist/init_one_parameter[pid=PROTOCOL_VERSION]: buffer too small\n"); return ERR_INVALID; } memcpy (&dest->protocol_version, dd->buf, sizeof (dest->protocol_version)); @@ -2360,9 +2346,9 @@ static int init_one_parameter /* Not accepting a submessage advertising a protocol version other than that advertised by the message header, unless I have good reason to, at least not when being strict. */ - TRACE (("plist/init_one_parameter[pid=PROTOCOL_VERSION,mode=STRICT]: version (%u.%u) mismatch with message (%u.%u)\n", + DDS_TRACE("plist/init_one_parameter[pid=PROTOCOL_VERSION,mode=STRICT]: version (%u.%u) mismatch with message (%u.%u)\n", dest->protocol_version.major, dest->protocol_version.minor, - dd->protocol_version.major, dd->protocol_version.minor)); + dd->protocol_version.major, dd->protocol_version.minor); return ERR_INVALID; } dest->present |= PP_PROTOCOL_VERSION; @@ -2377,8 +2363,8 @@ static int init_one_parameter dest->vendorid.id[1] != dd->vendorid.id[1])) { /* see PROTOCOL_VERSION */ - TRACE (("plist/init_one_parameter[pid=VENDORID,mode=STRICT]: vendor (%u.%u) mismatch with message (%u.%u)\n", - dest->vendorid.id[0], dest->vendorid.id[1], dd->vendorid.id[0], dd->vendorid.id[1])); + DDS_TRACE("plist/init_one_parameter[pid=VENDORID,mode=STRICT]: vendor (%u.%u) mismatch with message (%u.%u)\n", + dest->vendorid.id[0], dest->vendorid.id[1], dd->vendorid.id[0], dd->vendorid.id[1]); return ERR_INVALID; } dest->present |= PP_VENDORID; @@ -2422,15 +2408,15 @@ static int init_one_parameter case PID_EXPECTS_INLINE_QOS: if (dd->bufsz < sizeof (dest->expects_inline_qos)) { - TRACE (("plist/init_one_parameter[pid=EXPECTS_INLINE_QOS]: buffer too small\n")); + DDS_TRACE("plist/init_one_parameter[pid=EXPECTS_INLINE_QOS]: buffer too small\n"); return ERR_INVALID; } dest->expects_inline_qos = dd->buf[0]; /* boolean: only lsb may be set */ if (dest->expects_inline_qos & ~1) { - TRACE (("plist/init_one_parameter[pid=EXPECTS_INLINE_QOS]: invalid expects_inline_qos (%d)\n", - (int) dest->expects_inline_qos)); + DDS_TRACE("plist/init_one_parameter[pid=EXPECTS_INLINE_QOS]: invalid expects_inline_qos (%d)\n", + (int) dest->expects_inline_qos); return ERR_INVALID; } dest->present |= PP_EXPECTS_INLINE_QOS; @@ -2442,7 +2428,7 @@ static int init_one_parameter simply accept any value. */ if (dd->bufsz < sizeof (dest->participant_manual_liveliness_count)) { - TRACE (("plist/init_one_parameter[pid=PARTICIPANT_MANUAL_LIVELINESS_COUNT]: buffer too small\n")); + DDS_TRACE("plist/init_one_parameter[pid=PARTICIPANT_MANUAL_LIVELINESS_COUNT]: buffer too small\n"); return ERR_INVALID; } memcpy (&dest->participant_manual_liveliness_count, dd->buf, sizeof (dest->participant_manual_liveliness_count)); @@ -2476,7 +2462,7 @@ static int init_one_parameter case PID_BUILTIN_ENDPOINT_SET: if (dd->bufsz < sizeof (dest->builtin_endpoint_set)) { - TRACE (("plist/init_one_parameter[pid=BUILTIN_ENDPOINT_SET(%u)]: buffer too small\n", pid)); + DDS_TRACE("plist/init_one_parameter[pid=BUILTIN_ENDPOINT_SET(%u)]: buffer too small\n", pid); return ERR_INVALID; } memcpy (&dest->builtin_endpoint_set, dd->buf, sizeof (dest->builtin_endpoint_set)); @@ -2500,8 +2486,8 @@ static int init_one_parameter NN_BUILTIN_ENDPOINT_PARTICIPANT_MESSAGE_DATA_WRITER | NN_BUILTIN_ENDPOINT_PARTICIPANT_MESSAGE_DATA_READER)) != 0) { - TRACE (("plist/init_one_parameter[pid=BUILTIN_ENDPOINT_SET(%u),mode=STRICT,proto=%u.%u]: invalid set (0x%x)\n", - pid, dd->protocol_version.major, dd->protocol_version.minor, dest->builtin_endpoint_set)); + DDS_TRACE("plist/init_one_parameter[pid=BUILTIN_ENDPOINT_SET(%u),mode=STRICT,proto=%u.%u]: invalid set (0x%x)\n", + pid, dd->protocol_version.major, dd->protocol_version.minor, dest->builtin_endpoint_set); return ERR_INVALID; } dest->present |= PP_BUILTIN_ENDPOINT_SET; @@ -2512,7 +2498,7 @@ static int init_one_parameter return 0; else if (dd->bufsz < sizeof (dest->prismtech_builtin_endpoint_set)) { - TRACE (("plist/init_one_parameter[pid=PRISMTECH_BUILTIN_ENDPOINT_SET(%u)]: buffer too small\n", pid)); + DDS_TRACE("plist/init_one_parameter[pid=PRISMTECH_BUILTIN_ENDPOINT_SET(%u)]: buffer too small\n", pid); return ERR_INVALID; } else @@ -2535,7 +2521,7 @@ static int init_one_parameter case PID_KEYHASH: if (dd->bufsz < sizeof (dest->keyhash)) { - TRACE (("plist/init_one_parameter[pid=KEYHASH]: buffer too small\n")); + DDS_TRACE("plist/init_one_parameter[pid=KEYHASH]: buffer too small\n"); return ERR_INVALID; } memcpy (&dest->keyhash, dd->buf, sizeof (dest->keyhash)); @@ -2545,7 +2531,7 @@ static int init_one_parameter case PID_STATUSINFO: if (dd->bufsz < sizeof (dest->statusinfo)) { - TRACE (("plist/init_one_parameter[pid=STATUSINFO]: buffer too small\n")); + DDS_TRACE("plist/init_one_parameter[pid=STATUSINFO]: buffer too small\n"); return ERR_INVALID; } memcpy (&dest->statusinfo, dd->buf, sizeof (dest->statusinfo)); @@ -2555,8 +2541,8 @@ static int init_one_parameter { /* Spec says I may not interpret the reserved bits. But no-one may use them in this version of the specification */ - TRACE (("plist/init_one_parameter[pid=STATUSINFO,mode=STRICT,proto=%u.%u]: invalid statusinfo (0x%x)\n", - dd->protocol_version.major, dd->protocol_version.minor, dest->statusinfo)); + DDS_TRACE("plist/init_one_parameter[pid=STATUSINFO,mode=STRICT,proto=%u.%u]: invalid statusinfo (0x%x)\n", + dd->protocol_version.major, dd->protocol_version.minor, dest->statusinfo); return ERR_INVALID; } /* Clear all bits we don't understand, then add the extended bits if present */ @@ -2576,7 +2562,7 @@ static int init_one_parameter case PID_COHERENT_SET: if (dd->bufsz < sizeof (dest->coherent_set_seqno)) { - TRACE (("plist/init_one_parameter[pid=COHERENT_SET]: buffer too small\n")); + DDS_TRACE("plist/init_one_parameter[pid=COHERENT_SET]: buffer too small\n"); return ERR_INVALID; } else @@ -2592,7 +2578,7 @@ static int init_one_parameter seqno = fromSN(dest->coherent_set_seqno); if (seqno <= 0 && seqno != NN_SEQUENCE_NUMBER_UNKNOWN) { - TRACE (("plist/init_one_parameter[pid=COHERENT_SET]: invalid sequence number (%" PRId64 ")\n", seqno)); + DDS_TRACE("plist/init_one_parameter[pid=COHERENT_SET]: invalid sequence number (%" PRId64 ")\n", seqno); return ERR_INVALID; } dest->present |= PP_COHERENT_SET; @@ -2612,8 +2598,8 @@ static int init_one_parameter reject it: in (really) strict mode we do not accept undefined things, even though we are -arguably- supposed to ignore it. */ - TRACE (("plist/init_one_parameter[pid=ENDPOINT_GUID,mode=PEDANTIC,proto=%u.%u]: undefined pid\n", - dd->protocol_version.major, dd->protocol_version.minor)); + DDS_TRACE("plist/init_one_parameter[pid=ENDPOINT_GUID,mode=PEDANTIC,proto=%u.%u]: undefined pid\n", + dd->protocol_version.major, dd->protocol_version.minor); return ERR_INVALID; } return do_guid (&dest->endpoint_guid, &dest->present, PP_ENDPOINT_GUID, valid_endpoint_guid, dd); @@ -2670,7 +2656,7 @@ static int init_one_parameter return 0; if (dd->bufsz < sizeof (dest->service_type)) { - TRACE (("plist/init_one_parameter[pid=PRISMTECH_SERVICE_TYPE]: buffer too small\n")); + DDS_TRACE("plist/init_one_parameter[pid=PRISMTECH_SERVICE_TYPE]: buffer too small\n"); return ERR_INVALID; } memcpy (&dest->service_type, dd->buf, sizeof (dest->service_type)); @@ -2684,7 +2670,7 @@ static int init_one_parameter return 0; if (dd->bufsz < sizeof (dest->process_id)) { - TRACE (("plist/init_one_parameter[pid=PRISMTECH_PROCESS_ID]: buffer too small\n")); + DDS_TRACE("plist/init_one_parameter[pid=PRISMTECH_PROCESS_ID]: buffer too small\n"); return ERR_INVALID; } memcpy (&dest->process_id, dd->buf, sizeof (dest->process_id)); @@ -2703,7 +2689,7 @@ static int init_one_parameter return 0; else if (dd->bufsz < 2*sizeof (uint32_t)) { - TRACE (("plist/init_one_parameter[pid=PRISMTECH_EOTINFO]: buffer too small (1)\n")); + DDS_TRACE("plist/init_one_parameter[pid=PRISMTECH_EOTINFO]: buffer too small (1)\n"); return ERR_INVALID; } else @@ -2719,7 +2705,7 @@ static int init_one_parameter } if (q->n > (dd->bufsz - 2*sizeof (uint32_t)) / sizeof (nn_prismtech_eotgroup_tid_t)) { - TRACE (("plist/init_one_parameter[pid=PRISMTECH_EOTINFO]: buffer too small (2)\n")); + DDS_TRACE("plist/init_one_parameter[pid=PRISMTECH_EOTINFO]: buffer too small (2)\n"); return ERR_INVALID; } if (q->n == 0) @@ -2734,12 +2720,12 @@ static int init_one_parameter } dest->present |= PP_PRISMTECH_EOTINFO; dest->aliased |= PP_PRISMTECH_EOTINFO; - if (config.enabled_logcats & LC_PLIST) + if (dds_get_log_mask() & DDS_LC_PLIST) { - TRACE_PLIST (("eotinfo: txn %u {", q->transactionId)); + DDS_LOG(DDS_LC_PLIST, "eotinfo: txn %u {", q->transactionId); for (i = 0; i < q->n; i++) - TRACE_PLIST ((" %x:%u", q->tids[i].writer_entityid.u, q->tids[i].transactionId)); - TRACE_PLIST ((" }\n")); + DDS_LOG(DDS_LC_PLIST, " %x:%u", q->tids[i].writer_entityid.u, q->tids[i].transactionId); + DDS_LOG(DDS_LC_PLIST, " }\n"); } return 0; } @@ -2748,7 +2734,7 @@ static int init_one_parameter case PID_READER_FAVOURS_SSM: if (dd->bufsz < sizeof (dest->reader_favours_ssm)) { - TRACE (("plist/init_one_parameter[pid=READER_FAVOURS_SSM]: buffer too small\n")); + DDS_TRACE("plist/init_one_parameter[pid=READER_FAVOURS_SSM]: buffer too small\n"); return ERR_INVALID; } else @@ -2759,7 +2745,7 @@ static int init_one_parameter rfssm->state = bswap4u (rfssm->state); if (rfssm->state != 0 && rfssm->state != 1) { - TRACE (("plist/init_one_parameter[pid=READER_FAVOURS_SSM]: unsupported value: %u\n", rfssm->state)); + DDS_TRACE("plist/init_one_parameter[pid=READER_FAVOURS_SSM]: unsupported value: %u\n", rfssm->state); rfssm->state = 0; } dest->present |= PP_READER_FAVOURS_SSM; @@ -2799,8 +2785,8 @@ static int init_one_parameter return 0; else if (!protocol_version_is_newer (dd->protocol_version) && NN_STRICT_P) { - TRACE (("plist/init_one_parameter[pid=%u,mode=STRICT,proto=%u.%u]: undefined paramter id\n", - pid, dd->protocol_version.major, dd->protocol_version.minor)); + DDS_TRACE("plist/init_one_parameter[pid=%u,mode=STRICT,proto=%u.%u]: undefined paramter id\n", + pid, dd->protocol_version.major, dd->protocol_version.minor); return ERR_INVALID; } else @@ -2808,7 +2794,7 @@ static int init_one_parameter } assert (0); - TRACE (("plist/init_one_parameter: can't happen\n")); + DDS_TRACE("plist/init_one_parameter: can't happen\n"); return ERR_INVALID; } @@ -2985,7 +2971,7 @@ int nn_plist_init_frommsg #endif break; default: - NN_WARNING ("plist(vendor %u.%u): unknown encoding (%d)\n", + DDS_WARNING ("plist(vendor %u.%u): unknown encoding (%d)\n", src->vendorid.id[0], src->vendorid.id[1], src->encoding); return ERR_INVALID; } @@ -2993,7 +2979,7 @@ int nn_plist_init_frommsg dest->unalias_needs_bswap = dd.bswap; dest_tmp.present = 0; - TRACE_PLIST (("NN_PLIST_INIT (bswap %d)\n", dd.bswap)); + DDS_LOG(DDS_LC_PLIST, "NN_PLIST_INIT (bswap %d)\n", dd.bswap); pl = src->buf; while (pl + sizeof (nn_parameter_t) <= src->buf + src->bufsz) @@ -3011,7 +2997,7 @@ int nn_plist_init_frommsg { /* Sentinel terminates list, the length is ignored, DDSI 9.4.2.11. */ - TRACE_PLIST (("%4x PID %x\n", (unsigned) (pl - src->buf), pid)); + DDS_LOG(DDS_LC_PLIST, "%4x PID %x\n", (unsigned) (pl - src->buf), pid); if ((res = final_validation (dest)) < 0) { nn_plist_fini (dest); @@ -3027,24 +3013,24 @@ int nn_plist_init_frommsg } if (length > src->bufsz - sizeof (*par) - (unsigned) (pl - src->buf)) { - NN_WARNING ("plist(vendor %u.%u): parameter length %u out of bounds\n", - src->vendorid.id[0], src->vendorid.id[1], length); + DDS_WARNING("plist(vendor %u.%u): parameter length %u out of bounds\n", + src->vendorid.id[0], src->vendorid.id[1], length); nn_plist_fini (dest); return ERR_INVALID; } if ((length % 4) != 0) /* DDSI 9.4.2.11 */ { - NN_WARNING ("plist(vendor %u.%u): parameter length %u mod 4 != 0\n", - src->vendorid.id[0], src->vendorid.id[1], length); + DDS_WARNING("plist(vendor %u.%u): parameter length %u mod 4 != 0\n", + src->vendorid.id[0], src->vendorid.id[1], length); nn_plist_fini (dest); return ERR_INVALID; } - if (config.enabled_logcats & LC_PLIST) + if (dds_get_log_mask() & DDS_LC_PLIST) { - TRACE_PLIST (("%4x PID %x len %u ", (unsigned) (pl - src->buf), pid, length)); - log_octetseq(LC_PLIST, length, (const unsigned char *) (par + 1)); - TRACE_PLIST (("\n")); + DDS_LOG(DDS_LC_PLIST, "%4x PID %x len %u ", (unsigned) (pl - src->buf), pid, length); + log_octetseq(DDS_LC_PLIST, length, (const unsigned char *) (par + 1)); + DDS_LOG(DDS_LC_PLIST, "\n"); } dd.buf = (const unsigned char *) (par + 1); @@ -3052,7 +3038,7 @@ int nn_plist_init_frommsg if ((res = init_one_parameter (dest, &dest_tmp, pwanted, qwanted, pid, &dd)) < 0) { /* make sure we print a trace message on error */ - TRACE (("plist(vendor %u.%u): failed at pid=%u\n", src->vendorid.id[0], src->vendorid.id[1], pid)); + DDS_TRACE("plist(vendor %u.%u): failed at pid=%u\n", src->vendorid.id[0], src->vendorid.id[1], pid); nn_plist_fini (dest); return res; } @@ -3060,8 +3046,8 @@ int nn_plist_init_frommsg } /* If we get here, that means we reached the end of the message without encountering a sentinel. That is an error */ - NN_WARNING ("plist(vendor %u.%u): invalid parameter list: sentinel missing\n", - src->vendorid.id[0], src->vendorid.id[1]); + DDS_WARNING("plist(vendor %u.%u): invalid parameter list: sentinel missing\n", + src->vendorid.id[0], src->vendorid.id[1]); nn_plist_fini (dest); return ERR_INVALID; } @@ -3109,11 +3095,11 @@ unsigned char *nn_plist_quickscan (struct nn_rsample_info *dest, const struct nn #endif break; default: - NN_WARNING ("plist(vendor %u.%u): quickscan: unknown encoding (%d)\n", - src->vendorid.id[0], src->vendorid.id[1], src->encoding); + DDS_WARNING("plist(vendor %u.%u): quickscan: unknown encoding (%d)\n", + src->vendorid.id[0], src->vendorid.id[1], src->encoding); return NULL; } - TRACE_PLIST (("NN_PLIST_QUICKSCAN (bswap %d)\n", dest->bswap)); + DDS_LOG(DDS_LC_PLIST, "NN_PLIST_QUICKSCAN (bswap %d)\n", dest->bswap); pl = src->buf; while (pl + sizeof (nn_parameter_t) <= src->buf + src->bufsz) { @@ -3127,14 +3113,14 @@ unsigned char *nn_plist_quickscan (struct nn_rsample_info *dest, const struct nn return (unsigned char *) pl; if (length > src->bufsz - (size_t)(pl - src->buf)) { - NN_WARNING ("plist(vendor %u.%u): quickscan: parameter length %u out of bounds\n", + DDS_WARNING("plist(vendor %u.%u): quickscan: parameter length %u out of bounds\n", src->vendorid.id[0], src->vendorid.id[1], length); return NULL; } if ((length % 4) != 0) /* DDSI 9.4.2.11 */ { - NN_WARNING ("plist(vendor %u.%u): quickscan: parameter length %u mod 4 != 0\n", - src->vendorid.id[0], src->vendorid.id[1], length); + DDS_WARNING("plist(vendor %u.%u): quickscan: parameter length %u mod 4 != 0\n", + src->vendorid.id[0], src->vendorid.id[1], length); return NULL; } switch (pid) @@ -3144,8 +3130,8 @@ unsigned char *nn_plist_quickscan (struct nn_rsample_info *dest, const struct nn case PID_STATUSINFO: if (length < 4) { - TRACE (("plist(vendor %u.%u): quickscan(PID_STATUSINFO): buffer too small\n", - src->vendorid.id[0], src->vendorid.id[1])); + DDS_TRACE("plist(vendor %u.%u): quickscan(PID_STATUSINFO): buffer too small\n", + src->vendorid.id[0], src->vendorid.id[1]); return NULL; } else @@ -3161,7 +3147,7 @@ unsigned char *nn_plist_quickscan (struct nn_rsample_info *dest, const struct nn } break; default: - TRACE_PLIST (("(pid=%x complex_qos=1)", pid)); + DDS_LOG(DDS_LC_PLIST, "(pid=%x complex_qos=1)", pid); dest->complex_qos = 1; break; } @@ -3169,8 +3155,8 @@ unsigned char *nn_plist_quickscan (struct nn_rsample_info *dest, const struct nn } /* If we get here, that means we reached the end of the message without encountering a sentinel. That is an error */ - NN_WARNING ("plist(vendor %u.%u): quickscan: invalid parameter list: sentinel missing\n", - src->vendorid.id[0], src->vendorid.id[1]); + DDS_WARNING("plist(vendor %u.%u): quickscan: invalid parameter list: sentinel missing\n", + src->vendorid.id[0], src->vendorid.id[1]); return NULL; } @@ -3441,7 +3427,7 @@ void nn_xqos_copy (nn_xqos_t *dst, const nn_xqos_t *src) void nn_xqos_unalias (nn_xqos_t *xqos) { - TRACE_PLIST (("NN_XQOS_UNALIAS\n")); + DDS_LOG(DDS_LC_PLIST, "NN_XQOS_UNALIAS\n"); #define Q(name_, func_, field_) do { \ if ((xqos->present & QP_##name_) && (xqos->aliased & QP_##name_)) { \ unalias_##func_ (&xqos->field_, -1); \ @@ -3472,13 +3458,13 @@ void nn_xqos_fini (nn_xqos_t *xqos) { QP_RTI_TYPECODE, offsetof (nn_xqos_t, rti_typecode.value) } }; int i; - TRACE_PLIST (("NN_XQOS_FINI\n")); + DDS_LOG(DDS_LC_PLIST, "NN_XQOS_FINI\n"); for (i = 0; i < (int) (sizeof (qos_simple) / sizeof (*qos_simple)); i++) { if ((xqos->present & qos_simple[i].fl) && !(xqos->aliased & qos_simple[i].fl)) { void **pp = (void **) ((char *) xqos + qos_simple[i].off); - TRACE_PLIST (("NN_XQOS_FINI free %p\n", *pp)); + DDS_LOG(DDS_LC_PLIST, "NN_XQOS_FINI free %p\n", *pp); os_free (*pp); } } @@ -3491,7 +3477,7 @@ void nn_xqos_fini (nn_xqos_t *xqos) else { /* until proper message buffers arrive */ - TRACE_PLIST (("NN_XQOS_FINI free %p\n", xqos->partition.strs)); + DDS_LOG(DDS_LC_PLIST, "NN_XQOS_FINI free %p\n", xqos->partition.strs); os_free (xqos->partition.strs); } } @@ -3502,7 +3488,7 @@ void nn_xqos_fini (nn_xqos_t *xqos) else { /* until proper message buffers arrive */ - TRACE_PLIST (("NN_XQOS_FINI free %p\n", xqos->subscription_keys.key_list.strs)); + DDS_LOG(DDS_LC_PLIST, "NN_XQOS_FINI free %p\n", xqos->subscription_keys.key_list.strs); os_free (xqos->subscription_keys.key_list.strs); } } @@ -3962,7 +3948,7 @@ static unsigned isprint_runlen (unsigned n, const unsigned char *xs) } -static void log_octetseq (logcat_t cat, unsigned n, const unsigned char *xs) +static void log_octetseq (uint32_t cat, unsigned n, const unsigned char *xs) { unsigned i = 0; while (i < n) @@ -3970,7 +3956,7 @@ static void log_octetseq (logcat_t cat, unsigned n, const unsigned char *xs) unsigned m = isprint_runlen(n - i, xs); if (m >= 4) { - nn_log (cat, "%s\"%*.*s\"", i == 0 ? "" : ",", m, m, xs); + DDS_LOG(cat, "%s\"%*.*s\"", i == 0 ? "" : ",", m, m, xs); xs += m; i += m; } @@ -3980,23 +3966,23 @@ static void log_octetseq (logcat_t cat, unsigned n, const unsigned char *xs) m = 1; while (m--) { - nn_log (cat, "%s%u", i == 0 ? "" : ",", *xs++); + DDS_LOG(cat, "%s%u", i == 0 ? "" : ",", *xs++); i++; } } } } -void nn_log_xqos (logcat_t cat, const nn_xqos_t *xqos) +void nn_log_xqos (uint32_t cat, const nn_xqos_t *xqos) { uint64_t p = xqos->present; const char *prefix = ""; -#define LOGB0(fmt_) nn_log (cat, "%s" fmt_, prefix) -#define LOGB1(fmt_, arg0_) nn_log (cat, "%s" fmt_, prefix, arg0_) -#define LOGB2(fmt_, arg0_, arg1_) nn_log (cat, "%s" fmt_, prefix, arg0_, arg1_) -#define LOGB3(fmt_, arg0_, arg1_, arg2_) nn_log (cat, "%s" fmt_, prefix, arg0_, arg1_, arg2_) -#define LOGB4(fmt_, arg0_, arg1_, arg2_, arg3_) nn_log (cat, "%s" fmt_, prefix, arg0_, arg1_, arg2_, arg3_) -#define LOGB5(fmt_, arg0_, arg1_, arg2_, arg3_, arg4_) nn_log (cat, "%s" fmt_, prefix, arg0_, arg1_, arg2_, arg3_, arg4_) +#define LOGB0(fmt_) DDS_LOG(cat, "%s" fmt_, prefix) +#define LOGB1(fmt_, arg0_) DDS_LOG(cat, "%s" fmt_, prefix, arg0_) +#define LOGB2(fmt_, arg0_, arg1_) DDS_LOG(cat, "%s" fmt_, prefix, arg0_, arg1_) +#define LOGB3(fmt_, arg0_, arg1_, arg2_) DDS_LOG(cat, "%s" fmt_, prefix, arg0_, arg1_, arg2_) +#define LOGB4(fmt_, arg0_, arg1_, arg2_, arg3_) DDS_LOG(cat, "%s" fmt_, prefix, arg0_, arg1_, arg2_, arg3_) +#define LOGB5(fmt_, arg0_, arg1_, arg2_, arg3_, arg4_) DDS_LOG(cat, "%s" fmt_, prefix, arg0_, arg1_, arg2_, arg3_, arg4_) #define DO(name_, body_) do { if (p & QP_##name_) { { body_ } prefix = ","; } } while (0) #if DDSI_DURATION_ACCORDING_TO_SPEC @@ -4014,26 +4000,26 @@ void nn_log_xqos (logcat_t cat, const nn_xqos_t *xqos) unsigned i; LOGB0 ("partition={"); for (i = 0; i < xqos->partition.n; i++) { - nn_log (cat, "%s%s", (i == 0) ? "" : ",", xqos->partition.strs[i]); + DDS_LOG(cat, "%s%s", (i == 0) ? "" : ",", xqos->partition.strs[i]); } - nn_log (cat, "}"); + DDS_LOG(cat, "}"); }); DO (GROUP_DATA, { LOGB1 ("group_data=%u<", xqos->group_data.length); log_octetseq (cat, xqos->group_data.length, xqos->group_data.value); - nn_log (cat, ">"); + DDS_LOG(cat, ">"); }); DO (TOPIC_DATA, { LOGB1 ("topic_data=%u<", xqos->topic_data.length); log_octetseq (cat, xqos->topic_data.length, xqos->topic_data.value); - nn_log (cat, ">"); + DDS_LOG(cat, ">"); }); DO (DURABILITY, { LOGB1 ("durability=%d", xqos->durability.kind); }); DO (DURABILITY_SERVICE, { LOGB0 ("durability_service="); - nn_log (cat, FMT_DUR, PRINTARG_DUR (xqos->durability_service.service_cleanup_delay)); - nn_log (cat, ":{%d:%d}", xqos->durability_service.history.kind, xqos->durability_service.history.depth); - nn_log (cat, ":{%d:%d:%d}", xqos->durability_service.resource_limits.max_samples, xqos->durability_service.resource_limits.max_instances, xqos->durability_service.resource_limits.max_samples_per_instance); + DDS_LOG(cat, FMT_DUR, PRINTARG_DUR (xqos->durability_service.service_cleanup_delay)); + DDS_LOG(cat, ":{%d:%d}", xqos->durability_service.history.kind, xqos->durability_service.history.depth); + DDS_LOG(cat, ":{%d:%d:%d}", xqos->durability_service.resource_limits.max_samples, xqos->durability_service.resource_limits.max_instances, xqos->durability_service.resource_limits.max_samples_per_instance); }); DO (DEADLINE, { LOGB1 ("deadline="FMT_DUR, PRINTARG_DUR (xqos->deadline.deadline)); }); DO (LATENCY_BUDGET, { LOGB1 ("latency_budget="FMT_DUR, PRINTARG_DUR (xqos->latency_budget.duration)); }); @@ -4047,7 +4033,7 @@ void nn_log_xqos (logcat_t cat, const nn_xqos_t *xqos) DO (USER_DATA, { LOGB1 ("user_data=%u<", xqos->user_data.length); log_octetseq (cat, xqos->user_data.length, xqos->user_data.value); - nn_log (cat, ">"); + DDS_LOG(cat, ">"); }); DO (OWNERSHIP, { LOGB1 ("ownership=%d", xqos->ownership.kind); }); DO (OWNERSHIP_STRENGTH, { LOGB1 ("ownership_strength=%d", xqos->ownership_strength.value); }); @@ -4064,9 +4050,9 @@ void nn_log_xqos (logcat_t cat, const nn_xqos_t *xqos) unsigned i; LOGB1 ("subscription_keys={%u,{", xqos->subscription_keys.use_key_list); for (i = 0; i < xqos->subscription_keys.key_list.n; i++) { - nn_log (cat, "%s%s", (i == 0) ? "" : ",", xqos->subscription_keys.key_list.strs[i]); + DDS_LOG(cat, "%s%s", (i == 0) ? "" : ",", xqos->subscription_keys.key_list.strs[i]); } - nn_log (cat, "}}"); + DDS_LOG(cat, "}}"); }); DO (PRISMTECH_ENTITY_FACTORY, { LOGB1 ("entity_factory=%u", xqos->entity_factory.autoenable_created_entities); }); DO (PRISMTECH_SYNCHRONOUS_ENDPOINT, { LOGB1 ("synchronous_endpoint=%u", xqos->synchronous_endpoint.value); }); @@ -4074,25 +4060,25 @@ void nn_log_xqos (logcat_t cat, const nn_xqos_t *xqos) unsigned i; LOGB0 ("property={{"); for (i = 0; i < xqos->property.value.n; i++) { - nn_log (cat, "(\"%s\",\"%s\",%d)", + DDS_LOG(cat, "(\"%s\",\"%s\",%d)", xqos->property.value.props[i].name ? xqos->property.value.props[i].name : "nil", xqos->property.value.props[i].value ? xqos->property.value.props[i].value : "nil", (int)xqos->property.value.props[i].propagate); } - nn_log (cat, "},{"); + DDS_LOG(cat, "},{"); for (i = 0; i < xqos->property.binary_value.n; i++) { - nn_log (cat, "(\"%s\",<", + DDS_LOG(cat, "(\"%s\",<", xqos->property.binary_value.props[i].name ? xqos->property.binary_value.props[i].name : "nil"); log_octetseq (cat, xqos->property.binary_value.props[i].value.length, xqos->property.binary_value.props[i].value.value); - nn_log (cat, ">,%d)", + DDS_LOG(cat, ">,%d)", (int)xqos->property.binary_value.props[i].propagate); } - nn_log (cat, "}}"); + DDS_LOG(cat, "}}"); }); DO (RTI_TYPECODE, { LOGB1 ("rti_typecode=%u<", xqos->rti_typecode.length); log_octetseq (cat, xqos->rti_typecode.length, xqos->rti_typecode.value); - nn_log (cat, ">"); + DDS_LOG(cat, ">"); }); #undef PRINTARG_DUR diff --git a/src/core/ddsi/src/q_radmin.c b/src/core/ddsi/src/q_radmin.c index 65e7cd1..d698040 100644 --- a/src/core/ddsi/src/q_radmin.c +++ b/src/core/ddsi/src/q_radmin.c @@ -42,20 +42,6 @@ #include "ddsi/sysdeps.h" -/* Avoiding all nn_log-related activities when LC_RADMIN is not set - (and it hardly ever is, as it is not even included in "trace") - saves a couple of % CPU on a high-rate subscriber - that's worth - it. So we need a macro & a support function. */ -static int trace_radmin (const char *fmt, ...) -{ - va_list ap; - va_start (ap, fmt); - nn_vlog (LC_RADMIN, fmt, ap); - va_end (ap); - return 0; -} -#define TRACE_RADMIN(args) ((config.enabled_logcats & LC_RADMIN) ? (trace_radmin args) : 0) - /* OVERVIEW ------------------------------------------------------------ The receive path of DDSI2 has any number of receive threads that @@ -439,7 +425,7 @@ static struct nn_rbuf *nn_rbuf_alloc_new (struct nn_rbufpool *rbufpool) rb->size = rbufpool->rbuf_size; rb->max_rmsg_size = rbufpool->max_rmsg_size; rb->freeptr = rb->u.raw; - TRACE_RADMIN (("rbuf_alloc_new(%p) = %p\n", rbufpool, rb)); + DDS_LOG(DDS_LC_RADMIN, "rbuf_alloc_new(%p) = %p\n", rbufpool, rb); return rb; } @@ -461,10 +447,10 @@ static struct nn_rbuf *nn_rbuf_new (struct nn_rbufpool *rbufpool) static void nn_rbuf_release (struct nn_rbuf *rbuf) { struct nn_rbufpool *rbp = rbuf->rbufpool; - TRACE_RADMIN (("rbuf_release(%p) pool %p current %p\n", rbuf, rbp, rbp->current)); + DDS_LOG(DDS_LC_RADMIN, "rbuf_release(%p) pool %p current %p\n", rbuf, rbp, rbp->current); if (os_atomic_dec32_ov (&rbuf->n_live_rmsg_chunks) == 1) { - TRACE_RADMIN (("rbuf_release(%p) free\n", rbuf)); + DDS_LOG(DDS_LC_RADMIN, "rbuf_release(%p) free\n", rbuf); os_free (rbuf); } } @@ -491,7 +477,7 @@ static void *nn_rbuf_alloc (struct nn_rbufpool *rbufpool) /* Note: only one thread calls nn_rmsg_new on a pool */ uint32_t asize = max_rmsg_size_w_hdr (rbufpool->max_rmsg_size); struct nn_rbuf *rb; - TRACE_RADMIN (("rmsg_rbuf_alloc(%p, %u)\n", (void *) rbufpool, asize)); + DDS_LOG(DDS_LC_RADMIN, "rmsg_rbuf_alloc(%p, %u)\n", (void *) rbufpool, asize); ASSERT_RBUFPOOL_OWNER (rbufpool); rb = rbufpool->current; assert (rb != NULL); @@ -508,7 +494,7 @@ static void *nn_rbuf_alloc (struct nn_rbufpool *rbufpool) assert ((uint32_t) (rb->u.raw + rb->size - rb->freeptr) >= asize); } - TRACE_RADMIN (("rmsg_rbuf_alloc(%p, %u) = %p\n", (void *) rbufpool, asize, (void *) rb->freeptr)); + DDS_LOG(DDS_LC_RADMIN, "rmsg_rbuf_alloc(%p, %u) = %p\n", (void *) rbufpool, asize, (void *) rb->freeptr); #if USE_VALGRIND VALGRIND_MEMPOOL_ALLOC (rbufpool, rb->freeptr, asize); #endif @@ -527,7 +513,7 @@ struct nn_rmsg *nn_rmsg_new (struct nn_rbufpool *rbufpool) { /* Note: only one thread calls nn_rmsg_new on a pool */ struct nn_rmsg *rmsg; - TRACE_RADMIN (("rmsg_new(%p)\n", rbufpool)); + DDS_LOG(DDS_LC_RADMIN, "rmsg_new(%p)\n", rbufpool); rmsg = nn_rbuf_alloc (rbufpool); if (rmsg == NULL) @@ -540,14 +526,14 @@ struct nn_rmsg *nn_rmsg_new (struct nn_rbufpool *rbufpool) rmsg->lastchunk = &rmsg->chunk; /* Incrementing freeptr happens in commit(), so that discarding the message is really simple. */ - TRACE_RADMIN (("rmsg_new(%p) = %p\n", rbufpool, rmsg)); + DDS_LOG(DDS_LC_RADMIN, "rmsg_new(%p) = %p\n", rbufpool, rmsg); return rmsg; } void nn_rmsg_setsize (struct nn_rmsg *rmsg, uint32_t size) { uint32_t size8 = align8uint32 (size); - TRACE_RADMIN (("rmsg_setsize(%p, %u => %u)\n", rmsg, size, size8)); + DDS_LOG(DDS_LC_RADMIN, "rmsg_setsize(%p, %u => %u)\n", rmsg, size, size8); ASSERT_RBUFPOOL_OWNER (rmsg->chunk.rbuf->rbufpool); ASSERT_RMSG_UNCOMMITTED (rmsg); assert (os_atomic_ld32 (&rmsg->refcount) == RMSG_REFCOUNT_UNCOMMITTED_BIAS); @@ -570,7 +556,7 @@ void nn_rmsg_free (struct nn_rmsg *rmsg) free() which we don't do currently. And ideally, you'd use compare-and-swap for this. */ struct nn_rmsg_chunk *c; - TRACE_RADMIN (("rmsg_free(%p)\n", rmsg)); + DDS_LOG(DDS_LC_RADMIN, "rmsg_free(%p)\n", rmsg); assert (os_atomic_ld32 (&rmsg->refcount) == 0); c = &rmsg->chunk; while (c) @@ -593,7 +579,7 @@ void nn_rmsg_free (struct nn_rmsg *rmsg) static void commit_rmsg_chunk (struct nn_rmsg_chunk *chunk) { struct nn_rbuf *rbuf = chunk->rbuf; - TRACE_RADMIN (("commit_rmsg_chunk(%p)\n", chunk)); + DDS_LOG(DDS_LC_RADMIN, "commit_rmsg_chunk(%p)\n", chunk); rbuf->freeptr = chunk->u.payload + chunk->size; } @@ -608,8 +594,8 @@ void nn_rmsg_commit (struct nn_rmsg *rmsg) happens to be such that any asynchronous activities have completed before we got to commit. */ struct nn_rmsg_chunk *chunk = rmsg->lastchunk; - TRACE_RADMIN (("rmsg_commit(%p) refcount 0x%x last-chunk-size %u\n", - rmsg, rmsg->refcount, chunk->size)); + DDS_LOG(DDS_LC_RADMIN, "rmsg_commit(%p) refcount 0x%x last-chunk-size %u\n", + rmsg, rmsg->refcount.v, chunk->size); ASSERT_RBUFPOOL_OWNER (chunk->rbuf->rbufpool); ASSERT_RMSG_UNCOMMITTED (rmsg); assert (chunk->size <= chunk->rbuf->max_rmsg_size); @@ -624,7 +610,7 @@ void nn_rmsg_commit (struct nn_rmsg *rmsg) { /* Other references exist, so either stored in defrag, reorder and/or delivery queue */ - TRACE_RADMIN (("rmsg_commit(%p) => keep\n", rmsg)); + DDS_LOG(DDS_LC_RADMIN, "rmsg_commit(%p) => keep\n", rmsg); commit_rmsg_chunk (chunk); } } @@ -637,7 +623,7 @@ static void nn_rmsg_addbias (struct nn_rmsg *rmsg) However, other threads (e.g., delivery threads) may have been triggered already, so the increment must be done atomically. */ - TRACE_RADMIN (("rmsg_addbias(%p)\n", rmsg)); + DDS_LOG(DDS_LC_RADMIN, "rmsg_addbias(%p)\n", rmsg); ASSERT_RBUFPOOL_OWNER (rmsg->chunk.rbuf->rbufpool); ASSERT_RMSG_UNCOMMITTED (rmsg); os_atomic_add32 (&rmsg->refcount, RMSG_REFCOUNT_RDATA_BIAS); @@ -649,7 +635,7 @@ static void nn_rmsg_rmbias_and_adjust (struct nn_rmsg *rmsg, int adjust) progressing through the pipeline, but only by the receive thread. Can't require it to be uncommitted. */ uint32_t sub; - TRACE_RADMIN (("rmsg_rmbias_and_adjust(%p, %d)\n", rmsg, adjust)); + DDS_LOG(DDS_LC_RADMIN, "rmsg_rmbias_and_adjust(%p, %d)\n", rmsg, adjust); ASSERT_RBUFPOOL_OWNER (rmsg->chunk.rbuf->rbufpool); assert (adjust >= 0); assert ((uint32_t) adjust < RMSG_REFCOUNT_RDATA_BIAS); @@ -663,14 +649,14 @@ static void nn_rmsg_rmbias_anythread (struct nn_rmsg *rmsg) { /* For removing garbage when freeing a nn_defrag. */ uint32_t sub = RMSG_REFCOUNT_RDATA_BIAS; - TRACE_RADMIN (("rmsg_rmbias_anythread(%p)\n", rmsg)); + DDS_LOG(DDS_LC_RADMIN, "rmsg_rmbias_anythread(%p)\n", rmsg); assert (os_atomic_ld32 (&rmsg->refcount) >= sub); if (os_atomic_sub32_nv (&rmsg->refcount, sub) == 0) nn_rmsg_free (rmsg); } static void nn_rmsg_unref (struct nn_rmsg *rmsg) { - TRACE_RADMIN (("rmsg_unref(%p)\n", rmsg)); + DDS_LOG(DDS_LC_RADMIN, "rmsg_unref(%p)\n", rmsg); assert (os_atomic_ld32 (&rmsg->refcount) > 0); if (os_atomic_dec32_ov (&rmsg->refcount) == 1) nn_rmsg_free (rmsg); @@ -682,7 +668,7 @@ void *nn_rmsg_alloc (struct nn_rmsg *rmsg, uint32_t size) struct nn_rbuf *rbuf = chunk->rbuf; uint32_t size8 = align8uint32 (size); void *ptr; - TRACE_RADMIN (("rmsg_alloc(%p, %u => %u)\n", rmsg, size, size8)); + DDS_LOG(DDS_LC_RADMIN, "rmsg_alloc(%p, %u => %u)\n", rmsg, size, size8); ASSERT_RBUFPOOL_OWNER (rbuf->rbufpool); ASSERT_RMSG_UNCOMMITTED (rmsg); assert ((chunk->size % 8) == 0); @@ -692,12 +678,12 @@ void *nn_rmsg_alloc (struct nn_rmsg *rmsg, uint32_t size) { struct nn_rbufpool *rbufpool = rbuf->rbufpool; struct nn_rmsg_chunk *newchunk; - TRACE_RADMIN (("rmsg_alloc(%p, %u) limit hit - new chunk\n", rmsg, size)); + DDS_LOG(DDS_LC_RADMIN, "rmsg_alloc(%p, %u) limit hit - new chunk\n", rmsg, size); commit_rmsg_chunk (chunk); newchunk = nn_rbuf_alloc (rbufpool); if (newchunk == NULL) { - NN_WARNING ("nn_rmsg_alloc: can't allocate more memory (%u bytes) ... giving up\n", size); + DDS_WARNING ("nn_rmsg_alloc: can't allocate more memory (%u bytes) ... giving up\n", size); return NULL; } init_rmsg_chunk (newchunk, rbufpool->current); @@ -707,7 +693,7 @@ void *nn_rmsg_alloc (struct nn_rmsg *rmsg, uint32_t size) ptr = chunk->u.payload + chunk->size; chunk->size += size8; - TRACE_RADMIN (("rmsg_alloc(%p, %u) = %p\n", rmsg, size, ptr)); + DDS_LOG(DDS_LC_RADMIN, "rmsg_alloc(%p, %u) = %p\n", rmsg, size, ptr); #if USE_VALGRIND if (chunk == &rmsg->chunk) { VALGRIND_MEMPOOL_CHANGE (rbuf->rbufpool, rmsg, rmsg, offsetof (struct nn_rmsg, chunk.u.payload) + chunk->size); @@ -734,13 +720,13 @@ struct nn_rdata *nn_rdata_new (struct nn_rmsg *rmsg, uint32_t start, uint32_t en #ifndef NDEBUG os_atomic_st32 (&d->refcount_bias_added, 0); #endif - TRACE_RADMIN (("rdata_new(%p, bytes [%u,%u), submsg @ %u, payload @ %u) = %p\n", rmsg, start, endp1, NN_RDATA_SUBMSG_OFF (d), NN_RDATA_PAYLOAD_OFF (d), d)); + DDS_LOG(DDS_LC_RADMIN, "rdata_new(%p, bytes [%u,%u), submsg @ %u, payload @ %u) = %p\n", rmsg, start, endp1, NN_RDATA_SUBMSG_OFF (d), NN_RDATA_PAYLOAD_OFF (d), d); return d; } static void nn_rdata_addbias (struct nn_rdata *rdata) { - TRACE_RADMIN (("rdata_addbias(%p)\n", rdata)); + DDS_LOG(DDS_LC_RADMIN, "rdata_addbias(%p)\n", rdata); #ifndef NDEBUG ASSERT_RBUFPOOL_OWNER (rdata->rmsg->chunk.rbuf->rbufpool); if (os_atomic_inc32_nv (&rdata->refcount_bias_added) != 1) @@ -751,7 +737,7 @@ static void nn_rdata_addbias (struct nn_rdata *rdata) static void nn_rdata_rmbias_and_adjust (struct nn_rdata *rdata, int adjust) { - TRACE_RADMIN (("rdata_rmbias_and_adjust(%p, %d)\n", rdata, adjust)); + DDS_LOG(DDS_LC_RADMIN, "rdata_rmbias_and_adjust(%p, %d)\n", rdata, adjust); #ifndef NDEBUG if (os_atomic_dec32_ov (&rdata->refcount_bias_added) != 1) abort (); @@ -761,7 +747,7 @@ static void nn_rdata_rmbias_and_adjust (struct nn_rdata *rdata, int adjust) static void nn_rdata_rmbias_anythread (struct nn_rdata *rdata) { - TRACE_RADMIN (("rdata_rmbias_anytrhead(%p, %d)\n", rdata)); + DDS_LOG(DDS_LC_RADMIN, "rdata_rmbias_anythread(%p)\n", rdata); #ifndef NDEBUG if (os_atomic_dec32_ov (&rdata->refcount_bias_added) != 1) abort (); @@ -771,7 +757,7 @@ static void nn_rdata_rmbias_anythread (struct nn_rdata *rdata) static void nn_rdata_unref (struct nn_rdata *rdata) { - TRACE_RADMIN (("rdata_rdata_unref(%p)\n", rdata)); + DDS_LOG(DDS_LC_RADMIN, "rdata_rdata_unref(%p)\n", rdata); nn_rmsg_unref (rdata->rmsg); } @@ -908,7 +894,7 @@ struct nn_defrag *nn_defrag_new (enum nn_defrag_drop_mode drop_mode, uint32_t ma void nn_fragchain_adjust_refcount (struct nn_rdata *frag, int adjust) { struct nn_rdata *frag1; - TRACE_RADMIN (("fragchain_adjust_refcount(%p, %d)\n", frag, adjust)); + DDS_LOG(DDS_LC_RADMIN, "fragchain_adjust_refcount(%p, %d)\n", frag, adjust); while (frag) { frag1 = frag->nextfrag; @@ -920,7 +906,7 @@ void nn_fragchain_adjust_refcount (struct nn_rdata *frag, int adjust) static void nn_fragchain_rmbias_anythread (struct nn_rdata *frag, UNUSED_ARG (int adjust)) { struct nn_rdata *frag1; - TRACE_RADMIN (("fragchain_rmbias_anythread(%p)\n", frag)); + DDS_LOG(DDS_LC_RADMIN, "fragchain_rmbias_anythread(%p)\n", frag); while (frag) { frag1 = frag->nextfrag; @@ -940,7 +926,7 @@ static void defrag_rsample_drop (struct nn_defrag *defrag, struct nn_rsample *rs inorder treewalk does provide. */ ut_avlIter_t iter; struct nn_defrag_iv *iv; - TRACE_RADMIN ((" defrag_rsample_drop (%p, %p)\n", (void *) defrag, (void *) rsample)); + DDS_LOG(DDS_LC_RADMIN, " defrag_rsample_drop (%p, %p)\n", (void *) defrag, (void *) rsample); ut_avlDelete (&defrag_sampletree_treedef, &defrag->sampletree, rsample); assert (defrag->n_samples > 0); defrag->n_samples--; @@ -954,7 +940,7 @@ void nn_defrag_free (struct nn_defrag *defrag) s = ut_avlFindMin (&defrag_sampletree_treedef, &defrag->sampletree); while (s) { - TRACE_RADMIN (("defrag_free(%p, sample %p seq %lld)\n", defrag, s, s->u.defrag.seq)); + DDS_LOG(DDS_LC_RADMIN, "defrag_free(%p, sample %p seq %"PRId64")\n", defrag, s, s->u.defrag.seq); defrag_rsample_drop (defrag, s, nn_fragchain_rmbias_anythread); s = ut_avlFindMin (&defrag_sampletree_treedef, &defrag->sampletree); } @@ -966,21 +952,21 @@ static int defrag_try_merge_with_succ (struct nn_rsample_defrag *sample, struct { struct nn_defrag_iv *succ; - TRACE_RADMIN ((" defrag_try_merge_with_succ(%p [%u..%u)):\n", - (void *) node, node->min, node->maxp1)); + DDS_LOG(DDS_LC_RADMIN, " defrag_try_merge_with_succ(%p [%u..%u)):\n", + (void *) node, node->min, node->maxp1); if (node == sample->lastfrag) { /* there is no interval following node */ - TRACE_RADMIN ((" node is lastfrag\n")); + DDS_LOG(DDS_LC_RADMIN, " node is lastfrag\n"); return 0; } succ = ut_avlFindSucc (&rsample_defrag_fragtree_treedef, &sample->fragtree, node); assert (succ != NULL); - TRACE_RADMIN ((" succ is %p [%u..%u)\n", (void *) succ, succ->min, succ->maxp1)); + DDS_LOG(DDS_LC_RADMIN, " succ is %p [%u..%u)\n", (void *) succ, succ->min, succ->maxp1); if (succ->min > node->maxp1) { - TRACE_RADMIN ((" gap between node and succ\n")); + DDS_LOG(DDS_LC_RADMIN, " gap between node and succ\n"); return 0; } else @@ -993,7 +979,7 @@ static int defrag_try_merge_with_succ (struct nn_rsample_defrag *sample, struct ut_avlDelete (&rsample_defrag_fragtree_treedef, &sample->fragtree, succ); if (sample->lastfrag == succ) { - TRACE_RADMIN ((" succ is lastfrag\n")); + DDS_LOG(DDS_LC_RADMIN, " succ is lastfrag\n"); sample->lastfrag = node; } @@ -1008,9 +994,9 @@ static int defrag_try_merge_with_succ (struct nn_rsample_defrag *sample, struct references to rmsgs of the rdata in succ, freeing it may cause the rsample to be freed as well. */ if (node->maxp1 < succ_maxp1) - TRACE_RADMIN ((" succ adds data to node\n")); + DDS_LOG(DDS_LC_RADMIN, " succ adds data to node\n"); else - TRACE_RADMIN ((" succ is contained in node\n")); + DDS_LOG(DDS_LC_RADMIN, " succ is contained in node\n"); node->last->nextfrag = succ->first; node->last = succ->last; @@ -1181,9 +1167,9 @@ static struct nn_rsample *defrag_add_fragment (struct nn_rsample *sample, struct /* relatively expensive test: lastfrag, tree must be consistent */ assert (dfsample->lastfrag == ut_avlFindMax (&rsample_defrag_fragtree_treedef, &dfsample->fragtree)); - TRACE_RADMIN ((" lastfrag %p [%u..%u)\n", + DDS_LOG(DDS_LC_RADMIN, " lastfrag %p [%u..%u)\n", (void *) dfsample->lastfrag, - dfsample->lastfrag->min, dfsample->lastfrag->maxp1)); + dfsample->lastfrag->min, dfsample->lastfrag->maxp1); /* Interval tree is sorted on min offset; each key is unique: otherwise one would be wholly contained in another. */ @@ -1191,15 +1177,15 @@ static struct nn_rsample *defrag_add_fragment (struct nn_rsample *sample, struct { /* Assumed normal case: fragment appends data */ predeq = dfsample->lastfrag; - TRACE_RADMIN ((" fast path: predeq = lastfrag\n")); + DDS_LOG(DDS_LC_RADMIN, " fast path: predeq = lastfrag\n"); } else { /* Slow path: find preceding fragment by tree search */ predeq = ut_avlLookupPredEq (&rsample_defrag_fragtree_treedef, &dfsample->fragtree, &min); assert (predeq); - TRACE_RADMIN ((" slow path: predeq = lookup %u => %p [%u..%u)\n", - min, (void *) predeq, predeq->min, predeq->maxp1)); + DDS_LOG(DDS_LC_RADMIN, " slow path: predeq = lookup %u => %p [%u..%u)\n", + min, (void *) predeq, predeq->min, predeq->maxp1); } /* we have a sentinel interval of [0,0) until we receive a packet @@ -1211,7 +1197,7 @@ static struct nn_rsample *defrag_add_fragment (struct nn_rsample *sample, struct { /* new is contained in predeq, discard new; rdata did not cause completion of a sample */ - TRACE_RADMIN ((" new contained in predeq\n")); + DDS_LOG(DDS_LC_RADMIN, " new contained in predeq\n"); return NULL; } else if (min <= predeq->maxp1) @@ -1219,7 +1205,7 @@ static struct nn_rsample *defrag_add_fragment (struct nn_rsample *sample, struct /* new extends predeq, add it to the chain (necessarily at the end); this may close the gap to the successor of predeq; predeq need not have a fragment chain yet (it may be the sentinel) */ - TRACE_RADMIN ((" grow predeq with new\n")); + DDS_LOG(DDS_LC_RADMIN, " grow predeq with new\n"); nn_rdata_addbias (rdata); rdata->nextfrag = NULL; if (predeq->first) @@ -1247,8 +1233,8 @@ static struct nn_rsample *defrag_add_fragment (struct nn_rsample *sample, struct fragment in the chain adds value); but doesn't overlap with predeq so the tree structure doesn't change even though the key does change */ - TRACE_RADMIN ((" extending succ %p [%u..%u) at head\n", - (void *) succ, succ->min, succ->maxp1)); + DDS_LOG(DDS_LC_RADMIN, " extending succ %p [%u..%u) at head\n", + (void *) succ, succ->min, succ->maxp1); nn_rdata_addbias (rdata); rdata->nextfrag = succ->first; succ->first = rdata; @@ -1258,7 +1244,7 @@ static struct nn_rsample *defrag_add_fragment (struct nn_rsample *sample, struct succ-succ */ if (maxp1 > succ->maxp1) { - TRACE_RADMIN ((" extending succ at end as well\n")); + DDS_LOG(DDS_LC_RADMIN, " extending succ at end as well\n"); succ->maxp1 = maxp1; while (defrag_try_merge_with_succ (dfsample, succ)) ; @@ -1271,7 +1257,7 @@ static struct nn_rsample *defrag_add_fragment (struct nn_rsample *sample, struct /* doesn't extend either predeq at the end or succ at the head => new interval; rdata did not cause completion of sample */ ut_avlIPath_t path; - TRACE_RADMIN ((" new interval\n")); + DDS_LOG(DDS_LC_RADMIN, " new interval\n"); if (ut_avlLookupIPath (&rsample_defrag_fragtree_treedef, &dfsample->fragtree, &min, &path)) assert (0); defrag_rsample_addiv (dfsample, rdata, &path); @@ -1294,25 +1280,25 @@ static int defrag_limit_samples (struct nn_defrag *defrag, seqno_t seq, seqno_t return 1; /* max_samples >= 1 => some sample present => max_sample != NULL */ assert (defrag->max_sample != NULL); - TRACE_RADMIN ((" max samples reached\n")); + DDS_LOG(DDS_LC_RADMIN, " max samples reached\n"); switch (defrag->drop_mode) { case NN_DEFRAG_DROP_LATEST: - TRACE_RADMIN ((" drop mode = DROP_LATEST\n")); + DDS_LOG(DDS_LC_RADMIN, " drop mode = DROP_LATEST\n"); if (seq > defrag->max_sample->u.defrag.seq) { - TRACE_RADMIN ((" new sample is new latest => discarding it\n")); + DDS_LOG(DDS_LC_RADMIN, " new sample is new latest => discarding it\n"); return 0; } sample_to_drop = defrag->max_sample; break; case NN_DEFRAG_DROP_OLDEST: - TRACE_RADMIN ((" drop mode = DROP_OLDEST\n")); + DDS_LOG(DDS_LC_RADMIN, " drop mode = DROP_OLDEST\n"); sample_to_drop = ut_avlFindMin (&defrag_sampletree_treedef, &defrag->sampletree); assert (sample_to_drop); if (seq < sample_to_drop->u.defrag.seq) { - TRACE_RADMIN ((" new sample is new oldest => discarding it\n")); + DDS_LOG(DDS_LC_RADMIN, " new sample is new oldest => discarding it\n"); return 0; } break; @@ -1323,9 +1309,9 @@ static int defrag_limit_samples (struct nn_defrag *defrag, seqno_t seq, seqno_t { defrag->max_sample = ut_avlFindMax (&defrag_sampletree_treedef, &defrag->sampletree); *max_seq = defrag->max_sample ? defrag->max_sample->u.defrag.seq : 0; - TRACE_RADMIN ((" updating max_sample: now %p %lld\n", + DDS_LOG(DDS_LC_RADMIN, " updating max_sample: now %p %"PRId64"\n", (void *) defrag->max_sample, - defrag->max_sample ? defrag->max_sample->u.defrag.seq : 0)); + defrag->max_sample ? defrag->max_sample->u.defrag.seq : 0); } return 1; } @@ -1370,20 +1356,20 @@ struct nn_rsample *nn_defrag_rsample (struct nn_defrag *defrag, struct nn_rdata consistent. Max_sample must be consistent with tree */ assert (defrag->max_sample == ut_avlFindMax (&defrag_sampletree_treedef, &defrag->sampletree)); max_seq = defrag->max_sample ? defrag->max_sample->u.defrag.seq : 0; - TRACE_RADMIN (("defrag_rsample(%p, %p [%u..%u) msg %p, %p seq %lld size %u) max_seq %p %lld:\n", - (void *) defrag, (void *) rdata, rdata->min, rdata->maxp1, rdata->rmsg, - (void *) sampleinfo, sampleinfo->seq, sampleinfo->size, - (void *) defrag->max_sample, max_seq)); + DDS_LOG(DDS_LC_RADMIN, "defrag_rsample(%p, %p [%u..%u) msg %p, %p seq %"PRId64" size %u) max_seq %p %"PRId64":\n", + (void *) defrag, (void *) rdata, rdata->min, rdata->maxp1, rdata->rmsg, + (void *) sampleinfo, sampleinfo->seq, sampleinfo->size, + (void *) defrag->max_sample, max_seq); /* fast path: rdata is part of message with the highest sequence number we're currently defragmenting, or is beyond that */ if (sampleinfo->seq == max_seq) { - TRACE_RADMIN ((" add fragment to max_sample\n")); + DDS_LOG(DDS_LC_RADMIN, " add fragment to max_sample\n"); result = defrag_add_fragment (defrag->max_sample, rdata, sampleinfo); } else if (!defrag_limit_samples (defrag, sampleinfo->seq, &max_seq)) { - TRACE_RADMIN ((" discarding sample\n")); + DDS_LOG(DDS_LC_RADMIN, " discarding sample\n"); result = NULL; } else if (sampleinfo->seq > max_seq) @@ -1391,7 +1377,7 @@ struct nn_rsample *nn_defrag_rsample (struct nn_defrag *defrag, struct nn_rdata /* a node with a key greater than the maximum always is the right child of the old maximum node */ /* FIXME: MERGE THIS ONE WITH THE NEXT */ - TRACE_RADMIN ((" new max sample\n")); + DDS_LOG(DDS_LC_RADMIN, " new max sample\n"); ut_avlLookupIPath (&defrag_sampletree_treedef, &defrag->sampletree, &sampleinfo->seq, &path); if ((sample = defrag_rsample_new (rdata, sampleinfo)) == NULL) return NULL; @@ -1403,7 +1389,7 @@ struct nn_rsample *nn_defrag_rsample (struct nn_defrag *defrag, struct nn_rdata else if ((sample = ut_avlLookupIPath (&defrag_sampletree_treedef, &defrag->sampletree, &sampleinfo->seq, &path)) == NULL) { /* a new sequence number, but smaller than the maximum */ - TRACE_RADMIN ((" new sample less than max\n")); + DDS_LOG(DDS_LC_RADMIN, " new sample less than max\n"); assert (sampleinfo->seq < max_seq); if ((sample = defrag_rsample_new (rdata, sampleinfo)) == NULL) return NULL; @@ -1414,7 +1400,7 @@ struct nn_rsample *nn_defrag_rsample (struct nn_defrag *defrag, struct nn_rdata else { /* adds (or, as the case may be, doesn't add) to a known message */ - TRACE_RADMIN ((" add fragment to %p\n", (void *) sample)); + DDS_LOG(DDS_LC_RADMIN, " add fragment to %p\n", (void *) sample); result = defrag_add_fragment (sample, rdata, sampleinfo); } @@ -1423,16 +1409,16 @@ struct nn_rsample *nn_defrag_rsample (struct nn_defrag *defrag, struct nn_rdata /* Once completed, remove from defrag sample tree and convert to reorder format. If it is the sample with the maximum sequence in the tree, an update of max_sample is required. */ - TRACE_RADMIN ((" complete\n")); + DDS_LOG(DDS_LC_RADMIN, " complete\n"); ut_avlDelete (&defrag_sampletree_treedef, &defrag->sampletree, result); assert (defrag->n_samples > 0); defrag->n_samples--; if (result == defrag->max_sample) { defrag->max_sample = ut_avlFindMax (&defrag_sampletree_treedef, &defrag->sampletree); - TRACE_RADMIN ((" updating max_sample: now %p %lld\n", - (void *) defrag->max_sample, - defrag->max_sample ? defrag->max_sample->u.defrag.seq : 0)); + DDS_LOG(DDS_LC_RADMIN, " updating max_sample: now %p %"PRId64"\n", + (void *) defrag->max_sample, + defrag->max_sample ? defrag->max_sample->u.defrag.seq : 0); } rsample_convert_defrag_to_reorder (result); } @@ -1729,28 +1715,28 @@ static int reorder_try_append_and_discard (struct nn_reorder *reorder, struct nn { if (todiscard == NULL) { - TRACE_RADMIN ((" try_append_and_discard: fail: todiscard = NULL\n")); + DDS_LOG(DDS_LC_RADMIN, " try_append_and_discard: fail: todiscard = NULL\n"); return 0; } else if (appendto->u.reorder.maxp1 < todiscard->u.reorder.min) { - TRACE_RADMIN ((" try_append_and_discard: fail: appendto = [%lld,%lld) @ %p, " - "todiscard = [%lld,%lld) @ %p - gap\n", - appendto->u.reorder.min, appendto->u.reorder.maxp1, (void *) appendto, - todiscard->u.reorder.min, todiscard->u.reorder.maxp1, (void *) todiscard)); + DDS_LOG(DDS_LC_RADMIN, " try_append_and_discard: fail: appendto = [%"PRId64",%"PRId64") @ %p, " + "todiscard = [%"PRId64",%"PRId64") @ %p - gap\n", + appendto->u.reorder.min, appendto->u.reorder.maxp1, (void *) appendto, + todiscard->u.reorder.min, todiscard->u.reorder.maxp1, (void *) todiscard); return 0; } else { - TRACE_RADMIN ((" try_append_and_discard: success: appendto = [%lld,%lld) @ %p, " - "todiscard = [%lld,%lld) @ %p\n", - appendto->u.reorder.min, appendto->u.reorder.maxp1, (void *) appendto, - todiscard->u.reorder.min, todiscard->u.reorder.maxp1, (void *) todiscard)); + DDS_LOG(DDS_LC_RADMIN, " try_append_and_discard: success: appendto = [%"PRId64",%"PRId64") @ %p, " + "todiscard = [%"PRId64",%"PRId64") @ %p\n", + appendto->u.reorder.min, appendto->u.reorder.maxp1, (void *) appendto, + todiscard->u.reorder.min, todiscard->u.reorder.maxp1, (void *) todiscard); assert (todiscard->u.reorder.min == appendto->u.reorder.maxp1); ut_avlDelete (&reorder_sampleivtree_treedef, &reorder->sampleivtree, todiscard); append_rsample_interval (appendto, todiscard); - TRACE_RADMIN ((" try_append_and_discard: max_sampleiv needs update? %s\n", - (todiscard == reorder->max_sampleiv) ? "yes" : "no")); + DDS_LOG(DDS_LC_RADMIN, " try_append_and_discard: max_sampleiv needs update? %s\n", + (todiscard == reorder->max_sampleiv) ? "yes" : "no"); /* Inform caller whether reorder->max must be updated -- the expected thing to do is to update it to appendto here, but that fails if appendto isn't actually in the tree. And that happens @@ -1825,7 +1811,7 @@ static void delete_last_sample (struct nn_reorder *reorder) { /* Last sample is in an interval of its own - delete it, and recalc max_sampleiv. */ - TRACE_RADMIN ((" delete_last_sample: in singleton interval\n")); + DDS_LOG(DDS_LC_RADMIN, " delete_last_sample: in singleton interval\n"); fragchain = last->sc.first->fragchain; ut_avlDelete (&reorder_sampleivtree_treedef, &reorder->sampleivtree, reorder->max_sampleiv); reorder->max_sampleiv = ut_avlFindMax (&reorder_sampleivtree_treedef, &reorder->sampleivtree); @@ -1841,8 +1827,8 @@ static void delete_last_sample (struct nn_reorder *reorder) large!). Can't be a singleton list, so might as well chop off one evaluation of the loop condition. */ struct nn_rsample_chain_elem *e, *pe; - TRACE_RADMIN ((" delete_last_sample: scanning last interval [%llu..%llu)\n", - last->min, last->maxp1)); + DDS_LOG(DDS_LC_RADMIN, " delete_last_sample: scanning last interval [%"PRId64"..%"PRId64")\n", + last->min, last->maxp1); assert (last->n_samples >= 1); assert (last->min + last->n_samples <= last->maxp1); e = last->sc.first; @@ -1872,7 +1858,7 @@ nn_reorder_result_t nn_reorder_rsample (struct nn_rsample_chain *sc, struct nn_r refcount_adjust is incremented if the sample is not discarded. */ struct nn_rsample_reorder *s = &rsampleiv->u.reorder; - TRACE_RADMIN (("reorder_sample(%p %c, %lld @ %p) expecting %lld:\n", (void *) reorder, reorder_mode_as_char (reorder), rsampleiv->u.reorder.min, (void *) rsampleiv, reorder->next_seq)); + DDS_LOG(DDS_LC_RADMIN, "reorder_sample(%p %c, %"PRId64" @ %p) expecting %"PRId64":\n", (void *) reorder, reorder_mode_as_char (reorder), rsampleiv->u.reorder.min, (void *) rsampleiv, reorder->next_seq); /* Incoming rsample must be a singleton */ assert (rsample_is_singleton (s)); @@ -1883,7 +1869,7 @@ nn_reorder_result_t nn_reorder_rsample (struct nn_rsample_chain *sc, struct nn_r { struct nn_rsample *min = ut_avlFindMin (&reorder_sampleivtree_treedef, &reorder->sampleivtree); if (min) - TRACE_RADMIN ((" min = %lld @ %p\n", min->u.reorder.min, (void *) min)); + DDS_LOG(DDS_LC_RADMIN, " min = %"PRId64" @ %p\n", min->u.reorder.min, (void *) min); assert (min == NULL || reorder->next_seq < min->u.reorder.min); assert ((reorder->max_sampleiv == NULL && min == NULL) || (reorder->max_sampleiv != NULL && min != NULL)); @@ -1893,7 +1879,7 @@ nn_reorder_result_t nn_reorder_rsample (struct nn_rsample_chain *sc, struct nn_r assert (reorder->max_sampleiv == NULL || reorder->max_sampleiv == ut_avlFindMax (&reorder_sampleivtree_treedef, &reorder->sampleivtree)); assert (reorder->n_samples <= reorder->max_samples); if (reorder->max_sampleiv) - TRACE_RADMIN ((" max = [%lld,%lld) @ %p\n", reorder->max_sampleiv->u.reorder.min, reorder->max_sampleiv->u.reorder.maxp1, (void *) reorder->max_sampleiv)); + DDS_LOG(DDS_LC_RADMIN, " max = [%"PRId64",%"PRId64") @ %p\n", reorder->max_sampleiv->u.reorder.min, reorder->max_sampleiv->u.reorder.maxp1, (void *) reorder->max_sampleiv); if (s->min == reorder->next_seq || (s->min > reorder->next_seq && reorder->mode == NN_REORDER_MODE_MONOTONICALLY_INCREASING) || @@ -1907,7 +1893,7 @@ nn_reorder_result_t nn_reorder_rsample (struct nn_rsample_chain *sc, struct nn_r admin, or things go wrong very quickly.) */ if (delivery_queue_full_p) { - TRACE_RADMIN ((" discarding deliverable sample: delivery queue is full\n")); + DDS_LOG(DDS_LC_RADMIN, " discarding deliverable sample: delivery queue is full\n"); return NN_REORDER_REJECT; } @@ -1918,14 +1904,14 @@ nn_reorder_result_t nn_reorder_rsample (struct nn_rsample_chain *sc, struct nn_r if (reorder->max_sampleiv != NULL) { struct nn_rsample *min = ut_avlFindMin (&reorder_sampleivtree_treedef, &reorder->sampleivtree); - TRACE_RADMIN ((" try append_and_discard\n")); + DDS_LOG(DDS_LC_RADMIN, " try append_and_discard\n"); if (reorder_try_append_and_discard (reorder, rsampleiv, min)) reorder->max_sampleiv = NULL; } reorder->next_seq = s->maxp1; *sc = rsampleiv->u.reorder.sc; (*refcount_adjust)++; - TRACE_RADMIN ((" return [%lld,%lld)\n", s->min, s->maxp1)); + DDS_LOG(DDS_LC_RADMIN, " return [%"PRId64",%"PRId64")\n", s->min, s->maxp1); /* Adjust reorder->n_samples, new sample is not counted yet */ assert (s->maxp1 - s->min >= 1); @@ -1939,7 +1925,7 @@ nn_reorder_result_t nn_reorder_rsample (struct nn_rsample_chain *sc, struct nn_r { /* we've moved beyond this one: discard it; no need to adjust n_samples */ - TRACE_RADMIN ((" discard: too old\n")); + DDS_LOG(DDS_LC_RADMIN, " discard: too old\n"); return NN_REORDER_TOO_OLD; /* don't want refcount increment */ } else if (ut_avlIsEmpty (&reorder->sampleivtree)) @@ -1948,10 +1934,10 @@ nn_reorder_result_t nn_reorder_rsample (struct nn_rsample_chain *sc, struct nn_r is technically allowed, and potentially useful, so check for it */ assert (reorder->n_samples == 0); - TRACE_RADMIN ((" adding to empty store\n")); + DDS_LOG(DDS_LC_RADMIN, " adding to empty store\n"); if (reorder->max_samples == 0) { - TRACE_RADMIN ((" NOT - max_samples hit\n")); + DDS_LOG(DDS_LC_RADMIN, " NOT - max_samples hit\n"); return NN_REORDER_REJECT; } else @@ -1968,12 +1954,12 @@ nn_reorder_result_t nn_reorder_rsample (struct nn_rsample_chain *sc, struct nn_r if (delivery_queue_full_p) { /* growing last inteval will not be accepted when this flag is set */ - TRACE_RADMIN ((" discarding sample: only accepting delayed samples due to backlog in delivery queue\n")); + DDS_LOG(DDS_LC_RADMIN, " discarding sample: only accepting delayed samples due to backlog in delivery queue\n"); return NN_REORDER_REJECT; } /* grow the last interval, if we're still accepting samples */ - TRACE_RADMIN ((" growing last interval\n")); + DDS_LOG(DDS_LC_RADMIN, " growing last interval\n"); if (reorder->n_samples < reorder->max_samples) { append_rsample_interval (reorder->max_sampleiv, rsampleiv); @@ -1981,7 +1967,7 @@ nn_reorder_result_t nn_reorder_rsample (struct nn_rsample_chain *sc, struct nn_r } else { - TRACE_RADMIN ((" discarding sample: max_samples reached and sample at end\n")); + DDS_LOG(DDS_LC_RADMIN, " discarding sample: max_samples reached and sample at end\n"); return NN_REORDER_REJECT; } } @@ -1990,19 +1976,19 @@ nn_reorder_result_t nn_reorder_rsample (struct nn_rsample_chain *sc, struct nn_r if (delivery_queue_full_p) { /* new interval at the end will not be accepted when this flag is set */ - TRACE_RADMIN ((" discarding sample: only accepting delayed samples due to backlog in delivery queue\n")); + DDS_LOG(DDS_LC_RADMIN, " discarding sample: only accepting delayed samples due to backlog in delivery queue\n"); return NN_REORDER_REJECT; } if (reorder->n_samples < reorder->max_samples) { - TRACE_RADMIN ((" new interval at end\n")); + DDS_LOG(DDS_LC_RADMIN, " new interval at end\n"); reorder_add_rsampleiv (reorder, rsampleiv); reorder->max_sampleiv = rsampleiv; reorder->n_samples++; } else { - TRACE_RADMIN ((" discarding sample: max_samples reached and sample at end\n")); + DDS_LOG(DDS_LC_RADMIN, " discarding sample: max_samples reached and sample at end\n"); return NN_REORDER_REJECT; } } @@ -2016,37 +2002,37 @@ nn_reorder_result_t nn_reorder_rsample (struct nn_rsample_chain *sc, struct nn_r - if immsucc exists we can prepend s to immsucc - and possibly join predeq, s, and immsucc */ struct nn_rsample *predeq, *immsucc; - TRACE_RADMIN ((" hard case ...\n")); + DDS_LOG(DDS_LC_RADMIN, " hard case ...\n"); if (config.late_ack_mode && delivery_queue_full_p) { - TRACE_RADMIN ((" discarding sample: delivery queue full\n")); + DDS_LOG(DDS_LC_RADMIN, " discarding sample: delivery queue full\n"); return NN_REORDER_REJECT; } predeq = ut_avlLookupPredEq (&reorder_sampleivtree_treedef, &reorder->sampleivtree, &s->min); if (predeq) - TRACE_RADMIN ((" predeq = [%lld,%lld) @ %p\n", - predeq->u.reorder.min, predeq->u.reorder.maxp1, (void *) predeq)); + DDS_LOG(DDS_LC_RADMIN, " predeq = [%"PRId64",%"PRId64") @ %p\n", + predeq->u.reorder.min, predeq->u.reorder.maxp1, (void *) predeq); else - TRACE_RADMIN ((" predeq = null\n")); + DDS_LOG(DDS_LC_RADMIN, " predeq = null\n"); if (predeq && s->min >= predeq->u.reorder.min && s->min < predeq->u.reorder.maxp1) { /* contained in predeq */ - TRACE_RADMIN ((" discard: contained in predeq\n")); + DDS_LOG(DDS_LC_RADMIN, " discard: contained in predeq\n"); return NN_REORDER_REJECT; } immsucc = ut_avlLookup (&reorder_sampleivtree_treedef, &reorder->sampleivtree, &s->maxp1); if (immsucc) - TRACE_RADMIN ((" immsucc = [%lld,%lld) @ %p\n", - immsucc->u.reorder.min, immsucc->u.reorder.maxp1, (void *) immsucc)); + DDS_LOG(DDS_LC_RADMIN, " immsucc = [%"PRId64",%"PRId64") @ %p\n", + immsucc->u.reorder.min, immsucc->u.reorder.maxp1, (void *) immsucc); else - TRACE_RADMIN ((" immsucc = null\n")); + DDS_LOG(DDS_LC_RADMIN, " immsucc = null\n"); if (predeq && s->min == predeq->u.reorder.maxp1) { /* grow predeq at end, and maybe append immsucc as well */ - TRACE_RADMIN ((" growing predeq at end ...\n")); + DDS_LOG(DDS_LC_RADMIN, " growing predeq at end ...\n"); append_rsample_interval (predeq, rsampleiv); if (reorder_try_append_and_discard (reorder, predeq, immsucc)) reorder->max_sampleiv = predeq; @@ -2056,7 +2042,7 @@ nn_reorder_result_t nn_reorder_rsample (struct nn_rsample_chain *sc, struct nn_r /* no predecessor, grow immsucc at head, which _does_ alter the key of the node in the tree, but _doesn't_ change the tree's structure. */ - TRACE_RADMIN ((" growing immsucc at head\n")); + DDS_LOG(DDS_LC_RADMIN, " growing immsucc at head\n"); s->sc.last->next = immsucc->u.reorder.sc.first; immsucc->u.reorder.sc.first = s->sc.first; immsucc->u.reorder.min = s->min; @@ -2082,7 +2068,7 @@ nn_reorder_result_t nn_reorder_rsample (struct nn_rsample_chain *sc, struct nn_r else { /* neither extends predeq nor immsucc */ - TRACE_RADMIN ((" new interval\n")); + DDS_LOG(DDS_LC_RADMIN, " new interval\n"); reorder_add_rsampleiv (reorder, rsampleiv); } @@ -2209,18 +2195,18 @@ nn_reorder_result_t nn_reorder_gap (struct nn_rsample_chain *sc, struct nn_reord struct nn_rsample *coalesced; int valuable; - TRACE_RADMIN (("reorder_gap(%p %c, [%lld,%lld) data %p) expecting %lld:\n", + DDS_LOG(DDS_LC_RADMIN, "reorder_gap(%p %c, [%"PRId64",%"PRId64") data %p) expecting %"PRId64":\n", (void *) reorder, reorder_mode_as_char (reorder), - min, maxp1, (void *) rdata, reorder->next_seq)); + min, maxp1, (void *) rdata, reorder->next_seq); if (maxp1 <= reorder->next_seq) { - TRACE_RADMIN ((" too old\n")); + DDS_LOG(DDS_LC_RADMIN, " too old\n"); return NN_REORDER_TOO_OLD; } if (reorder->mode != NN_REORDER_MODE_NORMAL) { - TRACE_RADMIN ((" special mode => don't care\n")); + DDS_LOG(DDS_LC_RADMIN, " special mode => don't care\n"); return NN_REORDER_REJECT; } @@ -2228,10 +2214,10 @@ nn_reorder_result_t nn_reorder_gap (struct nn_rsample_chain *sc, struct nn_reord if ((coalesced = coalesce_intervals_touching_range (reorder, min, maxp1, &valuable)) == NULL) { nn_reorder_result_t res; - TRACE_RADMIN ((" coalesced = null\n")); + DDS_LOG(DDS_LC_RADMIN, " coalesced = null\n"); if (min <= reorder->next_seq) { - TRACE_RADMIN ((" next expected: %lld\n", maxp1)); + DDS_LOG(DDS_LC_RADMIN, " next expected: %"PRId64"\n", maxp1); reorder->next_seq = maxp1; res = NN_REORDER_ACCEPT; } @@ -2239,17 +2225,17 @@ nn_reorder_result_t nn_reorder_gap (struct nn_rsample_chain *sc, struct nn_reord (reorder->max_sampleiv == NULL || min > reorder->max_sampleiv->u.reorder.maxp1)) { /* n_samples = max_samples => (max_sampleiv = NULL <=> max_samples = 0) */ - TRACE_RADMIN ((" discarding gap: max_samples reached and gap at end\n")); + DDS_LOG(DDS_LC_RADMIN, " discarding gap: max_samples reached and gap at end\n"); res = NN_REORDER_REJECT; } else if (!reorder_insert_gap (reorder, rdata, min, maxp1)) { - TRACE_RADMIN ((" store gap failed: no memory\n")); + DDS_LOG(DDS_LC_RADMIN, " store gap failed: no memory\n"); res = NN_REORDER_REJECT; } else { - TRACE_RADMIN ((" storing gap\n")); + DDS_LOG(DDS_LC_RADMIN, " storing gap\n"); res = NN_REORDER_ACCEPT; /* do not let radmin grow beyond max_samples; there is a small possibility that we insert it & delete it immediately @@ -2265,15 +2251,15 @@ nn_reorder_result_t nn_reorder_gap (struct nn_rsample_chain *sc, struct nn_reord } else if (coalesced->u.reorder.min <= reorder->next_seq) { - TRACE_RADMIN ((" coalesced = [%lld,%lld) @ %p containing %d samples\n", - coalesced->u.reorder.min, coalesced->u.reorder.maxp1, - (void *) coalesced, coalesced->u.reorder.n_samples)); + DDS_LOG(DDS_LC_RADMIN, " coalesced = [%"PRId64",%"PRId64") @ %p containing %d samples\n", + coalesced->u.reorder.min, coalesced->u.reorder.maxp1, + (void *) coalesced, coalesced->u.reorder.n_samples); ut_avlDelete (&reorder_sampleivtree_treedef, &reorder->sampleivtree, coalesced); if (coalesced->u.reorder.min <= reorder->next_seq) assert (min <= reorder->next_seq); reorder->next_seq = coalesced->u.reorder.maxp1; reorder->max_sampleiv = ut_avlFindMax (&reorder_sampleivtree_treedef, &reorder->sampleivtree); - TRACE_RADMIN ((" next expected: %lld\n", reorder->next_seq)); + DDS_LOG(DDS_LC_RADMIN, " next expected: %"PRId64"\n", reorder->next_seq); *sc = coalesced->u.reorder.sc; /* Adjust n_samples */ @@ -2284,8 +2270,8 @@ nn_reorder_result_t nn_reorder_gap (struct nn_rsample_chain *sc, struct nn_reord } else { - TRACE_RADMIN ((" coalesced = [%lld,%lld) @ %p - that is all\n", - coalesced->u.reorder.min, coalesced->u.reorder.maxp1, (void *) coalesced)); + DDS_LOG(DDS_LC_RADMIN, " coalesced = [%"PRId64",%"PRId64") @ %p - that is all\n", + coalesced->u.reorder.min, coalesced->u.reorder.maxp1, (void *) coalesced); reorder->max_sampleiv = ut_avlFindMax (&reorder_sampleivtree_treedef, &reorder->sampleivtree); return valuable ? NN_REORDER_ACCEPT : NN_REORDER_REJECT; } @@ -2325,13 +2311,13 @@ unsigned nn_reorder_nackmap (struct nn_reorder *reorder, seqno_t base, seqno_t m #else if (base > reorder->next_seq) { - NN_ERROR ("nn_reorder_nackmap: incorrect base sequence number supplied (%"PRId64" > %"PRId64")\n", base, reorder->next_seq); + DDS_ERROR("nn_reorder_nackmap: incorrect base sequence number supplied (%"PRId64" > %"PRId64")\n", base, reorder->next_seq); base = reorder->next_seq; } #endif if (maxseq + 1 < base) { - NN_ERROR ("nn_reorder_nackmap: incorrect max sequence number supplied (maxseq %"PRId64" base %"PRId64")\n", maxseq, base); + DDS_ERROR("nn_reorder_nackmap: incorrect max sequence number supplied (maxseq %"PRId64" base %"PRId64")\n", maxseq, base); maxseq = base - 1; } diff --git a/src/core/ddsi/src/q_receive.c b/src/core/ddsi/src/q_receive.c index bf5846d..3a8e0a7 100644 --- a/src/core/ddsi/src/q_receive.c +++ b/src/core/ddsi/src/q_receive.c @@ -89,7 +89,7 @@ static void maybe_set_reader_in_sync (struct proxy_writer *pwr, struct pwr_rd_ma case PRMSS_OUT_OF_SYNC: if (nn_reorder_next_seq (wn->u.not_in_sync.reorder) - 1 >= wn->u.not_in_sync.end_of_out_of_sync_seq) { - TRACE ((" msr_in_sync(%x:%x:%x:%x out-of-sync to tlcatchup)", PGUID (wn->rd_guid))); + DDS_TRACE(" msr_in_sync(%x:%x:%x:%x out-of-sync to tlcatchup)", PGUID (wn->rd_guid)); wn->in_sync = PRMSS_TLCATCHUP; maybe_set_reader_in_sync (pwr, wn, last_deliv_seq); } @@ -623,15 +623,15 @@ static void force_heartbeat_to_peer (struct writer *wr, const struct whc_state * } add_Gap (m, wr, prd, seq, seq+1, 1, &bits); add_Heartbeat (m, wr, whcst, hbansreq, prd->e.guid.entityid, 1); - TRACE (("force_heartbeat_to_peer: %x:%x:%x:%x -> %x:%x:%x:%x - whc empty, queueing gap #%"PRId64" + heartbeat for transmit\n", - PGUID (wr->e.guid), PGUID (prd->e.guid), seq)); + DDS_TRACE("force_heartbeat_to_peer: %x:%x:%x:%x -> %x:%x:%x:%x - whc empty, queueing gap #%"PRId64" + heartbeat for transmit\n", + PGUID (wr->e.guid), PGUID (prd->e.guid), seq); } else { /* Send a Heartbeat just to this peer */ add_Heartbeat (m, wr, whcst, hbansreq, prd->e.guid.entityid, 0); - TRACE (("force_heartbeat_to_peer: %x:%x:%x:%x -> %x:%x:%x:%x - queue for transmit\n", - PGUID (wr->e.guid), PGUID (prd->e.guid))); + DDS_TRACE("force_heartbeat_to_peer: %x:%x:%x:%x -> %x:%x:%x:%x - queue for transmit\n", + PGUID (wr->e.guid), PGUID (prd->e.guid)); } qxev_msg (wr->evq, m); } @@ -725,21 +725,21 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac src.entityid = msg->readerId; dst.prefix = rst->dst_guid_prefix; dst.entityid = msg->writerId; - TRACE (("ACKNACK(%s#%d:%"PRId64"/%u:", msg->smhdr.flags & ACKNACK_FLAG_FINAL ? "F" : "", - *countp, fromSN (msg->readerSNState.bitmap_base), msg->readerSNState.numbits)); + DDS_TRACE("ACKNACK(%s#%d:%"PRId64"/%u:", msg->smhdr.flags & ACKNACK_FLAG_FINAL ? "F" : "", + *countp, fromSN (msg->readerSNState.bitmap_base), msg->readerSNState.numbits); for (i = 0; i < msg->readerSNState.numbits; i++) - TRACE (("%c", nn_bitset_isset (msg->readerSNState.numbits, msg->readerSNState.bits, i) ? '1' : '0')); + DDS_TRACE("%c", nn_bitset_isset (msg->readerSNState.numbits, msg->readerSNState.bits, i) ? '1' : '0'); seqbase = fromSN (msg->readerSNState.bitmap_base); if (!rst->forme) { - TRACE ((" %x:%x:%x:%x -> %x:%x:%x:%x not-for-me)", PGUID (src), PGUID (dst))); + DDS_TRACE(" %x:%x:%x:%x -> %x:%x:%x:%x not-for-me)", PGUID (src), PGUID (dst)); return 1; } if ((wr = ephash_lookup_writer_guid (&dst)) == NULL) { - TRACE ((" %x:%x:%x:%x -> %x:%x:%x:%x?)", PGUID (src), PGUID (dst))); + DDS_TRACE(" %x:%x:%x:%x -> %x:%x:%x:%x?)", PGUID (src), PGUID (dst)); return 1; } /* Always look up the proxy reader -- even though we don't need for @@ -748,7 +748,7 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac only retrieve it when needed. */ if ((prd = ephash_lookup_proxy_reader_guid (&src)) == NULL) { - TRACE ((" %x:%x:%x:%x? -> %x:%x:%x:%x)", PGUID (src), PGUID (dst))); + DDS_TRACE(" %x:%x:%x:%x? -> %x:%x:%x:%x)", PGUID (src), PGUID (dst)); return 1; } @@ -758,14 +758,14 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac if (!wr->reliable) /* note: reliability can't be changed */ { - TRACE ((" %x:%x:%x:%x -> %x:%x:%x:%x not a reliable writer!)", PGUID (src), PGUID (dst))); + DDS_TRACE(" %x:%x:%x:%x -> %x:%x:%x:%x not a reliable writer!)", PGUID (src), PGUID (dst)); return 1; } os_mutexLock (&wr->e.lock); if ((rn = ut_avlLookup (&wr_readers_treedef, &wr->readers, &src)) == NULL) { - TRACE ((" %x:%x:%x:%x -> %x:%x:%x:%x not a connection)", PGUID (src), PGUID (dst))); + DDS_TRACE(" %x:%x:%x:%x -> %x:%x:%x:%x not a connection)", PGUID (src), PGUID (dst)); goto out; } @@ -785,10 +785,10 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac if (!accept_ack_or_hb_w_timeout (*countp, &rn->next_acknack, tnow, &rn->t_acknack_accepted, is_preemptive_ack)) { - TRACE ((" [%x:%x:%x:%x -> %x:%x:%x:%x])", PGUID (src), PGUID (dst))); + DDS_TRACE(" [%x:%x:%x:%x -> %x:%x:%x:%x])", PGUID (src), PGUID (dst)); goto out; } - TRACE ((" %x:%x:%x:%x -> %x:%x:%x:%x", PGUID (src), PGUID (dst))); + DDS_TRACE(" %x:%x:%x:%x -> %x:%x:%x:%x", PGUID (src), PGUID (dst)); /* Update latency estimates if we have a timestamp -- won't actually work so well if the timestamp can be a left over from some other @@ -799,17 +799,17 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac nn_wctime_t tstamp_now = now (); nn_wctime_t tstamp_msg = nn_wctime_from_ddsi_time (timestamp); nn_lat_estim_update (&rn->hb_to_ack_latency, tstamp_now.v - tstamp_msg.v); - if ((config.enabled_logcats & (LC_TRACE | LC_INFO)) && + if ((dds_get_log_mask() & (DDS_LC_TRACE | DDS_LC_INFO)) && tstamp_now.v > rn->hb_to_ack_latency_tlastlog.v + 10 * T_SECOND) { - if (config.enabled_logcats & LC_TRACE) - nn_lat_estim_log (LC_TRACE, NULL, &rn->hb_to_ack_latency); - else if (config.enabled_logcats & LC_INFO) + if (dds_get_log_mask() & DDS_LC_TRACE) + nn_lat_estim_log (DDS_LC_TRACE, NULL, &rn->hb_to_ack_latency); + else if (dds_get_log_mask() & DDS_LC_INFO) { char tagbuf[2*(4*8+3) + 4 + 1]; (void) snprintf (tagbuf, sizeof (tagbuf), "%x:%x:%x:%x -> %x:%x:%x:%x", PGUID (src), PGUID (dst)); - if (nn_lat_estim_log (LC_INFO, tagbuf, &rn->hb_to_ack_latency)) - nn_log (LC_INFO, "\n"); + if (nn_lat_estim_log (DDS_LC_INFO, tagbuf, &rn->hb_to_ack_latency)) + DDS_LOG(DDS_LC_INFO, "\n"); } rn->hb_to_ack_latency_tlastlog = tstamp_now; } @@ -830,7 +830,7 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac } ut_avlAugmentUpdate (&wr_readers_treedef, rn); n = remove_acked_messages (wr, &whcst, &deferred_free_list); - TRACE ((" ACK%"PRId64" RM%u", n_ack, n)); + DDS_TRACE(" ACK%"PRId64" RM%u", n_ack, n); } else { @@ -856,7 +856,7 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac rn->seq = wr->seq; } ut_avlAugmentUpdate (&wr_readers_treedef, rn); - NN_WARNING ("writer %x:%x:%x:%x considering reader %x:%x:%x:%x responsive again\n", PGUID (wr->e.guid), PGUID (rn->prd_guid)); + DDS_WARNING("writer %x:%x:%x:%x considering reader %x:%x:%x:%x responsive again\n", PGUID (wr->e.guid), PGUID (rn->prd_guid)); } /* Second, the NACK bits (literally, that is). To do so, attempt to @@ -868,7 +868,7 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac max_seq_in_reply = 0; if (!rn->has_replied_to_hb && seqbase > 1 && is_pure_nonhist_ack) { - TRACE ((" setting-has-replied-to-hb")); + DDS_TRACE(" setting-has-replied-to-hb"); rn->has_replied_to_hb = 1; /* walk the whole tree to ensure all proxy readers for this writer have their unack'ed info updated */ @@ -882,16 +882,16 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac reader start-up and we respond with a heartbeat and, if we have data in our WHC, we start sending it regardless of whether the remote reader asked for it */ - TRACE ((" preemptive-nack")); + DDS_TRACE(" preemptive-nack"); if (WHCST_ISEMPTY(&whcst)) { - TRACE ((" whc-empty ")); + DDS_TRACE(" whc-empty "); force_heartbeat_to_peer (wr, &whcst, prd, 0); hb_sent_in_response = 1; } else { - TRACE ((" rebase ")); + DDS_TRACE(" rebase "); force_heartbeat_to_peer (wr, &whcst, prd, 0); hb_sent_in_response = 1; numbits = config.accelerate_rexmit_block_size; @@ -907,19 +907,19 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac that doesn't play too nicely with this. */ if (is_pure_nonhist_ack) { - TRACE ((" happy-now")); + DDS_TRACE(" happy-now"); rn->assumed_in_sync = 1; } else if (msg->readerSNState.numbits < config.accelerate_rexmit_block_size) { - TRACE ((" accelerating")); + DDS_TRACE(" accelerating"); accelerate_rexmit = 1; if (accelerate_rexmit && numbits < config.accelerate_rexmit_block_size) numbits = config.accelerate_rexmit_block_size; } else { - TRACE ((" complying")); + DDS_TRACE(" complying"); } } /* Retransmit requested messages, including whatever we decided to @@ -955,7 +955,7 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac nn_mtime_t tstamp = now_mt (); if (tstamp.v > sample.last_rexmit_ts.v + config.retransmit_merging_period) { - TRACE ((" RX%"PRId64, seqbase + i)); + DDS_TRACE(" RX%"PRId64, seqbase + i); enqueued = (enqueue_sample_wrlock_held (wr, seq, sample.plist, sample.serdata, NULL, 0) >= 0); if (enqueued) { @@ -966,13 +966,13 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac } else { - TRACE ((" RX%"PRId64" (merged)", seqbase + i)); + DDS_TRACE(" RX%"PRId64" (merged)", seqbase + i); } } else { /* no merging, send directed retransmit */ - TRACE ((" RX%"PRId64"", seqbase + i)); + DDS_TRACE(" RX%"PRId64"", seqbase + i); enqueued = (enqueue_sample_wrlock_held (wr, seq, sample.plist, sample.serdata, prd, 0) >= 0); if (enqueued) { @@ -986,21 +986,21 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac } else if (gapstart == -1) { - TRACE ((" M%"PRId64, seqbase + i)); + DDS_TRACE(" M%"PRId64, seqbase + i); gapstart = seqbase + i; gapend = gapstart + 1; msgs_lost++; } else if (seqbase + i == gapend) { - TRACE ((" M%"PRId64, seqbase + i)); + DDS_TRACE(" M%"PRId64, seqbase + i); gapend = seqbase + i + 1; msgs_lost++; } else if (seqbase + i - gapend < 256) { unsigned idx = (unsigned) (seqbase + i - gapend); - TRACE ((" M%"PRId64, seqbase + i)); + DDS_TRACE(" M%"PRId64, seqbase + i); gapnumbits = idx + 1; nn_bitset_set (gapnumbits, gapbits, idx); msgs_lost++; @@ -1008,7 +1008,7 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac } } if (!enqueued) - TRACE ((" rexmit-limit-hit")); + DDS_TRACE(" rexmit-limit-hit"); /* Generate a Gap message if some of the sequence is missing */ if (gapstart > 0) { @@ -1033,9 +1033,9 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac that. */ if (gapend-1 + gapnumbits > max_seq_in_reply) max_seq_in_reply = gapend-1 + gapnumbits; - TRACE ((" XGAP%"PRId64"..%"PRId64"/%u:", gapstart, gapend, gapnumbits)); + DDS_TRACE(" XGAP%"PRId64"..%"PRId64"/%u:", gapstart, gapend, gapnumbits); for (i = 0; i < gapnumbits; i++) - TRACE (("%c", nn_bitset_isset (gapnumbits, gapbits, i) ? '1' : '0')); + DDS_TRACE("%c", nn_bitset_isset (gapnumbits, gapbits, i) ? '1' : '0'); m = nn_xmsg_new (gv.xmsgpool, &wr->e.guid.prefix, 0, NN_XMSG_KIND_CONTROL); #ifdef DDSI_INCLUDE_NETWORK_PARTITIONS nn_xmsg_setencoderid (m, wr->partition_id); @@ -1058,7 +1058,7 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac it might ... [NB writer->seq is the last msg sent so far] */ if (msgs_sent && max_seq_in_reply < seq_xmit) { - TRACE ((" rexmit#%"PRIu32" maxseq:%"PRId64"<%"PRId64"<=%"PRId64"", msgs_sent, max_seq_in_reply, seq_xmit, wr->seq)); + DDS_TRACE(" rexmit#%"PRIu32" maxseq:%"PRId64"<%"PRId64"<=%"PRId64"", msgs_sent, max_seq_in_reply, seq_xmit, wr->seq); force_heartbeat_to_peer (wr, &whcst, prd, 1); hb_sent_in_response = 1; @@ -1073,7 +1073,7 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac now if we haven't done so already */ if (!(msg->smhdr.flags & ACKNACK_FLAG_FINAL) && !hb_sent_in_response) force_heartbeat_to_peer (wr, &whcst, prd, 0); - TRACE ((")")); + DDS_TRACE(")"); out: os_mutexUnlock (&wr->e.lock); whc_free_deferred_free_list (wr->whc, deferred_free_list); @@ -1148,7 +1148,7 @@ static void handle_Heartbeat_helper (struct pwr_rd_match * const wn, struct hand /* Not supposed to respond to repeats and old heartbeats. */ if (!accept_ack_or_hb_w_timeout (msg->count, &wn->next_heartbeat, arg->tnow, &wn->t_heartbeat_accepted, 0)) { - TRACE ((" (%x:%x:%x:%x)", PGUID (wn->rd_guid))); + DDS_TRACE(" (%x:%x:%x:%x)", PGUID (wn->rd_guid)); return; } @@ -1159,7 +1159,7 @@ static void handle_Heartbeat_helper (struct pwr_rd_match * const wn, struct hand refseq = nn_reorder_next_seq (pwr->reorder) - 1; else refseq = nn_reorder_next_seq (wn->u.not_in_sync.reorder) - 1; - TRACE ((" %x:%x:%x:%x@%"PRId64"%s", PGUID (wn->rd_guid), refseq, (wn->in_sync == PRMSS_SYNC) ? "(sync)" : (wn->in_sync == PRMSS_TLCATCHUP) ? "(tlcatchup)" : "")); + DDS_TRACE(" %x:%x:%x:%x@%"PRId64"%s", PGUID (wn->rd_guid), refseq, (wn->in_sync == PRMSS_SYNC) ? "(sync)" : (wn->in_sync == PRMSS_TLCATCHUP) ? "(tlcatchup)" : ""); /* Reschedule AckNack transmit if deemed appropriate; unreliable readers have acknack_xevent == NULL and can't do this. @@ -1174,13 +1174,13 @@ static void handle_Heartbeat_helper (struct pwr_rd_match * const wn, struct hand tsched.v = T_NEVER; if (pwr->last_seq > refseq) { - TRACE (("/NAK")); + DDS_TRACE("/NAK"); if (arg->tnow_mt.v >= wn->t_last_nack.v + config.nack_delay || refseq >= wn->seq_last_nack) tsched = arg->tnow_mt; else { tsched.v = arg->tnow_mt.v + config.nack_delay; - TRACE (("d")); + DDS_TRACE("d"); } } else if (!(msg->smhdr.flags & HEARTBEAT_FLAG_FINAL)) @@ -1218,18 +1218,18 @@ static int handle_Heartbeat (struct receiver_state *rst, nn_etime_t tnow, struct dst.prefix = rst->dst_guid_prefix; dst.entityid = msg->readerId; - TRACE (("HEARTBEAT(%s#%d:%"PRId64"..%"PRId64" ", msg->smhdr.flags & HEARTBEAT_FLAG_FINAL ? "F" : "", - msg->count, firstseq, fromSN (msg->lastSN))); + DDS_TRACE("HEARTBEAT(%s#%d:%"PRId64"..%"PRId64" ", msg->smhdr.flags & HEARTBEAT_FLAG_FINAL ? "F" : "", + msg->count, firstseq, fromSN (msg->lastSN)); if (!rst->forme) { - TRACE (("%x:%x:%x:%x -> %x:%x:%x:%x not-for-me)", PGUID (src), PGUID (dst))); + DDS_TRACE("%x:%x:%x:%x -> %x:%x:%x:%x not-for-me)", PGUID (src), PGUID (dst)); return 1; } if ((pwr = ephash_lookup_proxy_writer_guid (&src)) == NULL) { - TRACE (("%x:%x:%x:%x? -> %x:%x:%x:%x)", PGUID (src), PGUID (dst))); + DDS_TRACE("%x:%x:%x:%x? -> %x:%x:%x:%x)", PGUID (src), PGUID (dst)); return 1; } @@ -1237,7 +1237,7 @@ static int handle_Heartbeat (struct receiver_state *rst, nn_etime_t tnow, struct if (pwr->assert_pp_lease) lease_renew (os_atomic_ldvoidp (&pwr->c.proxypp->lease), tnow); - TRACE (("%x:%x:%x:%x -> %x:%x:%x:%x:", PGUID (src), PGUID (dst))); + DDS_TRACE("%x:%x:%x:%x -> %x:%x:%x:%x:", PGUID (src), PGUID (dst)); os_mutexLock (&pwr->e.lock); @@ -1297,7 +1297,7 @@ static int handle_Heartbeat (struct receiver_state *rst, nn_etime_t tnow, struct if (wn->u.not_in_sync.end_of_tl_seq == MAX_SEQ_NUMBER) { wn->u.not_in_sync.end_of_tl_seq = fromSN (msg->lastSN); - TRACE ((" end-of-tl-seq(rd %x:%x:%x:%x #%"PRId64")", PGUID(wn->rd_guid), wn->u.not_in_sync.end_of_tl_seq)); + DDS_TRACE(" end-of-tl-seq(rd %x:%x:%x:%x #%"PRId64")", PGUID(wn->rd_guid), wn->u.not_in_sync.end_of_tl_seq); } maybe_set_reader_in_sync (pwr, wn, last_deliv_seq); } @@ -1311,7 +1311,7 @@ static int handle_Heartbeat (struct receiver_state *rst, nn_etime_t tnow, struct arg.tnow = tnow; arg.tnow_mt = now_mt (); handle_forall_destinations (&dst, pwr, (ut_avlWalk_t) handle_Heartbeat_helper, &arg); - TRACE ((")")); + DDS_TRACE(")"); os_mutexUnlock (&pwr->e.lock); return 1; @@ -1329,16 +1329,16 @@ static int handle_HeartbeatFrag (struct receiver_state *rst, UNUSED_ARG(nn_etime dst.prefix = rst->dst_guid_prefix; dst.entityid = msg->readerId; - TRACE (("HEARTBEATFRAG(#%d:%"PRId64"/[1,%u]", msg->count, seq, fragnum+1)); + DDS_TRACE("HEARTBEATFRAG(#%d:%"PRId64"/[1,%u]", msg->count, seq, fragnum+1); if (!rst->forme) { - TRACE ((" %x:%x:%x:%x -> %x:%x:%x:%x not-for-me)", PGUID (src), PGUID (dst))); + DDS_TRACE(" %x:%x:%x:%x -> %x:%x:%x:%x not-for-me)", PGUID (src), PGUID (dst)); return 1; } if ((pwr = ephash_lookup_proxy_writer_guid (&src)) == NULL) { - TRACE ((" %x:%x:%x:%x? -> %x:%x:%x:%x)", PGUID (src), PGUID (dst))); + DDS_TRACE(" %x:%x:%x:%x? -> %x:%x:%x:%x)", PGUID (src), PGUID (dst)); return 1; } @@ -1346,7 +1346,7 @@ static int handle_HeartbeatFrag (struct receiver_state *rst, UNUSED_ARG(nn_etime if (pwr->assert_pp_lease) lease_renew (os_atomic_ldvoidp (&pwr->c.proxypp->lease), tnow); - TRACE ((" %x:%x:%x:%x -> %x:%x:%x:%x", PGUID (src), PGUID (dst))); + DDS_TRACE(" %x:%x:%x:%x -> %x:%x:%x:%x", PGUID (src), PGUID (dst)); os_mutexLock (&pwr->e.lock); if (seq > pwr->last_seq) @@ -1367,7 +1367,7 @@ static int handle_HeartbeatFrag (struct receiver_state *rst, UNUSED_ARG(nn_etime handle_Heartbeat's scheduling of an AckNack event when it must respond. Why? Just because. */ if (ut_avlIsEmpty (&pwr->readers) || pwr->local_matching_inprogress) - TRACE ((" no readers")); + DDS_TRACE(" no readers"); else { struct pwr_rd_match *m = NULL; @@ -1405,7 +1405,7 @@ static int handle_HeartbeatFrag (struct receiver_state *rst, UNUSED_ARG(nn_etime } if (m == NULL) - TRACE ((" no interested reliable readers")); + DDS_TRACE(" no interested reliable readers"); else { /* Check if we are missing something */ @@ -1418,12 +1418,12 @@ static int handle_HeartbeatFrag (struct receiver_state *rst, UNUSED_ARG(nn_etime /* Yes we are (note that this potentially also happens for samples we no longer care about) */ int64_t delay = config.nack_delay; - TRACE (("/nackfrag")); + DDS_TRACE("/nackfrag"); resched_xevent_if_earlier (m->acknack_xevent, add_duration_to_mtime (now_mt(), delay)); } } } - TRACE ((")")); + DDS_TRACE(")"); os_mutexUnlock (&pwr->e.lock); return 1; } @@ -1445,19 +1445,19 @@ static int handle_NackFrag (struct receiver_state *rst, nn_etime_t tnow, const N dst.prefix = rst->dst_guid_prefix; dst.entityid = msg->writerId; - TRACE (("NACKFRAG(#%d:%"PRId64"/%u/%u:", *countp, seq, msg->fragmentNumberState.bitmap_base, msg->fragmentNumberState.numbits)); + DDS_TRACE("NACKFRAG(#%d:%"PRId64"/%u/%u:", *countp, seq, msg->fragmentNumberState.bitmap_base, msg->fragmentNumberState.numbits); for (i = 0; i < msg->fragmentNumberState.numbits; i++) - TRACE (("%c", nn_bitset_isset (msg->fragmentNumberState.numbits, msg->fragmentNumberState.bits, i) ? '1' : '0')); + DDS_TRACE("%c", nn_bitset_isset (msg->fragmentNumberState.numbits, msg->fragmentNumberState.bits, i) ? '1' : '0'); if (!rst->forme) { - TRACE ((" %x:%x:%x:%x -> %x:%x:%x:%x not-for-me)", PGUID (src), PGUID (dst))); + DDS_TRACE(" %x:%x:%x:%x -> %x:%x:%x:%x not-for-me)", PGUID (src), PGUID (dst)); return 1; } if ((wr = ephash_lookup_writer_guid (&dst)) == NULL) { - TRACE ((" %x:%x:%x:%x -> %x:%x:%x:%x?)", PGUID (src), PGUID (dst))); + DDS_TRACE(" %x:%x:%x:%x -> %x:%x:%x:%x?)", PGUID (src), PGUID (dst)); return 1; } /* Always look up the proxy reader -- even though we don't need for @@ -1466,7 +1466,7 @@ static int handle_NackFrag (struct receiver_state *rst, nn_etime_t tnow, const N only retrieve it when needed. */ if ((prd = ephash_lookup_proxy_reader_guid (&src)) == NULL) { - TRACE ((" %x:%x:%x:%x? -> %x:%x:%x:%x)", PGUID (src), PGUID (dst))); + DDS_TRACE(" %x:%x:%x:%x? -> %x:%x:%x:%x)", PGUID (src), PGUID (dst)); return 1; } @@ -1476,25 +1476,25 @@ static int handle_NackFrag (struct receiver_state *rst, nn_etime_t tnow, const N if (!wr->reliable) /* note: reliability can't be changed */ { - TRACE ((" %x:%x:%x:%x -> %x:%x:%x:%x not a reliable writer)", PGUID (src), PGUID (dst))); + DDS_TRACE(" %x:%x:%x:%x -> %x:%x:%x:%x not a reliable writer)", PGUID (src), PGUID (dst)); return 1; } os_mutexLock (&wr->e.lock); if ((rn = ut_avlLookup (&wr_readers_treedef, &wr->readers, &src)) == NULL) { - TRACE ((" %x:%x:%x:%x -> %x:%x:%x:%x not a connection", PGUID (src), PGUID (dst))); + DDS_TRACE(" %x:%x:%x:%x -> %x:%x:%x:%x not a connection", PGUID (src), PGUID (dst)); goto out; } /* Ignore old NackFrags (see also handle_AckNack) */ if (*countp < rn->next_nackfrag) { - TRACE ((" [%x:%x:%x:%x -> %x:%x:%x:%x]", PGUID (src), PGUID (dst))); + DDS_TRACE(" [%x:%x:%x:%x -> %x:%x:%x:%x]", PGUID (src), PGUID (dst)); goto out; } rn->next_nackfrag = *countp + 1; - TRACE ((" %x:%x:%x:%x -> %x:%x:%x:%x", PGUID (src), PGUID (dst))); + DDS_TRACE(" %x:%x:%x:%x -> %x:%x:%x:%x", PGUID (src), PGUID (dst)); /* Resend the requested fragments if we still have the sample, send a Gap if we don't have them anymore. */ @@ -1502,7 +1502,7 @@ static int handle_NackFrag (struct receiver_state *rst, nn_etime_t tnow, const N { const unsigned base = msg->fragmentNumberState.bitmap_base - 1; int enqueued = 1; - TRACE ((" scheduling requested frags ...\n")); + DDS_TRACE(" scheduling requested frags ...\n"); for (i = 0; i < msg->fragmentNumberState.numbits && enqueued; i++) { if (nn_bitset_isset (msg->fragmentNumberState.numbits, msg->fragmentNumberState.bits, i)) @@ -1520,7 +1520,7 @@ static int handle_NackFrag (struct receiver_state *rst, nn_etime_t tnow, const N { static unsigned zero = 0; struct nn_xmsg *m; - TRACE ((" msg not available: scheduling Gap\n")); + DDS_TRACE(" msg not available: scheduling Gap\n"); m = nn_xmsg_new (gv.xmsgpool, &wr->e.guid.prefix, 0, NN_XMSG_KIND_CONTROL); #ifdef DDSI_INCLUDE_NETWORK_PARTITIONS nn_xmsg_setencoderid (m, wr->partition_id); @@ -1548,14 +1548,14 @@ static int handle_NackFrag (struct receiver_state *rst, nn_etime_t tnow, const N out: os_mutexUnlock (&wr->e.lock); - TRACE ((")")); + DDS_TRACE(")"); return 1; } static int handle_InfoDST (struct receiver_state *rst, const InfoDST_t *msg, const nn_guid_prefix_t *dst_prefix) { rst->dst_guid_prefix = nn_ntoh_guid_prefix (msg->guid_prefix); - TRACE (("INFODST(%x:%x:%x)", PGUIDPREFIX (rst->dst_guid_prefix))); + DDS_TRACE("INFODST(%x:%x:%x)", PGUIDPREFIX (rst->dst_guid_prefix)); if (rst->dst_guid_prefix.u[0] == 0 && rst->dst_guid_prefix.u[1] == 0 && rst->dst_guid_prefix.u[2] == 0) { if (dst_prefix) @@ -1577,29 +1577,29 @@ static int handle_InfoSRC (struct receiver_state *rst, const InfoSRC_t *msg) rst->src_guid_prefix = nn_ntoh_guid_prefix (msg->guid_prefix); rst->protocol_version = msg->version; rst->vendor = msg->vendorid; - TRACE (("INFOSRC(%x:%x:%x vendor %u.%u)", - PGUIDPREFIX (rst->src_guid_prefix), rst->vendor.id[0], rst->vendor.id[1])); + DDS_TRACE("INFOSRC(%x:%x:%x vendor %u.%u)", + PGUIDPREFIX (rst->src_guid_prefix), rst->vendor.id[0], rst->vendor.id[1]); return 1; } static int handle_InfoTS (const InfoTS_t *msg, nn_ddsi_time_t *timestamp) { - TRACE (("INFOTS(")); + DDS_TRACE("INFOTS("); if (msg->smhdr.flags & INFOTS_INVALIDATE_FLAG) { *timestamp = invalid_ddsi_timestamp; - TRACE (("invalidate")); + DDS_TRACE("invalidate"); } else { *timestamp = msg->time; - if (config.enabled_logcats & LC_TRACE) + if (dds_get_log_mask() & DDS_LC_TRACE) { nn_wctime_t t = nn_wctime_from_ddsi_time (* timestamp); - TRACE (("%d.%09d", (int) (t.v / 1000000000), (int) (t.v % 1000000000))); + DDS_TRACE("%d.%09d", (int) (t.v / 1000000000), (int) (t.v % 1000000000)); } } - TRACE ((")")); + DDS_TRACE(")"); return 1; } @@ -1696,7 +1696,7 @@ static int handle_Gap (struct receiver_state *rst, nn_etime_t tnow, struct nn_rm dst.entityid = msg->readerId; gapstart = fromSN (msg->gapStart); listbase = fromSN (msg->gapList.bitmap_base); - TRACE (("GAP(%"PRId64"..%"PRId64"/%u ", gapstart, listbase, msg->gapList.numbits)); + DDS_TRACE("GAP(%"PRId64"..%"PRId64"/%u ", gapstart, listbase, msg->gapList.numbits); /* There is no _good_ reason for a writer to start the bitmap with a 1 bit, but check for it just in case, to reduce the number of @@ -1708,13 +1708,13 @@ static int handle_Gap (struct receiver_state *rst, nn_etime_t tnow, struct nn_rm if (!rst->forme) { - TRACE (("%x:%x:%x:%x -> %x:%x:%x:%x not-for-me)", PGUID (src), PGUID (dst))); + DDS_TRACE("%x:%x:%x:%x -> %x:%x:%x:%x not-for-me)", PGUID (src), PGUID (dst)); return 1; } if ((pwr = ephash_lookup_proxy_writer_guid (&src)) == NULL) { - TRACE (("%x:%x:%x:%x? -> %x:%x:%x:%x)", PGUID (src), PGUID (dst))); + DDS_TRACE("%x:%x:%x:%x? -> %x:%x:%x:%x)", PGUID (src), PGUID (dst)); return 1; } @@ -1725,11 +1725,11 @@ static int handle_Gap (struct receiver_state *rst, nn_etime_t tnow, struct nn_rm os_mutexLock (&pwr->e.lock); if ((wn = ut_avlLookup (&pwr_readers_treedef, &pwr->readers, &dst)) == NULL) { - TRACE (("%x:%x:%x:%x -> %x:%x:%x:%x not a connection)", PGUID (src), PGUID (dst))); + DDS_TRACE("%x:%x:%x:%x -> %x:%x:%x:%x not a connection)", PGUID (src), PGUID (dst)); os_mutexUnlock (&pwr->e.lock); return 1; } - TRACE (("%x:%x:%x:%x -> %x:%x:%x:%x", PGUID (src), PGUID (dst))); + DDS_TRACE("%x:%x:%x:%x -> %x:%x:%x:%x", PGUID (src), PGUID (dst)); /* Notify reordering in proxy writer & and the addressed reader (if it is out-of-sync, &c.), while delivering samples that become @@ -1779,7 +1779,7 @@ static int handle_Gap (struct receiver_state *rst, nn_etime_t tnow, struct nn_rm pwr->last_fragnum = ~0u; pwr->last_fragnum_reset = 0; } - TRACE ((")")); + DDS_TRACE(")"); os_mutexUnlock (&pwr->e.lock); return 1; } @@ -1810,11 +1810,11 @@ static struct ddsi_serdata *extract_sample_from_data { const struct proxy_writer *pwr = sampleinfo->pwr; nn_guid_t guid = pwr ? pwr->e.guid : null_guid; /* can't be null _yet_, but that might change some day */ - TRACE (("data(application, vendor %u.%u): %x:%x:%x:%x #%"PRId64 + DDS_TRACE("data(application, vendor %u.%u): %x:%x:%x:%x #%"PRId64 ": write without proper payload (data_smhdr_flags 0x%x size %u)\n", sampleinfo->rst->vendor.id[0], sampleinfo->rst->vendor.id[1], PGUID (guid), sampleinfo->seq, - data_smhdr_flags, sampleinfo->size)); + data_smhdr_flags, sampleinfo->size); return NULL; } sample = get_serdata (topic, fragchain, sampleinfo->size, 0, statusinfo, tstamp); @@ -1859,7 +1859,7 @@ static struct ddsi_serdata *extract_sample_from_data /* No message => error out */ const struct proxy_writer *pwr = sampleinfo->pwr; nn_guid_t guid = pwr ? pwr->e.guid : null_guid; /* can't be null _yet_, but that might change some day */ - NN_WARNING + DDS_WARNING ( "data(application, vendor %u.%u): %x:%x:%x:%x #%"PRId64": deserialization %s/%s failed (%s)\n", sampleinfo->rst->vendor.id[0], sampleinfo->rst->vendor.id[1], @@ -1965,7 +1965,7 @@ static int deliver_user_data (const struct nn_rsample_info *sampleinfo, const st src.bufsz = NN_RDATA_PAYLOAD_OFF (fragchain) - qos_offset; if (nn_plist_init_frommsg (&qos, NULL, PP_STATUSINFO | PP_KEYHASH | PP_COHERENT_SET | PP_PRISMTECH_EOTINFO, 0, &src) < 0) { - NN_WARNING ("data(application, vendor %u.%u): %x:%x:%x:%x #%"PRId64": invalid inline qos\n", + DDS_WARNING ("data(application, vendor %u.%u): %x:%x:%x:%x #%"PRId64": invalid inline qos\n", src.vendorid.id[0], src.vendorid.id[1], PGUID (pwr->e.guid), sampleinfo->seq); return 0; } @@ -2004,7 +2004,7 @@ static int deliver_user_data (const struct nn_rsample_info *sampleinfo, const st if (rdguid == NULL) { - TRACE ((" %"PRId64"=>EVERYONE\n", sampleinfo->seq)); + DDS_TRACE(" %"PRId64"=>EVERYONE\n", sampleinfo->seq); /* FIXME: pwr->rdary is an array of pointers to attached readers. There's only one thread delivering data for the @@ -2024,7 +2024,7 @@ retry: unsigned i; for (i = 0; rdary[i]; i++) { - TRACE (("reader %x:%x:%x:%x\n", PGUID (rdary[i]->e.guid))); + DDS_TRACE("reader %x:%x:%x:%x\n", PGUID (rdary[i]->e.guid)); if (! (ddsi_plugin.rhc_plugin.rhc_store_fn) (rdary[i]->rhc, &pwr_info, payload, tk)) { if (pwr_locked) os_mutexUnlock (&pwr->e.lock); @@ -2055,7 +2055,7 @@ retry: struct reader *rd; if ((rd = ephash_lookup_reader_guid (&m->rd_guid)) != NULL) { - TRACE (("reader-via-guid %x:%x:%x:%x\n", PGUID (rd->e.guid))); + DDS_TRACE("reader-via-guid %x:%x:%x:%x\n", PGUID (rd->e.guid)); (void) (ddsi_plugin.rhc_plugin.rhc_store_fn) (rd->rhc, &pwr_info, payload, tk); } } @@ -2067,7 +2067,7 @@ retry: else { struct reader *rd = ephash_lookup_reader_guid (rdguid);; - TRACE ((" %"PRId64"=>%x:%x:%x:%x%s\n", sampleinfo->seq, PGUID (*rdguid), rd ? "" : "?")); + DDS_TRACE(" %"PRId64"=>%x:%x:%x:%x%s\n", sampleinfo->seq, PGUID (*rdguid), rd ? "" : "?"); while (rd && ! (ddsi_plugin.rhc_plugin.rhc_store_fn) (rd->rhc, &pwr_info, payload, tk) && ephash_lookup_proxy_writer_guid (&pwr->e.guid)) { if (pwr_locked) os_mutexUnlock (&pwr->e.lock); @@ -2140,7 +2140,7 @@ static void handle_regular (struct receiver_state *rst, nn_etime_t tnow, struct nn_guid_t src; src.prefix = rst->src_guid_prefix; src.entityid = msg->writerId; - TRACE ((" %x:%x:%x:%x? -> %x:%x:%x:%x", PGUID (src), PGUID (dst))); + DDS_TRACE(" %x:%x:%x:%x? -> %x:%x:%x:%x", PGUID (src), PGUID (dst)); return; } @@ -2157,7 +2157,7 @@ static void handle_regular (struct receiver_state *rst, nn_etime_t tnow, struct if (ut_avlIsEmpty (&pwr->readers) || pwr->local_matching_inprogress) { os_mutexUnlock (&pwr->e.lock); - TRACE ((" %x:%x:%x:%x -> %x:%x:%x:%x: no readers", PGUID (pwr->e.guid), PGUID (dst))); + DDS_TRACE(" %x:%x:%x:%x -> %x:%x:%x:%x: no readers", PGUID (pwr->e.guid), PGUID (dst)); return; } @@ -2301,7 +2301,7 @@ static void drop_oversize (struct receiver_state *rst, struct nn_rmsg *rmsg, con cause periodic warnings. */ if (msg->writerId.u == NN_ENTITYID_SPDP_BUILTIN_PARTICIPANT_WRITER) { - NN_WARNING ("dropping oversize (%u > %u) SPDP sample %"PRId64" from remote writer %x:%x:%x:%x\n", + DDS_WARNING ("dropping oversize (%u > %u) SPDP sample %"PRId64" from remote writer %x:%x:%x:%x\n", sampleinfo->size, config.max_sample_size, sampleinfo->seq, PGUIDPREFIX (rst->src_guid_prefix), msg->writerId.u); } @@ -2331,7 +2331,7 @@ static void drop_oversize (struct receiver_state *rst, struct nn_rmsg *rmsg, con { const char *tname = pwr->c.topic ? pwr->c.topic->name : "(null)"; const char *ttname = pwr->c.topic ? pwr->c.topic->typename : "(null)"; - NN_WARNING ("dropping oversize (%u > %u) sample %"PRId64" from remote writer %x:%x:%x:%x %s/%s\n", + DDS_WARNING ("dropping oversize (%u > %u) sample %"PRId64" from remote writer %x:%x:%x:%x %s/%s\n", sampleinfo->size, config.max_sample_size, sampleinfo->seq, PGUIDPREFIX (rst->src_guid_prefix), msg->writerId.u, tname, ttname); @@ -2341,13 +2341,13 @@ static void drop_oversize (struct receiver_state *rst, struct nn_rmsg *rmsg, con static int handle_Data (struct receiver_state *rst, nn_etime_t tnow, struct nn_rmsg *rmsg, const Data_t *msg, size_t size, struct nn_rsample_info *sampleinfo, unsigned char *datap) { - TRACE (("DATA(%x:%x:%x:%x -> %x:%x:%x:%x #%"PRId64"", + DDS_TRACE("DATA(%x:%x:%x:%x -> %x:%x:%x:%x #%"PRId64"", PGUIDPREFIX (rst->src_guid_prefix), msg->x.writerId.u, PGUIDPREFIX (rst->dst_guid_prefix), msg->x.readerId.u, - fromSN (msg->x.writerSN))); + fromSN (msg->x.writerSN)); if (!rst->forme) { - TRACE ((" not-for-me)")); + DDS_TRACE(" not-for-me)"); return 1; } @@ -2379,20 +2379,20 @@ static int handle_Data (struct receiver_state *rst, nn_etime_t tnow, struct nn_r handle_regular (rst, tnow, rmsg, &msg->x, sampleinfo, ~0u, rdata); } } - TRACE ((")")); + DDS_TRACE(")"); return 1; } static int handle_DataFrag (struct receiver_state *rst, nn_etime_t tnow, struct nn_rmsg *rmsg, const DataFrag_t *msg, size_t size, struct nn_rsample_info *sampleinfo, unsigned char *datap) { - TRACE (("DATAFRAG(%x:%x:%x:%x -> %x:%x:%x:%x #%"PRId64"/[%u..%u]", + DDS_TRACE("DATAFRAG(%x:%x:%x:%x -> %x:%x:%x:%x #%"PRId64"/[%u..%u]", PGUIDPREFIX (rst->src_guid_prefix), msg->x.writerId.u, PGUIDPREFIX (rst->dst_guid_prefix), msg->x.readerId.u, fromSN (msg->x.writerSN), - msg->fragmentStartingNum, msg->fragmentStartingNum + msg->fragmentsInSubmessage - 1)); + msg->fragmentStartingNum, msg->fragmentStartingNum + msg->fragmentsInSubmessage - 1); if (!rst->forme) { - TRACE ((" not-for-me)")); + DDS_TRACE(" not-for-me)"); return 1; } @@ -2405,7 +2405,7 @@ static int handle_DataFrag (struct receiver_state *rst, nn_etime_t tnow, struct uint32_t begin, endp1; if (msg->x.writerId.u == NN_ENTITYID_SPDP_BUILTIN_PARTICIPANT_WRITER) { - NN_WARNING ("DATAFRAG(%x:%x:%x:%x #%"PRId64" -> %x:%x:%x:%x) - fragmented builtin data not yet supported\n", + DDS_WARNING ("DATAFRAG(%x:%x:%x:%x #%"PRId64" -> %x:%x:%x:%x) - fragmented builtin data not yet supported\n", PGUIDPREFIX (rst->src_guid_prefix), msg->x.writerId.u, fromSN (msg->x.writerSN), PGUIDPREFIX (rst->dst_guid_prefix), msg->x.readerId.u); return 1; @@ -2438,7 +2438,7 @@ static int handle_DataFrag (struct receiver_state *rst, nn_etime_t tnow, struct here */ endp1 = msg->sampleSize; } - TRACE (("/[%u..%u) of %u", begin, endp1, msg->sampleSize)); + DDS_TRACE("/[%u..%u) of %u", begin, endp1, msg->sampleSize); rdata = nn_rdata_new (rmsg, begin, endp1, submsg_offset, payload_offset); @@ -2451,7 +2451,7 @@ static int handle_DataFrag (struct receiver_state *rst, nn_etime_t tnow, struct dealing with that. */ handle_regular (rst, tnow, rmsg, &msg->x, sampleinfo, msg->fragmentStartingNum + msg->fragmentsInSubmessage - 2, rdata); } - TRACE ((")")); + DDS_TRACE(")"); return 1; } @@ -2490,7 +2490,7 @@ static void malformed_packet_received_nosubmsg if (pos < sizeof (tmp)) pos += (size_t) snprintf (tmp + pos, sizeof (tmp) - pos, "> (note: maybe partially bswap'd)"); assert (pos < sizeof (tmp)); - NN_WARNING ("%s\n", tmp); + DDS_WARNING ("%s\n", tmp); } static void malformed_packet_received @@ -2597,7 +2597,7 @@ static void malformed_packet_received break; } - NN_WARNING ("%s\n", tmp); + DDS_WARNING ("%s\n", tmp); } static struct receiver_state *rst_cow_if_needed (int *rst_live, struct nn_rmsg *rmsg, struct receiver_state *rst) @@ -2696,11 +2696,11 @@ static int handle_submsg_sequence { submsg_size = (unsigned) (end - submsg); } - /*LC_TRACE (("submsg_size %d\n", submsg_size));*/ + /*DDS_TRACE(("submsg_size %d\n", submsg_size));*/ if (submsg + submsg_size > end) { - TRACE ((" BREAK (%u %"PRIuSIZE": %p %u)\n", (unsigned) (submsg - msg), submsg_size, msg, (unsigned) len)); + DDS_TRACE(" BREAK (%u %"PRIuSIZE": %p %u)\n", (unsigned) (submsg - msg), submsg_size, msg, (unsigned) len); break; } @@ -2709,7 +2709,7 @@ static int handle_submsg_sequence switch (sm->smhdr.submessageId) { case SMID_PAD: - TRACE (("PAD")); + DDS_TRACE("PAD"); break; case SMID_ACKNACK: state = "parse:acknack"; @@ -2756,7 +2756,7 @@ static int handle_submsg_sequence #if 0 state = "parse:info_reply_ip4"; #endif - TRACE (("INFO_REPLY_IP4")); + DDS_TRACE("INFO_REPLY_IP4"); /* no effect on ts_for_latmeas */ break; case SMID_INFO_DST: @@ -2771,7 +2771,7 @@ static int handle_submsg_sequence #if 0 state = "parse:info_reply"; #endif - TRACE (("INFO_REPLY")); + DDS_TRACE("INFO_REPLY"); /* no effect on ts_for_latmeas */ break; case SMID_NACK_FRAG: @@ -2825,7 +2825,7 @@ static int handle_submsg_sequence if (is_own_vendor (rst->vendor) || vendor_is_lite(rst->vendor)) { state = "parse:pt_info_container"; - TRACE (("PT_INFO_CONTAINER(")); + DDS_TRACE("PT_INFO_CONTAINER("); if (!valid_PT_InfoContainer (&sm->pt_infocontainer, submsg_size, byteswap)) goto malformed; switch (sm->pt_infocontainer.id) @@ -2849,7 +2849,7 @@ static int handle_submsg_sequence #endif /* DDSI_INCLUDE_ENCRYPTION */ break; default: - TRACE (("(unknown id %u?)\n", sm->pt_infocontainer.id)); + DDS_TRACE("(unknown id %u?)\n", sm->pt_infocontainer.id); } } break; @@ -2858,7 +2858,7 @@ static int handle_submsg_sequence #if 0 state = "parse:msg_len"; #endif - TRACE (("MSG_LEN(%u)", ((MsgLen_t*) sm)->length)); + DDS_TRACE("MSG_LEN(%u)", ((MsgLen_t*) sm)->length); break; } case SMID_PT_ENTITY_ID: @@ -2866,12 +2866,12 @@ static int handle_submsg_sequence #if 0 state = "parse:entity_id"; #endif - TRACE (("ENTITY_ID")); + DDS_TRACE("ENTITY_ID"); break; } default: state = "parse:undefined"; - TRACE (("UNDEFINED(%x)", sm->smhdr.submessageId)); + DDS_TRACE("UNDEFINED(%x)", sm->smhdr.submessageId); if (sm->smhdr.submessageId <= 0x7f) { /* Other submessages in the 0 .. 0x7f range may be added in @@ -2900,13 +2900,13 @@ static int handle_submsg_sequence break; } submsg += submsg_size; - TRACE (("\n")); + DDS_TRACE("\n"); } if (submsg != end) { state = "parse:shortmsg"; state_smkind = SMID_PAD; - TRACE (("short (size %"PRIuSIZE" exp %p act %p)", submsg_size, submsg, end)); + DDS_TRACE("short (size %"PRIuSIZE" exp %p act %p)", submsg_size, submsg, end); goto malformed; } return 0; @@ -3011,8 +3011,8 @@ static bool do_packet ) { if ((hdr->version.major == RTPS_MAJOR && hdr->version.minor < RTPS_MINOR_MINIMUM)) - TRACE (("HDR(%x:%x:%x vendor %d.%d) len %lu\n, version mismatch: %d.%d\n", - PGUIDPREFIX (hdr->guid_prefix), hdr->vendorid.id[0], hdr->vendorid.id[1], (unsigned long) sz, hdr->version.major, hdr->version.minor)); + DDS_TRACE("HDR(%x:%x:%x vendor %d.%d) len %lu\n, version mismatch: %d.%d\n", + PGUIDPREFIX (hdr->guid_prefix), hdr->vendorid.id[0], hdr->vendorid.id[1], (unsigned long) sz, hdr->version.major, hdr->version.minor); if (NN_PEDANTIC_P) malformed_packet_received_nosubmsg (buff, sz, "header", hdr->vendorid); } @@ -3020,12 +3020,12 @@ static bool do_packet { hdr->guid_prefix = nn_ntoh_guid_prefix (hdr->guid_prefix); - if (config.enabled_logcats & LC_TRACE) + if (dds_get_log_mask() & DDS_LC_TRACE) { char addrstr[DDSI_LOCSTRLEN]; ddsi_locator_to_string(addrstr, sizeof(addrstr), &srcloc); - nn_log (LC_TRACE, "HDR(%x:%x:%x vendor %d.%d) len %lu from %s\n", - PGUIDPREFIX (hdr->guid_prefix), hdr->vendorid.id[0], hdr->vendorid.id[1], (unsigned long) sz, addrstr); + DDS_TRACE("HDR(%x:%x:%x vendor %d.%d) len %lu from %s\n", + PGUIDPREFIX (hdr->guid_prefix), hdr->vendorid.id[0], hdr->vendorid.id[1], (unsigned long) sz, addrstr); } { @@ -3114,7 +3114,7 @@ static void rebuild_local_participant_set (struct thread_state1 *self, struct lo struct ephash_enum_participant est; struct participant *pp; unsigned nps_alloc; - TRACE (("pp set gen changed: local %u global %"PRIu32"\n", lps->gen, os_atomic_ld32(&gv.participant_set_generation))); + DDS_TRACE("pp set gen changed: local %u global %"PRIu32"\n", lps->gen, os_atomic_ld32(&gv.participant_set_generation)); thread_state_awake (self); restart: lps->gen = os_atomic_ld32 (&gv.participant_set_generation); @@ -3135,14 +3135,14 @@ static void rebuild_local_participant_set (struct thread_state1 *self, struct lo turns out we didn't allocate enough memory [an alternative would be to realloc on the fly]. */ ephash_enum_participant_fini (&est); - TRACE ((" need more memory - restarting\n")); + DDS_TRACE(" need more memory - restarting\n"); goto restart; } else { lps->ps[lps->nps].m_conn = pp->m_conn; lps->ps[lps->nps].guid_prefix = pp->e.guid.prefix; - TRACE ((" pp %x:%x:%x:%x handle %"PRIsock"\n", PGUID (pp->e.guid), ddsi_conn_handle (pp->m_conn))); + DDS_TRACE(" pp %x:%x:%x:%x handle %"PRIsock"\n", PGUID (pp->e.guid), ddsi_conn_handle (pp->m_conn)); lps->nps++; } } @@ -3157,7 +3157,7 @@ static void rebuild_local_participant_set (struct thread_state1 *self, struct lo os_atomic_fence_acq (); if (lps->gen != os_atomic_ld32 (&gv.participant_set_generation)) { - TRACE ((" set changed - restarting\n")); + DDS_TRACE(" set changed - restarting\n"); goto restart; } thread_state_asleep (self); @@ -3172,7 +3172,7 @@ static void rebuild_local_participant_set (struct thread_state1 *self, struct lo qsort (lps->ps, lps->nps, sizeof (*lps->ps), local_participant_cmp); lps->nps = (unsigned) dedup_sorted_array (lps->ps, lps->nps, sizeof (*lps->ps), local_participant_cmp); } - TRACE ((" nparticipants %u\n", lps->nps)); + DDS_TRACE(" nparticipants %u\n", lps->nps); } uint32_t listen_thread (struct ddsi_tran_listener * listener) @@ -3220,7 +3220,7 @@ static int check_and_handle_deafness_recover(struct local_deaf_state *st, unsign int rebuildws = 0; if (now_mt().v < st->tnext.v) { - TRACE(("check_and_handle_deafness_recover: state %d too early\n", (int)st->state)); + DDS_TRACE("check_and_handle_deafness_recover: state %d too early\n", (int)st->state); return 0; } switch (st->state) @@ -3230,20 +3230,20 @@ static int check_and_handle_deafness_recover(struct local_deaf_state *st, unsign break; case LDSR_DEAF: { ddsi_tran_conn_t disc = gv.disc_conn_mc, data = gv.data_conn_mc; - TRACE(("check_and_handle_deafness_recover: state %d create new sockets\n", (int)st->state)); + DDS_TRACE("check_and_handle_deafness_recover: state %d create new sockets\n", (int)st->state); if (!create_multicast_sockets()) goto error; - TRACE(("check_and_handle_deafness_recover: state %d transfer group membership admin\n", (int)st->state)); + DDS_TRACE("check_and_handle_deafness_recover: state %d transfer group membership admin\n", (int)st->state); ddsi_transfer_group_membership(disc, gv.disc_conn_mc); ddsi_transfer_group_membership(data, gv.data_conn_mc); - TRACE(("check_and_handle_deafness_recover: state %d drop from waitset and add new\n", (int)st->state)); + DDS_TRACE("check_and_handle_deafness_recover: state %d drop from waitset and add new\n", (int)st->state); /* see waitset construction code in recv_thread */ os_sockWaitsetPurge (gv.recv_threads[0].arg.u.many.ws, num_fixed_uc); if (recv_thread_waitset_add_conn (gv.recv_threads[0].arg.u.many.ws, gv.disc_conn_mc) < 0) - NN_FATAL("check_and_handle_deafness_recover: failed to add disc_conn_mc to waitset\n"); + DDS_FATAL("check_and_handle_deafness_recover: failed to add disc_conn_mc to waitset\n"); if (recv_thread_waitset_add_conn (gv.recv_threads[0].arg.u.many.ws, gv.data_conn_mc) < 0) - NN_FATAL("check_and_handle_deafness_recover: failed to add data_conn_mc to waitset\n"); - TRACE(("check_and_handle_deafness_recover: state %d close sockets\n", (int)st->state)); + DDS_FATAL("check_and_handle_deafness_recover: failed to add data_conn_mc to waitset\n"); + DDS_TRACE("check_and_handle_deafness_recover: state %d close sockets\n", (int)st->state); ddsi_conn_free(disc); ddsi_conn_free(data); rebuildws = 1; @@ -3251,20 +3251,20 @@ static int check_and_handle_deafness_recover(struct local_deaf_state *st, unsign } /* FALLS THROUGH */ case LDSR_REJOIN: - TRACE(("check_and_handle_deafness_recover: state %d rejoin on disc socket\n", (int)st->state)); + DDS_TRACE("check_and_handle_deafness_recover: state %d rejoin on disc socket\n", (int)st->state); if (ddsi_rejoin_transferred_mcgroups(gv.disc_conn_mc) < 0) goto error; - TRACE(("check_and_handle_deafness_recover: state %d rejoin on data socket\n", (int)st->state)); + DDS_TRACE("check_and_handle_deafness_recover: state %d rejoin on data socket\n", (int)st->state); if (ddsi_rejoin_transferred_mcgroups(gv.data_conn_mc) < 0) goto error; - TRACE(("check_and_handle_deafness_recover: state %d done\n", (int)st->state)); + DDS_TRACE("check_and_handle_deafness_recover: state %d done\n", (int)st->state); st->state = LDSR_NORMAL; break; } - TRACE(("check_and_handle_deafness_recover: state %d returning %d\n", (int)st->state, rebuildws)); + DDS_TRACE("check_and_handle_deafness_recover: state %d returning %d\n", (int)st->state, rebuildws); return rebuildws; error: - TRACE(("check_and_handle_deafness_recover: state %d failed, returning %d\n", (int)st->state, rebuildws)); +DDS_TRACE("check_and_handle_deafness_recover: state %d failed, returning %d\n", (int)st->state, rebuildws); st->state = LDSR_DEAF; st->tnext = add_duration_to_mtime(now_mt(), T_SECOND); return rebuildws; @@ -3278,14 +3278,14 @@ static int check_and_handle_deafness(struct local_deaf_state *st, unsigned num_f return 0; else if (gv_deaf) { - TRACE(("check_and_handle_deafness: going deaf (%d -> %d)\n", (int)st->state, (int)LDSR_DEAF)); + DDS_TRACE("check_and_handle_deafness: going deaf (%d -> %d)\n", (int)st->state, (int)LDSR_DEAF); st->state = LDSR_DEAF; st->tnext = now_mt(); return 0; } else if (!config.allowMulticast) { - TRACE(("check_and_handle_deafness: no longer deaf (multicast disabled)\n")); + DDS_TRACE("check_and_handle_deafness: no longer deaf (multicast disabled)\n"); st->state = LDSR_NORMAL; return 0; } @@ -3311,12 +3311,12 @@ void trigger_recv_threads (void) ddsi_iovec_t iov; iov.iov_base = &dummy; iov.iov_len = 1; - TRACE(("trigger_recv_threads: %d single %s\n", i, ddsi_locator_to_string (buf, sizeof (buf), dst))); + DDS_TRACE("trigger_recv_threads: %d single %s\n", i, ddsi_locator_to_string (buf, sizeof (buf), dst)); ddsi_conn_write (gv.data_conn_uc, dst, 1, &iov, 0); break; } case RTM_MANY: { - TRACE(("trigger_recv_threads: %d many %p\n", i, gv.recv_threads[i].arg.u.many.ws)); + DDS_TRACE("trigger_recv_threads: %d many %p\n", i, gv.recv_threads[i].arg.u.many.ws); os_sockWaitsetTrigger (gv.recv_threads[i].arg.u.many.ws); break; } @@ -3355,17 +3355,17 @@ uint32_t recv_thread (void *vrecv_thread_arg) { int rc; if ((rc = recv_thread_waitset_add_conn (waitset, gv.disc_conn_uc)) < 0) - NN_FATAL ("recv_thread: failed to add disc_conn_uc to waitset\n"); + DDS_FATAL("recv_thread: failed to add disc_conn_uc to waitset\n"); num_fixed_uc += (unsigned)rc; if ((rc = recv_thread_waitset_add_conn (waitset, gv.data_conn_uc)) < 0) - NN_FATAL ("recv_thread: failed to add data_conn_uc to waitset\n"); + DDS_FATAL("recv_thread: failed to add data_conn_uc to waitset\n"); num_fixed_uc += (unsigned)rc; num_fixed += num_fixed_uc; if ((rc = recv_thread_waitset_add_conn (waitset, gv.disc_conn_mc)) < 0) - NN_FATAL ("recv_thread: failed to add disc_conn_mc to waitset\n"); + DDS_FATAL("recv_thread: failed to add disc_conn_mc to waitset\n"); num_fixed += (unsigned)rc; if ((rc = recv_thread_waitset_add_conn (waitset, gv.data_conn_mc)) < 0) - NN_FATAL ("recv_thread: failed to add data_conn_mc to waitset\n"); + DDS_FATAL("recv_thread: failed to add data_conn_mc to waitset\n"); num_fixed += (unsigned)rc; } diff --git a/src/core/ddsi/src/q_security.c b/src/core/ddsi/src/q_security.c index d32bf48..3d4418e 100644 --- a/src/core/ddsi/src/q_security.c +++ b/src/core/ddsi/src/q_security.c @@ -79,7 +79,7 @@ #define Q_REPORT_OPENSSL_ERR(x) \ while ( ERR_peek_error() ) \ - NN_ERROR(x "%s", ERR_error_string(ERR_get_error(), NULL)); + DDS_ERROR(x "%s", ERR_error_string(ERR_get_error(), NULL)); @@ -315,10 +315,10 @@ static void tdumpCounter(unsigned char* counter, int counterLength) if (counter) { for (i=0; istate = Q_CODEC_STATE_DROP_PERM; encoder->cipherType = Q_CIPHER_UNDEFINED; @@ -804,7 +804,7 @@ q_securityPartitionEncoderInit(q_securityPartitionEncoder encoder,struct config_ /* intitialize the key-buffer */ if (cipherType != Q_CIPHER_NULL && cipherType != Q_CIPHER_NONE && !q_securityResolveCipherKeyFromUri(cipherKeyURL,cipherKeyLength,cipherKey)) { - NN_ERROR("DDSI Security Encoder: dropping traffic of partition '%s' (%d) due to invalid cipher key", + DDS_ERROR("DDSI Security Encoder: dropping traffic of partition '%s' (%d) due to invalid cipher key", encoder->partitionName, partitionId); encoder->state = Q_CODEC_STATE_DROP_TEMP; } @@ -855,7 +855,7 @@ q_securityPartitionDecoderInit(q_securityPartitionDecoder decoder,struct config_ memset(cipherKey, 0, sizeof(cipherKey)); if (!connected) { - TRACE(("Network Partition '%s' (%d) not connected, dropping inbound traffic permanently\n", partitionName, partitionId)); + DDS_TRACE("Network Partition '%s' (%d) not connected, dropping inbound traffic permanently\n", partitionName, partitionId); decoder->state = Q_CODEC_STATE_DROP_PERM; decoder->cipherType = Q_CIPHER_UNDEFINED; @@ -921,7 +921,7 @@ q_securityPartitionDecoderInit(q_securityPartitionDecoder decoder,struct config_ /* init key-buffer from URL */ if (cipherType != Q_CIPHER_NULL && cipherType != Q_CIPHER_NONE && !q_securityResolveCipherKeyFromUri(cipherKeyURL,cipherKeyLength,cipherKey)) { - NN_ERROR("DDSI Security Decoder: dropping traffic of partition '%s' (%d) due to invalid cipher key", + DDS_ERROR("DDSI Security Decoder: dropping traffic of partition '%s' (%d) due to invalid cipher key", decoder->partitionName, partitionId); /* can be solved by re-keying, rewriting the file */ decoder->state = Q_CODEC_STATE_DROP_TEMP; @@ -1002,15 +1002,15 @@ static q_securityEncoderSet q_securityEncoderSetNew (void) /* the codec config is faulty, the codec has been set into * DROP_TERMP or DROP_PERM state, depending on the kind of * fault. Continue to intitialize remaining codecs */ - NN_ERROR("q_securityEncoderSet:failed to initialize codec of partition '%s' (%d)\n", + DDS_ERROR("q_securityEncoderSet:failed to initialize codec of partition '%s' (%d)\n", p->name,p->partitionId ); } - TRACE(("Network Partition '%s' (%d) encoder secured by %s cipher, in status '%s'\n", - p->name, - p->partitionId, - cipherTypeAsString(currentEncoder->cipherType), - stateAsString(currentEncoder->state))); + DDS_TRACE("Network Partition '%s' (%d) encoder secured by %s cipher, in status '%s'\n", + p->name, + p->partitionId, + cipherTypeAsString(currentEncoder->cipherType), + stateAsString(currentEncoder->state)); headerSizeProfile = cipherTypeToHeaderSize(currentEncoder->cipherType); result->headerSizeMax = (headerSizeProfile > (result->headerSizeMax)) ? headerSizeProfile: (result->headerSizeMax); @@ -1021,9 +1021,9 @@ static q_securityEncoderSet q_securityEncoderSetNew (void) currentEncoder->cipherType = Q_CIPHER_NONE; currentEncoder->partitionName = p->name; - TRACE(("Network Partition '%s' (%d) is not secured by a cipher\n", - p->name, - p->partitionId)); + DDS_TRACE("Network Partition '%s' (%d) is not secured by a cipher\n", + p->name, + p->partitionId); } /* count up step by step, so in case of error * q_securityEncoderSetFree will only iterate those already @@ -1034,8 +1034,7 @@ static q_securityEncoderSet q_securityEncoderSetNew (void) } - TRACE(("reserving %d bytes for security header\n", result->headerSizeMax)); - + DDS_TRACE("reserving %d bytes for security header\n", result->headerSizeMax); } return result; @@ -1084,24 +1083,24 @@ static q_securityDecoderSet q_securityDecoderSetNew (void) /* the codec config is faulty, the codec has been set into * DROP_TERMP or DROP_PERM state, depending on the kind of * fault. Continue to intitialize remaining codecs */ - NN_ERROR("q_securityDecoderSet:failed to initialize codec of partition '%s' (%d)\n", + DDS_ERROR("q_securityDecoderSet:failed to initialize codec of partition '%s' (%d)\n", p->name,p->partitionId); } - TRACE(("Network Partition '%s' (%d) decoder secured by %s cipher, in status '%s'\n", + DDS_TRACE("Network Partition '%s' (%d) decoder secured by %s cipher, in status '%s'\n", p->name, p->partitionId, cipherTypeAsString(currentDecoder->cipherType), - stateAsString(currentDecoder->state))); + stateAsString(currentDecoder->state)); } else { memset(currentDecoder, 0, sizeof(*currentDecoder)); currentDecoder->state = Q_CODEC_STATE_DROP_PERM; currentDecoder->cipherType = Q_CIPHER_NONE; currentDecoder->partitionName = p->name; - TRACE(("Network Partition '%s' (%d) is not secured by a cipher\n", + DDS_TRACE("Network Partition '%s' (%d) is not secured by a cipher\n", p->name, - p->partitionId)); + p->partitionId); } /* count up step by step, so in case of error * q_securityEncoderSetFree will only iterate those already @@ -1202,7 +1201,7 @@ static c_bool counterEncryptOrDecryptInPlace /* encrypt the current counter */ if (!EVP_EncryptUpdate(ctx, keyStream, &num, counter, bl)) { /* ECB encrypts exactly 'bl' bytes */ - NN_WARNING("Incoming encrypted sub-message dropped: Decrypt failed (bufferLength %u, blockSize %u, where %u)",length, bl, where); + DDS_WARNING("Incoming encrypted sub-message dropped: Decrypt failed (bufferLength %u, blockSize %u, where %u)\n",length, bl, where); return FALSE; } @@ -1446,7 +1445,7 @@ static c_bool q_securityDecodeInPlace_Generic result = verifySha1(cipherText, *dataLength, sha1HeaderStart); TRACE((":BLF:%s", result?"OK":"ERROR")); /* debug */ if (!result) { - NN_WARNING("Incoming encrypted sub-message dropped: Decrypt (blowfish) verification failed for partition '%s' - possible Key-mismatch", decoder->partitionName); + DDS_WARNING("Incoming encrypted sub-message dropped: Decrypt (blowfish) verification failed for partition '%s' - possible Key-mismatch\n", decoder->partitionName); } } @@ -1479,9 +1478,9 @@ static c_bool q_securityDecodeInPlace_Generic if ( result){ /* will zero out the sha1Header values in buffer */ result = verifySha1(cipherText, *dataLength, sha1HeaderStart); - TRACE((":AES:%s", result?"OK":"ERROR")); /* debug */ + DDS_TRACE(":AES:%s", result?"OK":"ERROR"); /* debug */ if (!result) { - NN_WARNING("Incoming encrypted sub-message dropped: Decrypt (AES) verification failed for partition '%s' - possible Key-mismatch", decoder->partitionName); + DDS_WARNING("Incoming encrypted sub-message dropped: Decrypt (AES) verification failed for partition '%s' - possible Key-mismatch", decoder->partitionName); } } @@ -1492,7 +1491,7 @@ static c_bool q_securityDecodeInPlace_Generic assert(0 && "do not reach"); } - TRACE((":(%d->%d)", *dataLength, *dataLength - overallHeaderSize)); + DDS_TRACE(":(%d->%d)", *dataLength, *dataLength - overallHeaderSize); *dataLength -= overallHeaderSize; /* out */ @@ -1527,7 +1526,7 @@ static c_bool q_securityEncodeInPlace if (partitionId == 0 || partitionId > codec->nofPartitions) { /* if partitionId is larger than number of partitions, network service * seems to be in undefined state */ - NN_ERROR("q_securityEncodeInPlace:Sending message blocked, bad partitionid '%d'", + DDS_ERROR("q_securityEncodeInPlace:Sending message blocked, bad partitionid '%d'\n", partitionId); return FALSE; } @@ -1536,20 +1535,20 @@ static c_bool q_securityEncodeInPlace if (encoderIsBlocked(encoder)) { - NN_ERROR("q_securityEncodeInPlace:Sending message blocked, encoder of partitionid '%d' in bad state", + DDS_ERROR("q_securityEncodeInPlace:Sending message blocked, encoder of partitionid '%d' in bad state\n", partitionId); return FALSE; } if (*dataLength <= 0) { - NN_WARNING("q_securityEncodeInPlace:encoder called with empty buffer"); + DDS_WARNING("q_securityEncodeInPlace:encoder called with empty buffer\n"); return FALSE; } overallHeaderSize = cipherTypeToHeaderSize(encoder->cipherType); if (*dataLength + overallHeaderSize > fragmentLength) { - NN_ERROR("q_securityEncodeInPlace:sending message of %"PA_PRIu32" bytes overlaps with reserved space of %"PA_PRIu32" bytes", + DDS_ERROR("q_securityEncodeInPlace:sending message of %"PA_PRIu32" bytes overlaps with reserved space of %"PA_PRIu32" bytes\n", *dataLength, overallHeaderSize); return FALSE; } @@ -1620,7 +1619,7 @@ static c_bool q_securityDecodeInPlace } if ((partitionId < 1) || (partitionId > codec->nofPartitions)) { - NN_WARNING("Incoming encrypted sub-message dropped, bad partition hash '%u'", hash); + DDS_WARNING("Incoming encrypted sub-message dropped, bad partition hash '%u'\n", hash); return FALSE; } @@ -1629,16 +1628,16 @@ static c_bool q_securityDecodeInPlace overallHeaderSize = cipherTypeToHeaderSize(sendersCipherType); if (sendersCipherType!=decoder->cipherType) { - NN_WARNING("Incoming encrypted sub-message dropped: cipherType mismatch (%d != %d) for partition '%s'", sendersCipherType,decoder->cipherType, decoder->partitionName); + DDS_WARNING("Incoming encrypted sub-message dropped: cipherType mismatch (%d != %d) for partition '%s'\n", sendersCipherType,decoder->cipherType, decoder->partitionName); return FALSE; } if (decoderIsBlocked(decoder)) { - NN_WARNING("Incoming encrypted sub-message dropped: decoder is blocked for partition '%s'", decoder->partitionName); + DDS_WARNING("Incoming encrypted sub-message dropped: decoder is blocked for partition '%s'\n", decoder->partitionName); return FALSE; } if (overallHeaderSize > dataLength32) { - NN_WARNING("Incoming encrypted sub-message dropped: submessage too small(%"PA_PRIu32" bytes),for partition '%s'", dataLength32, decoder->partitionName); + DDS_WARNING("Incoming encrypted sub-message dropped: submessage too small(%"PA_PRIu32" bytes),for partition '%s'\n", dataLength32, decoder->partitionName); return FALSE; } diff --git a/src/core/ddsi/src/q_servicelease.c b/src/core/ddsi/src/q_servicelease.c index 3dac20e..f493cd0 100644 --- a/src/core/ddsi/src/q_servicelease.c +++ b/src/core/ddsi/src/q_servicelease.c @@ -84,7 +84,7 @@ static uint32_t lease_renewal_thread (struct nn_servicelease *sl) LOG_THREAD_CPUTIME (next_thread_cputime); - TRACE (("servicelease: tnow %"PRId64":", tnow.v)); + DDS_TRACE("servicelease: tnow %"PRId64":", tnow.v); /* Check progress only if enough time has passed: there is no guarantee that os_cond_timedwait wont ever return early, and we @@ -106,7 +106,7 @@ static uint32_t lease_renewal_thread (struct nn_servicelease *sl) vtime_t wd = thread_states.ts[i].watchdog; int alive = vtime_asleep_p (vt) || vtime_asleep_p (wd) || vtime_gt (wd, sl->av_ary[i].wd); n_alive += (unsigned) alive; - TRACE ((" %u(%s):%c:%u:%u->%u:", i, thread_states.ts[i].name, alive ? 'a' : 'd', vt, sl->av_ary[i].wd, wd)); + DDS_TRACE(" %u(%s):%c:%u:%u->%u:", i, thread_states.ts[i].name, alive ? 'a' : 'd', vt, sl->av_ary[i].wd, wd); sl->av_ary[i].wd = wd; if (sl->av_ary[i].alive != alive) { @@ -116,7 +116,7 @@ static uint32_t lease_renewal_thread (struct nn_servicelease *sl) msg = "failed to make progress"; else msg = "once again made progress"; - NN_WARNING ("thread %s %s\n", name ? name : "(anon)", msg); + DDS_WARNING("thread %s %s\n", name ? name : "(anon)", msg); sl->av_ary[i].alive = (char) alive; } } @@ -129,7 +129,7 @@ static uint32_t lease_renewal_thread (struct nn_servicelease *sl) the DDSI2 service to be marked as dead. */ if (n_alive == thread_states.nthreads) { - TRACE ((": [%u] renewing\n", n_alive)); + DDS_TRACE(": [%u] renewing\n", n_alive); /* FIXME: perhaps it would be nice to control automatic liveliness updates from here. FIXME: should terminate failure of renew_cb() */ @@ -138,7 +138,7 @@ static uint32_t lease_renewal_thread (struct nn_servicelease *sl) } else { - TRACE ((": [%u] NOT renewing\n", n_alive)); + DDS_TRACE(": [%u] NOT renewing\n", n_alive); if (was_alive) log_stack_traces (); was_alive = 0; @@ -149,16 +149,16 @@ static uint32_t lease_renewal_thread (struct nn_servicelease *sl) statistics to the trace. Getrusage() can't fail if the parameters are valid, and these are by the book. Still we check. */ - if (config.enabled_logcats & LC_TIMING) + if (dds_get_log_mask() & DDS_LC_TIMING) { struct rusage u; if (getrusage (RUSAGE_SELF, &u) == 0) { - nn_log (LC_TIMING, - "rusage: utime %d.%06d stime %d.%06d maxrss %ld data %ld vcsw %ld ivcsw %ld\n", - (int) u.ru_utime.tv_sec, (int) u.ru_utime.tv_usec, - (int) u.ru_stime.tv_sec, (int) u.ru_stime.tv_usec, - u.ru_maxrss, u.ru_idrss, u.ru_nvcsw, u.ru_nivcsw); + DDS_LOG(DDS_LC_TIMING, + "rusage: utime %d.%06d stime %d.%06d maxrss %ld data %ld vcsw %ld ivcsw %ld\n", + (int) u.ru_utime.tv_sec, (int) u.ru_utime.tv_usec, + (int) u.ru_stime.tv_sec, (int) u.ru_stime.tv_usec, + u.ru_maxrss, u.ru_idrss, u.ru_nvcsw, u.ru_nivcsw); } } #endif diff --git a/src/core/ddsi/src/q_sockwaitset.c b/src/core/ddsi/src/q_sockwaitset.c index dc6be48..6ab22a7 100644 --- a/src/core/ddsi/src/q_sockwaitset.c +++ b/src/core/ddsi/src/q_sockwaitset.c @@ -169,7 +169,7 @@ void os_sockWaitsetTrigger (os_sockWaitset ws) if (n != 1) { err = os_getErrno (); - NN_WARNING ("os_sockWaitsetTrigger: read failed on trigger pipe, errno = %d", err); + DDS_WARNING("os_sockWaitsetTrigger: read failed on trigger pipe, errno = %d\n", err); } } @@ -250,7 +250,7 @@ os_sockWaitsetCtx os_sockWaitsetWait (os_sockWaitset ws) nevs = 0; else { - NN_WARNING ("os_sockWaitsetWait: kevent failed, errno = %d", os_getErrno()); + DDS_WARNING("os_sockWaitsetWait: kevent failed, errno = %d\n", os_getErrno()); return NULL; } } @@ -330,7 +330,7 @@ void os_sockWaitsetPurge (os_sockWaitset ws, unsigned index) ws->ctx.conns[i] = NULL; if (!WSACloseEvent (ws->ctx.events[i])) { - NN_WARNING ("os_sockWaitsetPurge: WSACloseEvent (%x failed, error %d", (os_uint32) ws->ctx.events[i], os_getErrno ()); + DDS_WARNING("os_sockWaitsetPurge: WSACloseEvent (%x failed, error %d\n", (os_uint32) ws->ctx.events[i], os_getErrno ()); } } ws->ctx.n = index + 1; @@ -363,7 +363,7 @@ void os_sockWaitsetTrigger (os_sockWaitset ws) { if (! WSASetEvent (ws->ctx.events[0])) { - NN_WARNING ("os_sockWaitsetTrigger: WSASetEvent(%x) failed, error %d", (os_uint32) ws->ctx.events[0], os_getErrno ()); + DDS_WARNING("os_sockWaitsetTrigger: WSASetEvent(%x) failed, error %d\n", (os_uint32) ws->ctx.events[0], os_getErrno ()); } } @@ -392,7 +392,7 @@ int os_sockWaitsetAdd (os_sockWaitset ws, ddsi_tran_conn_t conn) { if (WSAEventSelect (sock, ev, FD_READ) == SOCKET_ERROR) { - NN_WARNING ("os_sockWaitsetAdd: WSAEventSelect(%x,%x) failed, error %d", (os_uint32) sock, (os_uint32) ev, os_getErrno ()); + DDS_WARNING("os_sockWaitsetAdd: WSAEventSelect(%x,%x) failed, error %d\n", (os_uint32) sock, (os_uint32) ev, os_getErrno ()); WSACloseEvent (ev); ret = -1; } @@ -422,7 +422,7 @@ os_sockWaitsetCtx os_sockWaitsetWait (os_sockWaitset ws) if ((idx = WSAWaitForMultipleEvents (ws->ctx0.n, ws->ctx0.events, FALSE, WSA_INFINITE, FALSE)) == WSA_WAIT_FAILED) { - NN_WARNING ("os_sockWaitsetWait: WSAWaitForMultipleEvents(%d,...,0,0,0) failed, error %d", ws->ctx0.n, os_getErrno ()); + DDS_WARNING("os_sockWaitsetWait: WSAWaitForMultipleEvents(%d,...,0,0,0) failed, error %d\n", ws->ctx0.n, os_getErrno ()); return NULL; } @@ -445,11 +445,11 @@ os_sockWaitsetCtx os_sockWaitsetWait (os_sockWaitset ws) if (idx == WAIT_IO_COMPLETION) { /* Presumably can't happen with alertable = FALSE */ - NN_WARNING ("os_sockWaitsetWait: WSAWaitForMultipleEvents(%d,...,0,0,0) returned unexpected WAIT_IO_COMPLETION", ws->ctx0.n); + DDS_WARNING("os_sockWaitsetWait: WSAWaitForMultipleEvents(%d,...,0,0,0) returned unexpected WAIT_IO_COMPLETION\n", ws->ctx0.n); } else { - NN_WARNING ("os_sockWaitsetWait: WSAWaitForMultipleEvents(%d,...,0,0,0) returned unrecognised %d", ws->ctx0.n, idx); + DDS_WARNING("os_sockWaitsetWait: WSAWaitForMultipleEvents(%d,...,0,0,0) returned unrecognised %d\n", ws->ctx0.n, idx); } #ifdef TEMP_DEF_WAIT_IO_COMPLETION #undef WAIT_IO_COMPLETION @@ -488,7 +488,7 @@ int os_sockWaitsetNextEvent (os_sockWaitsetCtx ctx, ddsi_tran_conn_t * conn) { /* May have a wakeup and a close in parallel, so the handle need not exist anymore. */ - NN_ERROR ("os_sockWaitsetNextEvent: WSAEnumNetworkEvents(%x,%x,...) failed, error %d", (os_uint32) handle, (os_uint32) ctx->events[idx], err); + DDS_ERROR("os_sockWaitsetNextEvent: WSAEnumNetworkEvents(%x,%x,...) failed, error %d", (os_uint32) handle, (os_uint32) ctx->events[idx], err); } return -1; } @@ -753,7 +753,7 @@ void os_sockWaitsetTrigger (os_sockWaitset ws) if (n != 1) { err = os_getErrno (); - NN_WARNING ("os_sockWaitsetTrigger: read failed on trigger pipe, errno = %d", err); + DDS_WARNING("os_sockWaitsetTrigger: read failed on trigger pipe, errno = %d", err); } } @@ -882,7 +882,7 @@ os_sockWaitsetCtx os_sockWaitsetWait (os_sockWaitset ws) err = os_getErrno (); if ((err != os_sockEINTR) && (err != os_sockEAGAIN)) { - NN_WARNING ("os_sockWaitsetWait: select failed, errno = %d", err); + DDS_WARNING("os_sockWaitsetWait: select failed, errno = %d", err); break; } } @@ -905,7 +905,7 @@ os_sockWaitsetCtx os_sockWaitsetWait (os_sockWaitset ws) if (n1 != 1) { err = os_getErrno (); - NN_WARNING ("os_sockWaitsetWait: read failed on trigger pipe, errno = %d", err); + DDS_WARNING("os_sockWaitsetWait: read failed on trigger pipe, errno = %d", err); assert (0); } } diff --git a/src/core/ddsi/src/q_thread.c b/src/core/ddsi/src/q_thread.c index d9003b8..5d65852 100644 --- a/src/core/ddsi/src/q_thread.c +++ b/src/core/ddsi/src/q_thread.c @@ -59,7 +59,7 @@ static void os_free_aligned ( _Pre_maybenull_ _Post_invalid_ void *ptr) void thread_states_init_static (void) { static struct thread_state1 ts = - { .state = THREAD_STATE_ALIVE, .vtime = 1, .watchdog = 1, .lb = NULL, .name = "(anon)" }; + { .state = THREAD_STATE_ALIVE, .vtime = 1, .watchdog = 1, .name = "(anon)" }; tsd_thread_state = &ts; } @@ -79,7 +79,6 @@ OS_WARNING_MSVC_OFF(6386); thread_states.ts[i].state = THREAD_STATE_ZERO; thread_states.ts[i].vtime = 1; thread_states.ts[i].watchdog = 1; - thread_states.ts[i].lb = NULL; thread_states.ts[i].name = NULL; } OS_WARNING_MSVC_ON(6386); @@ -134,10 +133,9 @@ lookup_thread_state( ts1 = init_thread_state(tname); if (ts1 != NULL) { os_osInit(); - ts1->lb = 0; ts1->extTid = tid; ts1->tid = tid; - nn_log (LC_INFO, "started application thread %s\n", tname); + DDS_LOG(DDS_LC_INFO, "started application thread %s\n", tname); os_threadCleanupPush(&cleanup_thread_state, NULL); } os_mutexUnlock(&thread_states.lock); @@ -177,7 +175,6 @@ static uint32_t create_thread_wrapper (_In_ _Post_invalid_ struct thread_context uint32_t ret; ctxt->self->tid = os_threadIdSelf (); ret = ctxt->f (ctxt->arg); - logbuf_free (ctxt->self->lb); os_free (ctxt); return ret; } @@ -194,7 +191,7 @@ static int find_free_slot (_In_z_ const char *name) break; } if (cand == -1) - NN_FATAL ("create_thread: %s: no free slot\n", name ? name : "(anon)"); + DDS_FATAL("create_thread: %s: no free slot\n", name ? name : "(anon)"); return cand; } @@ -210,7 +207,6 @@ void upgrade_main_thread (void) assert (vtime_asleep_p (ts1->vtime)); ts1->state = THREAD_STATE_ALIVE; ts1->tid = os_threadIdSelf (); - ts1->lb = logbuf_new (); ts1->name = main_thread_name; os_mutexUnlock (&thread_states.lock); tsd_thread_state = ts1; @@ -259,7 +255,6 @@ struct thread_state1 *create_thread (_In_z_ const char *name, _In_ uint32_t (*f) if (ts1 == NULL) goto fatal; - ts1->lb = logbuf_new (); ctxt->self = ts1; ctxt->f = f; ctxt->arg = arg; @@ -272,15 +267,15 @@ struct thread_state1 *create_thread (_In_z_ const char *name, _In_ uint32_t (*f) if (!tprops->stack_size.isdefault) tattr.stackSize = tprops->stack_size.value; } - TRACE (("create_thread: %s: class %d priority %d stack %u\n", name, (int) tattr.schedClass, tattr.schedPriority, tattr.stackSize)); + DDS_TRACE("create_thread: %s: class %d priority %d stack %u\n", name, (int) tattr.schedClass, tattr.schedPriority, tattr.stackSize); if (os_threadCreate (&tid, name, &tattr, (os_threadRoutine)&create_thread_wrapper, ctxt) != os_resultSuccess) { ts1->state = THREAD_STATE_ZERO; - NN_FATAL ("create_thread: %s: os_threadCreate failed\n", name); + DDS_FATAL("create_thread: %s: os_threadCreate failed\n", name); goto fatal; } - nn_log (LC_INFO, "started new thread 0x%"PRIxMAX" : %s\n", os_threadIdToInteger (tid), name); + DDS_LOG(DDS_LC_INFO, "started new thread 0x%"PRIxMAX" : %s\n", os_threadIdToInteger (tid), name); ts1->extTid = tid; /* overwrite the temporary value with the correct external one */ os_mutexUnlock (&thread_states.lock); return ts1; @@ -329,7 +324,6 @@ void downgrade_main_thread (void) { struct thread_state1 *ts1 = lookup_thread_state (); thread_state_asleep (ts1); - logbuf_free (ts1->lb); /* no need to sync with service lease: already stopped */ reap_thread_state (ts1, 0); thread_states_init_static (); diff --git a/src/core/ddsi/src/q_transmit.c b/src/core/ddsi/src/q_transmit.c index c6243b4..4c0a412 100644 --- a/src/core/ddsi/src/q_transmit.c +++ b/src/core/ddsi/src/q_transmit.c @@ -184,16 +184,16 @@ struct nn_xmsg *writer_hbcontrol_create_heartbeat (struct writer *wr, const stru } } - TRACE (("writer_hbcontrol: wr %x:%x:%x:%x ", PGUID (wr->e.guid))); + DDS_TRACE("writer_hbcontrol: wr %x:%x:%x:%x ", PGUID (wr->e.guid)); if (prd_guid == NULL) - TRACE (("multicasting ")); + DDS_TRACE("multicasting "); else - TRACE (("unicasting to prd %x:%x:%x:%x ", PGUID (*prd_guid))); - TRACE (("(rel-prd %d seq-eq-max %d seq %"PRId64" maxseq %"PRId64")\n", + DDS_TRACE("unicasting to prd %x:%x:%x:%x ", PGUID (*prd_guid)); + DDS_TRACE("(rel-prd %d seq-eq-max %d seq %"PRId64" maxseq %"PRId64")\n", wr->num_reliable_readers, ut_avlIsEmpty (&wr->readers) ? -1 : root_rdmatch (wr)->num_reliable_readers_where_seq_equals_max, wr->seq, - ut_avlIsEmpty (&wr->readers) ? (seqno_t) -1 : root_rdmatch (wr)->max_seq)); + ut_avlIsEmpty (&wr->readers) ? (seqno_t) -1 : root_rdmatch (wr)->max_seq); if (prd_guid == NULL) { @@ -208,7 +208,7 @@ struct nn_xmsg *writer_hbcontrol_create_heartbeat (struct writer *wr, const stru struct proxy_reader *prd; if ((prd = ephash_lookup_proxy_reader_guid (prd_guid)) == NULL) { - TRACE (("writer_hbcontrol: wr %x:%x:%x:%x unknown prd %x:%x:%x:%x\n", PGUID (wr->e.guid), PGUID (*prd_guid))); + DDS_TRACE("writer_hbcontrol: wr %x:%x:%x:%x unknown prd %x:%x:%x:%x\n", PGUID (wr->e.guid), PGUID (*prd_guid)); nn_xmsg_free (msg); return NULL; } @@ -306,13 +306,13 @@ struct nn_xmsg *writer_hbcontrol_piggyback (struct writer *wr, const struct whc_ if (msg) { - TRACE (("heartbeat(wr %x:%x:%x:%x%s) piggybacked, resched in %g s (min-ack %"PRId64"%s, avail-seq %"PRId64", xmit %"PRId64")\n", + DDS_TRACE("heartbeat(wr %x:%x:%x:%x%s) piggybacked, resched in %g s (min-ack %"PRId64"%s, avail-seq %"PRId64", xmit %"PRId64")\n", PGUID (wr->e.guid), *hbansreq ? "" : " final", (hbc->tsched.v == T_NEVER) ? POS_INFINITY_DOUBLE : (double) (hbc->tsched.v - tnow.v) / 1e9, ut_avlIsEmpty (&wr->readers) ? -1 : root_rdmatch (wr)->min_seq, ut_avlIsEmpty (&wr->readers) || root_rdmatch (wr)->all_have_replied_to_hb ? "" : "!", - whcst->max_seq, READ_SEQ_XMIT(wr))); + whcst->max_seq, READ_SEQ_XMIT(wr)); } return msg; @@ -400,13 +400,12 @@ static int create_fragment_message_simple (struct writer *wr, seqno_t seq, struc #define TEST_KEYHASH 0 const size_t expected_inline_qos_size = 4+8+20+4 + 32; struct nn_xmsg_marker sm_marker; - unsigned char contentflag; + unsigned char contentflag = 0; Data_t *data; switch (serdata->kind) { case SDK_EMPTY: - contentflag = 0; break; case SDK_KEY: #if TEST_KEYHASH @@ -634,9 +633,9 @@ int create_fragment_message (struct writer *wr, seqno_t seq, const struct nn_pli nn_xmsg_serdata (*pmsg, serdata, fragstart, fraglen); nn_xmsg_submsg_setnext (*pmsg, sm_marker); #if 0 - TRACE (("queue data%s %x:%x:%x:%x #%lld/%u[%u..%u)\n", + DDS_TRACE("queue data%s %x:%x:%x:%x #%lld/%u[%u..%u)\n", fragging ? "frag" : "", PGUID (wr->e.guid), - seq, fragnum+1, fragstart, fragstart + fraglen)); + seq, fragnum+1, fragstart, fragstart + fraglen); #endif return ret; @@ -859,7 +858,7 @@ static int insert_sample_in_whc (struct writer *wr, seqno_t seq, struct nn_plist ASSERT_MUTEX_HELD (&wr->e.lock); - if (config.enabled_logcats & LC_TRACE) + if (dds_get_log_mask() & DDS_LC_TRACE) { char ppbuf[1024]; int tmp; @@ -867,10 +866,10 @@ static int insert_sample_in_whc (struct writer *wr, seqno_t seq, struct nn_plist const char *ttname = wr->topic ? wr->topic->typename : "(null)"; ppbuf[0] = '\0'; tmp = sizeof (ppbuf) - 1; - nn_log (LC_TRACE, "write_sample %x:%x:%x:%x #%"PRId64"", PGUID (wr->e.guid), seq); + DDS_TRACE("write_sample %x:%x:%x:%x #%"PRId64"", PGUID (wr->e.guid), seq); if (plist != 0 && (plist->present & PP_COHERENT_SET)) - nn_log (LC_TRACE, " C#%"PRId64"", fromSN (plist->coherent_set_seqno)); - nn_log (LC_TRACE, ": ST%u %s/%s:%s%s\n", serdata->statusinfo, tname, ttname, ppbuf, tmp < (int) sizeof (ppbuf) ? "" : " (trunc)"); + DDS_TRACE(" C#%"PRId64"", fromSN (plist->coherent_set_seqno)); + DDS_TRACE(": ST%u %s/%s:%s%s\n", serdata->statusinfo, tname, ttname, ppbuf, tmp < (int) sizeof (ppbuf) ? "" : " (trunc)"); } assert (wr->reliable || have_reliable_subs (wr) == 0); @@ -959,7 +958,7 @@ static os_result throttle_writer (struct nn_xpack *xp, struct writer *wr) assert (!is_builtin_entityid(wr->e.guid.entityid, ownvendorid)); } - nn_log (LC_THROTTLE, "writer %x:%x:%x:%x waiting for whc to shrink below low-water mark (whc %"PRIuSIZE" low=%u high=%u)\n", PGUID (wr->e.guid), whcst.unacked_bytes, wr->whc_low, wr->whc_high); + DDS_LOG(DDS_LC_THROTTLE, "writer %x:%x:%x:%x waiting for whc to shrink below low-water mark (whc %"PRIuSIZE" low=%u high=%u)\n", PGUID (wr->e.guid), whcst.unacked_bytes, wr->whc_low, wr->whc_high); wr->throttling = 1; wr->throttle_count++; @@ -1007,7 +1006,7 @@ static os_result throttle_writer (struct nn_xpack *xp, struct writer *wr) os_condBroadcast (&wr->throttle_cond); } - nn_log (LC_THROTTLE, "writer %x:%x:%x:%x done waiting for whc to shrink below low-water mark (whc %"PRIuSIZE" low=%u high=%u)\n", PGUID (wr->e.guid), whcst.unacked_bytes, wr->whc_low, wr->whc_high); + DDS_LOG(DDS_LC_THROTTLE, "writer %x:%x:%x:%x done waiting for whc to shrink below low-water mark (whc %"PRIuSIZE" low=%u high=%u)\n", PGUID (wr->e.guid), whcst.unacked_bytes, wr->whc_low, wr->whc_high); return result; } @@ -1046,7 +1045,7 @@ static int write_sample_eot (struct nn_xpack *xp, struct writer *wr, struct nn_p const char *ttname = wr->topic ? wr->topic->typename : "(null)"; ppbuf[0] = '\0'; tmp = sizeof (ppbuf) - 1; - NN_WARNING ("dropping oversize (%u > %u) sample from local writer %x:%x:%x:%x %s/%s:%s%s\n", + DDS_WARNING ("dropping oversize (%u > %u) sample from local writer %x:%x:%x:%x %s/%s:%s%s\n", ddsi_serdata_size (serdata), config.max_sample_size, PGUID (wr->e.guid), tname, ttname, ppbuf, tmp < (int) sizeof (ppbuf) ? "" : " (trunc)"); diff --git a/src/core/ddsi/src/q_xevent.c b/src/core/ddsi/src/q_xevent.c index 9a3729d..fb545ac 100644 --- a/src/core/ddsi/src/q_xevent.c +++ b/src/core/ddsi/src/q_xevent.c @@ -175,7 +175,7 @@ static int compare_xevent_tsched (const void *va, const void *vb) static void update_rexmit_counts (struct xeventq *evq, struct xevent_nt *ev) { #if 0 - TRACE (("ZZZ(%p,%"PA_PRIuSIZE")", (void *) ev, ev->u.msg_rexmit.queued_rexmit_bytes)); + DDS_TRACE(("ZZZ(%p,%"PA_PRIuSIZE")", (void *) ev, ev->u.msg_rexmit.queued_rexmit_bytes); #endif assert (ev->kind == XEVK_MSG_REXMIT); assert (ev->u.msg_rexmit.queued_rexmit_bytes <= evq->queued_rexmit_bytes); @@ -187,13 +187,13 @@ static void update_rexmit_counts (struct xeventq *evq, struct xevent_nt *ev) #if 0 static void trace_msg (const char *func, const struct nn_xmsg *m) { - if (config.enabled_logcats & LC_TRACE) + if (dds_get_log_mask() & DDS_LC_TRACE) { nn_guid_t wrguid; seqno_t wrseq; nn_fragment_number_t wrfragid; nn_xmsg_guid_seq_fragid (m, &wrguid, &wrseq, &wrfragid); - TRACE ((" %s(%x:%x:%x:%x/%"PRId64"/%u)", func, PGUID (wrguid), wrseq, wrfragid)); + DDS_TRACE(" %s(%x:%x:%x:%x/%"PRId64"/%u)", func, PGUID (wrguid), wrseq, wrfragid); } } #else @@ -409,7 +409,7 @@ static struct xevent * qxev_common (struct xeventq *evq, nn_mtime_t tsched, enum if (tsched.v != T_NEVER && config.schedule_time_rounding != 0) { nn_mtime_t tsched_rounded = mtime_round_up (tsched, config.schedule_time_rounding); - TRACE (("rounded event scheduled for %"PRId64" to %"PRId64"\n", tsched.v, tsched_rounded.v)); + DDS_TRACE("rounded event scheduled for %"PRId64" to %"PRId64"\n", tsched.v, tsched_rounded.v); tsched = tsched_rounded; } @@ -462,7 +462,7 @@ static void qxev_insert_nt (struct xevent_nt *ev) struct xeventq *evq = ev->evq; ASSERT_MUTEX_HELD (&evq->lock); add_to_non_timed_xmit_list (evq, ev); - TRACE (("non-timed queue now has %d items\n", compute_non_timed_xmit_list_size (evq))); + DDS_TRACE("non-timed queue now has %d items\n", compute_non_timed_xmit_list_size (evq)); } static int msg_xevents_cmp (const void *a, const void *b) @@ -548,7 +548,7 @@ void xeventq_free (struct xeventq *evq) { union { void *v; void (*f) (struct xevent *ev, void *arg, nn_mtime_t tnow); } fp; fp.f = ev->u.callback.cb; - NN_WARNING("xeventq_free: callback %p did not schedule deletion as required, deleting event anyway\n", fp.v); + DDS_WARNING("xeventq_free: callback %p did not schedule deletion as required, deleting event anyway\n", fp.v); delete_xevent (ev); } } @@ -600,8 +600,8 @@ static void handle_xevk_heartbeat (struct nn_xpack *xp, struct xevent *ev, nn_mt if ((wr = ephash_lookup_writer_guid (&ev->u.heartbeat.wr_guid)) == NULL) { - TRACE (("heartbeat(wr %x:%x:%x:%x) writer gone\n", - PGUID (ev->u.heartbeat.wr_guid))); + DDS_TRACE("heartbeat(wr %x:%x:%x:%x) writer gone\n", + PGUID (ev->u.heartbeat.wr_guid)); return; } @@ -627,14 +627,14 @@ static void handle_xevk_heartbeat (struct nn_xpack *xp, struct xevent *ev, nn_mt t_next.v = tnow.v + writer_hbcontrol_intv (wr, &whcst, tnow); } - TRACE (("heartbeat(wr %x:%x:%x:%x%s) %s, resched in %g s (min-ack %"PRId64"%s, avail-seq %"PRId64", xmit %"PRId64")\n", + DDS_TRACE("heartbeat(wr %x:%x:%x:%x%s) %s, resched in %g s (min-ack %"PRId64"%s, avail-seq %"PRId64", xmit %"PRId64")\n", PGUID (wr->e.guid), hbansreq ? "" : " final", msg ? "sent" : "suppressed", (t_next.v == T_NEVER) ? POS_INFINITY_DOUBLE : (double)(t_next.v - tnow.v) / 1e9, ut_avlIsEmpty (&wr->readers) ? (seqno_t) -1 : ((struct wr_prd_match *) ut_avlRootNonEmpty (&wr_readers_treedef, &wr->readers))->min_seq, ut_avlIsEmpty (&wr->readers) || ((struct wr_prd_match *) ut_avlRootNonEmpty (&wr_readers_treedef, &wr->readers))->all_have_replied_to_hb ? "" : "!", - whcst.max_seq, READ_SEQ_XMIT(wr))); + whcst.max_seq, READ_SEQ_XMIT(wr)); resched_xevent_if_earlier (ev, t_next); wr->hbcontrol.tsched = t_next; os_mutexUnlock (&wr->e.lock); @@ -822,11 +822,11 @@ static void add_AckNack (struct nn_xmsg *msg, struct proxy_writer *pwr, struct p nn_xmsg_shrink (msg, sm_marker, ACKNACK_SIZE (an->readerSNState.numbits)); nn_xmsg_submsg_setnext (msg, sm_marker); - TRACE (("acknack %x:%x:%x:%x -> %x:%x:%x:%x: #%d:%"PRId64"/%u:", + DDS_TRACE("acknack %x:%x:%x:%x -> %x:%x:%x:%x: #%d:%"PRId64"/%u:", PGUID (rwn->rd_guid), PGUID (pwr->e.guid), rwn->count, - base, an->readerSNState.numbits)); + base, an->readerSNState.numbits); for (ui = 0; ui != an->readerSNState.numbits; ui++) - TRACE (("%c", nn_bitset_isset (numbits, an->readerSNState.bits, ui) ? '1' : '0')); + DDS_TRACE("%c", nn_bitset_isset (numbits, an->readerSNState.bits, ui) ? '1' : '0'); } if (nackfrag_numbits > 0) @@ -853,13 +853,13 @@ static void add_AckNack (struct nn_xmsg *msg, struct proxy_writer *pwr, struct p *countp = ++pwr->nackfragcount; nn_xmsg_submsg_setnext (msg, sm_marker); - TRACE ((" + nackfrag #%d:%"PRId64"/%u/%u:", *countp, fromSN (nf->writerSN), nf->fragmentNumberState.bitmap_base, nf->fragmentNumberState.numbits)); + DDS_TRACE(" + nackfrag #%d:%"PRId64"/%u/%u:", *countp, fromSN (nf->writerSN), nf->fragmentNumberState.bitmap_base, nf->fragmentNumberState.numbits); for (ui = 0; ui != nf->fragmentNumberState.numbits; ui++) - TRACE (("%c", nn_bitset_isset (nf->fragmentNumberState.numbits, nf->fragmentNumberState.bits, ui) ? '1' : '0')); + DDS_TRACE("%c", nn_bitset_isset (nf->fragmentNumberState.numbits, nf->fragmentNumberState.bits, ui) ? '1' : '0'); } } - TRACE (("\n")); + DDS_TRACE("\n"); } static void handle_xevk_acknack (UNUSED_ARG (struct nn_xpack *xp), struct xevent *ev, nn_mtime_t tnow) @@ -918,13 +918,13 @@ static void handle_xevk_acknack (UNUSED_ARG (struct nn_xpack *xp), struct xevent eventually. */ resched_xevent_if_earlier (ev, add_duration_to_mtime (tnow, config.auto_resched_nack_delay)); } - TRACE (("send acknack(rd %x:%x:%x:%x -> pwr %x:%x:%x:%x)\n", - PGUID (ev->u.acknack.rd_guid), PGUID (ev->u.acknack.pwr_guid))); + DDS_TRACE("send acknack(rd %x:%x:%x:%x -> pwr %x:%x:%x:%x)\n", + PGUID (ev->u.acknack.rd_guid), PGUID (ev->u.acknack.pwr_guid)); } else { - TRACE (("skip acknack(rd %x:%x:%x:%x -> pwr %x:%x:%x:%x): no address\n", - PGUID (ev->u.acknack.rd_guid), PGUID (ev->u.acknack.pwr_guid))); + DDS_TRACE("skip acknack(rd %x:%x:%x:%x -> pwr %x:%x:%x:%x): no address\n", + PGUID (ev->u.acknack.rd_guid), PGUID (ev->u.acknack.pwr_guid)); msg = NULL; } @@ -972,8 +972,8 @@ static void handle_xevk_spdp (UNUSED_ARG (struct nn_xpack *xp), struct xevent *e if ((pp = ephash_lookup_participant_guid (&ev->u.spdp.pp_guid)) == NULL) { - TRACE (("handle_xevk_spdp %x:%x:%x:%x - unknown guid\n", - PGUID (ev->u.spdp.pp_guid))); + DDS_TRACE("handle_xevk_spdp %x:%x:%x:%x - unknown guid\n", + PGUID (ev->u.spdp.pp_guid)); if (ev->u.spdp.directed) delete_xevent (ev); return; @@ -981,8 +981,8 @@ static void handle_xevk_spdp (UNUSED_ARG (struct nn_xpack *xp), struct xevent *e if ((spdp_wr = get_builtin_writer (pp, NN_ENTITYID_SPDP_BUILTIN_PARTICIPANT_WRITER)) == NULL) { - TRACE (("handle_xevk_spdp %x:%x:%x:%x - spdp writer of participant not found\n", - PGUID (ev->u.spdp.pp_guid))); + DDS_TRACE("handle_xevk_spdp %x:%x:%x:%x - spdp writer of participant not found\n", + PGUID (ev->u.spdp.pp_guid)); if (ev->u.spdp.directed) delete_xevent (ev); return; @@ -1001,7 +1001,7 @@ static void handle_xevk_spdp (UNUSED_ARG (struct nn_xpack *xp), struct xevent *e guid.entityid.u = NN_ENTITYID_SPDP_BUILTIN_PARTICIPANT_READER; if ((prd = ephash_lookup_proxy_reader_guid (&guid)) == NULL) { - TRACE (("xmit spdp: no proxy reader %x:%x:%x:%x\n", PGUID (guid))); + DDS_TRACE("xmit spdp: no proxy reader %x:%x:%x:%x\n", PGUID (guid)); goto skip; } } @@ -1068,8 +1068,8 @@ static void handle_xevk_spdp (UNUSED_ARG (struct nn_xpack *xp), struct xevent *e } else { - TRACE (("xmit spdp: suppressing early spdp response from %x:%x:%x:%x to %x:%x:%x:%x\n", - PGUID (pp->e.guid), PGUIDPREFIX (ev->u.spdp.dest_proxypp_guid_prefix), NN_ENTITYID_PARTICIPANT)); + DDS_TRACE("xmit spdp: suppressing early spdp response from %x:%x:%x:%x to %x:%x:%x:%x\n", + PGUID (pp->e.guid), PGUIDPREFIX (ev->u.spdp.dest_proxypp_guid_prefix), NN_ENTITYID_PARTICIPANT); } } #endif @@ -1084,10 +1084,10 @@ static void handle_xevk_spdp (UNUSED_ARG (struct nn_xpack *xp), struct xevent *e else { nn_mtime_t tnext = add_duration_to_mtime (tnow, T_SECOND); - TRACE (("xmit spdp %x:%x:%x:%x to %x:%x:%x:%x (resched %gs)\n", - PGUID (pp->e.guid), - PGUIDPREFIX (ev->u.spdp.dest_proxypp_guid_prefix), NN_ENTITYID_SPDP_BUILTIN_PARTICIPANT_READER, - (double)(tnext.v - tnow.v) / 1e9)); + DDS_TRACE("xmit spdp %x:%x:%x:%x to %x:%x:%x:%x (resched %gs)\n", + PGUID (pp->e.guid), + PGUIDPREFIX (ev->u.spdp.dest_proxypp_guid_prefix), NN_ENTITYID_SPDP_BUILTIN_PARTICIPANT_READER, + (double)(tnext.v - tnow.v) / 1e9); resched_xevent_if_earlier (ev, tnext); } } @@ -1111,10 +1111,10 @@ static void handle_xevk_spdp (UNUSED_ARG (struct nn_xpack *xp), struct xevent *e intv = config.spdp_interval; tnext = add_duration_to_mtime (tnow, intv); - TRACE (("xmit spdp %x:%x:%x:%x to %x:%x:%x:%x (resched %gs)\n", + DDS_TRACE("xmit spdp %x:%x:%x:%x to %x:%x:%x:%x (resched %gs)\n", PGUID (pp->e.guid), PGUIDPREFIX (ev->u.spdp.dest_proxypp_guid_prefix), NN_ENTITYID_SPDP_BUILTIN_PARTICIPANT_READER, - (double)(tnext.v - tnow.v) / 1e9)); + (double)(tnext.v - tnow.v) / 1e9); resched_xevent_if_earlier (ev, tnext); } } @@ -1132,7 +1132,7 @@ static void write_pmd_message (struct nn_xpack *xp, struct participant *pp, unsi if ((wr = get_builtin_writer (pp, NN_ENTITYID_P2P_BUILTIN_PARTICIPANT_MESSAGE_WRITER)) == NULL) { - TRACE (("write_pmd_message(%x:%x:%x:%x) - builtin pmd writer not found\n", PGUID (pp->e.guid))); + DDS_TRACE("write_pmd_message(%x:%x:%x:%x) - builtin pmd writer not found\n", PGUID (pp->e.guid)); return; } @@ -1182,7 +1182,7 @@ static void handle_xevk_pmd_update (struct nn_xpack *xp, struct xevent *ev, nn_m if (intv == T_NEVER) { tnext.v = T_NEVER; - TRACE (("resched pmd(%x:%x:%x:%x): never\n", PGUID (pp->e.guid))); + DDS_TRACE("resched pmd(%x:%x:%x:%x): never\n", PGUID (pp->e.guid)); } else { @@ -1192,7 +1192,7 @@ static void handle_xevk_pmd_update (struct nn_xpack *xp, struct xevent *ev, nn_m tnext.v = tnow.v + intv - 2 * T_SECOND; else tnext.v = tnow.v + 4 * intv / 5; - TRACE (("resched pmd(%x:%x:%x:%x): %gs\n", PGUID (pp->e.guid), (double)(tnext.v - tnow.v) / 1e9)); + DDS_TRACE("resched pmd(%x:%x:%x:%x): %gs\n", PGUID (pp->e.guid), (double)(tnext.v - tnow.v) / 1e9); } resched_xevent_if_earlier (ev, tnext); @@ -1204,7 +1204,7 @@ static void handle_xevk_end_startup_mode (UNUSED_ARG (struct nn_xpack *xp), stru struct ephash_enum_writer est; struct writer *wr; assert (gv.startup_mode); - nn_log (LC_DISCOVERY, "end startup mode\n"); + DDS_LOG(DDS_LC_DISCOVERY, "end startup mode\n"); gv.startup_mode = 0; /* FIXME: MEMBAR needed for startup mode (or use a lock) */ ephash_enum_writer_init (&est); @@ -1217,7 +1217,7 @@ static void handle_xevk_end_startup_mode (UNUSED_ARG (struct nn_xpack *xp), stru static void handle_xevk_delete_writer (UNUSED_ARG (struct nn_xpack *xp), struct xevent *ev, UNUSED_ARG (nn_mtime_t tnow)) { /* don't worry if the writer is already gone by the time we get here. */ - TRACE (("handle_xevk_delete_writer: %x:%x:%x:%x\n", PGUID (ev->u.delete_writer.guid))); + DDS_TRACE("handle_xevk_delete_writer: %x:%x:%x:%x\n", PGUID (ev->u.delete_writer.guid)); delete_writer_nolinger (&ev->u.delete_writer.guid); delete_xevent (ev); } @@ -1447,7 +1447,7 @@ void qxev_prd_entityid (struct proxy_reader * prd, nn_guid_prefix_t * id) msg = nn_xmsg_new (gv.xmsgpool, id, sizeof (EntityId_t), NN_XMSG_KIND_CONTROL); if (nn_xmsg_setdstPRD (msg, prd) == 0) { - TRACE ((" qxev_prd_entityid (%x:%x:%x)\n", PGUIDPREFIX (*id))); + DDS_TRACE(" qxev_prd_entityid (%x:%x:%x)\n", PGUIDPREFIX (*id)); nn_xmsg_add_entityid (msg); os_mutexLock (&gv.xevents->lock); ev = qxev_common_nt (gv.xevents, XEVK_ENTITYID); @@ -1474,7 +1474,7 @@ void qxev_pwr_entityid (struct proxy_writer * pwr, nn_guid_prefix_t * id) msg = nn_xmsg_new (gv.xmsgpool, id, sizeof (EntityId_t), NN_XMSG_KIND_CONTROL); if (nn_xmsg_setdstPWR (msg, pwr) == 0) { - TRACE ((" qxev_pwr_entityid (%x:%x:%x)\n", PGUIDPREFIX (*id))); + DDS_TRACE(" qxev_pwr_entityid (%x:%x:%x)\n", PGUIDPREFIX (*id)); nn_xmsg_add_entityid (msg); os_mutexLock (&pwr->evq->lock); ev = qxev_common_nt (pwr->evq, XEVK_ENTITYID); @@ -1512,8 +1512,8 @@ int qxev_msg_rexmit_wrlock_held (struct xeventq *evq, struct nn_xmsg *msg, int f os_mutexUnlock (&evq->lock); nn_xmsg_free (msg); #if 0 - TRACE ((" qxev_msg_rexmit%s drop (sz %"PA_PRIuSIZE" qb %"PA_PRIuSIZE" qm %"PA_PRIuSIZE")", force ? "!" : "", - msg_size, evq->queued_rexmit_bytes, evq->queued_rexmit_msgs)); + DDS_TRACE(" qxev_msg_rexmit%s drop (sz %"PA_PRIuSIZE" qb %"PA_PRIuSIZE" qm %"PA_PRIuSIZE")", force ? "!" : "", + msg_size, evq->queued_rexmit_bytes, evq->queued_rexmit_msgs); #endif return 0; } @@ -1526,7 +1526,7 @@ int qxev_msg_rexmit_wrlock_held (struct xeventq *evq, struct nn_xmsg *msg, int f evq->queued_rexmit_msgs++; qxev_insert_nt (ev); #if 0 - TRACE (("AAA(%p,%"PA_PRIuSIZE")", (void *) ev, msg_size)); + DDS_TRACE("AAA(%p,%"PA_PRIuSIZE")", (void *) ev, msg_size); #endif os_mutexUnlock (&evq->lock); return 2; diff --git a/src/core/ddsi/src/q_xmsg.c b/src/core/ddsi/src/q_xmsg.c index c32a509..8b470ae 100644 --- a/src/core/ddsi/src/q_xmsg.c +++ b/src/core/ddsi/src/q_xmsg.c @@ -256,7 +256,7 @@ static void nn_xmsg_realfree_wrap (void *elem) void nn_xmsgpool_free (struct nn_xmsgpool *pool) { nn_freelist_fini (&pool->freelist, nn_xmsg_realfree_wrap); - TRACE (("xmsgpool_free(%p)\n", pool)); + DDS_TRACE("xmsgpool_free(%p)\n", pool); os_free (pool); } @@ -588,7 +588,7 @@ int nn_xmsg_setdstPRD (struct nn_xmsg *m, const struct proxy_reader *prd) } else { - NN_WARNING("nn_xmsg_setdstPRD: no address for %x:%x:%x:%x", PGUID (prd->e.guid)); + DDS_WARNING("nn_xmsg_setdstPRD: no address for %x:%x:%x:%x", PGUID (prd->e.guid)); return ERR_NO_ADDRESS; } } @@ -601,7 +601,7 @@ int nn_xmsg_setdstPWR (struct nn_xmsg *m, const struct proxy_writer *pwr) nn_xmsg_setdst1 (m, &pwr->e.guid.prefix, &loc); return 0; } - NN_WARNING ("nn_xmsg_setdstPRD: no address for %x:%x:%x:%x", PGUID (pwr->e.guid)); + DDS_WARNING("nn_xmsg_setdstPRD: no address for %x:%x:%x:%x", PGUID (pwr->e.guid)); return ERR_NO_ADDRESS; } @@ -657,8 +657,8 @@ int nn_xmsg_merge_rexmit_destinations_wrlock_held (struct nn_xmsg *m, const stru assert (m->kindspecific.data.readerId_off != 0); assert (madd->kindspecific.data.readerId_off != 0); - TRACE ((" (%x:%x:%x:%x#%"PRId64"/%u:", - PGUID (m->kindspecific.data.wrguid), m->kindspecific.data.wrseq, m->kindspecific.data.wrfragid + 1)); + DDS_TRACE(" (%x:%x:%x:%x#%"PRId64"/%u:", + PGUID (m->kindspecific.data.wrguid), m->kindspecific.data.wrseq, m->kindspecific.data.wrfragid + 1); switch (m->dstmode) { @@ -667,7 +667,7 @@ int nn_xmsg_merge_rexmit_destinations_wrlock_held (struct nn_xmsg *m, const stru return 0; case NN_XMSG_DST_ALL: - TRACE (("*->*)")); + DDS_TRACE("*->*)"); return 1; case NN_XMSG_DST_ONE: @@ -678,7 +678,7 @@ int nn_xmsg_merge_rexmit_destinations_wrlock_held (struct nn_xmsg *m, const stru return 0; case NN_XMSG_DST_ALL: - TRACE (("1+*->*)")); + DDS_TRACE("1+*->*)"); clear_readerId (m); m->dstmode = NN_XMSG_DST_ALL; m->dstaddr.all.as = ref_addrset (madd->dstaddr.all.as); @@ -697,12 +697,12 @@ int nn_xmsg_merge_rexmit_destinations_wrlock_held (struct nn_xmsg *m, const stru can go and everyone's life will become easier! */ if ((wr = ephash_lookup_writer_guid (&m->kindspecific.data.wrguid)) == NULL) { - TRACE (("writer-dead)")); + DDS_TRACE("writer-dead)"); return 0; } else { - TRACE (("1+1->*)")); + DDS_TRACE("1+1->*)"); clear_readerId (m); m->dstmode = NN_XMSG_DST_ALL; m->dstaddr.all.as = ref_addrset (wr->as); @@ -712,12 +712,12 @@ int nn_xmsg_merge_rexmit_destinations_wrlock_held (struct nn_xmsg *m, const stru } else if (readerId_compatible (m, madd)) { - TRACE (("1+1->1)")); + DDS_TRACE("1+1->1)"); return 1; } else { - TRACE (("1+1->2)")); + DDS_TRACE("1+1->2)"); clear_readerId (m); return 1; } @@ -1181,19 +1181,19 @@ static void nn_bw_limit_sleep_if_needed(struct nn_bw_limiter* this, ssize_t size this->balance += (target_interval - actual_interval); - TRACE ((" balance < NN_BW_LIMIT_MAX_BUFFER ) { /* We're below the bandwidth limit, do not further accumulate */ this->balance = NN_BW_LIMIT_MAX_BUFFER; - TRACE ((":%"PRId64":max",this->balance/1000)); + DDS_TRACE(":%"PRId64":max",this->balance/1000); } else if ( this->balance > NN_BW_LIMIT_MIN_SLEEP ) { /* We're over the bandwidth limit far enough, to warrent a sleep. */ os_time delay; - TRACE ((":%"PRId64":sleep",this->balance/1000)); + DDS_TRACE(":%"PRId64":sleep",this->balance/1000); delay.tv_sec = (int32_t) (this->balance / T_SECOND); delay.tv_nsec = (int32_t) (this->balance % T_SECOND); thread_state_blocked (lookup_thread_state ()); @@ -1202,9 +1202,9 @@ static void nn_bw_limit_sleep_if_needed(struct nn_bw_limiter* this, ssize_t size } else { - TRACE ((":%"PRId64"",this->balance/1000)); + DDS_TRACE(":%"PRId64"",this->balance/1000); } - TRACE ((">")); + DDS_TRACE(">"); } } @@ -1312,10 +1312,10 @@ static ssize_t nn_xpack_send1 (const nn_locator_t *loc, void * varg) struct nn_xpack * xp = varg; ssize_t nbytes = 0; - if (config.enabled_logcats & LC_TRACE) + if (dds_get_log_mask() & DDS_LC_TRACE) { char buf[DDSI_LOCSTRLEN]; - TRACE ((" %s", ddsi_locator_to_string (buf, sizeof(buf), loc))); + DDS_TRACE(" %s", ddsi_locator_to_string (buf, sizeof(buf), loc)); } if (config.xmit_lossiness > 0) @@ -1324,7 +1324,7 @@ static ssize_t nn_xpack_send1 (const nn_locator_t *loc, void * varg) of all packets to be sent */ if ((random () % 1000) < config.xmit_lossiness) { - TRACE (("(dropped)")); + DDS_TRACE("(dropped)"); xp->call_flags = 0; return 0; } @@ -1344,7 +1344,7 @@ static ssize_t nn_xpack_send1 (const nn_locator_t *loc, void * varg) nbytes = ddsi_conn_write (xp->conn, loc, xp->niov, xp->iov, xp->call_flags); else { - TRACE (("(dropped)")); + DDS_TRACE("(dropped)"); nbytes = (ssize_t) xp->msg_len.length; } } @@ -1406,17 +1406,17 @@ static void nn_xpack_send_real (struct nn_xpack * xp) assert (xp->dstmode != NN_XMSG_DST_UNSET); - if (config.enabled_logcats & LC_TRACE) + if (dds_get_log_mask() & DDS_LC_TRACE) { int i; - TRACE (("nn_xpack_send %u:", xp->msg_len.length)); + DDS_TRACE("nn_xpack_send %u:", xp->msg_len.length); for (i = 0; i < (int) xp->niov; i++) { - TRACE ((" %p:%lu", (void *) xp->iov[i].iov_base, (unsigned long) xp->iov[i].iov_len)); + DDS_TRACE(" %p:%lu", (void *) xp->iov[i].iov_base, (unsigned long) xp->iov[i].iov_len); } } - TRACE ((" [")); + DDS_TRACE(" ["); if (xp->dstmode == NN_XMSG_DST_ONE) { calls = 1; @@ -1459,10 +1459,10 @@ static void nn_xpack_send_real (struct nn_xpack * xp) unref_addrset (xp->dstaddr.all.as_group); } } - TRACE ((" ]\n")); + DDS_TRACE(" ]\n"); if (calls) { - nn_log (LC_TRAFFIC, "traffic-xmit (%lu) %u\n", (unsigned long) calls, xp->msg_len.length); + DDS_LOG(DDS_LC_TRAFFIC, "traffic-xmit (%lu) %u\n", (unsigned long) calls, xp->msg_len.length); } nn_xmsg_chain_release (&xp->included_msgs); nn_xpack_reinit (xp); @@ -1692,22 +1692,22 @@ int nn_xpack_addmsg (struct nn_xpack *xp, struct nn_xmsg *m, const uint32_t flag But do make sure we can't run out of iovecs. */ assert (niov + NN_XMSG_MAX_SUBMESSAGE_IOVECS <= NN_XMSG_MAX_MESSAGE_IOVECS); - TRACE (("xpack_addmsg %p %p %u(", (void *) xp, (void *) m, flags)); + DDS_TRACE("xpack_addmsg %p %p %u(", (void *) xp, (void *) m, flags); switch (m->kind) { case NN_XMSG_KIND_CONTROL: - TRACE (("control")); + DDS_TRACE("control"); break; case NN_XMSG_KIND_DATA: case NN_XMSG_KIND_DATA_REXMIT: - TRACE (("%s(%x:%x:%x:%x:#%"PRId64"/%u)", + DDS_TRACE("%s(%x:%x:%x:%x:#%"PRId64"/%u)", (m->kind == NN_XMSG_KIND_DATA) ? "data" : "rexmit", PGUID (m->kindspecific.data.wrguid), m->kindspecific.data.wrseq, - m->kindspecific.data.wrfragid + 1)); + m->kindspecific.data.wrfragid + 1); break; } - TRACE (("): niov %d sz %"PRIuSIZE, (int) niov, sz)); + DDS_TRACE("): niov %d sz %"PRIuSIZE, (int) niov, sz); /* If a fresh xp has been provided, add an RTPS header */ @@ -1835,7 +1835,7 @@ int nn_xpack_addmsg (struct nn_xpack *xp, struct nn_xmsg *m, const uint32_t flag if (xpo_niov > 0 && sz > config.max_msg_size) { - TRACE ((" => now niov %d sz %"PRIuSIZE" > max_msg_size %u, nn_xpack_send niov %d sz %u now\n", (int) niov, sz, config.max_msg_size, (int) xpo_niov, xpo_sz)); + DDS_TRACE(" => now niov %d sz %"PRIuSIZE" > max_msg_size %u, nn_xpack_send niov %d sz %u now\n", (int) niov, sz, config.max_msg_size, (int) xpo_niov, xpo_sz); xp->msg_len.length = xpo_sz; xp->niov = xpo_niov; nn_xpack_send (xp, false); @@ -1845,7 +1845,7 @@ int nn_xpack_addmsg (struct nn_xpack *xp, struct nn_xmsg *m, const uint32_t flag { xp->call_flags = flags; nn_xmsg_chain_add (&xp->included_msgs, m); - TRACE ((" => now niov %d sz %"PRIuSIZE"\n", (int) niov, sz)); + DDS_TRACE(" => now niov %d sz %"PRIuSIZE"\n", (int) niov, sz); } return result; diff --git a/src/core/ddsi/src/sysdeps.c b/src/core/ddsi/src/sysdeps.c index 98e226a..68eeb13 100644 --- a/src/core/ddsi/src/sysdeps.c +++ b/src/core/ddsi/src/sysdeps.c @@ -267,17 +267,17 @@ static void log_stacktrace_sigh (int sig __attribute__ ((unused))) void log_stacktrace (const char *name, os_threadId tid) { - if (config.enabled_logcats == 0) + if (dds_get_log_mask() == 0) ; /* no op if nothing logged */ else if (!config.noprogress_log_stacktraces) - nn_log (~0u, "-- stack trace of %s requested, but traces disabled --\n", name); + DDS_LOG(~0u, "-- stack trace of %s requested, but traces disabled --\n", name); else { const os_time d = { 0, 1000000 }; struct sigaction act, oact; char **strs; int i; - nn_log (~0u, "-- stack trace of %s requested --\n", name); + DDS_LOG(~0u, "-- stack trace of %s requested --\n", name); act.sa_handler = log_stacktrace_sigh; act.sa_flags = 0; sigfillset (&act.sa_mask); @@ -289,15 +289,15 @@ void log_stacktrace (const char *name, os_threadId tid) os_nanoSleep (d); sigaction (SIGXCPU, &oact, NULL); if (pthread_kill (tid.v, 0) != 0) - nn_log (~0u, "-- thread exited --\n"); + DDS_LOG(~0u, "-- thread exited --\n"); else { - nn_log (~0u, "-- stack trace follows --\n"); + DDS_LOG(~0u, "-- stack trace follows --\n"); strs = backtrace_symbols (log_stacktrace_stk.stk, log_stacktrace_stk.depth); for (i = 0; i < log_stacktrace_stk.depth; i++) - nn_log (~0u, "%s\n", strs[i]); + DDS_LOG(~0u, "%s\n", strs[i]); free (strs); - nn_log (~0u, "-- end of stack trace --\n"); + DDS_LOG(~0u, "-- end of stack trace --\n"); } os_atomic_st32 (&log_stacktrace_flag, 0); } diff --git a/src/os/CMakeLists.txt b/src/os/CMakeLists.txt index 2fce835..cf713e7 100644 --- a/src/os/CMakeLists.txt +++ b/src/os/CMakeLists.txt @@ -11,16 +11,17 @@ # string(TOLOWER ${CMAKE_SYSTEM_NAME} platform) -# For posix platforms include the files in the posix/ directory. set (posix_platforms darwin linux sunos) IF(${platform} IN_LIST posix_platforms) set(platform posix) ENDIF() +# For posix platforms include the files in the posix/ directory. PREPEND(srcs_platform ${platform} os_platform_errno.c os_platform_heap.c os_platform_init.c os_platform_process.c os_platform_ifaddrs.c os_platform_socket.c os_platform_stdlib.c os_platform_sync.c os_platform_thread.c os_platform_time.c) include (GenerateExportHeader) -PREPEND(srcs_os "${CMAKE_CURRENT_SOURCE_DIR}/src" os_atomics.c os_init.c os_report.c os_ifaddrs.c os_socket.c os_thread.c os_time.c os_errno.c os_iter.c ${srcs_platform}) +PREPEND(srcs_os "${CMAKE_CURRENT_SOURCE_DIR}/src" os_atomics.c os_init.c os_log.c os_ifaddrs.c os_socket.c os_thread.c os_time.c os_errno.c os_iter.c ${srcs_platform}) + add_library(OSAPI ${srcs_os}) configure_file( diff --git a/src/os/include/os/os.h b/src/os/include/os/os.h index 836a7cf..70d8313 100644 --- a/src/os/include/os/os.h +++ b/src/os/include/os/os.h @@ -49,12 +49,11 @@ #include "os_socket.h" #include "os_heap.h" #include "os_stdlib.h" -#include "os_report.h" #include "os_init.h" #include "os_process.h" #include "os_errno.h" #include "os_iter.h" - +#include "os_log.h" #define OSPL_VERSION_STR "aap" #define OSPL_HOST_STR "noot" diff --git a/src/os/include/os/os_log.h b/src/os/include/os/os_log.h new file mode 100644 index 0000000..496f5cd --- /dev/null +++ b/src/os/include/os/os_log.h @@ -0,0 +1,234 @@ +/* + * Copyright(c) 2006 to 2018 ADLINK Technology Limited and others + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License + * v. 1.0 which is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause + */ + +/** @file + * + * @brief DDS C Logging API + * + * This header file defines the public API for logging and controlling logging + * in the DDS C language binding. + */ +#ifndef DDS_LOG_H +#define DDS_LOG_H + +#include "os/os_defs.h" + +#if defined (__cplusplus) +extern "C" { +#endif + +/** @defgroup log_categories Convenience log category definitions. + * + * These defines expand into numeric values that can be ORed together to + * specify messages of which categories must be passed to the respective sinks. + * + * Every category other than DDS_LC_FATAL, DDS_LC_ERROR, DDS_LC_WARNING and + * DDS_LC_INFO automatically falls into the trace category. + * + * @{ + */ +/** Fatal error condition. Immediate abort on sink return. */ +#define DDS_LC_FATAL (1u) +/** Error condition. */ +#define DDS_LC_ERROR (2u) +/** Warning condition. */ +#define DDS_LC_WARNING (4u) +/** Informational message. */ +#define DDS_LC_INFO (8u) +/** Debug/trace messages related to configuration settings. */ +#define DDS_LC_CONFIG (16u) +/** Debug/trace messages related to node discovery. */ +#define DDS_LC_DISCOVERY (32u) +/** Currently unused. */ +#define DDS_LC_DATA (64u) +/** Debug/trace messages for which no specialized category exists (yet). */ +#define DDS_LC_TRACE (128u) +/** Debug/trace messages related to receive administration. */ +#define DDS_LC_RADMIN (256u) +/** Debug/trace messages related to timing. */ +#define DDS_LC_TIMING (512u) +/** Debug/trace messages related to send administration. */ +#define DDS_LC_TRAFFIC (1024u) +/** Currently unused. */ +#define DDS_LC_TOPIC (2048u) +/** Debug/trace messages related to TCP communication. */ +#define DDS_LC_TCP (4096u) +/** Debug/trace messages related to parameter list processing. */ +#define DDS_LC_PLIST (8192u) +/** Debug/trace messages related to the writer history cache. */ +#define DDS_LC_WHC (16384u) +/** Debug/trace messages related to throttling. */ +#define DDS_LC_THROTTLE (32768u) +/** All common trace categories. */ +#define DDS_LC_ALL \ + (DDS_LC_FATAL | DDS_LC_ERROR | DDS_LC_WARNING | DDS_LC_INFO | \ + DDS_LC_CONFIG | DDS_LC_DISCOVERY | DDS_LC_DATA | DDS_LC_TRACE | \ + DDS_LC_TIMING | DDS_LC_TRAFFIC | DDS_LC_TCP | DDS_LC_THROTTLE) +/** @}*/ + +#define DDS_LOG_MASK \ + (DDS_LC_FATAL | DDS_LC_ERROR | DDS_LC_WARNING | DDS_LC_INFO) + +#define DDS_TRACE_MASK \ + (~DDS_LOG_MASK) + +/** Structure with log message and meta data passed to callbacks. */ +typedef struct { + /** Log category the message falls into. */ + uint32_t priority; + /** Filename where message was generated. */ + const char *file; + /** Line number in file where message was generated. */ + uint32_t line; + /** Name of function message where message was generated. */ + const char *function; + /** Log message. */ + const char *message; + /** Size of log message. */ + size_t size; +} dds_log_data_t; + +/** Function signature that log and trace callbacks must adhere too. */ +typedef void(*dds_log_write_fn_t)(void *, const dds_log_data_t *); + +extern uint32_t *const dds_log_mask; + +/** + * @brief Get currently enabled log and trace categories. + * + * @returns A uint32_t with enabled categories set. + */ +inline uint32_t +dds_get_log_mask(void) +{ + return *dds_log_mask; +} + +/** + * @brief Set enabled log and trace categories. + * + * @param[in] cats Log and trace categories to enable. + */ +OSAPI_EXPORT void +dds_set_log_mask( + _In_ uint32_t cats); + +/** + * @private + */ +OSAPI_EXPORT void +dds_set_log_file( + _In_ FILE *file); + +/** + * @private + */ +OSAPI_EXPORT void +dds_set_trace_file( + _In_ FILE *file); + +/** + * @brief Register callback to receive log messages + * + * Callbacks registered to handle log messages will receive messages of type + * info, warning, error and fatal. Messages that fall into the trace category + * will never be delivered to the callback. + * + * This operation is synchronous and only returns once the operation is + * registered with all threads. Meaning that neither callback or userdata will + * be referenced by the DDS stack on return. + * + * @param[in] callback Function pointer matching dds_log_write_fn signature + * or a null pointer to restore the default sink. + * @param[in] userdata User specified data passed along with each invocation + * of callback. + */ +OSAPI_EXPORT void +dds_set_log_sink( + _In_opt_ dds_log_write_fn_t callback, + _In_opt_ void *userdata); + +/** + * @brief Register callback to receive trace messages + * + * Callbacks registered to handle trace messages will receive messages of type + * info, warning, error and fatal as well as all message types that fall into + * the trace category depending on the log mask. + * + * This operation is synchronous and only returns once the operation is + * registered with all threads. Meaning that neither callback or + * userdata will be referenced by the DDS stack on return. + * + * @param[in] callback Function pointer matching dds_log_write_fn_t signature + * or a null pointer to restore the default sink. + * @param[in] userdata User specified data passed along with each invocation + * of callback. + */ +OSAPI_EXPORT void +dds_set_trace_sink( + _In_opt_ dds_log_write_fn_t callback, + _In_opt_ void *userdata); + +/** + * @brief Write a log or trace message. + * + * Write a log or trace message to one (or both) of the currently active sinks. + * + * Direct use of #dds_log is discouraged. Use #DDS_INFO, #DDS_WARNING, + * #DDS_ERROR, #DDS_FATAL or #DDS_LOG instead. + */ +OSAPI_EXPORT int +dds_log( + _In_ uint32_t prio, + _In_z_ const char *file, + _In_ uint32_t line, + _In_z_ const char *func, + _In_z_ _Printf_format_string_ const char *fmt, + ...) __attribute_format__((printf,5,6)); + +/** + * @brief Write a log message. + * + * Write a log or trace message to the currently active log and/or trace sinks + * if the log category is enabled. Whether or not the category is enabled is + * checked before any dds_log-related activities to save a couple of % CPU. + * + * Only messages that fall into one of the log categories are passed onto + * dds_log. While messages that fall into a trace category could have been + * passed just as easily, they are rejected so that tracing is kept entirely + * separate from logging, if only cosmetic. + */ +#define DDS_LOG(cat, ...) \ + ((dds_get_log_mask() & (cat)) ? \ + dds_log(cat, __FILE__, __LINE__, OS_FUNCTION, __VA_ARGS__) : 0) + +/** Write a log message of type #DDS_LC_INFO. */ +#define DDS_INFO(...) \ + DDS_LOG(DDS_LC_INFO, __VA_ARGS__) +/** Write a log message of type #DDS_LC_WARNING. */ +#define DDS_WARNING(...) \ + DDS_LOG(DDS_LC_WARNING, __VA_ARGS__) +/** Write a log message of type #DDS_LC_ERROR. */ +#define DDS_ERROR(...) \ + DDS_LOG(DDS_LC_ERROR, __VA_ARGS__) +/** Write a log message of type #DDS_LC_ERROR and abort. */ +#define DDS_FATAL(...) \ + dds_log(DDS_LC_FATAL, __FILE__, __LINE__, OS_FUNCTION, __VA_ARGS__) +/** Write a #DDS_LC_TRACE message. */ +#define DDS_TRACE(...) \ + DDS_LOG(DDS_LC_TRACE, __VA_ARGS__) + +#if defined (__cplusplus) +} +#endif + +#endif /* DDS_LOG_H */ diff --git a/src/os/include/os/os_report.h b/src/os/include/os/os_report.h deleted file mode 100644 index a8220f4..0000000 --- a/src/os/include/os/os_report.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright(c) 2006 to 2018 ADLINK Technology Limited and others - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License - * v. 1.0 which is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause - */ -#ifndef OS_REPORT_H -#define OS_REPORT_H - -#include - -#if defined (__cplusplus) -extern "C" { -#endif - - /* !!!!!!!!NOTE From here no more includes are allowed!!!!!!! */ - - /* Subcomponents might need to alter the report before actually handing it over - * to os_report. Since os_report truncates messages, those components can get - * away with fixed size buffers as well, but the maximum size must known at - * that point. - */ -#define OS_REPORT_BUFLEN 1024 - - /* - Note - in the below the check of reportType against os_reportVerbosity is also present - in os_report. By duplicating it we avoid putting the call onto the stack and evaluating - args if not necessary. - */ - -#define OS_REPORT(type,context,code,message,...) \ -(((type) >= os_reportVerbosity) ? os_report((type),(context),__FILE__,__LINE__,(code),(message),##__VA_ARGS__) : (void)0) - - -#define OS_DEBUG(context,code,message,...) OS_REPORT(OS_REPORT_DEBUG,(context),(code),(message),##__VA_ARGS__) -#define OS_INFO(context,code,message,...) OS_REPORT(OS_REPORT_INFO,(context),(code),(message),##__VA_ARGS__) -#define OS_WARNING(context,code,message,...) OS_REPORT(OS_REPORT_WARNING,(context),(code),(message),##__VA_ARGS__) -#define OS_ERROR(context,code,message,...) OS_REPORT(OS_REPORT_ERROR,(context),(code),(message),##__VA_ARGS__) -#define OS_CRITICAL(context,code,message,...) OS_REPORT(OS_REPORT_CRITICAL,(context),(code),(message),##__VA_ARGS__) -#define OS_FATAL(context,code,message,...) OS_REPORT(OS_REPORT_FATAL,(context),(code),(message),##__VA_ARGS__) - -#define OS_REPORT_STACK() \ -os_report_stack() - -#define OS_REPORT_FLUSH(condition) \ -os_report_flush((condition), OS_FUNCTION, __FILE__, __LINE__) - - /** - * These types are an ordered series of incremental 'importance' (to the user) - * levels. - * @see os_reportVerbosity - */ - typedef enum os_reportType { - OS_REPORT_DEBUG, - OS_REPORT_INFO, - OS_REPORT_WARNING, - OS_REPORT_ERROR, - OS_REPORT_FATAL, - OS_REPORT_CRITICAL, - OS_REPORT_NONE - } os_reportType; - - OSAPI_EXPORT extern os_reportType os_reportVerbosity; - - OSAPI_EXPORT void - os_reportInit(_In_ bool forceReInit); - - OSAPI_EXPORT void - os_reportExit(void); - - /** \brief Report message - * - * Consider this function private. It should be invoked by reporting functions - * specified in the language bindings only. - * - * @param type type of report - * @param context context in which report was generated, often function name - * from which function was invoked - * @param path path of file from which function was invoked - * @param line line of file from which function was invoked - * @param code error code associated with the report - * @param format message to log - * @param ... Parameter to log - */ - - OSAPI_EXPORT void - os_report( - _In_ os_reportType type, - _In_z_ const char *context, - _In_z_ const char *path, - _In_ int32_t line, - _In_ int32_t code, - _In_z_ _Printf_format_string_ const char *format, - ...) __attribute_format__((printf,6,7)); - - /***************************************** - * Report stack related functions - *****************************************/ - - /** - * The os_report_stack operation enables a report stack for the current thread. - * The stack will be disabled again by the os_report_flush operation. - */ - OSAPI_EXPORT void - os_report_stack( - void); - - /** - * The os_report_stack_free operation frees all memory allocated by the current - * thread for the report stack. - */ - OSAPI_EXPORT void - os_report_stack_free( - void); - - /** - * The os_report_flush operation removes the report message from the stack, - * and if valid is TRUE also writes them into the report device. - * This operation additionally disables the stack. - */ - OSAPI_EXPORT void - os_report_flush( - _In_ bool valid, - _In_z_ const char *context, - _In_z_ const char *file, - _In_ int line); - -#if defined (__cplusplus) -} -#endif - -#endif /* OS_REPORT_H */ diff --git a/src/os/include/os/os_stdlib.h b/src/os/include/os/os_stdlib.h index c8a665b..2032a63 100644 --- a/src/os/include/os/os_stdlib.h +++ b/src/os/include/os/os_stdlib.h @@ -82,127 +82,6 @@ extern "C" { os_putenv( char *variable_definition); - /** \brief Get file seperator - * - * Possible Results: - * - "" - */ - OSAPI_EXPORT const char * - os_fileSep(void); - - /** \brief Get path seperator - * - * Possible Results: - * - "" - */ - OSAPI_EXPORT const char * - os_pathSep(void); - -#define OS_PATHSEPCHAR OS_OS_PATHSEPCHAR -#define OS_EXESUFFIX OS_OS_EXESUFFIX -#define OS_BATSUFFIX OS_OS_BATSUFFIX -#define OS_LIB_LOAD_PATH_VAR OS_OS_LIB_LOAD_PATH_VAR - - /** \brief Check user's permissions for a file - * - * Precondition: - * - permission is a mask of: - * OS_ROK check for read access - * OS_WOK check for write access - * OS_XOK check for execution access - * OS_FOK check for existence of the file - * - * Possible results: - * - return os_resultSuccess if - * requested file access is granted - * - return os_resultFail if - * requested file access is not granted - */ - OSAPI_EXPORT os_result - os_access( - const char *file_path, - int32_t permission); - - /** \brief Locate an executable file in the path - * - * Precondition: - * - permission is a mask of: - * OS_ROK check for read access - * OS_WOK check for write access - * OS_XOK check for execution access - * OS_FOK check for existence of the file - * - * Possible results: - * - return an os_malloc-ed string if a file with - * the given permission mask was found in - * PATH. The return value contains the full - * path name of the file found. - * If the name of the file contains an - * absolute or relative path, then no - * search is done in the PATH. - * - return NULL if no file was found in PATH - */ - OSAPI_EXPORT char * - os_locate( - const char *name, - int32_t permission); - - /** \brief mkdir wrapper - * - * because operating systems has different - * interfaces to mkdir a wrapper is made - * - * Precondition: - * None - * - * Possible results: - * - return 0 if - * requested dir is created - * - return -1 if - * requested dir could not be created - */ - OSAPI_EXPORT int32_t - os_mkdir( - const char *path, - os_mode_t mode); - - /** \brief Create a path including parent dirs - * - * Alternative to os_mkdir that creates all path elements instead - * of only the top-level directory - * - * Preconditions: - * None - * - * Possible results: - * - return os_resultSuccess if - * requested path is created - * - return os_resultFail if - * requested path could not be created - * - * When path creation fails an appropriate error message is reported - */ - OSAPI_EXPORT os_result - os_mkpath( - const char *path, - os_mode_t mode); - - /** \brief dirname wrapper - * - * because not all operating systems have - * interfaces to dirname a wrapper is made - * - * Precondition: - * None - * - * Possible results: - * - return '.' if - * path is a null pointer - * - return char * - * to a string that is the parent directory of path - */ - OSAPI_EXPORT char * os_dirname_r(char *path); - /** \brief rindex wrapper * * because not all operating systems have @@ -576,91 +455,6 @@ extern "C" { OSAPI_EXPORT char * os_strtok_r(char *str, const char *delim, char **saveptr); - struct os_stat { - /* The mode_t macro's (like OS_ISDIR) are defined in the platform specific header files! */ - /* NEVER name these fields identical to the POSIX standard! Since e.g. the Linux implementation - has defined it as follows: - struct stat { - ... - struct timespec st_mtim; - #define st_mtime st_mtim.tvsec - ... - }; - This results in the fact that our definition is also changed, causing compilation errors! - */ - os_mode_t stat_mode; - size_t stat_size; - os_time stat_mtime; - }; - - OSAPI_EXPORT os_result - os_stat( - const char *path, - struct os_stat *buf); - - /** \brief Removes the file or directory given by name. - * - * This function is equivalent to POSIX remove(3) - * - */ - - OSAPI_EXPORT os_result os_remove (const char *name); - - /** \brief Renames a file or directory - * - * This function is equivalent to POSIX rename(3) - * - */ - - OSAPI_EXPORT os_result os_rename (const char *oldpath, const char *newpath); - - /** \brief Transforms the given filepath into a platform specific filepath. - * - * This translation function will replace any platform file seperator into - * the fileseperator of the current platform. - * - * Precondition: - * none - * - * Possible results: - * - returns normalized filepath conform current platform - * - return NULL if out of memory. - */ - _Ret_z_ - _Must_inspect_result_ - OSAPI_EXPORT char * - os_fileNormalize( - _In_z_ const char *filepath); - - /** - * \brief Flushes the internal buffers associated with the file handle to disk - * - * Precondition: - * The file should be open. - * - * Possible results: - * - os_resultSuccess if function succeeded - * - os_resultFail if function failed - */ - OSAPI_EXPORT os_result - os_fsync( - FILE *fHandle); - - /** - * \brief returns the location of the temporary files used by OpenSplice. - * This may be the key file describing the shared memory or the shared - * file itself depending on the operating system - * - * Precondition: - * none - * - * Possible results: - * - char * of the absolute path of the temporary location. This will return - * always return a valid value, using a default if necessary - */ - OSAPI_EXPORT _Ret_opt_z_ const char * - os_getTempDir(void); - /** * \brief writes up to count bytes from the buffer pointed buf to the file referred to by the file descriptor fd. * @@ -678,42 +472,6 @@ extern "C" { _In_reads_bytes_(count) void const* buf, _In_ size_t count); - /** - * \brief the os_flockfile() function waits for *filehandle to be - * no longer locked by a different thread, then makes the current - * thread owner of *filehandle, and increments the lockcount. - * (not effective on VxWorks DKM platform) - * - * Precondition: - * none - * - * Possible results: - * - No error information is returned. - * The thread will block until the lock is acquired. - * An explicit call to os_funlockfile has to be used to release the lock. - * - */ - OSAPI_EXPORT void os_flockfile( - FILE *file); - - /** - * \brief the os_funlockfile function decrements the lock count and releases - * the internal locking object of the *filehandle. The *filehandle must - * have been locked before by a call to os_flockfile. - * (not effective on VxWorks DKM platform) - * - * Precondition: - * none - * - * Possible results: - * - No error information is returned. - * The behaviour is undefined if a thread other than the current owner calls - * the os_funlockfile() function. - * - */ - OSAPI_EXPORT void os_funlockfile( - FILE *file); - /** * \brief binary search algorithm on an already sorted list. * diff --git a/src/os/include/os/os_thread.h b/src/os/include/os/os_thread.h index 0b8c74e..b1a8d84 100644 --- a/src/os/include/os/os_thread.h +++ b/src/os/include/os/os_thread.h @@ -37,7 +37,6 @@ extern "C" { OS_THREAD_WARNING, OS_THREAD_ALLOCATOR_STATE, OS_THREAD_NAME, - OS_THREAD_REPORT_STACK, OS_THREAD_PROCESS_INFO, OS_THREAD_STATE, /* Used for monitoring thread progress */ OS_THREAD_STR_ERROR, diff --git a/src/os/include/os/posix/os_platform_sync.h b/src/os/include/os/posix/os_platform_sync.h index dc73db6..cd7987d 100644 --- a/src/os/include/os/posix/os_platform_sync.h +++ b/src/os/include/os/posix/os_platform_sync.h @@ -23,27 +23,15 @@ extern "C" { #endif typedef struct os_cond { -#ifdef OSPL_STRICT_MEM - /* Used to identify initialized cond when memory is freed - - keep this first in the structure so its so its address is - the same as the os_cond */ - uint64_t signature; -#endif pthread_cond_t cond; } os_cond; typedef struct os_mutex { -#ifdef OSPL_STRICT_MEM - /* Used to identify initialized cond when memory is freed - - keep this first in the structure so its so its address is - the same as the os_cond */ - uint64_t signature; -#endif pthread_mutex_t mutex; } os_mutex; typedef struct os_rwlock { - os_mutex mutex; + pthread_rwlock_t rwlock; } os_rwlock; typedef pthread_once_t os_once_t; diff --git a/src/os/src/os_log.c b/src/os/src/os_log.c new file mode 100644 index 0000000..cb6e06d --- /dev/null +++ b/src/os/src/os_log.c @@ -0,0 +1,298 @@ +/* + * Copyright(c) 2006 to 2018 ADLINK Technology Limited and others + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License + * v. 1.0 which is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause + */ +#include +#include +#include +#include + +#include "os/os.h" + +#define MAX_TIMESTAMP_LEN (10 + 1 + 6) +#define MAX_TID_LEN (10) +#define HDR_LEN (MAX_TIMESTAMP_LEN + 1 + MAX_TID_LEN + 2) + +#define BUF_OFFSET HDR_LEN + +typedef struct { + char buf[2048]; + size_t bufsz; + size_t pos; +} log_buffer_t; + +typedef struct { + dds_log_write_fn_t funcs[2]; + void *ptr; + FILE *out; +} log_sink_t; + +static os_threadLocal log_buffer_t log_buffer; + +static os_once_t lock_inited = OS_ONCE_T_STATIC_INIT; +static os_rwlock lock; + +static uint32_t log_mask = DDS_LC_ERROR | DDS_LC_WARNING; + +static void default_sink(void *ptr, const dds_log_data_t *data) +{ + fwrite(data->message - HDR_LEN, 1, HDR_LEN + data->size + 1, (FILE *)ptr); + fflush((FILE *)ptr); +} + +static void nop_sink(void *ptr, const dds_log_data_t *data) +{ + (void)ptr; + (void)data; + return; +} + +#define LOG (0) +#define TRACE (1) +#define USE (0) +#define SET (1) + +static log_sink_t sinks[] = { + /* Log */ + { .funcs = { default_sink, default_sink }, .ptr = NULL, .out = NULL }, + /* Trace */ + { .funcs = { nop_sink, default_sink }, .ptr = NULL, .out = NULL } +}; + +uint32_t *const dds_log_mask = &log_mask; + +#define RDLOCK (1) +#define WRLOCK (2) + +static void init_lock(void) +{ + os_rwlockInit(&lock); + sinks[LOG].ptr = sinks[TRACE].ptr = stderr; + sinks[LOG].out = sinks[TRACE].out = stderr; +} + +static void lock_sink(int type) +{ + assert(type == RDLOCK || type == WRLOCK); + os_once(&lock_inited, &init_lock); + + if (type == RDLOCK) { + os_rwlockRead(&lock); + } else { + os_rwlockWrite(&lock); + } +} + +static void unlock_sink(void) +{ + os_rwlockUnlock(&lock); +} + +static void set_active_log_sinks(void) +{ + if (dds_get_log_mask() & DDS_LOG_MASK) { + sinks[LOG].funcs[USE] = sinks[LOG].funcs[SET]; + } else { + sinks[LOG].funcs[USE] = nop_sink; + } + if (dds_get_log_mask() & DDS_TRACE_MASK) { + sinks[TRACE].funcs[USE] = sinks[TRACE].funcs[SET]; + } else { + sinks[TRACE].funcs[USE] = nop_sink; + } + if (sinks[LOG].funcs[USE] == sinks[TRACE].funcs[USE] && + sinks[LOG].ptr == sinks[TRACE].ptr) + { + sinks[LOG].funcs[USE] = nop_sink; + } +} + +static void +set_log_sink( + _In_ log_sink_t *sink, + _In_opt_ dds_log_write_fn_t func, + _In_opt_ void *ptr) +{ + assert(sink != NULL); + + /* No life cycle management is done for log sinks, the caller is + responsible for that. Ensure this operation is deterministic and that on + return, no thread in the DDS stack still uses the deprecated sink. */ + lock_sink(WRLOCK); + + if (func == 0) { + sink->funcs[SET] = default_sink; + sink->ptr = sink->out; + } else { + sink->funcs[SET] = func; + sink->ptr = ptr; + } + + set_active_log_sinks(); + unlock_sink(); +} + +/* dds_set_log_file must be considered private. */ +void dds_set_log_file(_In_ FILE *file) +{ + lock_sink(WRLOCK); + sinks[LOG].out = file; + if (sinks[LOG].funcs[SET] == default_sink) { + sinks[LOG].ptr = sinks[LOG].out; + } + unlock_sink(); +} + +void dds_set_trace_file(_In_ FILE *file) +{ + lock_sink(WRLOCK); + sinks[TRACE].out = file; + if (sinks[TRACE].funcs[SET] == default_sink) { + sinks[TRACE].ptr = sinks[TRACE].out; + } + unlock_sink(); +} + +void dds_set_log_sink( + _In_opt_ dds_log_write_fn_t callback, + _In_opt_ void *userdata) +{ + set_log_sink(&sinks[LOG], callback, userdata); +} + +void dds_set_trace_sink( + _In_opt_ dds_log_write_fn_t callback, + _In_opt_ void *userdata) +{ + set_log_sink(&sinks[TRACE], callback, userdata); +} + +extern inline uint32_t +dds_get_log_mask(void); + +void +dds_set_log_mask(_In_ uint32_t cats) +{ + lock_sink(WRLOCK); + *dds_log_mask = (cats & (DDS_LOG_MASK | DDS_TRACE_MASK)); + set_active_log_sinks(); + unlock_sink(); +} + +static void print_header(char *str) +{ + int cnt; + char *tid, buf[MAX_TID_LEN] = { 0 }; + static const char fmt[] = "%10u.%06d/%*.*s:"; + os_time tv; + unsigned sec; + int usec; + + (void)os_threadGetThreadName(buf, sizeof(buf)); + tid = (buf[0] == '\0' ? "(anon)" : buf); + tv = os_timeGet(); + sec = (unsigned)tv.tv_sec; + usec = (int)(tv.tv_nsec / 1000); + + cnt = snprintf( + str, HDR_LEN, fmt, sec, usec, MAX_TID_LEN, MAX_TID_LEN, tid); + assert(cnt == (HDR_LEN - 1)); + str[cnt] = ' '; /* Replace snprintf null byte by space. */ +} + +static void vlog( + _In_ uint32_t cat, + _In_z_ const char *file, + _In_ uint32_t line, + _In_z_ const char *func, + _In_z_ const char *fmt, + va_list ap) +{ + int n, trunc = 0; + size_t nrem; + log_buffer_t *lb; + dds_log_data_t data; + + if (*fmt == 0) { + return; + } + + lock_sink(RDLOCK); + lb = &log_buffer; + + /* Thread-local buffer is always initialized with all zeroes. The pos + member must always be greater or equal to BUF_OFFSET. */ + if (lb->pos < BUF_OFFSET) { + lb->pos = BUF_OFFSET; + lb->buf[lb->pos] = 0; + } + nrem = lb->bufsz - lb->pos; + if (nrem > 0) { + n = os_vsnprintf(lb->buf + lb->pos, nrem, fmt, ap); + if (n >= 0 && (size_t) n < nrem) { + lb->pos += (size_t) n; + } else { + lb->pos += nrem; + trunc = 1; + } + if (trunc) { + static const char msg[] = "(trunc)\n"; + const size_t msglen = sizeof (msg) - 1; + assert(lb->pos <= lb->bufsz); + assert(lb->pos >= msglen); + memcpy(lb->buf + lb->pos - msglen, msg, msglen); + } + } + + if (fmt[strlen (fmt) - 1] == '\n') { + print_header(lb->buf); + + data.priority = cat; + data.file = file; + data.function = func; + data.line = line; + data.message = lb->buf + BUF_OFFSET; + data.size = strlen(data.message) - 1; + + for (size_t i = (cat & DDS_LOG_MASK) ? LOG : TRACE; + i < sizeof(sinks) / sizeof(sinks[0]); + i++) + { + sinks[i].funcs[USE](sinks[i].ptr, &data); + } + + lb->pos = BUF_OFFSET; + lb->buf[lb->pos] = 0; + } + + unlock_sink(); +} + +int +dds_log( + _In_ uint32_t cat, + _In_z_ const char *file, + _In_ uint32_t line, + _In_z_ const char *func, + _In_z_ _Printf_format_string_ const char *fmt, + ...) +{ + if ((dds_get_log_mask() & cat) || (cat & DDS_LC_FATAL)) { + va_list ap; + va_start(ap, fmt); + vlog(cat, file, line, func, fmt, ap); + va_end(ap); + } + if (cat & DDS_LC_FATAL) { + abort(); + } + + return 0; +} diff --git a/src/os/src/os_report.c b/src/os/src/os_report.c deleted file mode 100644 index c05935f..0000000 --- a/src/os/src/os_report.c +++ /dev/null @@ -1,909 +0,0 @@ -/* - * Copyright(c) 2006 to 2018 ADLINK Technology Limited and others - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License - * v. 1.0 which is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause - */ -#ifdef PIKEOS_POSIX -#include -#endif - -#include "os/os.h" -#include "os/os_project.h" - -#include -#include -#include -#include - -#define OS_REPORT_TYPE_DEBUG (1u) -#define OS_REPORT_TYPE_WARNING (1u<= this value will be written. - * This value defaults to OS_REPORT_INFO, meaning that all types 'above' (i.e. - * other than) OS_REPORT_DEBUG will be written and OS_REPORT_DEBUG will not be. - */ -os_reportType os_reportVerbosity = OS_REPORT_INFO; - -/** - * Labels corresponding to os_reportType values. - * @see os_reportType - */ -const char *os_reportTypeText [] = { - "DEBUG", - "INFO", - "WARNING", - "ERROR", - "CRITICAL", - "FATAL", - "NONE" -}; - -enum os_report_logType { - OS_REPORT_INFO_LOG, - OS_REPORT_ERROR_LOG -}; - -static char * os_report_defaultInfoFileName = OS_PROJECT_NAME_NOSPACE_SMALL"-info.log"; -static char * os_report_defaultErrorFileName = OS_PROJECT_NAME_NOSPACE_SMALL"-error.log"; -static const char os_env_logdir[] = OS_PROJECT_NAME_NOSPACE_CAPS"_LOGPATH"; -static const char os_env_infofile[] = OS_PROJECT_NAME_NOSPACE_CAPS"_INFOFILE"; -static const char os_env_errorfile[] = OS_PROJECT_NAME_NOSPACE_CAPS"_ERRORFILE"; -static const char os_env_verbosity[] = OS_PROJECT_NAME_NOSPACE_CAPS"_VERBOSITY"; -static const char os_env_append[] = OS_PROJECT_NAME_NOSPACE_CAPS"_LOGAPPEND"; -#if defined _WRS_KERNEL -static const char os_default_logdir[] = "/tgtsvr"; -#else -static const char os_default_logdir[] = "."; -#endif - -static _Ret_maybenull_ FILE * -os__open_file ( - _In_z_ const char * file_name) -{ - FILE *logfile=NULL; - const char *dir = os_getenv (os_env_logdir); - char * nomalized_dir; - char *str; - size_t len; - os_result res = os_resultSuccess; - - if (dir == NULL) { - dir = os_default_logdir; - } - - len = strlen (dir) + 2; /* '/' + '\0' */ - str = os_malloc (len); - if (str != NULL) { - (void)snprintf (str, len, "%s/", dir); - nomalized_dir = os_fileNormalize (str); - os_free (str); - if (nomalized_dir == NULL) { - res = os_resultFail; - } - os_free(nomalized_dir); - } else { - res = os_resultFail; - } - - if (res == os_resultSuccess) { - logfile = fopen (file_name, "a"); - } - - return logfile; -} - -static void -os__close_file ( - _In_z_ const char * file_name, - _In_ _Post_invalid_ FILE *file) -{ - if (strcmp(file_name, "") != 0 && strcmp(file_name, "") != 0) - { - fclose(file); - } -} - -_Check_return_ _Ret_z_ -static char *os__report_createFileNormalize( - _In_z_ const char *file_dir, - _In_z_ const char *file_name) -{ - char file_path[MAX_FILE_PATH]; - int len; - - len = snprintf(file_path, MAX_FILE_PATH, "%s/%s", file_dir, file_name); - /* Note bug in glibc < 2.0.6 returns -1 for output truncated */ - if ( len < MAX_FILE_PATH && len > -1 ) { - return (os_fileNormalize(file_path)); - } else { - return os_strdup(file_name); - } -} - -/** - * Return either a log file path string or a pseudo file name/path value - * like or . - * The result of os_report_file_path must be freed with os_free - * @param override_variable An environment variable name that may hold a filename - * or pseudo filename. If this var is set, and is not a pseudo filename, - * the value of this var will be added to the value of env variable - * {OS_PROJECT_NAME_NOSPACE_CAPS}_LOGPATH (if set or './' if not) to create the - * log file path. - * @param default_file If override_variable is not defined in the environment - * this is the filename used. - */ -_Ret_z_ -_Check_return_ -static char * -os__report_file_path( - _In_z_ const char * default_file, - _In_opt_z_ const char * override_variable, - _In_ enum os_report_logType type) -{ - const char *file_dir; - const char *file_name = NULL; - - if (override_variable != NULL) - { - file_name = os_getenv(override_variable); - } - if (!file_name) - { - file_name = default_file; - } - - file_dir = os_getenv(os_env_logdir); - if (!file_dir) - { - file_dir = os_default_logdir; - } - else - { - /* We just need to check if a file can be written to the directory, we just use the - * default info file as there will always be one created, if we used the variables - * passed in we would create an empty error log (which is bad for testing) and we - * cannot delete it as we open the file with append - */ - if (type == OS_REPORT_INFO_LOG) - { - FILE *logfile; - char *full_file_path; - - full_file_path = os_malloc(strlen(file_dir) + 1 + strlen(file_name) + 1); - strcpy(full_file_path, file_dir); - strcat(full_file_path, "/"); - strcat(full_file_path, file_name); - logfile = fopen (full_file_path, "a"); - if (logfile) - { - fclose(logfile); - } - os_free (full_file_path); - } - } - if (strcmp(file_name, "") != 0 && strcmp(file_name, "") != 0) - { - return (os__report_createFileNormalize(file_dir, file_name)); - } - return os_strdup (file_name); -} - -/** - * Overrides the current minimum output level to be reported from - * this process. - * @param newVerbosity String holding either an integer value corresponding - * to an acceptable (in range) log verbosity or a string verbosity 'name' - * like 'ERROR' or 'warning' or 'DEBUG' or somesuch. - * @return os_resultFail if the string contains neither of the above; - * os_resultSuccess otherwise. - */ -static os_result -os__determine_verbosity( - _In_z_ const char* newVerbosity) -{ - long verbosityInt; - os_result result = os_resultFail; - verbosityInt = strtol(newVerbosity, NULL, 0); - - if (verbosityInt == 0 && strcmp("0", newVerbosity)) { - /* Conversion from int failed. See if it's one of the string forms. */ - while (verbosityInt < (long) (sizeof(os_reportTypeText) / sizeof(os_reportTypeText[0]))) { - if (os_strcasecmp(newVerbosity, os_reportTypeText[verbosityInt]) == 0) { - break; - } - ++verbosityInt; - } - } - if (verbosityInt >= 0 && verbosityInt < (long) (sizeof(os_reportTypeText) / sizeof(os_reportTypeText[0]))) { - /* OS_API_INFO label is kept for backwards compatibility. */ - os_reportVerbosity = (os_reportType)verbosityInt; - result = os_resultSuccess; - } - - return result; -} - -void os__set_verbosity(void) -{ - const char * envValue = os_getenv(os_env_verbosity); - if (envValue != NULL) - { - if (os__determine_verbosity(envValue) == os_resultFail) - { - OS_WARNING("os_reportInit", 0, - "Cannot parse report verbosity %s value \"%s\"," - " reporting verbosity remains %s", os_env_verbosity, envValue, os_reportTypeText[os_reportVerbosity]); - } - } -} - -/** - * Get the destination for logging error reports. Env property {OS_PROJECT_NAME_NOSPACE_CAPS}_INFOFILE and - * {OS_PROJECT_NAME_NOSPACE_CAPS}_LOGPATH controls this value. - * If {OS_PROJECT_NAME_NOSPACE_CAPS}_INFOFILE is not set & this process is a service, default - * to logging to a file named {OS_PROJECT_NAME_NOSPACE_SMALL}-info.log, otherwise - * use standard out. - * @see os_report_file_path - */ -_Ret_z_ -_Check_return_ -static char * -os__get_info_file_name(void) -{ - char * file_name; - os_mutexLock(&infologcreateMutex); - file_name = os__report_file_path (os_report_defaultInfoFileName, os_env_infofile, OS_REPORT_INFO_LOG); - os_mutexUnlock(&infologcreateMutex); - return file_name; -} - -/** - * Get the destination for logging error reports. Env property {OS_PROJECT_NAME_NOSPACE_CAPS}_ERRORFILE and - * {OS_PROJECT_NAME_NOSPACE_CAPS}_LOGPATH controls this value. - * If {OS_PROJECT_NAME_NOSPACE_CAPS}_ERRORFILE is not set & this process is a service, default - * to logging to a file named {OS_PROJECT_NAME_NOSPACE_SMALL}-error.log, otherwise - * use standard error. - * @see os_report_file_path - */ -_Ret_z_ -_Check_return_ -static char * -os__get_error_file_name(void) -{ - char * file_name; - os_mutexLock(&errorlogcreateMutex); - file_name = os__report_file_path (os_report_defaultErrorFileName, os_env_errorfile, OS_REPORT_ERROR_LOG); - os_mutexUnlock(&errorlogcreateMutex); - return file_name; -} - -static void os__remove_stale_logs(void) -{ - if (!StaleLogsRemoved) { - /* TODO: Only a single process or spliced (as 1st process) is allowed to - * delete the log files. */ - /* Remove ospl-info.log and ospl-error.log. - * Ignore the result because it is possible that they don't exist yet. */ - char * log_file_name; - - log_file_name = os__get_error_file_name(); - (void)os_remove(log_file_name); - os_free(log_file_name); - - log_file_name = os__get_info_file_name(); - (void)os_remove(log_file_name); - os_free(log_file_name); - - StaleLogsRemoved = true; - } -} - - -static void os__check_removal_stale_logs(void) -{ - const char * envValue = os_getenv(os_env_append); - if (envValue != NULL) - { - if (os_strcasecmp(envValue, "FALSE") == 0 || - os_strcasecmp(envValue, "0") == 0 || -- os_strcasecmp(envValue, "NO") == 0) { - os__remove_stale_logs(); - } - } -} - -/** - * Read environment properties. In particular ones that can't be left until - * there is a requirement to log. - */ -void os_reportInit( - _In_ bool forceReInit) -{ - if (forceReInit) { - inited = false; - } - - if (!inited) - { - os_mutexInit(&reportMutex); - os_mutexInit(&errorlogcreateMutex); - os_mutexInit(&infologcreateMutex); - - os__check_removal_stale_logs(); - os__set_verbosity(); - } - inited = true; -} - -void os_reportExit(void) -{ - char *name; - os_reportStack reports; - if (!inited) { - return; - } - - reports = os_threadMemGet(OS_THREAD_REPORT_STACK); - if (reports) { - os__report_dumpStack(OS_FUNCTION, __FILE__, __LINE__); - os_iterFree(reports->reports, NULL); - os_threadMemFree(OS_THREAD_REPORT_STACK); - } - inited = false; - os_mutexDestroy(&reportMutex); - - if (error_log) - { - name = os__get_error_file_name(); - os__close_file(name, error_log); - os_free (name); - error_log = NULL; - } - - if (info_log) - { - name = os__get_info_file_name(); - os__close_file(name, info_log); - os_free (name); - info_log = NULL; - } - os_mutexDestroy(&errorlogcreateMutex); - os_mutexDestroy(&infologcreateMutex); -} - -static void os__report_fprintf( - _Inout_ FILE *file, - _In_z_ _Printf_format_string_ const char *format, ...) -{ - int BytesWritten = 0; - va_list args; - va_start(args, format); - BytesWritten = os_vfprintfnosigpipe(file, format, args); - va_end(args); - if (BytesWritten == -1) { - /* error occurred ?, try to write to stdout. (also with no sigpipe, - * stdout can also give broken pipe) - */ - va_start(args, format); - (void) os_vfprintfnosigpipe(stdout, format, args); - va_end(args); - } -} - -static _Ret_notnull_ FILE* os__get_info_file (void) -{ - if (info_log == NULL) { - char * name = os__get_info_file_name(); - info_log = os__open_file(name); - if (!info_log) - { - info_log = stdout; - } - os_free (name); - } - return info_log; -} - -static _Ret_notnull_ FILE* os__get_error_file (void) -{ - if (error_log == NULL) { - char * name = os__get_error_file_name(); - error_log = os__open_file(name); - if (!error_log) - { - error_log = stderr; - } - os_free (name); - } - return error_log; -} - -static void os__sectionReport( - _Pre_notnull_ _Post_notnull_ os_reportEventV1 event, - _In_ bool useErrorLog) -{ - os_time ostime; - FILE *log = useErrorLog ? os__get_error_file() : os__get_info_file(); - - ostime = os_timeGet(); - os_mutexLock(&reportMutex); - os__report_fprintf(log, - "----------------------------------------------------------------------------------------\n" - "Report : %s\n" - "Internals : %s/%s/%d/%d/%d.%09d\n", - event->description, - event->reportContext, - event->fileName, - event->lineNo, - event->code, - ostime.tv_sec, - ostime.tv_nsec); - fflush (log); - os_mutexUnlock(&reportMutex); -} - -static void os__headerReport( - _Pre_notnull_ _Post_notnull_ os_reportEventV1 event, - _In_ bool useErrorLog) -{ - os_time ostime; - char node[64]; - char date_time[128]; - FILE *log = NULL; - if (useErrorLog) - log = os__get_error_file(); - else log = os__get_info_file(); - - ostime = os_timeGet(); - os_ctime_r(&ostime, date_time, sizeof(date_time)); - - if (os_gethostname(node, sizeof(node)-1) == os_resultSuccess) - { - node[sizeof(node)-1] = '\0'; - } - else - { - strcpy(node, "UnkownNode"); - } - - os_mutexLock(&reportMutex); - - os__report_fprintf(log, - "========================================================================================\n" - "ReportType : %s\n" - "Context : %s\n" - "Date : %s\n" - "Node : %s\n" - "Process : %s\n" - "Thread : %s\n" - "Internals : %s/%d/%s/%s/%s\n", - os_reportTypeText[event->reportType], - event->description, - date_time, - node, - event->processDesc, - event->threadDesc, - event->fileName, - event->lineNo, - OSPL_VERSION_STR, - OSPL_INNER_REV_STR, - OSPL_OUTER_REV_STR); - - fflush (log); - - os_mutexUnlock(&reportMutex); -} - -static void os__defaultReport( - _Pre_notnull_ _Post_notnull_ os_reportEventV1 event) -{ - os_time ostime; - char node[64]; - char date_time[128]; - FILE *log; - - switch (event->reportType) { - case OS_REPORT_DEBUG: - case OS_REPORT_INFO: - case OS_REPORT_WARNING: - log = os__get_info_file(); - break; - case OS_REPORT_ERROR: - case OS_REPORT_CRITICAL: - case OS_REPORT_FATAL: - default: - log = os__get_error_file(); - break; - } - - ostime = os_timeGet(); - os_ctime_r(&ostime, date_time, sizeof(date_time)); - - if (os_gethostname(node, sizeof(node)-1) == os_resultSuccess) - { - node[sizeof(node)-1] = '\0'; - } - else - { - strcpy(node, "UnkownNode"); - } - - os_mutexLock(&reportMutex); - os__report_fprintf (log, - "========================================================================================\n" - "Report : %s\n" - "Date : %s\n" - "Description : %s\n" - "Node : %s\n" - "Process : %s\n" - "Thread : %s\n" - "Internals : %s/%s/%s/%s/%s/%d/%d/%d.%09d\n", - os_reportTypeText[event->reportType], - date_time, - event->description, - node, - event->processDesc, - event->threadDesc, - OSPL_VERSION_STR, - OSPL_INNER_REV_STR, - OSPL_OUTER_REV_STR, - event->reportContext, - event->fileName, - event->lineNo, - event->code, - ostime.tv_sec, - ostime.tv_nsec); - fflush (log); - os_mutexUnlock(&reportMutex); -} - - - -void os_report_message( - _In_ os_reportType type, - _In_z_ const char *context, - _In_z_ const char *path, - _In_ int32_t line, - _In_ int32_t code, - _In_z_ const char *message) -{ - char *file; - char procid[256], thrid[64]; - os_reportStack stack; - - struct os_reportEventV1_s report = { OS_REPORT_EVENT_V1, /* version */ - OS_REPORT_NONE, /* reportType */ - NULL, /* reportContext */ - NULL, /* fileName */ - 0, /* lineNo */ - 0, /* code */ - NULL, /* description */ - NULL, /* threadDesc */ - NULL /* processDesc */ - }; - - file = (char *)path; - - /* Only figure out process and thread identities if the user requested an - entry in the default log file or registered a typed report plugin. */ - os_procNamePid (procid, sizeof (procid)); - os_threadFigureIdentity (thrid, sizeof (thrid)); - - report.reportType = type; - report.reportContext = (char *)context; - report.fileName = (char *)file; - report.lineNo = line; - report.code = code; - report.description = (char *)message; - report.threadDesc = thrid; - report.processDesc = procid; - - stack = (os_reportStack)os_threadMemGet(OS_THREAD_REPORT_STACK); - if (stack && stack->count) { - if (report.reportType != OS_REPORT_NONE) { - os__report_append (stack, &report); - } - } else { - os__defaultReport (&report); - } -} - -void os_report( - _In_ os_reportType type, - _In_z_ const char *context, - _In_z_ const char *path, - _In_ int32_t line, - _In_ int32_t code, - _In_z_ _Printf_format_string_ const char *format, - ...) -{ - char buf[OS_REPORT_BUFLEN]; - va_list args; - - if (!inited) { - return; - } - - if (type < os_reportVerbosity) { - return; - } - - va_start (args, format); - (void)os_vsnprintf (buf, sizeof(buf), format, args); - va_end (args); - - os_report_message(type, context, path, line, code, buf); -} - -/***************************************** - * Report-stack related functions - *****************************************/ -void os_report_stack(void) -{ - os_reportStack _this; - - if (inited == false) { - return; - } - _this = (os_reportStack)os_threadMemGet(OS_THREAD_REPORT_STACK); - if (!_this) { - /* Report stack does not exist yet, so create it */ - _this = os_threadMemMalloc(OS_THREAD_REPORT_STACK, sizeof(struct os_reportStack_s)); - if (_this) { - _this->count = 1; - _this->typeset = 0; - _this->file = NULL; - _this->lineno = 0; - _this->signature = NULL; - _this->reports = os_iterNew(); - } else { - OS_ERROR("os_report_stack", 0, - "Failed to initialize report stack (could not allocate thread-specific memory)"); - } - } else { - /* Use previously created report stack */ - if (_this->count == 0) { - _this->file = NULL; - _this->lineno = 0; - _this->signature = NULL; - } - _this->count++; - - } -} - -void os_report_stack_free(void) -{ - os_reportStack _this; - os_reportEventV1 report; - - _this = (os_reportStack)os_threadMemGet(OS_THREAD_REPORT_STACK); - if (_this) { - while((report = os_iterTake(_this->reports, -1))) { - os__report_free(report); - } - os_iterFree(_this->reports, NULL); - os_threadMemFree(OS_THREAD_REPORT_STACK); - } -} - -static void -os__report_stack_unwind( - _Inout_ os_reportStack _this, - _In_ bool valid, - _In_z_ const char *context, - _In_z_ const char *path, - _In_ int line) -{ - struct os_reportEventV1_s header; - os_reportEventV1 report; - char *file; - bool useErrorLog; - os_reportType reportType = OS_REPORT_ERROR; - - if (!valid) { - if (OS_REPORT_IS_ALWAYS(_this->typeset)) { - valid = true; - } - } else { - reportType = OS_REPORT_FLAG_TYPE(_this->typeset); - } - - useErrorLog = OS_REPORT_IS_ERROR(_this->typeset); - - /* Typeset will be set when a report was appended. */ - if (valid && (_this->typeset != 0)) { - char proc[256], procid[256]; - char thr[64], thrid[64]; - - assert (context != NULL); - assert (path != NULL); - - file = (char *)path; - - os_procNamePid (procid, sizeof (procid)); - os_procName (proc, sizeof (proc)); - os_threadFigureIdentity (thrid, sizeof (thrid)); - os_threadGetThreadName (thr, sizeof (thr)); - - header.reportType = reportType; - header.description = (char *)context; - header.processDesc = procid; - header.threadDesc = thrid; - header.fileName = file; - header.lineNo = line; - - os__headerReport (&header, useErrorLog); - } - - while ((report = os_iterTake(_this->reports, -1))) { - if (valid) { - os__sectionReport (report, useErrorLog); - } - os__report_free(report); - } - - _this->typeset = 0; -} - -static void -os__report_dumpStack( - _In_z_ const char *context, - _In_z_ const char *path, - _In_ int line) -{ - os_reportStack _this; - - if (inited == false) { - return; - } - _this = os_threadMemGet(OS_THREAD_REPORT_STACK); - if ((_this) && (_this->count > 0)) { - os__report_stack_unwind(_this, true, context, path, line); - } -} - -void os_report_flush( - _In_ bool valid, - _In_z_ const char *context, - _In_z_ const char *path, - _In_ int line) -{ - os_reportStack _this; - - if (inited == false) { - return; - } - _this = os_threadMemGet(OS_THREAD_REPORT_STACK); - if ((_this) && (_this->count)) { - if (_this->count == 1) { - os__report_stack_unwind(_this, valid, context, path, line); - _this->file = NULL; - _this->signature = NULL; - _this->lineno = 0; - } - _this->count--; - } -} - -#define OS__STRDUP(str) (str != NULL ? os_strdup(str) : os_strdup("NULL")) - -static void -os__report_append( - _Inout_ os_reportStack _this, - _In_ const os_reportEventV1 report) -{ - os_reportEventV1 copy; - - copy = os_malloc(sizeof(*copy)); - copy->code = report->code; - copy->description = OS__STRDUP(report->description); - copy->fileName = OS__STRDUP(report->fileName); - copy->lineNo = report->lineNo; - copy->processDesc = OS__STRDUP(report->processDesc); - copy->reportContext = OS__STRDUP(report->reportContext); - copy->reportType = report->reportType; - copy->threadDesc = OS__STRDUP(report->threadDesc); - copy->version = report->version; - _this->typeset |= OS_REPORT_TYPE_FLAG(report->reportType); - os_iterAppend(_this->reports, copy); -} - -static void -os__report_free( - _In_ _Post_invalid_ os_reportEventV1 report) -{ - os_free(report->description); - os_free(report->fileName); - os_free(report->processDesc); - os_free(report->reportContext); - os_free(report->threadDesc); - os_free(report); -} diff --git a/src/os/src/os_socket.c b/src/os/src/os_socket.c index b6525f0..1a976a5 100644 --- a/src/os/src/os_socket.c +++ b/src/os/src/os_socket.c @@ -256,13 +256,13 @@ os_sockaddrStringToAddress( ret = getaddrinfo(addressString, NULL, &hints, &res); if (ret != 0) { fmt = "getaddrinfo(\"%s\") failed: %s"; - OS_DEBUG(OS_FUNCTION, 0, fmt, addressString, os_gai_strerror(ret)); + DDS_TRACE(fmt, addressString, os_gai_strerror(ret)); } else if (res != NULL) { memcpy(addressOut, res->ai_addr, res->ai_addrlen); freeaddrinfo(res); } else { fmt = "getaddrinfo(\"%s\") did not return any results"; - OS_DEBUG(OS_FUNCTION, 0, fmt, addressString); + DDS_TRACE(fmt, addressString); } return (ret == 0 && res != NULL); diff --git a/src/os/src/os_thread.c b/src/os/src/os_thread.c index f35cc7d..79e0855 100644 --- a/src/os/src/os_thread.c +++ b/src/os/src/os_thread.c @@ -37,3 +37,32 @@ os_threadAttrInit ( threadAttr->schedPriority = 0; threadAttr->stackSize = 0; } + +int32_t +os_threadFigureIdentity(char *str, uint32_t size) +{ + int32_t cnt; + uintmax_t id; + char *fmt, *ptr, buf[1] = { '\0' }; + uint32_t sz; + + assert(str != NULL); + assert(size >= 1); + + id = os_threadIdToInteger(os_threadIdSelf()); + cnt = os_threadGetThreadName(str, size); + if (cnt >= 0) { + fmt = (cnt > 0 ? " 0x%"PRIxMAX : "0x%"PRIxMAX); + if ((uint32_t)cnt < size) { + ptr = str + (uint32_t)cnt; + sz = size - (uint32_t)cnt; + } else { + ptr = buf; + sz = sizeof(buf); + } + + cnt += snprintf(ptr, sz, fmt, id); + } + + return cnt; +} diff --git a/src/os/src/posix/os_platform_init.c b/src/os/src/posix/os_platform_init.c index d95bdc0..0ab4b10 100644 --- a/src/os/src/posix/os_platform_init.c +++ b/src/os/src/posix/os_platform_init.c @@ -32,14 +32,12 @@ void os_osPlatformInit (void) os_syncModuleInit(); os_threadModuleInit(); os_processModuleInit(); - os_reportInit(false); } /** \brief OS layer deinitialization */ void os_osPlatformExit (void) { - os_reportExit(); os_processModuleExit(); os_threadModuleExit(); os_syncModuleExit(); diff --git a/src/os/src/posix/os_platform_sync.c b/src/os/src/posix/os_platform_sync.c index abc8c29..8c4a75f 100644 --- a/src/os/src/posix/os_platform_sync.c +++ b/src/os/src/posix/os_platform_sync.c @@ -78,9 +78,7 @@ void os_mutexInit (os_mutex *mutex) { int shared; assert (mutex != NULL); -#ifdef OSPL_STRICT_MEM - assert (mutex->signature != OS_MUTEX_MAGIC_SIG); -#endif + pthread_mutex_init (&mutex->mutex, NULL); #if HAVE_LKST if (ospl_lkst_enabled) @@ -88,9 +86,6 @@ void os_mutexInit (os_mutex *mutex) #else (void)shared; #endif -#ifdef OSPL_STRICT_MEM - mutex->signature = OS_MUTEX_MAGIC_SIG; -#endif } void os_mutexDestroy (os_mutex *mutex) @@ -100,22 +95,15 @@ void os_mutexDestroy (os_mutex *mutex) if (ospl_lkst_enabled) lkst_track_destroy (mutex); #endif -#ifdef OSPL_STRICT_MEM - assert(mutex->signature == OS_MUTEX_MAGIC_SIG); -#endif + if (pthread_mutex_destroy (&mutex->mutex) != 0) abort(); -#ifdef OSPL_STRICT_MEM - mutex->signature = 0; -#endif } void os_mutexLock (os_mutex *mutex) { assert (mutex != NULL); -#ifdef OSPL_STRICT_MEM - assert(mutex->signature == OS_MUTEX_MAGIC_SIG); -#endif + #if HAVE_LKST if (!ospl_lkst_enabled) #endif @@ -146,9 +134,7 @@ os_result os_mutexLock_s (os_mutex *mutex) { int result; assert (mutex != NULL); -#ifdef OSPL_STRICT_MEM - assert(mutex->signature == OS_MUTEX_MAGIC_SIG); -#endif + #if HAVE_LKST if (!ospl_lkst_enabled) #endif @@ -178,9 +164,7 @@ os_result os_mutexTryLock (os_mutex *mutex) { int result; assert (mutex != NULL); -#ifdef OSPL_STRICT_MEM - assert(mutex->signature == OS_MUTEX_MAGIC_SIG); -#endif + result = pthread_mutex_trylock (&mutex->mutex); if (result != 0 && result != EBUSY) abort(); @@ -194,9 +178,7 @@ os_result os_mutexTryLock (os_mutex *mutex) void os_mutexUnlock (os_mutex *mutex) { assert (mutex != NULL); -#ifdef OSPL_STRICT_MEM - assert(mutex->signature == OS_MUTEX_MAGIC_SIG); -#endif + #if HAVE_LKST if (ospl_lkst_enabled) lkst_track_op (mutex, LKST_UNLOCK, mach_absolute_time (), 0); @@ -208,36 +190,23 @@ void os_mutexUnlock (os_mutex *mutex) void os_condInit (os_cond *cond, os_mutex *dummymtx __attribute__ ((unused))) { assert (cond != NULL); -#ifdef OSPL_STRICT_MEM - assert(cond->signature != OS_COND_MAGIC_SIG); -#endif + pthread_cond_init (&cond->cond, NULL); -#ifdef OSPL_STRICT_MEM - cond->signature = OS_COND_MAGIC_SIG; -#endif } void os_condDestroy (os_cond *cond) { assert (cond != NULL); -#ifdef OSPL_STRICT_MEM - assert(cond->signature == OS_COND_MAGIC_SIG); -#endif + if (pthread_cond_destroy (&cond->cond) != 0) abort(); -#ifdef OSPL_STRICT_MEM - cond->signature = 0; -#endif } void os_condWait (os_cond *cond, os_mutex *mutex) { assert (cond != NULL); assert (mutex != NULL); -#ifdef OSPL_STRICT_MEM - assert( cond->signature == OS_COND_MAGIC_SIG ); - assert( mutex->signature == OS_MUTEX_MAGIC_SIG ); -#endif + #if HAVE_LKST if (ospl_lkst_enabled) lkst_track_op (mutex, LKST_UNLOCK, mach_absolute_time (), 0); @@ -263,10 +232,6 @@ os_result os_condTimedWait (os_cond *cond, os_mutex *mutex, const os_time *time) assert (cond != NULL); assert (mutex != NULL); assert (time != NULL); -#ifdef OSPL_STRICT_MEM - assert( cond->signature == OS_COND_MAGIC_SIG ); - assert( mutex->signature == OS_MUTEX_MAGIC_SIG ); -#endif (void) gettimeofday (&tv, NULL); @@ -300,9 +265,7 @@ os_result os_condTimedWait (os_cond *cond, os_mutex *mutex, const os_time *time) void os_condSignal (os_cond *cond) { assert (cond != NULL); -#ifdef OSPL_STRICT_MEM - assert( cond->signature == OS_COND_MAGIC_SIG ); -#endif + if (pthread_cond_signal (&cond->cond) != 0) abort(); } @@ -310,47 +273,89 @@ void os_condSignal (os_cond *cond) void os_condBroadcast (os_cond *cond) { assert (cond != NULL); -#ifdef OSPL_STRICT_MEM - assert( cond->signature == OS_COND_MAGIC_SIG ); -#endif + if (pthread_cond_broadcast (&cond->cond) != 0) abort(); } -void os_rwlockInit (os_rwlock *rwlock) +void os_rwlockInit(os_rwlock *rwlock) { - os_mutexInit (&rwlock->mutex); + int err = 0; + + assert(rwlock != NULL); + + /* process-shared attribute is set to PTHREAD_PROCESS_PRIVATE by default */ + if ((err = pthread_rwlock_init(&rwlock->rwlock, NULL)) != 0) { + abort(); + } } -void os_rwlockDestroy (os_rwlock *rwlock) +void os_rwlockDestroy(os_rwlock *rwlock) { - assert (rwlock != NULL); - os_mutexDestroy (&rwlock->mutex); + int err; + + assert(rwlock != NULL); + + if ((err = pthread_rwlock_destroy(&rwlock->rwlock)) != 0) { + abort(); + } } -void os_rwlockRead (os_rwlock *rwlock) +void os_rwlockRead(os_rwlock *rwlock) { - os_mutexLock (&rwlock->mutex); + int err; + + assert(rwlock != NULL); + + err = pthread_rwlock_rdlock(&rwlock->rwlock); + assert(err == 0); + (void)err; } -void os_rwlockWrite (os_rwlock *rwlock) +void os_rwlockWrite(os_rwlock *rwlock) { - os_mutexLock (&rwlock->mutex); + int err; + + assert(rwlock != NULL); + + err = pthread_rwlock_wrlock(&rwlock->rwlock); + assert(err == 0); + (void)err; } -os_result os_rwlockTryRead (os_rwlock *rwlock) +os_result os_rwlockTryRead(os_rwlock *rwlock) { - return os_mutexTryLock (&rwlock->mutex); + int err; + + assert(rwlock != NULL); + + err = pthread_rwlock_tryrdlock(&rwlock->rwlock); + assert(err == 0 || err == EBUSY); + + return err == 0 ? os_resultSuccess : os_resultBusy; } -os_result os_rwlockTryWrite (os_rwlock *rwlock) +os_result os_rwlockTryWrite(os_rwlock *rwlock) { - return os_mutexTryLock (&rwlock->mutex); + int err; + + assert(rwlock != NULL); + + err = pthread_rwlock_trywrlock(&rwlock->rwlock); + assert(err == 0 || err == EBUSY); + + return err == 0 ? os_resultSuccess : os_resultBusy; } -void os_rwlockUnlock (os_rwlock *rwlock) +void os_rwlockUnlock(os_rwlock *rwlock) { - os_mutexUnlock (&rwlock->mutex); + int err; + + assert(rwlock != NULL); + + err = pthread_rwlock_unlock(&rwlock->rwlock); + assert(err == 0); + (void)err; } void diff --git a/src/os/src/snippets/code/os_posix_thread.c b/src/os/src/snippets/code/os_posix_thread.c index 6943485..5fae4dc 100644 --- a/src/os/src/snippets/code/os_posix_thread.c +++ b/src/os/src/snippets/code/os_posix_thread.c @@ -65,13 +65,12 @@ os_threadMemInit ( if (pthreadMemArray != NULL) { memset (pthreadMemArray, 0, sizeof(void *) * OS_THREAD_MEM_ARRAY_SIZE); if (pthread_setspecific (os_threadMemKey, pthreadMemArray) == EINVAL) { - OS_ERROR("os_threadMemInit", 4, - "pthread_setspecific failed with error EINVAL (%d), " - "invalid threadMemKey value", EINVAL); + DDS_ERROR("pthread_setspecific failed with error EINVAL (%d), " + "invalid threadMemKey value\n", EINVAL); os_free(pthreadMemArray); } } else { - OS_ERROR("os_threadMemInit", 3, "Out of heap memory"); + DDS_ERROR("Out of heap memory\n"); } } @@ -106,7 +105,7 @@ os_threadMemExit( os_free (pthreadMemArray); pthreadMemArray = NULL; if (pthread_setspecific (os_threadMemKey, pthreadMemArray) == EINVAL) { - OS_ERROR("os_threadMemExit", 4, "pthread_setspecific failed with error %d", EINVAL); + DDS_ERROR("pthread_setspecific failed with error %d\n", EINVAL); } } } @@ -164,9 +163,8 @@ os_startRoutineWrapper ( /* store the thread name with the thread via thread specific data; failure isn't */ if (pthread_setspecific (os_threadNameKey, context->threadName) == EINVAL) { - OS_WARNING("os_startRoutineWrapper", 0, - "pthread_setspecific failed with error EINVAL (%d), " - "invalid os_threadNameKey value", EINVAL); + DDS_WARNING("pthread_setspecific failed with error EINVAL (%d), " + "invalid os_threadNameKey value\n", EINVAL); } /* allocate an array to store thread private memory references */ @@ -175,12 +173,10 @@ os_startRoutineWrapper ( /* Call the user routine */ resultValue = context->startRoutine (context->arguments); - os_report_stack_free(); - /* Free the thread context resources, arguments is responsibility */ /* for the caller of os_procCreate */ - os_free (context->threadName); - os_free (context); + os_free(context->threadName); + os_free(context); /* deallocate the array to store thread private memory references */ os_threadMemExit (); @@ -276,32 +272,28 @@ os_threadCreate ( if (result != 0) { char errmsg[64]; (void)os_strerror_r(result, errmsg, sizeof(errmsg)); - OS_WARNING("os_threadCreate", 2, - "pthread_attr_setschedpolicy failed for SCHED_FIFO with "\ - "error %d (%s) for thread '%s', reverting to SCHED_OTHER.", - result, errmsg, name); + DDS_WARNING("pthread_attr_setschedpolicy failed for SCHED_FIFO with " + "error %d (%s) for thread '%s', reverting to SCHED_OTHER\n", + result, errmsg, name); result = pthread_attr_setschedpolicy (&attr, SCHED_OTHER); if (result != 0) { - OS_WARNING("os_threadCreate", 2, "pthread_attr_setschedpolicy failed with error %d (%s)", result, name); + DDS_WARNING("pthread_attr_setschedpolicy failed with error %d (%s)\n", result, name); } } } else { result = pthread_attr_setschedpolicy (&attr, SCHED_OTHER); if (result != 0) { - OS_WARNING("os_threadCreate", 2, - "pthread_attr_setschedpolicy failed with error %d (%s)", - result, name); + DDS_WARNING("pthread_attr_setschedpolicy failed with error %d (%s)\n", result, name); } } pthread_attr_getschedpolicy(&attr, &policy); if ((tattr.schedPriority < sched_get_priority_min(policy)) || (tattr.schedPriority > sched_get_priority_max(policy))) { - OS_WARNING("os_threadCreate", 2, - "scheduling priority outside valid range for the policy "\ - "reverted to valid value (%s)", name); + DDS_WARNING("scheduling priority outside valid range for the policy " + "reverted to valid value (%s)\n", name); sched_param.sched_priority = (sched_get_priority_min(policy) + sched_get_priority_max(policy)) / 2; } else { @@ -317,9 +309,8 @@ os_threadCreate ( /* start the thread */ result = pthread_attr_setschedparam (&attr, &sched_param); if (result != 0) { - OS_WARNING("os_threadCreate", 2, - "pthread_attr_setschedparam failed with error %d (%s)", - result, name); + DDS_WARNING("pthread_attr_setschedparam failed with error %d (%s)\n", + result, name); } create_ret = pthread_create(&threadId->v, &attr, os_startRoutineWrapper, @@ -330,19 +321,17 @@ os_threadCreate ( */ if((create_ret == EPERM) && (tattr.schedClass == OS_SCHED_REALTIME)) { - OS_WARNING("os_threadCreate", 2, - "pthread_create failed with SCHED_FIFO " \ - "for thread '%s', reverting to SCHED_OTHER.", - name); + DDS_WARNING("pthread_create failed with SCHED_FIFO " + "for thread '%s', reverting to SCHED_OTHER\n", + name); (void) pthread_attr_setschedpolicy (&attr, SCHED_OTHER); /* SCHED_OTHER is always supported */ pthread_attr_getschedpolicy(&attr, &policy); if ((tattr.schedPriority < sched_get_priority_min(policy)) || (tattr.schedPriority > sched_get_priority_max(policy))) { - OS_WARNING("os_threadCreate", 2, - "scheduling priority outside valid range for the " \ - "policy reverted to valid value (%s)", name); + DDS_WARNING("scheduling priority outside valid range for the " + "policy reverted to valid value (%s)\n", name); sched_param.sched_priority = (sched_get_priority_min(policy) + sched_get_priority_max(policy)) / 2; @@ -352,9 +341,8 @@ os_threadCreate ( result = pthread_attr_setschedparam (&attr, &sched_param); if (result != 0) { - OS_WARNING("os_threadCreate", 2, - "pthread_attr_setschedparam failed " \ - "with error %d (%s)", result, name); + DDS_WARNING("pthread_attr_setschedparam failed " + "with error %d (%s)", result, name); } else { create_ret = pthread_create(&threadId->v, &attr, os_startRoutineWrapper, threadContext); @@ -366,7 +354,7 @@ os_threadCreate ( if(create_ret != 0){ os_free (threadContext->threadName); os_free (threadContext); - OS_WARNING("os_threadCreate", 2, "pthread_create failed with error %d (%s)", create_ret, name); + DDS_WARNING("pthread_create failed with error %d (%s)\n", create_ret, name); rv = os_resultFail; } } @@ -398,29 +386,6 @@ os_threadIdSelf (void) return id; } -/** \brief Figure out the identity of the current thread - * - * \b os_threadFigureIdentity determines the numeric identity - * of a thread. POSIX does not identify threads by name, - * therefore only the numeric identification is returned, - */ -int32_t -os_threadFigureIdentity ( - char *threadIdentity, - uint32_t threadIdentitySize) -{ - int size; - char *threadName; - - threadName = pthread_getspecific (os_threadNameKey); - if (threadName != NULL) { - size = snprintf (threadIdentity, threadIdentitySize, "%s 0x%"PRIxMAX, threadName, (uintmax_t)pthread_self ()); - } else { - size = snprintf (threadIdentity, threadIdentitySize, "0x%"PRIxMAX, (uintmax_t)pthread_self ()); - } - return size; -} - int32_t os_threadGetThreadName ( char *buffer, @@ -486,7 +451,7 @@ os_threadWaitExit ( if (result != 0) { /* NOTE: The below report actually is a debug output; makes no sense from * a customer perspective. Made OS_INFO for now. */ - OS_INFO("os_threadWaitExit", 2, "pthread_join(0x%"PRIxMAX") failed with error %d", os_threadIdToInteger(threadId), result); + DDS_INFO("pthread_join(0x%"PRIxMAX") failed with error %d\n", os_threadIdToInteger(threadId), result); rv = os_resultFail; } else { rv = os_resultSuccess; @@ -652,7 +617,7 @@ os_threadCleanupPush( itr = os_iterNew(); assert(itr != NULL); if (pthread_setspecific(cleanup_key, itr) == EINVAL) { - OS_WARNING(OS_FUNCTION, 0, "pthread_setspecific failed with error EINVAL (%d)", EINVAL); + DDS_WARNING("pthread_setspecific failed with error EINVAL (%d)\n", EINVAL); os_iterFree(itr, NULL); itr = NULL; } diff --git a/src/os/src/snippets/code/os_stdlib.c b/src/os/src/snippets/code/os_stdlib.c index af9f0d4..b001913 100644 --- a/src/os/src/snippets/code/os_stdlib.c +++ b/src/os/src/snippets/code/os_stdlib.c @@ -62,28 +62,6 @@ os_pathSep(void) return ":"; } -os_result -os_access( - const char *file_path, - int32_t permission) -{ - os_result result; -#ifdef VXWORKS_RTP - /* The access function is broken for vxworks RTP for some filesystems - so best ignore the result, and assume the user has correct permissions */ - (void) file_path; - (void) permission; - result = os_resultSuccess; -#else - if (access (file_path, permission) == 0) { - result = os_resultSuccess; - } else { - result = os_resultFail; - } -#endif - return result; -} - int os_vsnprintf( char *str, @@ -130,125 +108,11 @@ os_vfprintfnosigpipe( return result; } -os_result -os_stat( - const char *path, - struct os_stat *buf) -{ - os_result result; - struct stat _buf; - int r; - - r = stat(path, &_buf); - if (r == 0) { - buf->stat_mode = _buf.st_mode; - buf->stat_size = (size_t) _buf.st_size; - buf->stat_mtime.tv_sec = (os_timeSec) _buf.st_mtime; - buf->stat_mtime.tv_nsec = 0; - result = os_resultSuccess; - } else { - result = os_resultFail; - } - - return result; -} - -os_result os_remove (const char *pathname) -{ - return (remove (pathname) == 0) ? os_resultSuccess : os_resultFail; -} - -os_result os_rename (const char *oldpath, const char *newpath) -{ - return (rename (oldpath, newpath) == 0) ? os_resultSuccess : os_resultFail; -} - -/* The result of os_fileNormalize should be freed with os_free */ -char * -os_fileNormalize( - const char *filepath) -{ - char *norm; - const char *fpPtr; - char *normPtr; - - norm = NULL; - if ((filepath != NULL) && (*filepath != '\0')) { - norm = os_malloc(strlen(filepath) + 1); - /* replace any / or \ by OS_FILESEPCHAR */ - fpPtr = (char *) filepath; - normPtr = norm; - while (*fpPtr != '\0') { - *normPtr = *fpPtr; - if ((*fpPtr == '/') || (*fpPtr == '\\')) { - *normPtr = OS_FILESEPCHAR; - normPtr++; - } else { - if (*fpPtr != '\"') { - normPtr++; - } - } - fpPtr++; - } - *normPtr = '\0'; - } - - return norm; -} - -os_result -os_fsync( - FILE *fHandle) -{ - os_result r; - - if (fsync(fileno(fHandle)) == 0) { - r = os_resultSuccess; - } else { - r = os_resultFail; - } - - return r; -} - -_Ret_opt_z_ const char * -os_getTempDir(void) -{ - const char * dir_name = NULL; - - dir_name = os_getenv("OSPL_TEMP"); - - /* if OSPL_TEMP is not defined the default is /tmp */ - if (dir_name == NULL || (strcmp (dir_name, "") == 0)) { - dir_name = "/tmp"; - } - - return dir_name; -} - ssize_t os_write(int fd, const void *buf, size_t count) { return write(fd, buf, count); } -void os_flockfile(FILE *file) -{ - /* flockfile is not supported on the VxWorks DKM platform. - * Therefore, this function block is empty on the VxWorks platform. */ -#ifndef _WRS_KERNEL - flockfile (file); -#endif -} - -void os_funlockfile(FILE *file) -{ - /* funlockfile is not supported on the VxWorks DKM platform. - * Therefore, this function block is empty on the VxWorks platform. */ -#ifndef _WRS_KERNEL - funlockfile (file); -#endif -} - int os_getopt(int argc, char **argv, const char *opts) { return getopt(argc, argv, opts); diff --git a/src/os/src/snippets/code/os_stdlib_strtod.c b/src/os/src/snippets/code/os_stdlib_strtod.c index de405ce..b5cd6a5 100644 --- a/src/os/src/snippets/code/os_stdlib_strtod.c +++ b/src/os/src/snippets/code/os_stdlib_strtod.c @@ -23,8 +23,6 @@ * independent conversions. */ -#include "os/os_report.h" - /* * Determine the maximum size that a string should have to be * able to contain a double. @@ -76,9 +74,8 @@ os_lcNumericGet(void) (void) snprintf(num, 4, "%3.1f", 2.2); lcNumeric = num [1]; if (lcNumeric != '.') { - OS_WARNING("os_stdlib", 0, - "Locale with LC_NUMERIC \'%c\' detected, which is not '.'. This can decrease performance.", - lcNumeric); + DDS_WARNING("Locale with LC_NUMERIC \'%c\' detected, which is not '.'. " + "This can decrease performance.", lcNumeric); } } diff --git a/src/os/src/vxworks/os_platform_init.c b/src/os/src/vxworks/os_platform_init.c index c273f51..a88bd75 100644 --- a/src/os/src/vxworks/os_platform_init.c +++ b/src/os/src/vxworks/os_platform_init.c @@ -84,7 +84,7 @@ void os_osExit (void) uint32_t initCount; #if defined(OS_USE_ALLIGNED_MALLOC) && !defined(NDEBUG) - OS_INFO("os__reallocdoublecopycount", 0, "count=%d", vxAtomicGet(&os__reallocdoublecopycount)); + DDS_INFO("count=%d\n", vxAtomicGet(&os__reallocdoublecopycount)); #endif initCount = os_atomic_dec32_nv(&_ospl_osInitCount); @@ -96,7 +96,7 @@ void os_osExit (void) /* The 0 boundary is passed, so os_osExit is called more often than * os_osInit. Therefore undo decrement as nothing happened and warn. */ initCount = os_atomic_inc32_nv(&_ospl_osInitCount); - OS_WARNING("os_osExit", 1, "OS-layer not initialized"); + DDS_WARNING("OS-layer not initialized\n"); /* Fail in case of DEV, as it is incorrect API usage */ assert(0); } diff --git a/src/os/src/windows/os_platform_init.c b/src/os/src/windows/os_platform_init.c index 39ccce3..bce0825 100644 --- a/src/os/src/windows/os_platform_init.c +++ b/src/os/src/windows/os_platform_init.c @@ -26,14 +26,12 @@ void os_osPlatformInit (void) os_processModuleInit(); os_threadModuleInit(); os_timeModuleInit(); - os_reportInit(false); os_socketModuleInit(); } void os_osPlatformExit (void) { os_socketModuleExit(); - os_reportExit(); os_timeModuleExit(); os_threadModuleExit(); os_processModuleExit(); diff --git a/src/os/src/windows/os_platform_socket.c b/src/os/src/windows/os_platform_socket.c index 4d0f720..15a8b08 100644 --- a/src/os/src/windows/os_platform_socket.c +++ b/src/os/src/windows/os_platform_socket.c @@ -58,7 +58,7 @@ os_socketModuleInit() err = WSAStartup (wVersionRequested, &wsaData); if (err != 0) { - OS_FATAL("os_socketModuleInit", 0, "WSAStartup failed, no compatible socket implementation available"); + DDS_FATAL("WSAStartup failed, no compatible socket implementation available\n"); /* Tell the user that we could not find a usable */ /* WinSock DLL. */ return; @@ -74,14 +74,14 @@ os_socketModuleInit() (HIBYTE(wsaData.wVersion) != OS_SOCK_REVISION)) { /* Tell the user that we could not find a usable */ /* WinSock DLL. */ - OS_FATAL("os_socketModuleInit", 1, "WSAStartup failed, no compatible socket implementation available"); + DDS_FATAL("WSAStartup failed, no compatible socket implementation available\n"); WSACleanup(); return; } qwaveDLLModuleLock = CreateMutex(NULL, FALSE, NULL); if (qwaveDLLModuleLock == NULL) { - OS_ERROR("os_socketModuleInit", 0, "Failed to create mutex"); + DDS_ERROR("Failed to create mutex\n"); } } @@ -232,7 +232,7 @@ os_sockSetDscpValueWithTos( char errmsg[1024]; int errNo = os_getErrno(); (void) os_strerror_r(errNo, errmsg, sizeof errmsg); - OS_WARNING("os_sockSetDscpValue", 0, "Failed to set diffserv value to %lu: %d %s", value, errNo, errmsg); + DDS_WARNING("Failed to set diffserv value to %lu: %d %s\n", value, errNo, errmsg); result = os_resultFail; } @@ -244,16 +244,14 @@ static os_result os_sockLoadQwaveLibrary(void) { if (qwaveDLLModuleLock == NULL) { - OS_WARNING("os_sockLoadQwaveLibrary", 0, - "Failed to load QWAVE.DLL for using diffserv on outgoing IP packets"); + DDS_WARNING("Failed to load QWAVE.DLL for using diffserv on outgoing IP packets\n"); goto err_lock; } WaitForSingleObject(qwaveDLLModuleLock, INFINITE); if (qwaveDLLModuleHandle == NULL) { if ((qwaveDLLModuleHandle = LoadLibrary("QWAVE.DLL")) == NULL) { - OS_WARNING("os_sockLoadQwaveLibrary", 0, - "Failed to load QWAVE.DLL for using diffserv on outgoing IP packets"); + DDS_WARNING("Failed to load QWAVE.DLL for using diffserv on outgoing IP packets\n"); goto err_load_lib; } @@ -264,8 +262,7 @@ os_sockLoadQwaveLibrary(void) if ((qwaveQOSCreateHandleFunc == 0) || (qwaveQOSCloseHandleFunc == 0) || (qwaveQOSAddSocketToFlowFunc == 0) || (qwaveQOSSetFlowFunc == 0)) { - OS_WARNING("os_sockLoadQwaveLibrary", 0, - "Failed to resolve entry points for using diffserv on outgoing IP packets"); + DDS_WARNING("Failed to resolve entry points for using diffserv on outgoing IP packets\n"); goto err_find_func; } } @@ -277,7 +274,6 @@ err_find_func: err_load_lib: ReleaseMutex(qwaveDLLModuleLock); err_lock: - return os_resultFail; } @@ -384,7 +380,7 @@ os_sockSetDscpValueWithQos( char errmsg[1024]; errNo = os_getErrno(); (void)os_strerror_r(errNo, errmsg, sizeof errmsg); - OS_ERROR("os_sockSetDscpValue", 0, "QOSCreateHandle failed: %d %s", errNo, errmsg); + DDS_ERROR("QOSCreateHandle failed: %d %s\n", errNo, errmsg); goto err_create_handle; } @@ -397,7 +393,7 @@ os_sockSetDscpValueWithQos( char errmsg[1024]; errNo = os_getErrno(); (void)os_strerror_r(errNo, errmsg, sizeof errmsg); - OS_ERROR("os_sockSetDscpValue", 0, "QOSAddSocketToFlow failed: %d %s", errNo, errmsg); + DDS_ERROR("QOSAddSocketToFlow failed: %d %s\n", errNo, errmsg); qwaveQOSCloseHandleFunc(qosHandle); goto err_add_flow; } @@ -405,9 +401,8 @@ os_sockSetDscpValueWithQos( if (value != defaultDscp) { if (!setDscpSupported) { - OS_WARNING("os_sockSetDscpValue", 0, - "Failed to set diffserv value to %lu value used is %d, not supported on this platform", - value, defaultDscp); + DDS_WARNING("Failed to set diffserv value to %lu value used is %d, not supported on this platform\n", + value, defaultDscp); goto err_set_flow; } @@ -417,14 +412,13 @@ os_sockSetDscpValueWithQos( if (!qosResult) { errNo = os_getErrno(); if ((errNo == ERROR_ACCESS_DENIED) || (errNo == ERROR_ACCESS_DISABLED_BY_POLICY)) { - OS_WARNING("os_sockSetDscpValue", 0, - "Failed to set diffserv value to %lu value used is %d, not enough privileges", - value, defaultDscp); + DDS_WARNING("Failed to set diffserv value to %lu value used is %d, not enough privileges\n", + value, defaultDscp); } else { char errmsg[1024]; errNo = os_getErrno(); (void)os_strerror_r(errNo, errmsg, sizeof errmsg); - OS_ERROR("os_sockSetDscpValue", 0, "QOSSetFlow failed: %d %s", errNo, errmsg); + DDS_ERROR("QOSSetFlow failed: %d %s\n", errNo, errmsg); } goto err_set_flow; } @@ -435,7 +429,6 @@ os_sockSetDscpValueWithQos( err_set_flow: err_add_flow: err_create_handle: - return result; } @@ -447,11 +440,11 @@ os_sockSetDscpValue( { os_result result; - if (IsWindowsVistaOrGreater() && (os_sockLoadQwaveLibrary() == os_resultSuccess)) { - result = os_sockSetDscpValueWithQos(sock, value, IsWindows7OrGreater()); - } else { - result = os_sockSetDscpValueWithTos(sock, value); - } + if (IsWindowsVistaOrGreater() && (os_sockLoadQwaveLibrary() == os_resultSuccess)) { + result = os_sockSetDscpValueWithQos(sock, value, IsWindows7OrGreater()); + } else { + result = os_sockSetDscpValueWithTos(sock, value); + } return result; } @@ -516,7 +509,7 @@ os_sockSetNonBlocking( r = os_resultInvalid; break; case WSANOTINITIALISED: - OS_FATAL("os_sockSetNonBlocking", 0, "Socket-module not initialised; ensure os_socketModuleInit is performed before using the socket module."); + DDS_FATAL("Socket-module not initialised; ensure os_socketModuleInit is performed before using the socket module\n"); default: r = os_resultFail; break; diff --git a/src/os/src/windows/os_platform_stdlib.c b/src/os/src/windows/os_platform_stdlib.c index 9b9ff3c..343ea0c 100644 --- a/src/os/src/windows/os_platform_stdlib.c +++ b/src/os/src/windows/os_platform_stdlib.c @@ -26,32 +26,6 @@ #include "../snippets/code/os_stdlib_strcasecmp.c" #include "../snippets/code/os_stdlib_strncasecmp.c" -static int32_t -os__ensurePathExists( - _In_z_ const char* dir_name); - -/** -* \brief create a directory with default -* security descriptor. The mode parameter -* is ignored for this Operating System. -* -*/ -int32_t -os_mkdir( - const char *path, - os_mode_t mode) -{ - int32_t result = 0; - - if (CreateDirectory(path, NULL)) { - result = 0; - } - else { - result = -1; - } - return result; -} - os_result os_gethostname( char *hostname, @@ -67,7 +41,7 @@ os_gethostname( err = WSAStartup(wVersionRequested, &wsaData); if (err != 0) { - OS_FATAL("os_gethostname", 0, "WSAStartup failed, no compatible socket implementation available"); + DDS_FATAL("WSAStartup failed, no compatible socket implementation available\n"); /* Tell the user that we could not find a usable */ /* WinSock DLL. */ return os_resultFail; @@ -114,38 +88,6 @@ os_putenv( return result; } -const char * -os_fileSep(void) -{ - return "\\"; -} - -const char * -os_pathSep(void) -{ - return ";"; -} - -os_result -os_access( - const char *file_path, - int32_t permission) -{ - struct _stat statbuf; - os_result result; - - result = os_resultFail; - if (file_path) { - if (_stat(file_path, &statbuf) == 0) { - if ((statbuf.st_mode & permission) == permission) { - result = os_resultSuccess; - } - } - } - - return result; -} - #pragma warning( disable : 4996 ) int os_vfprintfnosigpipe( @@ -156,184 +98,6 @@ os_vfprintfnosigpipe( return vfprintf(file, format, args); } -os_result -os_stat( - const char *path, -struct os_stat *buf) -{ - os_result result; - struct _stat32 _buf; - int r; - - r = _stat32(path, &_buf); - if (r == 0) { - buf->stat_mode = _buf.st_mode; - buf->stat_size = _buf.st_size; - buf->stat_mtime.tv_sec = _buf.st_mtime; - buf->stat_mtime.tv_nsec = 0; - result = os_resultSuccess; - } - else { - result = os_resultFail; - } - - return result; -} - -os_result os_remove(const char *pathname) -{ - return (remove(pathname) == 0) ? os_resultSuccess : os_resultFail; -} - -os_result os_rename(const char *oldpath, const char *newpath) -{ - (void)os_remove(newpath); - return (rename(oldpath, newpath) == 0) ? os_resultSuccess : os_resultFail; -} - -/* The result of os_fileNormalize should be freed with os_free */ -_Ret_z_ -_Must_inspect_result_ -char * -os_fileNormalize( - _In_z_ const char *filepath) -{ - char *norm; - const char *fpPtr; - char *normPtr; - - norm = os_malloc(strlen(filepath) + 1); - fpPtr = filepath; - normPtr = norm; - while (*fpPtr != '\0') { - *normPtr = *fpPtr; - if ((*fpPtr == '/') || (*fpPtr == '\\')) { - *normPtr = OS_FILESEPCHAR; - normPtr++; - } else { - if (*fpPtr != '\"') { - normPtr++; - } - } - fpPtr++; - } - *normPtr = '\0'; - - return norm; -} - -os_result -os_fsync( - FILE *fHandle) -{ - os_result r; - - if (FlushFileBuffers((HANDLE)fHandle)) { - r = os_resultSuccess; - } - else { - r = os_resultFail; - } - return r; -} - -_Ret_opt_z_ const char * -os_getTempDir(void) -{ - const char * dir_name = NULL; - - dir_name = os_getenv("OSPL_TEMP"); - - /* if OSPL_TEMP is not defined use the TEMP variable */ - if (dir_name == NULL || (strcmp(dir_name, "") == 0)) { - dir_name = os_getenv("TEMP"); - } - - /* if TEMP is not defined use the TMP variable */ - if (dir_name == NULL || (strcmp(dir_name, "") == 0)) { - dir_name = os_getenv("TMP"); - } - - /* Now we need to verify if we found a temp directory path, and if we did - * we have to make sure all the (sub)directories in the path exist. - * This is needed to prevent any other operations from using the directory - * path while it doesn't exist and therefore running into errors. - */ - if (dir_name == NULL || (strcmp(dir_name, "") == 0)) { - OS_ERROR("os_getTempDir", 0, - "Could not retrieve temporary directory path - " - "neither of environment variables TEMP, TMP, OSPL_TEMP were set"); - } - else if (os__ensurePathExists(dir_name) != 0) - { - OS_ERROR("os_getTempDir", 0, - "Could not ensure all (sub)directories of the temporary directory\n" - "path '%s' exist.\n" - "This has consequences for the ability of OpenSpliceDDS to run\n" - "properly, as the directory path must be accessible to create\n" - "database and key files in. Without this ability OpenSpliceDDS can\n" - "not start.\n", - dir_name); - } - - return dir_name; -} - -int32_t -os__ensurePathExists( - _In_z_ const char* dir_name) -{ - char* tmp; - char* ptr; - char ptrTmp; - struct os_stat statBuf; - os_result status; - int32_t result = 0; - int32_t cont = 1; - - tmp = os_strdup(dir_name); - - for (ptr = tmp; cont; ptr++) - { - if (*ptr == '\\' || *ptr == '/' || *ptr == '\0') - { - ptrTmp = ptr[0]; - ptr[0] = '\0'; - status = os_stat(tmp, &statBuf); - - if (status != os_resultSuccess) - { - os_mkdir(tmp, 0); - status = os_stat(tmp, &statBuf); - } - - if (!OS_ISDIR(statBuf.stat_mode)) - { - if ((strlen(tmp) == 2) && (tmp[1] == ':')) { - /*This is a device like for instance: 'C:'*/ - } - else - { - OS_ERROR("os_ensurePathExists", 0, - "Unable to create directory '%s' within path '%s'. Errorcode: %d", - tmp, - dir_name, - os_getErrno()); - result = -1; - } - } - ptr[0] = ptrTmp; - } - if (*ptr == '\0' || result == -1) - { - cont = 0; - } - } - os_free(tmp); - - return result; -} - #pragma warning( disable : 4996 ) int os_vsnprintf( @@ -404,16 +168,6 @@ ssize_t os_write( return _write(fd, buf, (unsigned int)count); /* Type casting is done for the warning of conversion from 'size_t' to 'unsigned int', which may cause possible loss of data */ } -void os_flockfile(FILE *file) -{ - _lock_file (file); -} - -void os_funlockfile(FILE *file) -{ - _unlock_file (file); -} - int os_getopt( _In_range_(0, INT_MAX) int argc, _In_reads_z_(argc) char **argv, diff --git a/src/os/src/windows/os_platform_sync.c b/src/os/src/windows/os_platform_sync.c index 34a5141..5084b13 100644 --- a/src/os/src/windows/os_platform_sync.c +++ b/src/os/src/windows/os_platform_sync.c @@ -13,234 +13,179 @@ #include "os/os.h" void os_mutexInit( - _Out_ os_mutex *mutex) + _Out_ os_mutex *mutex) { - assert(mutex != NULL); -#ifdef OSPL_STRICT_MEM - assert(mutex->signature != OS_MUTEX_MAGIC_SIG); -#endif - InitializeSRWLock(&mutex->lock); -#ifdef OSPL_STRICT_MEM - mutex->signature = OS_MUTEX_MAGIC_SIG; -#endif + assert(mutex != NULL); + + InitializeSRWLock(&mutex->lock); } void os_mutexDestroy( - _Inout_ _Post_invalid_ os_mutex *mutex) + _Inout_ _Post_invalid_ os_mutex *mutex) { - assert(mutex != NULL); -#ifdef OSPL_STRICT_MEM - assert(mutex->signature == OS_MUTEX_MAGIC_SIG); - mutex->signature = 0; -#endif + assert(mutex != NULL); } _Acquires_nonreentrant_lock_(&mutex->lock) void os_mutexLock( - _Inout_ os_mutex *mutex) + _Inout_ os_mutex *mutex) { - assert(mutex != NULL); -#ifdef OSPL_STRICT_MEM - assert(mutex->signature == OS_MUTEX_MAGIC_SIG); -#endif - AcquireSRWLockExclusive(&mutex->lock); + assert(mutex != NULL); + + AcquireSRWLockExclusive(&mutex->lock); } _Check_return_ _When_(return == os_resultSuccess, _Acquires_nonreentrant_lock_(&mutex->lock)) os_result os_mutexLock_s( - _Inout_ os_mutex *mutex) + _Inout_ os_mutex *mutex) { - os_mutexLock(mutex); - return os_resultSuccess; + os_mutexLock(mutex); + return os_resultSuccess; } _Check_return_ _When_(return == os_resultSuccess, _Acquires_nonreentrant_lock_(&mutex->lock)) os_result os_mutexTryLock( - _Inout_ os_mutex *mutex) + _Inout_ os_mutex *mutex) { - assert(mutex != NULL); -#ifdef OSPL_STRICT_MEM - assert(mutex->signature == OS_MUTEX_MAGIC_SIG); -#endif - return TryAcquireSRWLockExclusive(&mutex->lock) ? os_resultSuccess : os_resultBusy; + assert(mutex != NULL); + + return TryAcquireSRWLockExclusive(&mutex->lock) ? os_resultSuccess : os_resultBusy; } _Releases_nonreentrant_lock_(&mutex->lock) void os_mutexUnlock( - _Inout_ os_mutex *mutex) + _Inout_ os_mutex *mutex) { - assert(mutex != NULL); -#ifdef OSPL_STRICT_MEM - assert(mutex->signature == OS_MUTEX_MAGIC_SIG); -#endif - ReleaseSRWLockExclusive(&mutex->lock); + assert(mutex != NULL); + + ReleaseSRWLockExclusive(&mutex->lock); } void os_condInit( _Out_ os_cond *cond, _In_ os_mutex *dummymtx) { - assert(cond != NULL); - assert(dummymtx != NULL); -#ifdef OSPL_STRICT_MEM - assert(cond->signature != OS_COND_MAGIC_SIG); -#endif - (void)dummymtx; - InitializeConditionVariable(&cond->cond); -#ifdef OSPL_STRICT_MEM - cond->signature = OS_COND_MAGIC_SIG; -#endif + assert(cond != NULL); + assert(dummymtx != NULL); + + (void)dummymtx; + InitializeConditionVariable(&cond->cond); } void os_condDestroy( _Inout_ _Post_invalid_ os_cond *cond) { - assert(cond != NULL); -#ifdef OSPL_STRICT_MEM - assert(cond->signature == OS_COND_MAGIC_SIG); - cond->signature = 0; -#endif + assert(cond != NULL); } void os_condWait(os_cond *cond, os_mutex *mutex) { - assert(cond != NULL); - assert(mutex != NULL); -#ifdef OSPL_STRICT_MEM - assert(cond->signature == OS_COND_MAGIC_SIG); - assert(mutex->signature == OS_MUTEX_MAGIC_SIG); -#endif - if (!SleepConditionVariableSRW(&cond->cond, &mutex->lock, INFINITE, 0)) { - abort(); - } + assert(cond != NULL); + assert(mutex != NULL); + + if (!SleepConditionVariableSRW(&cond->cond, &mutex->lock, INFINITE, 0)) { + abort(); + } } os_result os_condTimedWait(os_cond *cond, os_mutex *mutex, const os_time *time) { - DWORD timems; - assert(cond != NULL); - assert(mutex != NULL); -#ifdef OSPL_STRICT_MEM - assert(cond->signature == OS_COND_MAGIC_SIG); - assert(mutex->signature == OS_MUTEX_MAGIC_SIG); -#endif - timems = time->tv_sec * 1000 + (time->tv_nsec + 999999999) / 1000000; - if (SleepConditionVariableSRW(&cond->cond, &mutex->lock, timems, 0)) - return os_resultSuccess; - else if (GetLastError() != ERROR_TIMEOUT) - abort(); - else if (timems != INFINITE) - return os_resultTimeout; - else - return os_resultSuccess; + DWORD timems; + assert(cond != NULL); + assert(mutex != NULL); + + timems = time->tv_sec * 1000 + (time->tv_nsec + 999999999) / 1000000; + if (SleepConditionVariableSRW(&cond->cond, &mutex->lock, timems, 0)) { + return os_resultSuccess; + } else if (GetLastError() != ERROR_TIMEOUT) { + abort(); + } else if (timems != INFINITE) { + return os_resultTimeout; + } else { + return os_resultSuccess; + } } void os_condSignal(os_cond *cond) { - assert(cond != NULL); -#ifdef OSPL_STRICT_MEM - assert(cond->signature == OS_COND_MAGIC_SIG); -#endif - WakeConditionVariable(&cond->cond); + assert(cond != NULL); + + WakeConditionVariable(&cond->cond); } void os_condBroadcast(os_cond *cond) { - assert(cond != NULL); -#ifdef OSPL_STRICT_MEM - assert(cond->signature == OS_COND_MAGIC_SIG); -#endif - WakeAllConditionVariable(&cond->cond); + assert(cond != NULL); + + WakeAllConditionVariable(&cond->cond); } void os_rwlockInit(_Out_ os_rwlock *rwlock) { - assert(rwlock); -#ifdef OSPL_STRICT_MEM - assert(rwlock->signature != OS_RWLOCK_MAGIC_SIG); -#endif - InitializeSRWLock(&rwlock->lock); - rwlock->state = 0; -#ifdef OSPL_STRICT_MEM - rwlock->signature = OS_RWLOCK_MAGIC_SIG; -#endif + assert(rwlock); + + InitializeSRWLock(&rwlock->lock); + rwlock->state = 0; } void os_rwlockDestroy(_Inout_ _Post_invalid_ os_rwlock *rwlock) { - assert(rwlock); -#ifdef OSPL_STRICT_MEM - assert(rwlock->signature != OS_RWLOCK_MAGIC_SIG); - rwlock->signature = 0; -#endif + assert(rwlock); } void os_rwlockRead(os_rwlock *rwlock) { - assert(rwlock); -#ifdef OSPL_STRICT_MEM - assert(rwlock->signature != OS_RWLOCK_MAGIC_SIG); -#endif - AcquireSRWLockShared(&rwlock->lock); - rwlock->state = 1; + assert(rwlock); + + AcquireSRWLockShared(&rwlock->lock); + rwlock->state = 1; } void os_rwlockWrite(os_rwlock *rwlock) { - assert(rwlock); -#ifdef OSPL_STRICT_MEM - assert(rwlock->signature != OS_RWLOCK_MAGIC_SIG); -#endif - AcquireSRWLockExclusive(&rwlock->lock); - rwlock->state = -1; + assert(rwlock); + + AcquireSRWLockExclusive(&rwlock->lock); + rwlock->state = -1; } os_result os_rwlockTryRead(os_rwlock *rwlock) { - assert(rwlock); -#ifdef OSPL_STRICT_MEM - assert(rwlock->signature != OS_RWLOCK_MAGIC_SIG); -#endif - if (TryAcquireSRWLockShared(&rwlock->lock)) { - rwlock->state = 1; - return os_resultSuccess; - } - else { - return os_resultBusy; - } + assert(rwlock); + + if (TryAcquireSRWLockShared(&rwlock->lock)) { + rwlock->state = 1; + return os_resultSuccess; + } + + return os_resultBusy; } os_result os_rwlockTryWrite(os_rwlock *rwlock) { - assert(rwlock); -#ifdef OSPL_STRICT_MEM - assert(rwlock->signature != OS_RWLOCK_MAGIC_SIG); -#endif - if (TryAcquireSRWLockExclusive(&rwlock->lock)) { - rwlock->state = -1; - return os_resultSuccess; - } - else { - return os_resultBusy; - } + assert(rwlock); + + if (TryAcquireSRWLockExclusive(&rwlock->lock)) { + rwlock->state = -1; + return os_resultSuccess; + } + + return os_resultBusy; } void os_rwlockUnlock(os_rwlock *rwlock) { - assert(rwlock); -#ifdef OSPL_STRICT_MEM - assert(rwlock->signature != OS_RWLOCK_MAGIC_SIG); -#endif - assert(rwlock->state != 0); - if (rwlock->state > 0) { - ReleaseSRWLockShared(&rwlock->lock); - } - else { - ReleaseSRWLockExclusive(&rwlock->lock); - } + assert(rwlock); + + assert(rwlock->state != 0); + if (rwlock->state > 0) { + ReleaseSRWLockShared(&rwlock->lock); + } else { + ReleaseSRWLockExclusive(&rwlock->lock); + } } struct os__onceWrapper { diff --git a/src/os/src/windows/os_platform_thread.c b/src/os/src/windows/os_platform_thread.c index 688f8ea..943e93f 100644 --- a/src/os/src/windows/os_platform_thread.c +++ b/src/os/src/windows/os_platform_thread.c @@ -188,8 +188,6 @@ os_startRoutineWrapper( /* Call the user routine */ resultValue = context->startRoutine(context->arguments); - os_report_stack_free(); - /* Free the thread context resources, arguments is responsibility */ /* for the caller of os_threadCreate */ os_free (context->threadName); @@ -236,7 +234,7 @@ os_threadCreate( (LPVOID)threadContext, (DWORD)0, &threadIdent); if (threadHandle == 0) { - OS_WARNING("os_threadCreate", os_getErrno(), "Failed with System Error Code: %i\n", os_getErrno ()); + DDS_WARNING("Failed with System Error Code: %i\n", os_getErrno ()); return os_resultFail; } @@ -277,7 +275,7 @@ os_threadCreate( } } if (SetThreadPriority (threadHandle, effective_priority) == 0) { - OS_INFO("os_threadCreate", os_getErrno(), "SetThreadPriority failed with %i", os_getErrno()); + DDS_INFO("SetThreadPriority failed with %i\n", os_getErrno()); } /* ES: dds2086: Close handle should not be performed here. Instead the handle @@ -358,29 +356,6 @@ os_threadWaitExit( return os_resultSuccess; } -/** \brief Figure out the identity of the current thread - * - * Possible Results: - * - returns the actual length of threadIdentity - */ -int -os_threadFigureIdentity( - char *threadIdentity, - uint32_t threadIdentitySize) -{ - int size; - char* threadName; - - threadName = (char *)os_threadMemGet(OS_THREAD_NAME); - if (threadName != NULL) { - size = snprintf (threadIdentity, threadIdentitySize, "%s 0x%"PRIx32, threadName, GetCurrentThreadId()); - } else { - size = snprintf (threadIdentity, threadIdentitySize, "0x%"PRIx32, GetCurrentThreadId()); - } - - return size; -} - int os_threadGetThreadName( char *buffer, diff --git a/src/os/tests/CMakeLists.txt b/src/os/tests/CMakeLists.txt index 469c991..93868df 100644 --- a/src/os/tests/CMakeLists.txt +++ b/src/os/tests/CMakeLists.txt @@ -19,13 +19,13 @@ set(sources "iter.c" "mutex.c" "once.c" - "report.c" "rwlock.c" "stdlib.c" "strtoll.c" "thread.c" "thread_cleanup.c" - "strcasecmp.c") + "strcasecmp.c" + "log.c") add_cunit_executable(abstraction ${sources}) target_link_libraries(abstraction OSAPI) diff --git a/src/os/tests/log.c b/src/os/tests/log.c new file mode 100644 index 0000000..8d3b6ee --- /dev/null +++ b/src/os/tests/log.c @@ -0,0 +1,364 @@ +/* + * Copyright(c) 2006 to 2018 ADLINK Technology Limited and others + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License + * v. 1.0 which is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause + */ +#include +#include +#include +#include + +#ifdef __APPLE__ +#include +#endif /* __APPLE__ */ + +#include "CUnit/Test.h" +#include "os/os.h" + +static FILE *fh = NULL; + +#ifdef _WIN32 +#include +#include + +/* Windows does not support opening a stream to a buffer like fmemopen on + * Linux does. A temporary file that will never be flushed to disk is created + * instead. See the link below for more detail. + * + * https://blogs.msdn.microsoft.com/larryosterman/2004/04/19/its-only-temporary/ + */ + +FILE *fmemopen(void *buf, size_t size, const char *mode) +{ + int err = 0; + int fd = -1; + DWORD ret; + FILE *fh = NULL; + HANDLE hdl = INVALID_HANDLE_VALUE; + /* GetTempFileName will fail if the directory is be longer than MAX_PATH-14 + characters */ + char tmpdir[(MAX_PATH + 1) - 14]; + char tmpfile[MAX_PATH + 1]; + static const int max = 1000; + static const char pfx[] = "cyclone"; /* Up to first three are used. */ + + (void)buf; + (void)size; + + ret = GetTempPath(sizeof(tmpdir), tmpdir); + if (ret == 0) { + err = GetLastError(); + } else if (ret > sizeof(tmpdir)) { + err = ENOMEM; + } + + if (GetTempFileName(tmpdir, pfx, 0, tmpfile) == 0) { + err = GetLastError(); + assert(err != ERROR_BUFFER_OVERFLOW); + } else { + /* The combination of FILE_ATTRIBUTE_TEMPORARY and + FILE_FLAG_DELETE_ON_CLOSE hints to the filesystem that the file + should never be flushed to disk. */ + hdl = CreateFile( + tmpfile, + GENERIC_READ | GENERIC_WRITE, + 0, + NULL, + CREATE_ALWAYS, + FILE_FLAG_DELETE_ON_CLOSE | FILE_ATTRIBUTE_TEMPORARY, + NULL); + if (hdl == INVALID_HANDLE_VALUE) { + err = GetLastError(); + } + } + + if (err) { + errno = err; + } else { + if ((fd = _open_osfhandle((intptr_t)hdl, _O_APPEND)) == -1) { + /* errno set by _open_osfhandle. */ + CloseHandle(hdl); + } else if ((fh = fdopen(fd, mode)) == NULL) { + /* errno set by fdopen. */ + _close(fd); /* Automatically closes underlying handle. */ + } else { + return fh; + } + } + + return NULL; +} +#endif /* _WIN32 */ + +static void count(void *ptr, const dds_log_data_t *data) +{ + (void)data; + *(int *)ptr += 1; +} + +static void copy(void *ptr, const dds_log_data_t *data) +{ + *(char **)ptr = os_strdup(data->message); +} + +static void setup(void) +{ + fh = fmemopen(NULL, 1024, "wb+"); + CU_ASSERT_PTR_NOT_NULL_FATAL(fh); +} + +static void teardown(void) +{ + (void)fclose(fh); +} + +/* By default only DDS_LC_FATAL and DDS_LC_ERROR are set. This means setting a + trace sink should not have any effect, because no trace categories are + enabled. The message should end up in the log file. */ +CU_Test(dds_log, only_log_file, .init=setup, .fini=teardown) +{ + char buf[1024], *ptr; + int cnt = 0; + size_t nbytes; + + dds_set_log_file(fh); + dds_set_trace_sink(&count, &cnt); + DDS_ERROR("foo%s\n", "bar"); + (void)fseek(fh, 0L, SEEK_SET); + nbytes = fread(buf, 1, sizeof(buf) - 1, fh); + /* At least foobar should have been printed to the log file. */ + CU_ASSERT_FATAL(nbytes > 6); + buf[nbytes] = '\0'; + ptr = strstr(buf, "foobar\n"); + CU_ASSERT_PTR_NOT_NULL(ptr); + /* No trace categories are enabled by default, verify trace callback was + not invoked. */ + CU_ASSERT_EQUAL(cnt, 0); +} + +/* Messages must be printed to the trace file if at least one trace category + is enabled. Messages must not be written twice if the trace file is the + same as the log file. */ +CU_Test(dds_log, same_file, .init=setup, .fini=teardown) +{ + char buf[1024], *ptr; + size_t nbytes; + + dds_set_log_mask(DDS_LC_ALL); + dds_set_log_file(fh); + dds_set_trace_file(fh); + DDS_ERROR("foo%s\n", "bar"); + (void)fseek(fh, 0L, SEEK_SET); + nbytes = fread(buf, 1, sizeof(buf) - 1, fh); + /* At least foobar should have been written to the trace file. */ + CU_ASSERT_FATAL(nbytes > 6); + buf[nbytes] = '\0'; + ptr = strstr(buf, "foobar\n"); + CU_ASSERT_PTR_NOT_NULL_FATAL(ptr); + /* The message should only have been printed once, verify foobar does not + occur again. */ + ptr = strstr(ptr + 1, "foobar\n"); + CU_ASSERT_PTR_NULL(ptr); +} + +/* The sinks are considered to be the same only if the callback and userdata + both are an exact match. If the userdata is different, the function should + be called twice for log messages. */ +CU_Test(dds_log, same_sink_function) +{ + int log_cnt = 0, trace_cnt = 0; + + dds_set_log_mask(DDS_LC_ALL); + dds_set_log_sink(&count, &log_cnt); + dds_set_trace_sink(&count, &trace_cnt); + DDS_ERROR("foo%s\n", "bar"); + CU_ASSERT_EQUAL(log_cnt, 1); + CU_ASSERT_EQUAL(trace_cnt, 1); +} + +CU_Test(dds_log, exact_same_sink) +{ + int cnt = 0; + + dds_set_log_mask(DDS_LC_ALL); + dds_set_log_sink(&count, &cnt); + dds_set_trace_sink(&count, &cnt); + DDS_ERROR("foo%s\n", "bar"); + CU_ASSERT_EQUAL(cnt, 1); +} + +/* The log file must be restored if the sink is unregistered, verify the log + file is not used while the sink is registered. Verify use of the log file is + restored again when the sink is unregistered. */ +CU_Test(dds_log, no_sink, .init=setup, .fini=teardown) +{ + int ret; + char buf[1024], *ptr = NULL; + size_t cnt[2] = {0, 0}; + + /* Set the destination log file and verify the message is written. */ + dds_set_log_file(fh); + DDS_ERROR("foobar\n"); + ret = fseek(fh, 0L, SEEK_SET); + CU_ASSERT_EQUAL_FATAL(ret, 0); + buf[0] = '\0'; + cnt[0] = fread(buf, 1, sizeof(buf) - 1, fh); + buf[cnt[0]] = '\0'; + ptr = strstr(buf, "foobar\n"); + CU_ASSERT_PTR_NOT_NULL_FATAL(ptr); + + /* Register a custom sink and verify it receives the message. */ + ptr = NULL; + dds_set_log_sink(©, &ptr); + DDS_ERROR("foobaz\n"); + CU_ASSERT_PTR_NOT_NULL_FATAL(ptr); + CU_ASSERT(strcmp(ptr, "foobaz\n") == 0); + os_free(ptr); + ptr = NULL; + /* Verify it has not been written to the stream. */ + ret = fseek(fh, 0L, SEEK_SET); + CU_ASSERT_EQUAL_FATAL(ret, 0); + buf[0] = '\0'; + cnt[1] = fread(buf, 1, sizeof(buf) - 1, fh); + buf[cnt[1]] = '\0'; + ptr = strstr(buf, "foobaz\n"); + CU_ASSERT_PTR_NULL_FATAL(ptr); + + /* Unregister the custom sink and verify the default is restored. */ + dds_set_log_sink(0, NULL); + ret = fseek(fh, 0, SEEK_SET); + CU_ASSERT_EQUAL_FATAL(ret, 0); + ptr = NULL; + DDS_ERROR("foobaz\n"); + ret = fseek(fh, 0, SEEK_SET); + CU_ASSERT_PTR_NULL(ptr); + if (ptr != NULL) { + os_free(ptr); + ptr = NULL; + } + buf[0]= '\0'; + cnt[1] = fread(buf, 1, sizeof(buf) - 1, fh); +#ifdef _WIN32 + /* Write on Windows appends. */ + CU_ASSERT_EQUAL(cnt[1], cnt[0] * 2); +#else + CU_ASSERT_EQUAL(cnt[1], cnt[0]); +#endif + buf[cnt[1]] = '\0'; + ptr = strstr(buf, "foobaz\n"); + CU_ASSERT_PTR_NOT_NULL_FATAL(ptr); +} + +/* A newline terminates the message. Until that a newline is encountered, the + messages must be concatenated in the buffer. The newline is replaced by a + NULL byte if it is flushed to a sink. */ +CU_Test(dds_log, newline_terminates) +{ + char *msg = NULL; + + dds_set_log_sink(©, &msg); + DDS_ERROR("foo"); + CU_ASSERT_PTR_NULL_FATAL(msg); + DDS_ERROR("bar"); + CU_ASSERT_PTR_NULL_FATAL(msg); + DDS_ERROR("baz\n"); + CU_ASSERT_PTR_NOT_NULL_FATAL(msg); + CU_ASSERT(strcmp(msg, "foobarbaz\n") == 0); + os_free(msg); +} + +/* Nothing must be written unless a category is enabled. */ +CU_Test(dds_log, disabled_categories_discarded) +{ + char *msg = NULL; + + dds_set_log_sink(©, &msg); + DDS_INFO("foobar\n"); + CU_ASSERT_PTR_NULL_FATAL(msg); + dds_set_log_mask(DDS_LC_FATAL | DDS_LC_ERROR | DDS_LC_INFO); + DDS_INFO("foobar\n"); + CU_ASSERT_PTR_NOT_NULL_FATAL(msg); + CU_ASSERT(strcmp(msg, "foobar\n") == 0); + os_free(msg); +} + + +static os_cond cond; +static os_mutex mutex; + +struct arg { + os_cond *cond; + os_mutex *mutex; + os_time stamp; + os_time pause; +}; + +static void dummy(void *ptr, const dds_log_data_t *data) +{ + (void)ptr; + (void)data; +} + +static void block(void *ptr, const dds_log_data_t *data) +{ + (void)data; + struct arg *arg = (struct arg *)ptr; + os_mutexLock(arg->mutex); + arg->stamp = os_timeGet(); + os_condBroadcast(arg->cond); + os_mutexUnlock(arg->mutex); + + os_nanoSleep(arg->pause); +} + +static uint32_t run(void *ptr) +{ + (void)ptr; + + DDS_ERROR("foobar\n"); + + return 0; +} + +/* Log and trace sinks can be changed at runtime. However, the operation must + be synchronous! Verify the dds_set_log_sink blocks while other threads + reside in the log or trace sinks. */ +CU_Test(dds_log, synchronous_sink_changes) +{ + struct arg arg; + os_time diff, stamp; + os_threadId tid; + os_threadAttr tattr; + os_result res; + + os_mutexInit(&mutex); + os_condInit(&cond, &mutex); + (void)memset(&arg, 0, sizeof(arg)); + arg.mutex = &mutex; + arg.cond = &cond; + arg.pause.tv_sec = 0; + arg.pause.tv_nsec = 1000000; + + os_mutexLock(&mutex); + dds_set_log_sink(&block, &arg); + os_threadAttrInit(&tattr); +#ifdef __APPLE__ + tattr.schedPriority = sched_get_priority_min(SCHED_OTHER); +#endif /* __APPLE__ */ + + res = os_threadCreate(&tid, "foobar", &tattr, &run, &arg); + CU_ASSERT_EQUAL_FATAL(res, os_resultSuccess); + os_condWait(&cond, &mutex); + dds_set_log_sink(dummy, NULL); + stamp = os_timeGet(); + + CU_ASSERT(os_timeCompare(arg.stamp, stamp) == -1); + diff = os_timeSub(stamp, arg.stamp); + CU_ASSERT(os_timeCompare(arg.pause, diff) == -1); +} diff --git a/src/os/tests/report.c b/src/os/tests/report.c deleted file mode 100644 index 8032cb1..0000000 --- a/src/os/tests/report.c +++ /dev/null @@ -1,404 +0,0 @@ -/* - * Copyright(c) 2006 to 2018 ADLINK Technology Limited and others - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License - * v. 1.0 which is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause - */ -#include "CUnit/Test.h" -#include "os/os.h" -#include "os/os_project.h" - -#include - -CU_Init(os_report) -{ - os_putenv(OS_PROJECT_NAME_NOSPACE_CAPS"_ERRORFILE=vdds_test_error"); - os_putenv(OS_PROJECT_NAME_NOSPACE_CAPS"_INFOFILE=vdds_test_info"); - os_putenv(OS_PROJECT_NAME_NOSPACE_CAPS"_LOGAPPEND=TRUE"); - - return 0; -} - -void remove_logs() -{ - const char * error_file_name = os_getenv(OS_PROJECT_NAME_NOSPACE_CAPS"_ERRORFILE"); - const char * info_file_name = os_getenv(OS_PROJECT_NAME_NOSPACE_CAPS"_INFOFILE"); - - os_remove(error_file_name); - os_remove(info_file_name); -} - -void check_existence(os_result error_log_existence, os_result info_log_existence) -{ - const char * error_file_name = os_getenv(OS_PROJECT_NAME_NOSPACE_CAPS"_ERRORFILE"); - const char * info_file_name = os_getenv(OS_PROJECT_NAME_NOSPACE_CAPS"_INFOFILE"); - - CU_ASSERT(os_access(error_file_name, OS_ROK) == error_log_existence); - CU_ASSERT(os_access(info_file_name, OS_ROK) == info_log_existence); -} - -CU_Clean(os_report) -{ - remove_logs(); - - return 0; -} - - -CU_Test(os_report, re_init) -{ - os_reportInit(true); - - OS_INFO(OS_FUNCTION, 0, "os_report-info-test %d", __LINE__); - OS_ERROR(OS_FUNCTION, 0, "os_report-error-test %d", __LINE__); - - check_existence(os_resultSuccess, os_resultSuccess); - - os_reportExit(); - - os_reportInit(true); - check_existence(os_resultSuccess, os_resultSuccess); - - OS_INFO(OS_FUNCTION, 0, "os_report-info-test %d", __LINE__); - - os_reportExit(); - - remove_logs(); -} - - -CU_Test(os_report, stack_critical) -{ - os_reportInit(true); - - OS_REPORT_STACK(); - - OS_CRITICAL(OS_FUNCTION, 0, "os_report-error-test %d", __LINE__); - - check_existence(os_resultFail, os_resultFail); - - OS_REPORT_FLUSH(false); - - // Since a critical is logged, the error log should be created - check_existence(os_resultSuccess, os_resultFail); - - os_reportExit(); - - remove_logs(); -} - - -CU_Test(os_report, stack_non_critical) -{ - os_reportInit(true); - - OS_REPORT_STACK(); - - OS_ERROR(OS_FUNCTION, 0, "os_report-error-test %d", __LINE__); - - check_existence(os_resultFail, os_resultFail); - - OS_REPORT_FLUSH(false); - - // Since a non critical is logged, the error log should not be created - check_existence(os_resultFail, os_resultFail); - - os_reportExit(); - - remove_logs(); -} - - -CU_Test(os_report, error_file_creation_critical) -{ - os_reportInit(true); - - OS_CRITICAL(OS_FUNCTION, 0, "os_report-critical-test %d", __LINE__); - - check_existence(os_resultSuccess, os_resultFail); - - os_reportExit(); - - remove_logs(); -} - - -CU_Test(os_report, error_file_creation_fatal) -{ - os_reportInit(true); - - OS_FATAL(OS_FUNCTION, 0, "os_report-fatal-test %d", __LINE__); - - check_existence(os_resultSuccess, os_resultFail); - - os_reportExit(); - - remove_logs(); -} - - -CU_Test(os_report, info_file_creation_warning) -{ - os_reportInit(true); - - OS_WARNING(OS_FUNCTION, 0, "os_report-warning-test %d", __LINE__); - - check_existence(os_resultFail, os_resultSuccess); - - os_reportExit(); - - remove_logs(); -} - - -CU_Test(os_report, info_file_creation_info) -{ - os_reportInit(true); - - OS_INFO(OS_FUNCTION, 0, "os_report-info-test %d", __LINE__); - - check_existence(os_resultFail, os_resultSuccess); - - os_reportExit(); - - remove_logs(); -} - - -CU_Test(os_report, verbosity_low) -{ - os_reportInit(true); - check_existence(os_resultFail, os_resultFail); - - os_reportVerbosity = OS_REPORT_ERROR; - - OS_WARNING(OS_FUNCTION, 0, "os_report-info-test %d", __LINE__); - - check_existence(os_resultFail, os_resultFail); - - os_reportExit(); - - remove_logs(); -} - - -CU_Test(os_report, verbosity_high) -{ - os_reportInit(true); - check_existence(os_resultFail, os_resultFail); - - os_reportVerbosity = OS_REPORT_DEBUG; - - OS_WARNING(OS_FUNCTION, 0, "os_report-info-test %d", __LINE__); - - check_existence(os_resultFail, os_resultSuccess); - - os_reportExit(); - - remove_logs(); -} - - - -CU_Test(os_report, verbosity_equal) -{ - os_reportInit(true); - check_existence(os_resultFail, os_resultFail); - - os_reportVerbosity = OS_REPORT_WARNING; - - OS_WARNING(OS_FUNCTION, 0, "os_report-info-test %d", __LINE__); - - check_existence(os_resultFail, os_resultSuccess); - - os_reportExit(); - - remove_logs(); -} - - -CU_Test(os_report, stack_verbosity_low) -{ - os_reportInit(true); - check_existence(os_resultFail, os_resultFail); - - os_reportVerbosity = OS_REPORT_ERROR; - - OS_REPORT_STACK(); - OS_WARNING(OS_FUNCTION, 0, "os_report-info-test %d", __LINE__); - OS_REPORT_FLUSH(true); - - check_existence(os_resultFail, os_resultFail); - - os_reportExit(); - - remove_logs(); -} - - -CU_Test(os_report, stack_verbosity_high) -{ - os_reportInit(true); - check_existence(os_resultFail, os_resultFail); - - os_reportVerbosity = OS_REPORT_DEBUG; - - OS_REPORT_STACK(); - OS_WARNING(OS_FUNCTION, 0, "os_report-info-test %d", __LINE__); - OS_REPORT_FLUSH(true); - - check_existence(os_resultFail, os_resultSuccess); - - os_reportExit(); - - remove_logs(); -} - - - -CU_Test(os_report, stack_verbosity_equal) -{ - os_reportInit(true); - check_existence(os_resultFail, os_resultFail); - - os_reportVerbosity = OS_REPORT_WARNING; - - OS_REPORT_STACK(); - OS_WARNING(OS_FUNCTION, 0, "os_report-info-test %d", __LINE__); - OS_REPORT_FLUSH(true); - - check_existence(os_resultFail, os_resultSuccess); - - os_reportExit(); - - remove_logs(); -} - - -CU_Test(os_report, no_log_append) -{ - os_reportInit(true); - check_existence(os_resultFail, os_resultFail); - - OS_ERROR(OS_FUNCTION, 0, "os_report-error-test %d", __LINE__); - OS_INFO(OS_FUNCTION, 0, "os_report-info-test %d", __LINE__); - - check_existence(os_resultSuccess, os_resultSuccess); - - os_reportExit(); - - os_putenv(OS_PROJECT_NAME_NOSPACE_CAPS"_LOGAPPEND=FALSE"); - - os_reportInit(true); - - // Both logs should be deleted - check_existence(os_resultFail, os_resultFail); - - os_reportExit(); - - remove_logs(); -} - - -CU_Test(os_report, log_dir) -{ - os_putenv(OS_PROJECT_NAME_NOSPACE_CAPS"_LOGPATH=."); - - os_reportInit(true); - - check_existence(os_resultFail, os_resultFail); - - OS_ERROR(OS_FUNCTION, 0, "os_report-error-test %d", __LINE__); - OS_INFO(OS_FUNCTION, 0, "os_report-info-test %d", __LINE__); - - check_existence(os_resultSuccess, os_resultSuccess); - - os_reportExit(); - - remove_logs(); -} - - -CU_Test(os_report, verbosity_env_value_info) -{ - os_putenv(OS_PROJECT_NAME_NOSPACE_CAPS"_VERBOSITY=0"); - os_reportInit(true); - check_existence(os_resultFail, os_resultFail); - - OS_ERROR(OS_FUNCTION, 0, "os_report-error-test %d", __LINE__); - OS_INFO(OS_FUNCTION, 0, "os_report-info-test %d", __LINE__); - - check_existence(os_resultSuccess, os_resultSuccess); - - os_reportExit(); - - remove_logs(); - - //reset for other tests. - os_putenv(OS_PROJECT_NAME_NOSPACE_CAPS"_VERBOSITY="); -} - - -CU_Test(os_report, verbosity_env_value_error) -{ - os_putenv(OS_PROJECT_NAME_NOSPACE_CAPS"_VERBOSITY=3"); - os_reportInit(true); - check_existence(os_resultFail, os_resultFail); - - OS_ERROR(OS_FUNCTION, 0, "os_report-error-test %d", __LINE__); - OS_INFO(OS_FUNCTION, 0, "os_report-info-test %d", __LINE__); - - check_existence(os_resultSuccess, os_resultFail); - - os_reportExit(); - - remove_logs(); - - //reset for other tests. - os_putenv(OS_PROJECT_NAME_NOSPACE_CAPS"_VERBOSITY="); -} - - -CU_Test(os_report, verbosity_env_value_error_as_string) -{ - os_putenv(OS_PROJECT_NAME_NOSPACE_CAPS"_VERBOSITY=ERROR"); - os_reportInit(true); - check_existence(os_resultFail, os_resultFail); - - OS_ERROR(OS_FUNCTION, 0, "os_report-error-test %d", __LINE__); - OS_DEBUG(OS_FUNCTION, 0, "os_report-info-test %d", __LINE__); - - check_existence(os_resultSuccess, os_resultFail); - - os_reportExit(); - - remove_logs(); - - //reset for other tests. - os_putenv(OS_PROJECT_NAME_NOSPACE_CAPS"_VERBOSITY="); -} - - -CU_Test(os_report, verbosity_wrong_env_value) -{ - os_putenv(OS_PROJECT_NAME_NOSPACE_CAPS"_VERBOSITY=WRONG"); - os_reportInit(true); - check_existence(os_resultFail, os_resultFail); - - OS_ERROR(OS_FUNCTION, 0, "os_report-error-test %d", __LINE__); - OS_DEBUG(OS_FUNCTION, 0, "os_report-error-test %d", __LINE__); - - check_existence(os_resultSuccess, os_resultFail); - - os_reportExit(); - - remove_logs(); - - //reset for other tests. - os_putenv(OS_PROJECT_NAME_NOSPACE_CAPS"_VERBOSITY="); -} diff --git a/src/os/tests/stdlib.c b/src/os/tests/stdlib.c index 81ae916..8125816 100644 --- a/src/os/tests/stdlib.c +++ b/src/os/tests/stdlib.c @@ -12,261 +12,8 @@ #include "CUnit/Test.h" #include "os/os.h" -#ifndef WINCE -#include -#endif - -#if (defined WIN32 || defined WIN64) -#include -#include -#endif - -static const os_time wait_time_out = { 1, 0 }; -static FILE *file; - #define ENABLE_TRACING 0 -#define FLOCKFILE_THREAD1_INPUT1 "thread1_flockfile_proc: *** input 1 ***" -#define FLOCKFILE_THREAD1_INPUT3 "thread1_flockfile_proc: *** input 3 ***" -#define FLOCKFILE_THREAD2_INPUT2 "thread2_flockfile_proc: *** input 2 ***" - -#define defSignal(signal) \ - static os_cond signal;\ - static bool signal##_set = false; - -#define initSignal(signal, mutex) \ - os_condInit(&signal, &mutex);\ - signal##_set = false; - -#define sendSignal(signal, mutex) \ - os_mutexLock(&mutex);\ - /* signaling */ \ - signal##_set = true; \ - os_condSignal(&signal);\ - os_mutexUnlock(&mutex); - -#define waitForSignal(signal, mutex) \ - os_mutexLock(&mutex);\ - while(!signal##_set) { \ - /* waiting for signal */ \ - os_condWait(&signal, &mutex);\ - /* received */ \ - } /* else already signal received */ \ - os_mutexUnlock(&mutex); - -#define timedWaitSignal(signal, mutex, time) \ - { \ - os_time duration = time; \ - os_time startTime, currentTime; \ - os_result rc; \ - os_mutexLock(&mutex); \ - startTime = os_timeGetElapsed(); \ - while(!signal##_set) { \ - /* waiting for signal */ \ - rc = os_condTimedWait(&signal, &mutex, &duration); \ - /* signal received or timeout */ \ - if(rc == os_resultTimeout) { \ - break; \ - } else { \ - currentTime = os_timeGetElapsed(); \ - if(os_timeCompare(os_timeSub(currentTime, startTime), wait_time_out) >= 0) { \ - break; \ - } \ - duration = os_timeSub(wait_time_out, os_timeSub(currentTime, startTime)); \ - } \ - } /* else already signal received */ \ - os_mutexUnlock(&mutex);\ - } - -static os_mutex mutex; -static bool do_locking; - -/* signals set by threads */ -defSignal(thread1_started); -defSignal(thread2_started); -defSignal(action1_done); -defSignal(action2_done); - -/* signals set by the test orchestrator (doFlockfileTest) */ -defSignal(do_action1); -defSignal(do_action2); -defSignal(do_action3); - -static uint32_t thread1_flockfile_proc(void* args) { - int result = 0; - (void)args; - - /* thread1: start */ - sendSignal(thread1_started, mutex); - - waitForSignal(do_action1, mutex); - if(do_locking) os_flockfile(file); - /* Thread1: writing input 1 to the file */ - result = fputs(FLOCKFILE_THREAD1_INPUT1, file); - CU_ASSERT(result >= 0); - - sendSignal(action1_done, mutex); - - waitForSignal(do_action3, mutex); - /* Thread1: writing input 3 to the file */ - result = fputs(FLOCKFILE_THREAD1_INPUT3, file); - CU_ASSERT(result >= 0); - if(do_locking) os_funlockfile(file); - /* thread1: end */ - - return 0; -} - -static uint32_t thread2_flockfile_proc(void* args) { - int result = 0; - (void)args; - - /* thread2: start */ - sendSignal(thread2_started, mutex); - - waitForSignal(do_action2, mutex); - /* Thread2: writing input 2 to the file */ - result = fputs(FLOCKFILE_THREAD2_INPUT2, file); - CU_ASSERT(result >= 0); - - sendSignal(action2_done, mutex); - /* thread2: end */ - - return 0; -} - -bool doFlockfileTest(bool lock) { - bool testPassed = true; - bool strcmpResult = true; - os_result result; - os_threadAttr threadAttr; - os_threadId thread1; - os_threadId thread2; - int FLOCKFILE_INPUT_MAX = sizeof(FLOCKFILE_THREAD1_INPUT1); - - do_locking = lock; - - char *buffer = os_malloc(sizeof(char) * (unsigned)FLOCKFILE_INPUT_MAX); - - file = tmpfile(); - - os_mutexInit(&mutex); - - /* initialize all signal conditions */ - os_mutexLock(&mutex); - initSignal(thread1_started, mutex); - initSignal(thread2_started, mutex); - initSignal(action1_done, mutex); - initSignal(action2_done, mutex); - - initSignal(do_action1, mutex); - initSignal(do_action2, mutex); - initSignal(do_action3, mutex); - os_mutexUnlock(&mutex); - - /* create threads... */ - os_threadAttrInit(&threadAttr); - - result = os_threadCreate( - &thread1, - "thread 1", - &threadAttr, - thread1_flockfile_proc, - NULL); - CU_ASSERT(result == os_resultSuccess); - - result = os_threadCreate( - &thread2, - "thread 2", - &threadAttr, - thread2_flockfile_proc, - NULL); - CU_ASSERT(result == os_resultSuccess); - - /* wait for threads to start */ - waitForSignal(thread1_started, mutex); - waitForSignal(thread2_started, mutex); - - /* get thread one to do its first thing */ - sendSignal(do_action1, mutex); - - /* wait for thread 1 to acknowledge */ - timedWaitSignal(action1_done, mutex, wait_time_out); - - /* kick thead 2 */ - sendSignal(do_action2, mutex); - - /* wait for thread 2 to acknowledge */ - timedWaitSignal(action2_done, mutex, wait_time_out); - - /* kick thread 1, again */ - sendSignal(do_action3, mutex); - - /* wait for threads to shutdown */ - result = os_threadWaitExit(thread1,NULL); - CU_ASSERT(result == os_resultSuccess); - - result = os_threadWaitExit(thread2,NULL); - CU_ASSERT(result == os_resultSuccess); - - /* if lock then Expected action order: 1 3 2 - * else Expected action order: 1 2 3 */ - - rewind(file); - - if(lock) { - if(fgets(buffer, FLOCKFILE_INPUT_MAX, file) > (char*)0) { - strcmpResult = (strcmp(buffer, FLOCKFILE_THREAD1_INPUT1) == 0); - CU_ASSERT(strcmpResult); - testPassed = testPassed && strcmpResult; /* update flag indicating overall test state */ - } - if(fgets(buffer, FLOCKFILE_INPUT_MAX, file) > (char*)0) { - strcmpResult = (strcmp(buffer, FLOCKFILE_THREAD1_INPUT3) == 0); - CU_ASSERT(strcmpResult); - testPassed = testPassed && strcmpResult; /* update flag indicating overall test state */ - } - if(fgets(buffer, FLOCKFILE_INPUT_MAX, file) > (char*)0) { - strcmpResult = (strcmp(buffer, FLOCKFILE_THREAD2_INPUT2) == 0); - CU_ASSERT(strcmpResult); - testPassed = testPassed && strcmpResult; /* update flag indicating overall test state */ - } - } else { - if(fgets(buffer, FLOCKFILE_INPUT_MAX, file) > (char*)0) { - strcmpResult = (strcmp(buffer, FLOCKFILE_THREAD1_INPUT1) == 0); - CU_ASSERT(strcmpResult); - testPassed = testPassed && strcmpResult; /* update flag indicating overall test state */ - } - if(fgets(buffer, FLOCKFILE_INPUT_MAX, file) > (char*)0) { - strcmpResult = (strcmp(buffer, FLOCKFILE_THREAD2_INPUT2) == 0); - CU_ASSERT(strcmpResult); - testPassed = testPassed && strcmpResult; /* update flag indicating overall test state */ - } - if(fgets(buffer, FLOCKFILE_INPUT_MAX, file) > (char*)0) { - strcmpResult = (strcmp(buffer, FLOCKFILE_THREAD1_INPUT3) == 0); - CU_ASSERT(strcmpResult); - testPassed = testPassed && strcmpResult; /* update flag indicating overall test state */ - } - } - - /* cleanup */ - os_free(buffer); - fclose(file); - - os_mutexLock(&mutex); - os_condDestroy(&do_action1); - os_condDestroy(&do_action2); - os_condDestroy(&do_action3); - - os_condDestroy(&thread1_started); - os_condDestroy(&thread2_started); - os_condDestroy(&action1_done); - os_condDestroy(&action2_done); - os_mutexUnlock(&mutex); - os_mutexDestroy(&mutex); - /* doFlockfileTest */ - return testPassed; -} - static int vsnprintfTest( const char *format, @@ -292,15 +39,8 @@ CU_Init(os_stdlib) CU_Clean(os_stdlib) { - /* Remove files used to test permissions */ - remove ("exec_only"); - remove ("read_exec"); - remove ("read_only"); - remove ("read_write_exec"); - remove ("write_only"); - remove ("existing_file"); - os_osExit(); - return 0; + os_osExit(); + return 0; } CU_Test(os_stdlib, gethostname) @@ -356,254 +96,6 @@ CU_Test(os_stdlib, getenv) printf ("Ending os_stdlib_getenv\n"); } -CU_Test(os_stdlib, fileSep) -{ - #if defined WIN32 - const char *wanted= "\\"; - #else - const char *wanted= "/"; - #endif - printf ("Starting os_stdlib_fileSep_001\n"); - CU_ASSERT (strcmp(os_fileSep(), wanted) == 0); - printf ("Ending os_stdlib_fileSep\n"); -} - -CU_Test(os_stdlib, access) -{ - os_result os_res; - os_result wanted; - int fh; - - /* Check correct functioning of os_access, non existing file read access */ - printf ("Starting os_stdlib_access_001\n"); -#if defined VXWORKS_RTP || defined _WRS_KERNEL - printf ("N.A - Not tested for vxworks.\n"); -#else - os_res = os_access("non_existing_file", OS_ROK); - CU_ASSERT (os_res == os_resultFail); - - /* Check correct functioning of os_access, non existing file write access */ - printf ("Starting os_stdlib_access_002\n"); - os_res = os_access("non_existing_file", OS_WOK); - CU_ASSERT (os_res == os_resultFail); - - /* Check correct functioning of os_access, non existing file execute access */ - printf ("Starting os_stdlib_access_003\n"); - os_res = os_access("non_existing_file", OS_XOK); - CU_ASSERT (os_res == os_resultFail); - - /* Check correct functioning of os_access, non existing file existence */ - printf ("Starting os_stdlib_access_004\n"); - os_res = os_access("non_existing_file", OS_FOK); - CU_ASSERT (os_res == os_resultFail); - - /* Check correct functioning of os_access, existing file with no - permissions read access */ - printf ("Starting os_stdlib_access_005\n"); - #ifdef WIN32 - fh= _creat("existing_file", 0000); /* Note always has read & execute */ - if (fh != -1) - _close(fh); - wanted = os_resultSuccess; - #else - fh= creat("existing_file", 0000); - if (fh != -1) - close(fh); - wanted = os_resultFail; - #endif /* WIN32 */ - os_res = os_access("existing_file", OS_ROK); - CU_ASSERT (os_res == wanted); - - /* Check correct functioning of os_access, existing file with no - permissions write access */ - printf ("Starting os_stdlib_access_006\n"); - os_res = os_access("existing_file", OS_WOK); - CU_ASSERT (os_res == os_resultFail); - - /* Check correct functioning of os_access, existing file with no - permissions execute access */ - printf ("Starting os_stdlib_access_007\n"); - os_res = os_access("existing_file", OS_XOK); - CU_ASSERT (os_res == os_resultFail); - - /* Check correct functioning of os_access, existing file with no permissions existence */ - printf ("Starting os_stdlib_access_008\n"); - os_res = os_access("existing_file", OS_FOK); - CU_ASSERT (os_res == os_resultSuccess); - - /* Check correct functioning of os_access, - existing file with read permissions read access */ - printf ("Starting os_stdlib_access_009\n"); - #ifdef WIN32 - fh= _creat("read_only", _S_IREAD); /* Note always has read & execute */ - if (fh != -1) - _close(fh); - #else - fh= creat("read_only", S_IRUSR); - if (fh != -1) - close(fh); - #endif /* WIN32 */ - os_res = os_access("read_only", OS_ROK); - CU_ASSERT (os_res == os_resultSuccess); - - /* Check correct functioning of os_access, - existing file with read permissions write access */ - printf ("Starting os_stdlib_access_010\n"); - os_res = os_access("read_only", OS_WOK); - CU_ASSERT (os_res == os_resultFail); - - /* Check correct functioning of os_access, - existing file with read permissions execute access */ - printf ("Starting os_stdlib_access_011\n"); - os_res = os_access("read_only", OS_XOK); - CU_ASSERT (os_res == os_resultFail); - - /* Check correct functioning of os_access, - existing file with read permissions existence */ - printf ("Starting os_stdlib_access_012\n"); - os_res = os_access("read_only", OS_FOK); - CU_ASSERT (os_res == os_resultSuccess); - - /* Check correct functioning of os_access, - existing file with write permissions read access */ - printf ("Starting os_stdlib_access_013\n"); - #ifdef WIN32 - fh= _creat("write_only", _S_IWRITE); /* Note windows automatically has read access can't have write only */ - if (fh != -1) - _close(fh); - wanted = os_resultSuccess; - #else - fh= creat("write_only", S_IWUSR); - if (fh != -1) - close(fh); - wanted = os_resultFail; - #endif /* WIN32 */ - os_res = os_access("write_only", OS_ROK); - CU_ASSERT (os_res == wanted); - - /* Check correct functioning of os_access, - existing file with write permissions write access */ - printf ("Starting os_stdlib_access_014\n"); - os_res = os_access("write_only", OS_WOK); - CU_ASSERT (os_res == os_resultSuccess); - - /* Check correct functioning of os_access, - existing file with write permissions execute access */ - printf ("Starting os_stdlib_access_015\n"); - os_res = os_access("write_only", OS_XOK); - CU_ASSERT (os_res == os_resultFail); - - /* Check correct functioning of os_access, - existing file with write permissions existence */ - printf ("Starting os_stdlib_access_016\n"); - os_res = os_access("write_only", OS_FOK); - CU_ASSERT (os_res == os_resultSuccess); - - /* Check correct functioning of os_access, - existing file with exec permissions read access */ - printf ("Starting os_stdlib_access_017\n"); - #ifdef WIN32 - fh= _creat("exec_only" OS_OS_EXESUFFIX, _S_IREAD); /* Windows always has read and can't do execute (that's based upon filename ext only) */ - if (fh != -1) - _close(fh); - wanted = os_resultSuccess; - #else - fh= creat("exec_only" OS_OS_EXESUFFIX, S_IXUSR); - if (fh != -1) - close(fh); - wanted = os_resultFail; - #endif /* WIN32 */ - os_res = os_access("exec_only" OS_OS_EXESUFFIX, OS_ROK); - CU_ASSERT (os_res == wanted); - - /* Check correct functioning of os_access, - existing file with exec permissions write access */ - printf ("Starting os_stdlib_access_018\n"); - os_res = os_access("exec_only" OS_OS_EXESUFFIX, OS_WOK); - CU_ASSERT (os_res == os_resultFail); - - /* Check correct functioning of os_access, - existing file with exec permissions execute access */ - printf ("Starting os_stdlib_access_019\n"); - os_res = os_access("exec_only" OS_OS_EXESUFFIX, OS_XOK); - CU_ASSERT (os_res == os_resultSuccess); - - /* Check correct functioning of os_access, - existing file with exec permissions existence */ - printf ("Starting os_stdlib_access_020\n"); - os_res = os_access("exec_only" OS_OS_EXESUFFIX, OS_FOK); - CU_ASSERT (os_res == os_resultSuccess); - - /* Check correct functioning of os_access, - existing file with read/write/exec permissions read access */ - printf ("Starting os_stdlib_access_021\n"); - #ifdef WIN32 - fh= _creat("read_write_exec" OS_OS_EXESUFFIX, _S_IREAD | _S_IWRITE); /* Windows always has read and can't do execute (that's based upon filename ext only) */ - if (fh != -1) - _close(fh); - #else - fh= creat("read_write_exec" OS_OS_EXESUFFIX, S_IRUSR | S_IWUSR | S_IXUSR); - if (fh != -1) - close(fh); - #endif /* WIN32 */ - os_res = os_access("read_write_exec" OS_OS_EXESUFFIX, OS_ROK); - CU_ASSERT (os_res == os_resultSuccess); - - /* Check correct functioning of os_access, - existing file with read/write/exec permissions write access */ - printf ("Starting os_stdlib_access_022\n"); - os_res = os_access("read_write_exec" OS_OS_EXESUFFIX, OS_WOK); - CU_ASSERT (os_res == os_resultSuccess); - - /* Check correct functioning of os_access, - existing file with read/write/exec permissions execute access */ - printf ("Starting os_stdlib_access_023\n"); - os_res = os_access("read_write_exec" OS_OS_EXESUFFIX, OS_XOK); - CU_ASSERT (os_res == os_resultSuccess); - - /* Check correct functioning of os_access, - existing file with read/write/exec permissions existence */ - printf ("Starting os_stdlib_access_024\n"); - os_res = os_access("read_write_exec" OS_OS_EXESUFFIX, OS_FOK); - CU_ASSERT (os_res == os_resultSuccess); - - /* Check correct functioning of os_access, - existing file with read/exec permissions read+write access */ - printf ("Starting os_stdlib_access_025\n"); - #ifdef WIN32 - fh= _creat("read_exec" OS_OS_EXESUFFIX, _S_IREAD); /* Windows always has read and can't do execute (that's based upon filename ext only) */ - if (fh != -1) - _close(fh); - #else - fh= creat("read_exec" OS_OS_EXESUFFIX, S_IRUSR | S_IXUSR); - if (fh != -1) - close(fh); - #endif /* WIN32 */ - os_res = os_access("read_exec" OS_OS_EXESUFFIX, OS_ROK|OS_WOK); - CU_ASSERT (os_res == os_resultFail); - - /* Check correct functioning of os_access, - existing file with read/exec permissions write+exec access */ - printf ("Starting os_stdlib_access_026\n"); - os_res = os_access("read_exec" OS_OS_EXESUFFIX, OS_WOK|OS_XOK); - CU_ASSERT (os_res == os_resultFail); - - /* Check correct functioning of os_access, - existing file with read/exec permissions read+exec access */ - printf ("Starting os_stdlib_access_027\n"); - os_res = os_access("read_exec" OS_OS_EXESUFFIX, OS_ROK|OS_XOK); - CU_ASSERT (os_res == os_resultSuccess); - - /* Check correct functioning of os_access, - existing file with read/exec permissions read+exec+existence */ - printf ("Starting os_stdlib_access_028\n"); - os_res = os_access("read_exec" OS_OS_EXESUFFIX, OS_ROK|OS_XOK|OS_FOK); - CU_ASSERT (os_res == os_resultSuccess); -#endif /* VXWORKS */ - - printf ("Ending stdlib_os_access\n"); -} - CU_Test(os_stdlib, vsnprintf) { printf ("Starting os_stdlib_vsnprintf_001\n"); @@ -694,27 +186,6 @@ CU_Test(os_stdlib, index) printf ("Ending os_stdlib_index\n"); } -CU_Test(os_stdlib, flockfile) -{ - bool result = false; - - os_osInit(); - - /* Check writing in a FILE from multiple threads without using os_flockfile. */ - printf ("Starting os_stdlib_flockfile_001\n"); - result = doFlockfileTest(false); - CU_ASSERT (result); - - /* Check writing in a FILE from multiple threads using os_flockfile in the first thread. */ - printf ("Starting os_stdlib_flockfile_002\n"); - result = doFlockfileTest(true); - CU_ASSERT (result); - - printf ("Ending os_stdlib_flockfile\n"); - - os_osExit(); -} - CU_Test(os_stdlib, getopt) { int c = 0; diff --git a/src/tools/pubsub/pubsub.c b/src/tools/pubsub/pubsub.c index f2ef8f2..9dfe496 100755 --- a/src/tools/pubsub/pubsub.c +++ b/src/tools/pubsub/pubsub.c @@ -146,6 +146,8 @@ struct wrspeclist { struct wrspeclist *prev, *next; /* circular */ }; +static os_mutex output_mutex; + static void terminate(void) { // const char c = 0; termflag = 1; @@ -850,7 +852,7 @@ static void print_sampleinfo(dds_time_t *tstart, dds_time_t tnow, const dds_samp static void print_K(dds_time_t *tstart, dds_time_t tnow, dds_entity_t rd, const char *tag, const dds_sample_info_t *si, int32_t keyval, uint32_t seq, int (*getkeyval) (dds_entity_t rd, int32_t *key, dds_instance_handle_t ih)) { int result; - os_flockfile(stdout); + os_mutexLock(&output_mutex); print_sampleinfo(tstart, tnow, si, tag); if (si->valid_data) { if(printmode == TGPM_MULTILINE) { @@ -880,7 +882,7 @@ static void print_K(dds_time_t *tstart, dds_time_t tnow, dds_entity_t rd, const } else printf ("get_key_value: error (%s)\n", dds_err_str(result)); } - os_funlockfile(stdout); + os_mutexUnlock(&output_mutex); } static void print_seq_KS(dds_time_t *tstart, dds_time_t tnow, dds_entity_t rd, const char *tag, const dds_sample_info_t *iseq, KeyedSeq **mseq, int count) { @@ -917,7 +919,7 @@ static void print_seq_OU(dds_time_t *tstart, dds_time_t tnow, dds_entity_t rd __ int i; for (i = 0; i < count; i++) { - os_flockfile(stdout); + os_mutexLock(&output_mutex); print_sampleinfo(tstart, tnow, si, tag); if (si->valid_data) { if(printmode == TGPM_MULTILINE) { @@ -930,7 +932,7 @@ static void print_seq_OU(dds_time_t *tstart, dds_time_t tnow, dds_entity_t rd __ } else { printf ("NA\n"); } - os_funlockfile(stdout); + os_mutexUnlock(&output_mutex); } } @@ -2190,6 +2192,7 @@ int MAIN(int argc, char *argv[]) { struct wrspeclist *wrspecs = NULL; memset (&sigtid, 0, sizeof(sigtid)); memset (&inptid, 0, sizeof(inptid)); + os_mutexInit(&output_mutex); if (os_strcasecmp(execname(argc, argv), "sub") == 0) want_writer = 0; @@ -2795,5 +2798,6 @@ int MAIN(int argc, char *argv[]) { if (sleep_at_end) { dds_sleepfor(DDS_SECS(sleep_at_end)); } + os_mutexDestroy(&output_mutex); return (int) exitcode; } diff --git a/src/util/src/ut_expand_envvars.c b/src/util/src/ut_expand_envvars.c index d22060f..2297a47 100644 --- a/src/util/src/ut_expand_envvars.c +++ b/src/util/src/ut_expand_envvars.c @@ -44,7 +44,7 @@ static char *expand_env (const char *name, char op, const char *alt, expand_fn e return os_strdup (env); } else { char *altx = expand (alt); - OS_ERROR("configuration parser", 0, "%s: %s\n", name, altx); + DDS_ERROR("%s: %s\n", name, altx); os_free (altx); return NULL; } @@ -123,7 +123,7 @@ static char *expand_envbrace (const char **src, expand_fn expand) return x; } err: - OS_ERROR("configuration parser", 0, "%*.*s: invalid expansion\n", (int) (*src - start), (int) (*src - start), start); + DDS_ERROR("%*.*s: invalid expansion\n", (int) (*src - start), (int) (*src - start), start); return NULL; } @@ -163,7 +163,7 @@ char *ut_expand_envvars_sh (const char *src0) if (*src == '\\') { src++; if (*src == 0) { - OS_ERROR("configuration parser", 0, "%s: incomplete escape at end of string\n", src0); + DDS_ERROR("%s: incomplete escape at end of string\n", src0); os_free(dst); return NULL; } @@ -172,7 +172,7 @@ char *ut_expand_envvars_sh (const char *src0) char *x, *xp; src++; if (*src == 0) { - OS_ERROR("configuration parser", 0, "%s: incomplete variable expansion at end of string\n", src0); + DDS_ERROR("%s: incomplete variable expansion at end of string\n", src0); os_free(dst); return NULL; } else if (*src == '{') {