Merge branch 'master' into merge2
Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>
This commit is contained in:
commit
3fc777e631
477 changed files with 31941 additions and 32175 deletions
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||
# Copyright(c) 2019 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
|
||||
|
|
@ -11,192 +11,21 @@
|
|||
#
|
||||
cmake_minimum_required(VERSION 3.7)
|
||||
|
||||
# Set a default build type if none was specified
|
||||
set(default_build_type "RelWithDebInfo")
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
|
||||
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
|
||||
STRING "Choose the type of build." FORCE)
|
||||
# Set the possible values of build type for cmake-gui
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
|
||||
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
||||
if(NOT ${PROJECT_NAME} STREQUAL "CycloneDDS")
|
||||
get_filename_component(dir ${CMAKE_CURRENT_LIST_DIR} DIRECTORY)
|
||||
message(FATAL_ERROR "Top-level CMakeLists.txt was moved to the top-level directory. Please run cmake on ${dir} instead of ${CMAKE_CURRENT_LIST_DIR}")
|
||||
endif()
|
||||
|
||||
FUNCTION(PREPEND var prefix)
|
||||
SET(listVar "")
|
||||
FOREACH(f ${ARGN})
|
||||
LIST(APPEND listVar "${prefix}/${f}")
|
||||
ENDFOREACH(f)
|
||||
SET(${var} "${listVar}" PARENT_SCOPE)
|
||||
ENDFUNCTION(PREPEND)
|
||||
|
||||
# Update the git submodules
|
||||
execute_process(COMMAND git submodule init
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||
execute_process(COMMAND git submodule update
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||
|
||||
# Set module path before defining project so platform files will work.
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/modules")
|
||||
set(CMAKE_PROJECT_NAME_FULL "Eclipse Cyclone DDS")
|
||||
set(PROJECT_NAME "CycloneDDS")
|
||||
project(${PROJECT_NAME} VERSION 0.1.0)
|
||||
|
||||
# Set some convenience variants of the project-name
|
||||
string(REPLACE " " "-" CMAKE_PROJECT_NAME_DASHED "${CMAKE_PROJECT_NAME_FULL}")
|
||||
string(TOUPPER ${CMAKE_PROJECT_NAME} CMAKE_PROJECT_NAME_CAPS)
|
||||
string(TOLOWER ${CMAKE_PROJECT_NAME} CMAKE_PROJECT_NAME_SMALL)
|
||||
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "VxWorks")
|
||||
add_definitions(-std=c99)
|
||||
endif()
|
||||
|
||||
if(${CMAKE_C_COMPILER_ID} STREQUAL "SunPro")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64 -xc99 -D__restrict=restrict -D__deprecated__=")
|
||||
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -m64")
|
||||
endif()
|
||||
|
||||
# Conan
|
||||
if(EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
|
||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||
if(APPLE)
|
||||
# By default Conan strips all RPATHs (see conanbuildinfo.cmake), which
|
||||
# causes tests to fail as the executables cannot find the library target.
|
||||
# By setting KEEP_RPATHS, Conan does not set CMAKE_SKIP_RPATH and the
|
||||
# resulting binaries still have the RPATH information. This is fine because
|
||||
# CMake will strip the build RPATH information in the install step.
|
||||
#
|
||||
# NOTE:
|
||||
# Conan's default approach is to use the "imports" feature, which copies
|
||||
# all the dependencies into the bin directory. Of course, this doesn't work
|
||||
# quite that well for libraries generated in this Project (see Conan
|
||||
# documentation).
|
||||
#
|
||||
# See the links below for more information.
|
||||
# https://github.com/conan-io/conan/issues/337
|
||||
# https://docs.conan.io/en/latest/howtos/manage_shared_libraries/rpaths.html
|
||||
# https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling
|
||||
conan_basic_setup(KEEP_RPATHS)
|
||||
else()
|
||||
conan_basic_setup()
|
||||
endif()
|
||||
conan_define_targets()
|
||||
endif()
|
||||
|
||||
# Set reasonably strict warning options for clang, gcc, msvc
|
||||
# Enable coloured ouput if Ninja is used for building
|
||||
if(${CMAKE_C_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_C_COMPILER_ID} STREQUAL "AppleClang")
|
||||
add_definitions(-Wall -Wextra -Wconversion -Wunused)
|
||||
if(${CMAKE_GENERATOR} STREQUAL "Ninja")
|
||||
add_definitions(-Xclang -fcolor-diagnostics)
|
||||
endif()
|
||||
elseif(${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
|
||||
add_definitions(-Wall -Wextra -Wconversion)
|
||||
if(${CMAKE_GENERATOR} STREQUAL "Ninja")
|
||||
add_definitions(-fdiagnostics-color=always)
|
||||
endif()
|
||||
elseif(${CMAKE_C_COMPILER_ID} STREQUAL "MSVC")
|
||||
add_definitions(/W3)
|
||||
endif()
|
||||
|
||||
# I don't know how to enable warnings properly so that it ends up in Xcode projects as well
|
||||
if(${CMAKE_GENERATOR} STREQUAL "Xcode")
|
||||
set (CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_EMPTY_BODY YES)
|
||||
set (CMAKE_XCODE_ATTRIBUTE_GCC_WARN_SHADOW YES)
|
||||
set (CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_BOOL_CONVERSION YES)
|
||||
set (CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_CONSTANT_CONVERSION YES)
|
||||
set (CMAKE_XCODE_ATTRIBUTE_GCC_WARN_64_TO_32_BIT_CONVERSION YES)
|
||||
set (CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_ENUM_CONVERSION YES)
|
||||
set (CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_FLOAT_CONVERSION YES)
|
||||
set (CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_INT_CONVERSION YES)
|
||||
set (CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_NON_LITERAL_NULL_CONVERSION YES)
|
||||
set (CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_IMPLICIT_SIGN_CONVERSION YES)
|
||||
set (CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_INFINITE_RECURSION YES)
|
||||
set (CMAKE_XCODE_ATTRIBUTE_GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED YES)
|
||||
set (CMAKE_XCODE_ATTRIBUTE_GCC_WARN_ABOUT_RETURN_TYPE YES)
|
||||
set (CMAKE_XCODE_ATTRIBUTE_GCC_WARN_MISSING_PARENTHESES YES)
|
||||
set (CMAKE_XCODE_ATTRIBUTE_GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS YES)
|
||||
set (CMAKE_XCODE_ATTRIBUTE_GCC_WARN_ABOUT_MISSING_NEWLINE YES)
|
||||
set (CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_ASSIGN_ENUM YES)
|
||||
set (CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_SEMICOLON_BEFORE_METHOD_BODY YES)
|
||||
set (CMAKE_XCODE_ATTRIBUTE_GCC_WARN_SIGN_COMPARE YES)
|
||||
set (CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_STRICT_PROTOTYPES YES)
|
||||
set (CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_COMMA YES)
|
||||
set (CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION YES)
|
||||
set (CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNINITIALIZED_AUTOS YES_AGGRESSIVE)
|
||||
set (CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_FUNCTION YES)
|
||||
set (CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_LABEL YES)
|
||||
set (CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_PARAMETER YES)
|
||||
set (CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_VALUE YES)
|
||||
set (CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_VARIABLE YES)
|
||||
endif()
|
||||
|
||||
# Make it easy to enable one of Clang's/gcc's analyzers, and default to using
|
||||
# the address sanitizer for ordinary debug builds; gcc is giving some grief on
|
||||
# Travis, so don't enable it for gcc by default
|
||||
if(NOT USE_SANITIZER)
|
||||
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug" AND
|
||||
NOT (${CMAKE_GENERATOR} STREQUAL "Xcode") AND
|
||||
(${CMAKE_C_COMPILER_ID} STREQUAL "Clang"
|
||||
OR ${CMAKE_C_COMPILER_ID} STREQUAL "AppleClang"))
|
||||
message(STATUS "Enabling address sanitizer; set USE_SANITIZER=none to prevent this")
|
||||
set(USE_SANITIZER address)
|
||||
else()
|
||||
set(USE_SANITIZER none)
|
||||
endif()
|
||||
endif()
|
||||
if(NOT (${USE_SANITIZER} STREQUAL "none"))
|
||||
message(STATUS "Sanitizer set to ${USE_SANITIZER}")
|
||||
add_compile_options(-fno-omit-frame-pointer -fsanitize=${USE_SANITIZER})
|
||||
link_libraries(-fno-omit-frame-pointer -fsanitize=${USE_SANITIZER})
|
||||
endif()
|
||||
|
||||
include(GNUInstallDirs)
|
||||
include(AnalyzeBuild)
|
||||
if(APPLE)
|
||||
set(CMAKE_INSTALL_RPATH "@loader_path/../${CMAKE_INSTALL_LIBDIR}")
|
||||
else()
|
||||
set(CMAKE_INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}")
|
||||
endif()
|
||||
# Include Coverage before CTest so that COVERAGE_COMMAND can be modified
|
||||
# in the Coverage module should that ever be necessary.
|
||||
include(Coverage)
|
||||
set(MEMORYCHECK_COMMAND_OPTIONS "--track-origins=yes --leak-check=full --trace-children=yes --child-silent-after-fork=yes --xml=yes --xml-file=TestResultValgrind_%p.xml --tool=memcheck --show-reachable=yes --leak-resolution=high")
|
||||
|
||||
# By default building the testing tree is enabled by including CTest, but
|
||||
# since not everybody has CUnit, and because it is not strictly required to
|
||||
# build the product itself, switch to off by default.
|
||||
option(BUILD_TESTING "Build the testing tree." OFF)
|
||||
include(CTest)
|
||||
|
||||
# Build all executables and libraries into the top-level /bin and /lib folders.
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
||||
|
||||
add_subdirectory(idlc)
|
||||
add_subdirectory(ddsrt)
|
||||
add_subdirectory(etc)
|
||||
|
||||
# some of the tests in the core rely on preprocessing IDL, so idlc has to
|
||||
# come first
|
||||
if(BUILD_IDLC)
|
||||
add_subdirectory(idlc)
|
||||
endif()
|
||||
add_subdirectory(security/api)
|
||||
add_subdirectory(core)
|
||||
add_subdirectory(tools)
|
||||
add_subdirectory(scripts)
|
||||
|
||||
option(USE_DOCS "Enable documentation." OFF)
|
||||
if(USE_DOCS)
|
||||
add_subdirectory(docs)
|
||||
else()
|
||||
message(STATUS "${CMAKE_PROJECT_NAME} documentation: disabled (-DUSE_DOCS=1 to enable)")
|
||||
endif()
|
||||
|
||||
add_subdirectory(examples)
|
||||
|
||||
if (BUILD_TESTING)
|
||||
# Multi Process Tests
|
||||
if(BUILD_TESTING AND HAVE_MULTI_PROCESS AND BUILD_IDLC)
|
||||
add_subdirectory(mpt)
|
||||
endif()
|
||||
|
||||
|
||||
# Pull-in CPack and support for generating <Package>Config.cmake and packages.
|
||||
include(Packaging)
|
||||
|
|
|
|||
|
|
@ -1,31 +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
|
||||
#
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
set(COVERAGE_SOURCE_DIR "@PROJECT_SOURCE_DIR@")
|
||||
set(COVERAGE_RUN_DIR "@CMAKE_BINARY_DIR@")
|
||||
set(COVERAGE_OUTPUT_DIR "@CMAKE_BINARY_DIR@/coverage")
|
||||
|
||||
# TODO: Make this a list instead of separate variables when more directories
|
||||
# need to be excluded. Currently there's actually only one directory to
|
||||
# be excluded, but when the test(s) are moved, more directories will be
|
||||
# added. I just added two directories to indicate how the coverage
|
||||
# generators handle multiple exclusion directories.
|
||||
#
|
||||
# Do not include the various test directories.
|
||||
set(COVERAGE_EXCLUDE_TESTS "tests")
|
||||
set(COVERAGE_EXCLUDE_EXAMPLES "examples")
|
||||
set(COVERAGE_EXCLUDE_BUILD_SUPPORT "cmake")
|
||||
|
||||
# Add this flag when you want to suppress LCOV and ctest outputs during coverage collecting.
|
||||
#set(COVERAGE_QUIET_FLAG "--quiet")
|
||||
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
@echo off
|
||||
REM Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||
REM
|
||||
REM This program and the accompanying materials are made available under the
|
||||
REM terms of the Eclipse Public License v. 2.0 which is available at
|
||||
REM http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||
REM v. 1.0 which is available at
|
||||
REM http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
REM
|
||||
REM SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
|
||||
REM VxWorks toolchain requires WIND_BASE to be exported, should the user be
|
||||
REM compiling for VxWorks and not have WIND_BASE exported, do that here before
|
||||
REM invoking the compiler.
|
||||
if "%WIND_BASE%" == "" (
|
||||
set WIND_BASE="@WIND_BASE@"
|
||||
)
|
||||
|
||||
REM Strip C compiler from command line arguments for compatibility because
|
||||
REM this launcher may also be used from an integrated development environment
|
||||
REM at some point.
|
||||
if "%1" == "@CMAKE_C_COMPILER@" (
|
||||
shift
|
||||
)
|
||||
|
||||
"@CMAKE_C_COMPILER@" %*
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 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
|
||||
#
|
||||
|
||||
# VxWorks toolchain requires WIND_BASE to be exported, should the user be
|
||||
# compiling for VxWorks and not have WIND_BASE exported, to that here before
|
||||
# invoking the compiler.
|
||||
if [ -z "${WIND_BASE}" ] && [ -n "@WIND_BASE@" ]; then
|
||||
WIND_BASE="@WIND_BASE@"
|
||||
export WIND_BASE
|
||||
fi
|
||||
|
||||
if [ -n "@WIND_LMAPI@" ]; then
|
||||
if [ -z "${LD_LIBRARY_PATH}" ]; then
|
||||
LD_LIBRARY_PATH="@WIND_LMAPI@"
|
||||
export LD_LIBRARY_PATH
|
||||
elif [[ "${LD_LIBRARY_PATH}" == ?(*:)"@WIND_LMAPI@"?(:*) ]]; then
|
||||
LD_LIBRARY_PATH="@WIND_LMAPI@:${LD_LIBRARY_PATH}"
|
||||
export LD_LIBRARY_PATH
|
||||
fi
|
||||
fi
|
||||
|
||||
# Strip C compiler from command line arguments for compatibility because this
|
||||
# launcher may also be used from an integrated development environment at some
|
||||
# point.
|
||||
if [ "$1" = "@CMAKE_C_COMPILER@" ]; then
|
||||
shift
|
||||
fi
|
||||
|
||||
exec "@CMAKE_C_COMPILER@" "$@"
|
||||
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
@echo off
|
||||
REM Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||
REM
|
||||
REM This program and the accompanying materials are made available under the
|
||||
REM terms of the Eclipse Public License v. 2.0 which is available at
|
||||
REM http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||
REM v. 1.0 which is available at
|
||||
REM http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
REM
|
||||
REM SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
|
||||
REM VxWorks toolchain requires WIND_BASE to be exported, should the user be
|
||||
REM compiling for VxWorks and not have WIND_BASE exported, do that here before
|
||||
REM invoking the compiler.
|
||||
if "%WIND_BASE%" == "" (
|
||||
set WIND_BASE="@WIND_BASE@"
|
||||
)
|
||||
|
||||
REM Strip C compiler from command line arguments for compatibility because
|
||||
REM this launcher may also be used from an integrated development environment
|
||||
REM at some point.
|
||||
if "%1" == "@CMAKE_CXX_COMPILER@" (
|
||||
shift
|
||||
)
|
||||
|
||||
"@CMAKE_CXX_COMPILER@" %*
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 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
|
||||
#
|
||||
|
||||
# VxWorks toolchain requires WIND_BASE to be exported, should the user be
|
||||
# compiling for VxWorks and not have WIND_BASE exported, to that here before
|
||||
# invoking the compiler.
|
||||
if [ -z "${WIND_BASE}" ] && [ -n "@WIND_BASE@" ]; then
|
||||
WIND_BASE="@WIND_BASE@"
|
||||
export WIND_BASE
|
||||
fi
|
||||
|
||||
if [ -n "@WIND_LMAPI@" ]; then
|
||||
if [ -z "${LD_LIBRARY_PATH}" ]; then
|
||||
LD_LIBRARY_PATH="@WIND_LMAPI@"
|
||||
export LD_LIBRARY_PATH
|
||||
elif [[ "${LD_LIBRARY_PATH}" == ?(*:)"@WIND_LMAPI@"?(:*) ]]; then
|
||||
LD_LIBRARY_PATH="@WIND_LMAPI@:${LD_LIBRARY_PATH}"
|
||||
export LD_LIBRARY_PATH
|
||||
fi
|
||||
fi
|
||||
|
||||
# Strip C compiler from command line arguments for compatibility because this
|
||||
# launcher may also be used from an integrated development environment at some
|
||||
# point.
|
||||
if [ "$1" = "@CMAKE_CXX_COMPILER@" ]; then
|
||||
shift
|
||||
fi
|
||||
|
||||
exec "@CMAKE_CXX_COMPILER@" "$@"
|
||||
|
||||
|
|
@ -1,65 +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
|
||||
#
|
||||
cmake_minimum_required(VERSION 3.3) # For IN_LIST
|
||||
|
||||
option(ANALYZE_BUILD "Enable static analysis during build" OFF)
|
||||
|
||||
if(ANALYZE_BUILD)
|
||||
get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES)
|
||||
set(scan_build_supported Clang AppleClang GNU)
|
||||
|
||||
if("C" IN_LIST languages)
|
||||
include(CheckCCompilerFlag)
|
||||
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
|
||||
set(ANALYZE_C_BUILD_FLAG "/analyze")
|
||||
elseif(CMAKE_C_COMPILER_ID IN_LIST scan_build_supported)
|
||||
message(STATUS "Static analysis for C using ${CMAKE_C_COMPILER_ID}-compiler is available by using 'scan-build' manually only")
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
|
||||
CHECK_C_COMPILER_FLAG(${ANALYZE_C_BUILD_FLAG} C_COMPILER_HAS_ANALYZE_BUILD)
|
||||
|
||||
if(C_COMPILER_HAS_ANALYZE_BUILD)
|
||||
if(CMAKE_GENERATOR MATCHES "Visual Studio")
|
||||
# $<COMPILE_LANGUAGE:...> may not be used with Visual Studio generators.
|
||||
add_compile_options(${ANALYZE_C_BUILD_FLAG})
|
||||
else()
|
||||
add_compile_options($<$<COMPILE_LANGUAGE:C>:${ANALYZE_C_BUILD_FLAG}>)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if("CXX" IN_LIST languages)
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
set(ANALYZE_CXX_BUILD_FLAG "/analyze")
|
||||
elseif(CMAKE_C_COMPILER_ID IN_LIST scan_build_supported)
|
||||
message(STATUS "Static analysis for CXX using ${CMAKE_CXX_COMPILER_ID}-compiler is available by using 'scan-build' manually only")
|
||||
endif()
|
||||
|
||||
if(DEFINED ANALYZE_CXX_BUILD_FLAG)
|
||||
CHECK_CXX_COMPILER_FLAG(${ANALYZE_CXX_BUILD_FLAG} CXX_COMPILER_HAS_ANALYZE_BUILD)
|
||||
|
||||
if(CXX_COMPILER_HAS_ANALYZE_BUILD)
|
||||
if(CMAKE_GENERATOR MATCHES "Visual Studio")
|
||||
add_compile_options(${ANALYZE_CXX_BUILD_FLAG})
|
||||
else()
|
||||
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:${ANALYZE_CXX_BUILD_FLAG}>)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
@ -1,311 +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
|
||||
#
|
||||
find_package(CUnit REQUIRED)
|
||||
|
||||
set(CUNIT_DIR "${CMAKE_CURRENT_LIST_DIR}/CUnit")
|
||||
|
||||
|
||||
function(get_cunit_header_file SOURCE_FILE HEADER_FILE)
|
||||
# Return a unique (but consistent) filename where Theory macros can be
|
||||
# written. The path that will be returned is the location to a header file
|
||||
# located in the same relative directory, using the basename of the source
|
||||
# file postfixed with .h. e.g. <project>/foo/bar.h would be converted to
|
||||
# <project>/build/foo/bar.h.
|
||||
get_filename_component(SOURCE_FILE "${SOURCE_FILE}" ABSOLUTE)
|
||||
file(RELATIVE_PATH SOURCE_FILE "${PROJECT_SOURCE_DIR}" "${SOURCE_FILE}")
|
||||
get_filename_component(basename "${SOURCE_FILE}" NAME_WE)
|
||||
get_filename_component(dir "${SOURCE_FILE}" DIRECTORY)
|
||||
set(${HEADER_FILE} "${CMAKE_BINARY_DIR}/${dir}/${basename}.h" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(parse_cunit_fixtures INPUT TEST_DISABLED TEST_TIMEOUT)
|
||||
if(INPUT MATCHES ".disabled${s}*=${s}*([tT][rR][uU][eE]|[0-9]+)")
|
||||
set(${TEST_DISABLED} "TRUE" PARENT_SCOPE)
|
||||
else()
|
||||
set(${TEST_DISABLED} "FALSE" PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
if(INPUT MATCHES ".timeout${s}*=${s}*([0-9]+)")
|
||||
set(${TEST_TIMEOUT} "${CMAKE_MATCH_1}" PARENT_SCOPE)
|
||||
else()
|
||||
set(${TEST_TIMEOUT} "0" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Parse a single source file, generate a header file with theory definitions
|
||||
# (if applicable) and return suite and test definitions.
|
||||
function(process_cunit_source_file SOURCE_FILE HEADER_FILE SUITES TESTS)
|
||||
set(x "\\*")
|
||||
set(s "[ \t\r\n]")
|
||||
set(s_or_x "[ \t\r\n\\*]")
|
||||
set(w "[_a-zA-Z0-9]")
|
||||
set(ident_expr "(${s}*${w}+${s}*)")
|
||||
# Very basic type recognition, only things that contain word characters and
|
||||
# pointers are handled. And since this script does not actually have to
|
||||
# compile any code, type checking is left to the compiler. An error (or
|
||||
# warning) will be thrown if something is off.
|
||||
#
|
||||
# The "type" regular expression below will match things like:
|
||||
# - <word> <word>
|
||||
# - <word> *<word>
|
||||
# - <word>* <word> *<word>
|
||||
set(type_expr "(${s}*${w}+${x}*${s}+${s_or_x}*)+")
|
||||
set(param_expr "${type_expr}${ident_expr}")
|
||||
# Test fixture support (based on test fixtures as implemented in Criterion),
|
||||
# to enable per-test (de)initializers, which is very different from
|
||||
# per-suite (de)initializers, and timeouts.
|
||||
#
|
||||
# The following fixtures are supported:
|
||||
# - init
|
||||
# - fini
|
||||
# - disabled
|
||||
# - timeout
|
||||
set(data_expr "(${s}*,${s}*\\.${w}+${s}*=[^,\\)]+)*")
|
||||
|
||||
set(suites_wo_init_n_clean)
|
||||
set(suites_w_init)
|
||||
set(suites_w_clean)
|
||||
|
||||
file(READ "${SOURCE_FILE}" content)
|
||||
|
||||
# CU_Init and CU_Clean
|
||||
#
|
||||
# Extract all suite initializers and deinitializers so that the list of
|
||||
# suites can be probably populated when tests and theories are parsed. Suites
|
||||
# are only registered if it contains at least one test or theory.
|
||||
set(suite_expr "CU_(Init|Clean)${s}*\\(${ident_expr}\\)")
|
||||
string(REGEX MATCHALL "${suite_expr}" matches "${content}")
|
||||
foreach(match ${matches})
|
||||
string(REGEX REPLACE "${suite_expr}" "\\2" suite "${match}")
|
||||
|
||||
if("${match}" MATCHES "CU_Init")
|
||||
list(APPEND suites_w_init ${suite})
|
||||
elseif("${match}" MATCHES "CU_Clean")
|
||||
list(APPEND suites_w_deinit ${suite})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# CU_Test
|
||||
set(test_expr "CU_Test${s}*\\(${ident_expr},${ident_expr}${data_expr}\\)")
|
||||
string(REGEX MATCHALL "${test_expr}" matches "${content}")
|
||||
foreach(match ${matches})
|
||||
string(REGEX REPLACE "${test_expr}" "\\1" suite "${match}")
|
||||
string(REGEX REPLACE "${test_expr}" "\\2" test "${match}")
|
||||
# Remove leading and trailing whitespace
|
||||
string(STRIP "${suite}" suite)
|
||||
string(STRIP "${test}" test)
|
||||
|
||||
# Extract fixtures that must be handled by CMake (.disabled and .timeout).
|
||||
parse_cunit_fixtures("${match}" disabled timeout)
|
||||
list(APPEND suites_wo_init_n_clean "${suite}")
|
||||
list(APPEND tests "${suite}:${test}:${disabled}:${timeout}")
|
||||
endforeach()
|
||||
|
||||
# CU_Theory
|
||||
#
|
||||
# CU_Theory signatures must be recognized in order to generate structures to
|
||||
# hold the CU_DataPoints declarations. The generated type is added to the
|
||||
# compile definitions and inserted by the preprocessor when CU_TheoryDataPoints
|
||||
# is expanded.
|
||||
#
|
||||
# NOTE: Since not all compilers support pushing function-style definitions
|
||||
# from the command line (CMake will generate a warning too), a header
|
||||
# file is generated instead. A define is pushed and expanded at
|
||||
# compile time. It is included by CUnit/Theory.h.
|
||||
get_cunit_header_file("${SOURCE_FILE}" header)
|
||||
|
||||
set(theory_expr "CU_Theory${s}*\\(${s}*\\((${param_expr}(,${param_expr})*)\\)${s}*,${ident_expr},${ident_expr}${data_expr}\\)")
|
||||
string(REGEX MATCHALL "${theory_expr}" matches "${content}")
|
||||
foreach(match ${matches})
|
||||
if(NOT theories)
|
||||
# Ensure generated header is truncated before anything is written.
|
||||
file(WRITE "${header}" "")
|
||||
endif()
|
||||
string(REGEX REPLACE "${theory_expr}" "\\1" params "${match}")
|
||||
string(REGEX REPLACE "${theory_expr}" "\\7" suite "${match}")
|
||||
string(REGEX REPLACE "${theory_expr}" "\\8" test "${match}")
|
||||
# Remove leading and trailing whitespace
|
||||
string(STRIP "${params}" params)
|
||||
string(STRIP "${suite}" suite)
|
||||
string(STRIP "${test}" test)
|
||||
# Convert parameters from a string to a list
|
||||
string(REGEX REPLACE "${s}*,${s}*" ";" params "${params}")
|
||||
|
||||
# Extract fixtures that must be handled by CMake (.disabled and .timeout)
|
||||
parse_cunit_fixtures("${match}" disabled timeout)
|
||||
list(APPEND suites_wo_init_n_clean "${suite}")
|
||||
list(APPEND theories "${suite}:${test}:${disabled}:${timeout}")
|
||||
|
||||
set(sep)
|
||||
set(size "CU_TheoryDataPointsSize_${suite}_${test}(datapoints) (")
|
||||
set(slice "CU_TheoryDataPointsSlice_${suite}_${test}(datapoints, index) (")
|
||||
set(typedef "CU_TheoryDataPointsTypedef_${suite}_${test}() {")
|
||||
foreach(param ${params})
|
||||
string(
|
||||
REGEX REPLACE "(${type_expr})${ident_expr}" "\\3" name "${param}")
|
||||
string(
|
||||
REGEX REPLACE "(${type_expr})${ident_expr}" "\\1" type "${param}")
|
||||
string(STRIP "${name}" name)
|
||||
string(STRIP "${type}" type)
|
||||
|
||||
set(slice "${slice}${sep} datapoints.${name}.p[index]")
|
||||
if (NOT sep)
|
||||
set(size "${size} datapoints.${name}.n")
|
||||
set(sep ",")
|
||||
endif()
|
||||
set(typedef "${typedef} struct { size_t n; ${type} *p; } ${name};")
|
||||
endforeach()
|
||||
set(typedef "${typedef} }")
|
||||
set(slice "${slice} )")
|
||||
set(size "${size} )")
|
||||
|
||||
file(APPEND "${header}" "#define ${size}\n")
|
||||
file(APPEND "${header}" "#define ${slice}\n")
|
||||
file(APPEND "${header}" "#define ${typedef}\n")
|
||||
endforeach()
|
||||
|
||||
# Propagate suites, tests and theories extracted from the source file.
|
||||
if(suites_wo_init_n_clean)
|
||||
list(REMOVE_DUPLICATES suites_wo_init_n_clean)
|
||||
list(SORT suites_wo_init_n_clean)
|
||||
foreach(suite ${suites_wo_init_n_clean})
|
||||
set(init "FALSE")
|
||||
set(clean "FALSE")
|
||||
if(${suite} IN_LIST suites_w_init)
|
||||
set(init "TRUE")
|
||||
endif()
|
||||
if(${suite} IN_LIST suites_w_deinit)
|
||||
set(clean "TRUE")
|
||||
endif()
|
||||
|
||||
list(APPEND suites "${suite}:${init}:${clean}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(theories)
|
||||
set(${HEADER_FILE} "${header}" PARENT_SCOPE)
|
||||
else()
|
||||
unset(${HEADER_FILE} PARENT_SCOPE)
|
||||
endif()
|
||||
set(${SUITES} ${suites} PARENT_SCOPE)
|
||||
set(${TESTS} ${tests};${theories} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(add_cunit_executable TARGET)
|
||||
# Retrieve location of shared libary, which is need to extend the PATH
|
||||
# environment variable on Microsoft Windows, so that the operating
|
||||
# system can locate the .dll that it was linked against.
|
||||
# On macOS, this mechanism is used to set the DYLD_LIBRARY_PATH.
|
||||
get_target_property(CUNIT_LIBRARY_TYPE CUnit TYPE)
|
||||
get_target_property(CUNIT_IMPORTED_LOCATION CUnit IMPORTED_LOCATION)
|
||||
get_filename_component(CUNIT_LIBRARY_DIR "${CUNIT_IMPORTED_LOCATION}" PATH)
|
||||
|
||||
set(decls)
|
||||
set(defns)
|
||||
set(sources)
|
||||
|
||||
foreach(source ${ARGN})
|
||||
if((EXISTS "${source}" OR EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${source}"))
|
||||
unset(suites)
|
||||
unset(tests)
|
||||
|
||||
process_cunit_source_file("${source}" header suites tests)
|
||||
if(header)
|
||||
set_property(
|
||||
SOURCE "${source}"
|
||||
PROPERTY COMPILE_DEFINITIONS CU_THEORY_INCLUDE_FILE=\"${header}\")
|
||||
endif()
|
||||
|
||||
# Disable missing-field-initializers warnings as not having to specify
|
||||
# every member, aka fixture, is intended behavior.
|
||||
if(${CMAKE_C_COMPILER_ID} STREQUAL "Clang" OR
|
||||
${CMAKE_C_COMPILER_ID} STREQUAL "AppleClang" OR
|
||||
${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
|
||||
set_property(
|
||||
SOURCE "${source}"
|
||||
PROPERTY COMPILE_FLAGS -Wno-missing-field-initializers)
|
||||
endif()
|
||||
|
||||
foreach(suite ${suites})
|
||||
string(REPLACE ":" ";" suite ${suite})
|
||||
list(GET suite 2 clean)
|
||||
list(GET suite 1 init)
|
||||
list(GET suite 0 suite)
|
||||
set(init_func "NULL")
|
||||
set(clean_func "NULL")
|
||||
if(init)
|
||||
set(decls "${decls}\nCU_InitDecl(${suite});")
|
||||
set(init_func "CU_InitName(${suite})")
|
||||
endif()
|
||||
if(clean)
|
||||
set(decls "${decls}\nCU_CleanDecl(${suite});")
|
||||
set(clean_func "CU_CleanName(${suite})")
|
||||
endif()
|
||||
set(defns "${defns}\nADD_SUITE(${suite}, ${init_func}, ${clean_func});")
|
||||
endforeach()
|
||||
|
||||
foreach(test ${tests})
|
||||
string(REPLACE ":" ";" test ${test})
|
||||
list(GET test 3 timeout)
|
||||
list(GET test 2 disabled)
|
||||
list(GET test 0 suite)
|
||||
list(GET test 1 test)
|
||||
|
||||
set(enable "true")
|
||||
if(disabled)
|
||||
set(enable "false")
|
||||
endif()
|
||||
if(NOT timeout)
|
||||
set(timeout 10)
|
||||
endif()
|
||||
|
||||
set(decls "${decls}\nCU_TestDecl(${suite}, ${test});")
|
||||
set(defns "${defns}\nADD_TEST(${suite}, ${test}, ${enable});")
|
||||
set(ctest "CUnit_${suite}_${test}")
|
||||
|
||||
add_test(
|
||||
NAME ${ctest}
|
||||
COMMAND ${TARGET} -a -r "${suite}-${test}" -s ${suite} -t ${test})
|
||||
set_property(TEST ${ctest} PROPERTY TIMEOUT ${timeout})
|
||||
set_property(TEST ${ctest} PROPERTY DISABLED ${disabled})
|
||||
if(APPLE)
|
||||
set_property(
|
||||
TEST ${ctest}
|
||||
PROPERTY ENVIRONMENT
|
||||
"DYLD_LIBRARY_PATH=${CUNIT_LIBRARY_DIR}:$ENV{DYLD_LIBRARY_PATH}")
|
||||
elseif(WIN32 AND ${CUNIT_LIBRARY_TYPE} STREQUAL "SHARED_LIBRARY")
|
||||
set_property(
|
||||
TEST ${ctest}
|
||||
PROPERTY ENVIRONMENT
|
||||
"PATH=${CUNIT_LIBRARY_DIR};$ENV{PATH}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
list(APPEND sources "${source}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
configure_file(
|
||||
"${CUNIT_DIR}/src/main.c.in" "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.c" @ONLY)
|
||||
if("2.1.3" VERSION_LESS_EQUAL
|
||||
"${CUNIT_VERSION_MAJOR}.${CUNIT_VERSION_MINOR}.${CUNIT_VERSION_PATCH}")
|
||||
set_property(
|
||||
SOURCE "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.c"
|
||||
PROPERTY COMPILE_DEFINITIONS HAVE_ENABLE_JUNIT_XML)
|
||||
endif()
|
||||
|
||||
add_executable(
|
||||
${TARGET} "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.c" ${sources})
|
||||
target_link_libraries(${TARGET} PRIVATE CUnit)
|
||||
target_include_directories(${TARGET} PRIVATE "${CUNIT_DIR}/include")
|
||||
endfunction()
|
||||
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
#ifndef CUNIT_TEST_H
|
||||
#define CUNIT_TEST_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <CUnit/CUnit.h>
|
||||
#include <CUnit/CUError.h>
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void(*cu_test_init_func_t)(void);
|
||||
typedef void(*cu_test_fini_func_t)(void);
|
||||
|
||||
typedef struct {
|
||||
cu_test_init_func_t init;
|
||||
cu_test_fini_func_t fini;
|
||||
int disabled; /* Parsed by CMake, used at test registration in main. */
|
||||
int timeout; /* Parsed by CMake, used at test registration in CMake. */
|
||||
} cu_data_t;
|
||||
|
||||
#define CU_InitName(suite) \
|
||||
CU_Init_ ## suite
|
||||
#define CU_CleanName(suite) \
|
||||
CU_Fini_ ## suite
|
||||
#define CU_TestName(suite, test) \
|
||||
CU_Test_ ## suite ## _ ## test
|
||||
#define CU_TestProxyName(suite, test) \
|
||||
CU_TestProxy_ ## suite ## _ ## test
|
||||
|
||||
#define CU_Init(suite) \
|
||||
int CU_InitName(suite)(void)
|
||||
#define CU_InitDecl(suite) \
|
||||
extern CU_Init(suite)
|
||||
|
||||
#define CU_Clean(suite) \
|
||||
int CU_CleanName(suite)(void)
|
||||
#define CU_CleanDecl(suite) \
|
||||
extern CU_Clean(suite)
|
||||
|
||||
/* CU_Test generates a wrapper function that takes care of per-test
|
||||
initialization and deinitialization, if provided in the CU_Test
|
||||
signature. */
|
||||
#define CU_Test(suite, test, ...) \
|
||||
static void CU_TestName(suite, test)(void); \
|
||||
\
|
||||
void CU_TestProxyName(suite, test)(void) { \
|
||||
cu_data_t data = CU_Fixture(__VA_ARGS__); \
|
||||
\
|
||||
if (data.init != NULL) { \
|
||||
data.init(); \
|
||||
} \
|
||||
\
|
||||
CU_TestName(suite, test)(); \
|
||||
\
|
||||
if (data.fini != NULL) { \
|
||||
data.fini(); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
static void CU_TestName(suite, test)(void)
|
||||
|
||||
#define CU_TestDecl(suite, test) \
|
||||
extern void CU_TestProxyName(suite, test)(void)
|
||||
|
||||
/* Microsoft Visual Studio does not like empty struct initializers, i.e.
|
||||
no fixtures are specified. To work around that issue CU_Fixture inserts a
|
||||
NULL initializer as fall back. */
|
||||
#define CU_Comma() ,
|
||||
#define CU_Reduce(one, ...) one
|
||||
|
||||
#ifdef _WIN32
|
||||
/* Microsoft Visual Studio does not expand __VA_ARGS__ correctly. */
|
||||
#define CU_Fixture__(...) CU_Fixture____((__VA_ARGS__))
|
||||
#define CU_Fixture____(tuple) CU_Fixture___ tuple
|
||||
#else
|
||||
#define CU_Fixture__(...) CU_Fixture___(__VA_ARGS__)
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#define CU_Fixture___(throw, away, value, ...) value
|
||||
|
||||
#define CU_Fixture(...) \
|
||||
CU_Fixture_( CU_Comma CU_Reduce(__VA_ARGS__,) (), __VA_ARGS__ )
|
||||
|
||||
#define CU_Fixture_(throwaway, ...) \
|
||||
CU_Fixture__(throwaway, ((cu_data_t){ 0 }), ((cu_data_t){ __VA_ARGS__ }))
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CUNIT_TEST_H */
|
||||
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
#ifndef CUNIT_THEORY_H
|
||||
#define CUNIT_THEORY_H
|
||||
|
||||
/* Function-style macros cannot be defined on the command line. */
|
||||
#ifdef CU_THEORY_INCLUDE_FILE
|
||||
#include CU_THEORY_INCLUDE_FILE
|
||||
#endif
|
||||
|
||||
#include "CUnit/Test.h"
|
||||
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define CU_TheoryDataPointsName(suite, test) \
|
||||
CU_TheoryDataPoints_ ## suite ## _ ## test
|
||||
|
||||
#define CU_TheoryDataPointsTypeName(suite, test) \
|
||||
CU_TheoryDataPointsType_ ## suite ## _ ## test
|
||||
|
||||
#define CU_TheoryDataPointsSize(suite, test) \
|
||||
CU_TheoryDataPointsSize_ ## suite ## _ ## test ( \
|
||||
CU_TheoryDataPointsName(suite, test))
|
||||
|
||||
#define CU_TheoryDataPointsSlice(suite, test, index) \
|
||||
CU_TheoryDataPointsSlice_ ## suite ## _ ## test ( \
|
||||
CU_TheoryDataPointsName(suite, test), index)
|
||||
|
||||
#define CU_TheoryDataPointsTypedef(suite, test) \
|
||||
CU_TheoryDataPointsTypedef_ ## suite ## _ ## test()
|
||||
|
||||
#define CU_TheoryDataPoints(suite, test) \
|
||||
struct CU_TheoryDataPointsTypeName(suite, test) \
|
||||
CU_TheoryDataPointsTypedef(suite, test) ; \
|
||||
\
|
||||
static struct CU_TheoryDataPointsTypeName(suite, test) \
|
||||
CU_TheoryDataPointsName(suite, test)
|
||||
|
||||
#define CU_DataPoints(type, ...) { \
|
||||
.p = (type[]) { __VA_ARGS__ }, \
|
||||
.n = (sizeof((type[]) { __VA_ARGS__ }) / sizeof(type)) \
|
||||
}
|
||||
|
||||
#define CU_Theory(signature, suite, test, ...) \
|
||||
static void CU_TestName(suite, test) signature; \
|
||||
\
|
||||
void CU_TestProxyName(suite, test)(void) { \
|
||||
cu_data_t data = CU_Fixture(__VA_ARGS__); \
|
||||
size_t i, n; \
|
||||
\
|
||||
if (data.init != NULL) { \
|
||||
data.init(); \
|
||||
} \
|
||||
\
|
||||
for (i = 0, n = CU_TheoryDataPointsSize(suite, test); i < n; i++) { \
|
||||
CU_TestName(suite, test) CU_TheoryDataPointsSlice(suite, test, i) ; \
|
||||
} \
|
||||
\
|
||||
if (data.fini != NULL) { \
|
||||
data.fini(); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
static void CU_TestName(suite, test) signature
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CUNIT_THEORY_H */
|
||||
|
||||
|
|
@ -1,243 +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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <sysexits.h>
|
||||
#else
|
||||
#define EX_USAGE (64)
|
||||
#define EX_SOFTWARE (70)
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#include <CUnit/Basic.h>
|
||||
#include <CUnit/Automated.h>
|
||||
#include "CUnit/Test.h"
|
||||
|
||||
static struct {
|
||||
bool print_help;
|
||||
bool automated;
|
||||
bool junit;
|
||||
const char *results;
|
||||
CU_BasicRunMode mode;
|
||||
CU_ErrorAction error_action;
|
||||
const char *suite;
|
||||
const char *test;
|
||||
} opts = {
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
NULL,
|
||||
CU_BRM_NORMAL,
|
||||
CUEA_IGNORE,
|
||||
"*",
|
||||
"*"
|
||||
};
|
||||
|
||||
static int patmatch(const char *pat, const char *str)
|
||||
{
|
||||
while (*pat) {
|
||||
if (*pat == '?') {
|
||||
/* any character will do */
|
||||
if (*str++ == 0) {
|
||||
return 0;
|
||||
}
|
||||
pat++;
|
||||
} else if (*pat == '*') {
|
||||
/* collapse a sequence of wildcards, requiring as many
|
||||
characters in str as there are ?s in the sequence */
|
||||
while (*pat == '*' || *pat == '?') {
|
||||
if (*pat == '?' && *str++ == 0) {
|
||||
return 0;
|
||||
}
|
||||
pat++;
|
||||
}
|
||||
/* try matching on all positions where str matches pat */
|
||||
while (*str) {
|
||||
if (*str == *pat && patmatch(pat+1, str+1)) {
|
||||
return 1;
|
||||
}
|
||||
str++;
|
||||
}
|
||||
return *pat == 0;
|
||||
} else {
|
||||
/* only an exact match */
|
||||
if (*str++ != *pat++) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return *str == 0;
|
||||
}
|
||||
|
||||
static void usage(const char *name)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s OPTIONS\n", name);
|
||||
fprintf(stderr, "Try '%s -h' for more information\n", name);
|
||||
}
|
||||
|
||||
static void help(const char *name)
|
||||
{
|
||||
printf("Usage: %s [OPTIONS]\n", name);
|
||||
printf("\n");
|
||||
printf("Possible options:\n");
|
||||
printf(" -a run in automated mode\n");
|
||||
printf(" -f fail fast\n");
|
||||
printf(" -h display this help and exit\n");
|
||||
printf(" -j junit format results \n");
|
||||
printf(" -r FILENAME results file for automated run\n");
|
||||
printf(" -s PATTERN run only tests in suites matching pattern\n");
|
||||
printf(" -t PATTERN run only test matching pattern\n");
|
||||
printf("\n");
|
||||
printf("Exit codes:\n");
|
||||
printf(" %-2d Successful termination\n", EXIT_SUCCESS);
|
||||
printf(" %-2d One or more failing test cases\n", EXIT_FAILURE);
|
||||
printf(" %-2d Command line usage error\n", EX_USAGE);
|
||||
printf(" %-2d Internal software error\n", EX_SOFTWARE);
|
||||
}
|
||||
|
||||
static int parse_options(int argc, char *argv[])
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
for (int i = 1; err == 0 && i < argc; i++) {
|
||||
switch ((argv[i][0] == '-') ? argv[i][1] : 0) {
|
||||
case 'a':
|
||||
opts.automated = true;
|
||||
break;
|
||||
case 'f':
|
||||
opts.error_action = CUEA_FAIL;
|
||||
break;
|
||||
case 'h':
|
||||
opts.print_help = true;
|
||||
break;
|
||||
case 'j':
|
||||
opts.junit = true;
|
||||
break;
|
||||
case 'r':
|
||||
if((i+1) < argc){
|
||||
opts.results = argv[++i];
|
||||
break;
|
||||
}
|
||||
/* FALLS THROUGH */
|
||||
case 's':
|
||||
if ((i+1) < argc) {
|
||||
opts.suite = argv[++i];
|
||||
break;
|
||||
}
|
||||
/* FALLS THROUGH */
|
||||
case 't':
|
||||
if ((i+1) < argc) {
|
||||
opts.test = argv[++i];
|
||||
break;
|
||||
}
|
||||
/* FALLS THROUGH */
|
||||
default:
|
||||
err = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static void
|
||||
add_suite(
|
||||
const char *suite,
|
||||
CU_InitializeFunc pInitFunc,
|
||||
CU_CleanupFunc pCleanFunc)
|
||||
{
|
||||
CU_pSuite pSuite;
|
||||
|
||||
pSuite = CU_get_suite(suite);
|
||||
if (pSuite == NULL) {
|
||||
pSuite = CU_add_suite(suite, pInitFunc, pCleanFunc);
|
||||
CU_set_suite_active(pSuite, patmatch(opts.suite, suite));
|
||||
}
|
||||
}
|
||||
|
||||
#define ADD_SUITE(suite, init, clean) \
|
||||
add_suite(#suite, init, clean)
|
||||
|
||||
static void
|
||||
add_test(
|
||||
const char *suite,
|
||||
const char *test,
|
||||
CU_TestFunc pTestFunc,
|
||||
bool enable)
|
||||
{
|
||||
CU_pSuite pSuite;
|
||||
CU_pTest pTest;
|
||||
|
||||
pSuite = CU_get_suite(suite);
|
||||
pTest = CU_add_test(pSuite, test, pTestFunc);
|
||||
CU_set_test_active(pTest, enable && patmatch(opts.test, test));
|
||||
}
|
||||
|
||||
#define ADD_TEST(suite, test, enable) \
|
||||
add_test(#suite, #test, CU_TestProxyName(suite, test), enable)
|
||||
|
||||
/* CMake will expand the macro below to declare generated functions. */
|
||||
@decls@
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int ret = EXIT_SUCCESS;
|
||||
|
||||
if (parse_options(argc, argv) != 0) {
|
||||
usage(argv[0]);
|
||||
return EX_USAGE;
|
||||
} else if (opts.print_help) {
|
||||
help(argv[0]);
|
||||
return ret;
|
||||
} else if (CU_initialize_registry() != CUE_SUCCESS) {
|
||||
fprintf(stderr, "CU_initialize_registry: %s\n", CU_get_error_msg());
|
||||
return EX_SOFTWARE;
|
||||
}
|
||||
|
||||
/* CMake will expand the macro below to register all suites and tests. */
|
||||
@defns@
|
||||
|
||||
CU_set_error_action(opts.error_action);
|
||||
|
||||
if (opts.automated) {
|
||||
if (opts.results != NULL) {
|
||||
CU_set_output_filename(opts.results);
|
||||
}
|
||||
|
||||
#if defined(HAVE_ENABLE_JUNIT_XML)
|
||||
if (opts.junit) {
|
||||
CU_automated_enable_junit_xml(CU_TRUE);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
CU_list_tests_to_file();
|
||||
}
|
||||
CU_automated_run_tests();
|
||||
} else {
|
||||
CU_basic_set_mode(opts.mode);
|
||||
CU_basic_run_tests();
|
||||
}
|
||||
|
||||
if (CU_get_error() != CUE_SUCCESS) {
|
||||
ret = EX_SOFTWARE;
|
||||
} else if (CU_get_number_of_failures() != 0) {
|
||||
ret = EXIT_FAILURE;
|
||||
}
|
||||
|
||||
CU_cleanup_registry();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -1,50 +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
|
||||
#
|
||||
if("${CMAKE_BUILD_TYPE}" STREQUAL "Coverage")
|
||||
set(BUILD_TYPE_SUPPORTED False)
|
||||
mark_as_advanced(BUILD_TYPE_SUPPORTED)
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(BUILD_TYPE_SUPPORTED True)
|
||||
elseif(("${CMAKE_C_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang") AND
|
||||
("${CMAKE_C_COMPILER_VERSION}" VERSION_GREATER "3.0.0"))
|
||||
set(BUILD_TYPE_SUPPORTED True)
|
||||
endif()
|
||||
|
||||
if(NOT BUILD_TYPE_SUPPORTED)
|
||||
message(FATAL_ERROR "Coverage build type not supported. (GCC or Clang "
|
||||
">3.0.0 required)")
|
||||
endif()
|
||||
|
||||
# NOTE: Since either GCC or Clang is required for now, and the coverage
|
||||
# flags are the same for both, there is no need for seperate branches
|
||||
# to set compiler flags. That might change in the future.
|
||||
|
||||
# CMake has per build type compiler and linker flags. If 'Coverage' is
|
||||
# chosen, the flags below are automatically inserted into CMAKE_C_FLAGS.
|
||||
#
|
||||
# Any optimizations are disabled to ensure coverage results are correct.
|
||||
# See https://gcc.gnu.org/onlinedocs/gcc/Gcov-and-Optimization.html.
|
||||
set(CMAKE_C_FLAGS_COVERAGE
|
||||
"-DNDEBUG -g -O0 --coverage -fprofile-arcs -ftest-coverage")
|
||||
set(CMAKE_CXX_FLAGS_COVERAGE
|
||||
"-DNDEBUG -g -O0 --coverage -fprofile-arcs -ftest-coverage")
|
||||
mark_as_advanced(
|
||||
CMAKE_C_FLAGS_COVERAGE
|
||||
CMAKE_CXX_FLAGS_COVERAGE
|
||||
CMAKE_EXE_LINKER_FLAGS_COVERAGE
|
||||
CMAKE_SHARED_LINKER_FLAGS_COVERAGE)
|
||||
|
||||
configure_file(${CMAKE_MODULE_PATH}/../CoverageSettings.cmake.in CoverageSettings.cmake @ONLY)
|
||||
|
||||
message(STATUS "Coverage build type available")
|
||||
endif()
|
||||
|
||||
|
|
@ -1,81 +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
|
||||
#
|
||||
set(CUNIT_HEADER "CUnit/CUnit.h")
|
||||
|
||||
find_path(CUNIT_INCLUDE_DIR ${CUNIT_HEADER})
|
||||
mark_as_advanced(CUNIT_INCLUDE_DIR)
|
||||
|
||||
if(CUNIT_INCLUDE_DIR AND EXISTS "${CUNIT_INCLUDE_DIR}/${CUNIT_HEADER}")
|
||||
set(PATTERN "^#define CU_VERSION \"([0-9]+)\\.([0-9]+)\\-([0-9]+)\"$")
|
||||
file(STRINGS "${CUNIT_INCLUDE_DIR}/${CUNIT_HEADER}" CUNIT_H REGEX "${PATTERN}")
|
||||
|
||||
string(REGEX REPLACE "${PATTERN}" "\\1" CUNIT_VERSION_MAJOR "${CUNIT_H}")
|
||||
string(REGEX REPLACE "${PATTERN}" "\\2" CUNIT_VERSION_MINOR "${CUNIT_H}")
|
||||
string(REGEX REPLACE "${PATTERN}" "\\3" CUNIT_VERSION_PATCH "${CUNIT_H}")
|
||||
|
||||
set(CUNIT_VERSION "${CUNIT_VERSION_MAJOR}.${CUNIT_VERSION_MINOR}-${CUNIT_VERSION_PATCH}")
|
||||
endif()
|
||||
|
||||
find_library(CUNIT_LIBRARY cunit)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(
|
||||
CUnit
|
||||
REQUIRED_VARS
|
||||
CUNIT_LIBRARY CUNIT_INCLUDE_DIR
|
||||
VERSION_VAR
|
||||
CUNIT_VERSION)
|
||||
|
||||
if(CUNIT_FOUND)
|
||||
set(CUNIT_INCLUDE_DIRS ${CUNIT_INCLUDE_DIR})
|
||||
set(CUNIT_LIBRARIES ${CUNIT_LIBRARY})
|
||||
|
||||
if(WIN32)
|
||||
get_filename_component(CUNIT_LIBRARY_DIR "${CUNIT_LIBRARY}}" PATH)
|
||||
get_filename_component(CUNIT_BASENAME "${CUNIT_LIBRARY}}" NAME_WE)
|
||||
get_filename_component(CUNIT_PREFIX "${CUNIT_LIBRARY_DIR}" PATH)
|
||||
|
||||
find_program(
|
||||
CUNIT_DLL
|
||||
"${CMAKE_SHARED_LIBRARY_PREFIX}${CUNIT_BASENAME}${CMAKE_SHARED_LIBRARY_SUFFIX}"
|
||||
HINTS
|
||||
${CUNIT_PREFIX}
|
||||
PATH_SUFFIXES
|
||||
bin
|
||||
NO_DEFAULT_PATH)
|
||||
mark_as_advanced(CUNIT_DLL)
|
||||
|
||||
# IMPORTANT:
|
||||
# Providing a .dll file as the value for IMPORTED_LOCATION can only be
|
||||
# done for "SHARED" libraries, otherwise the location of the .dll will be
|
||||
# passed to linker, causing it to fail.
|
||||
if(CUNIT_DLL)
|
||||
add_library(CUnit SHARED IMPORTED)
|
||||
set_target_properties(
|
||||
CUnit PROPERTIES IMPORTED_IMPLIB "${CUNIT_LIBRARY}")
|
||||
set_target_properties(
|
||||
CUnit PROPERTIES IMPORTED_LOCATION "${CUNIT_DLL}")
|
||||
else()
|
||||
add_library(CUnit STATIC IMPORTED)
|
||||
set_target_properties(
|
||||
CUnit PROPERTIES IMPORTED_LOCATION "${CUNIT_LIBRARY}")
|
||||
endif()
|
||||
else()
|
||||
add_library(CUnit UNKNOWN IMPORTED)
|
||||
set_target_properties(
|
||||
CUnit PROPERTIES IMPORTED_LOCATION "${CUNIT_LIBRARY}")
|
||||
endif()
|
||||
|
||||
set_target_properties(
|
||||
CUnit PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CUNIT_INCLUDE_DIR}")
|
||||
endif()
|
||||
|
||||
|
|
@ -1,83 +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
|
||||
#
|
||||
if(DEFINED ENV{M2})
|
||||
list(APPEND _mvn_hints "$ENV{M2}")
|
||||
endif()
|
||||
|
||||
if(DEFINED ENV{M2_HOME})
|
||||
list(APPEND _mvn_hints "$ENV{M2_HOME}/bin")
|
||||
endif()
|
||||
|
||||
# Chocolatey installs packages under C:\ProgramData\chocolatey.
|
||||
if(NOT "$ENV{ProgramData}" STREQUAL "")
|
||||
if(IS_DIRECTORY "$ENV{ProgramData}/chocolatey/bin")
|
||||
list(APPEND _mvn_paths "$ENV{ProgramData}/chocolatey/bin")
|
||||
endif()
|
||||
if(IS_DIRECTORY "$ENV{ProgramData}/chocolatey/bin")
|
||||
list(APPEND _dirs "$ENV{ProgramData}/chocolatey/lib/maven")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Maven documentation mentions intalling maven under C:\Program Files on
|
||||
# Windows and under /opt on *NIX platforms.
|
||||
if(WIN32)
|
||||
foreach(_env "ProgramFiles" "ProgramFiles(x86)")
|
||||
if(ENV{${_env}} AND IS_DIRECTORY "$ENV{${_env}}")
|
||||
list(APPEND _dirs "$ENV{${_env}}")
|
||||
endif()
|
||||
endforeach()
|
||||
else()
|
||||
list(APPEND _dirs "/opt")
|
||||
endif()
|
||||
|
||||
foreach(_dir ${_dirs})
|
||||
file(GLOB _mvn_dirs "${_dir}/apache-maven-*")
|
||||
foreach(_mvn_dir ${_mvn_dirs})
|
||||
if((IS_DIRECTORY "${_mvn_dir}") AND (IS_DIRECTORY "${_mvn_dir}/bin"))
|
||||
list(APPEND _mvn_paths "${_mvn_dir}/bin")
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
if(WIN32)
|
||||
set(_mvn_names "mvn.cmd" "mvn.exe")
|
||||
else()
|
||||
set(_mvn_names "mvn")
|
||||
endif()
|
||||
|
||||
find_program(Maven_EXECUTABLE
|
||||
NAMES ${_mvn_names}
|
||||
HINTS ${_mvn_hints}
|
||||
PATHS ${_mvn_paths})
|
||||
|
||||
if(Maven_EXECUTABLE)
|
||||
execute_process(COMMAND ${Maven_EXECUTABLE} -version
|
||||
RESULT_VARIABLE res
|
||||
OUTPUT_VARIABLE var
|
||||
ERROR_VARIABLE var
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT res)
|
||||
if(var MATCHES "Apache Maven ([0-9]+)\\.([0-9]+)\\.([0-9]+)")
|
||||
set(Maven_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Maven
|
||||
FOUND_VAR Maven_FOUND
|
||||
VERSION_VAR Maven_VERSION
|
||||
REQUIRED_VARS Maven_EXECUTABLE Maven_VERSION)
|
||||
|
||||
mark_as_advanced(Maven_FOUND Maven_EXECUTABLE Maven_VERSION)
|
||||
|
||||
|
|
@ -1,34 +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
|
||||
#
|
||||
if(TARGET CONAN_PKG::OpenSSL)
|
||||
add_library(OpenSSL::SSL INTERFACE IMPORTED)
|
||||
target_link_libraries(OpenSSL::SSL INTERFACE CONAN_PKG::OpenSSL)
|
||||
set(OPENSSL_FOUND TRUE)
|
||||
else()
|
||||
# Loop over a list of possible module paths (without the current directory).
|
||||
get_filename_component(DIR "${CMAKE_CURRENT_LIST_DIR}" ABSOLUTE)
|
||||
|
||||
foreach(MODULE_DIR ${CMAKE_MODULE_PATH} ${CMAKE_ROOT}/Modules)
|
||||
get_filename_component(MODULE_DIR "${MODULE_DIR}" ABSOLUTE)
|
||||
if(NOT MODULE_DIR STREQUAL DIR)
|
||||
if(EXISTS "${MODULE_DIR}/FindOpenSSL.cmake")
|
||||
set(FIND_PACKAGE_FILE "${MODULE_DIR}/FindOpenSSL.cmake")
|
||||
break()
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(FIND_PACKAGE_FILE)
|
||||
include("${FIND_PACKAGE_FILE}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
@ -1,38 +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
|
||||
#
|
||||
function(glob variable extension)
|
||||
set(dirname "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
foreach(filename ${ARGN})
|
||||
unset(filenames)
|
||||
|
||||
if((NOT IS_ABSOLUTE "${filename}") AND
|
||||
(EXISTS "${dirname}/${filename}"))
|
||||
set(filename "${dirname}/${filename}")
|
||||
endif()
|
||||
|
||||
if(IS_DIRECTORY "${filename}")
|
||||
file(GLOB_RECURSE filenames "${filename}/*.${extension}")
|
||||
elseif(EXISTS "${filename}")
|
||||
if("${filename}" MATCHES "\.${extension}$")
|
||||
set(filenames "${filename}")
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "File ${filename} does not exist")
|
||||
endif()
|
||||
|
||||
list(APPEND files ${filenames})
|
||||
endforeach()
|
||||
|
||||
set(${variable} "${files}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
|
|
@ -1,170 +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
|
||||
#
|
||||
if(PACKAGING_INCLUDED)
|
||||
return()
|
||||
endif()
|
||||
set(PACKAGING_INCLUDED true)
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
set(PACKAGING_MODULE_DIR "${PROJECT_SOURCE_DIR}/cmake/modules/Packaging")
|
||||
set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJECT_NAME}")
|
||||
|
||||
# Generates <Package>Config.cmake.
|
||||
configure_package_config_file(
|
||||
"${PACKAGING_MODULE_DIR}/PackageConfig.cmake.in"
|
||||
"${CMAKE_PROJECT_NAME}Config.cmake"
|
||||
INSTALL_DESTINATION "${CMAKE_INSTALL_CMAKEDIR}")
|
||||
|
||||
# Generates <Package>Version.cmake.
|
||||
write_basic_package_version_file(
|
||||
"${CMAKE_PROJECT_NAME}Version.cmake"
|
||||
VERSION ${PROJECT_VERSION}
|
||||
COMPATIBILITY SameMajorVersion)
|
||||
|
||||
install(
|
||||
FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Version.cmake"
|
||||
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}" COMPONENT dev)
|
||||
|
||||
if(DDSC_SHARED AND ((NOT DEFINED BUILD_SHARED_LIBS) OR BUILD_SHARED_LIBS))
|
||||
# Generates <Package>Targets.cmake file included by <Package>Config.cmake.
|
||||
# The files are placed in CMakeFiles/Export in the build tree.
|
||||
install(
|
||||
EXPORT "${CMAKE_PROJECT_NAME}"
|
||||
FILE "${CMAKE_PROJECT_NAME}Targets.cmake"
|
||||
NAMESPACE "${CMAKE_PROJECT_NAME}::"
|
||||
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}" COMPONENT dev)
|
||||
endif()
|
||||
|
||||
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
|
||||
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
|
||||
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
|
||||
set(CPACK_PACKAGE_VERSION_TWEAK ${PROJECT_VERSION_TWEAK})
|
||||
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
|
||||
|
||||
set(VENDOR_INSTALL_ROOT "ADLINK")
|
||||
set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
|
||||
set(CPACK_PACKAGE_VENDOR "ADLINK Technology Inc.")
|
||||
set(CPACK_PACKAGE_CONTACT "${CMAKE_PROJECT_NAME} core developers <info@adlinktech.com>")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Leading OMG DDS implementation from ADLINK Technology")
|
||||
set(CPACK_PACKAGE_ICON "${PACKAGING_MODULE_DIR}/vortex.ico")
|
||||
|
||||
# WiX requires a .txt file extension for CPACK_RESOURCE_FILE_LICENSE
|
||||
file(COPY "${PROJECT_SOURCE_DIR}/../LICENSE" DESTINATION "${CMAKE_BINARY_DIR}")
|
||||
file(RENAME "${CMAKE_BINARY_DIR}/LICENSE" "${CMAKE_BINARY_DIR}/license.txt")
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_BINARY_DIR}/license.txt")
|
||||
|
||||
# Packages could be generated on alien systems. e.g. Debian packages could be
|
||||
# created on Red Hat Enterprise Linux, but since packages also need to be
|
||||
# verified on the target platform, please refrain from doing so. Another
|
||||
# reason for building installer packages on the target platform is to ensure
|
||||
# the binaries are linked to the libc version shipped with that platform. To
|
||||
# support "generic" Linux distributions, eventually compressed tarballs will
|
||||
# be shipped.
|
||||
#
|
||||
# NOTE: Settings for different platforms are in separate control branches.
|
||||
# Although that does not make sense from a technical point-of-view, it
|
||||
# does help to clearify which settings are required for a platform.
|
||||
|
||||
set(CPACK_COMPONENTS_ALL dev lib)
|
||||
set(CPACK_COMPONENT_LIB_DISPLAY_NAME "${CMAKE_PROJECT_NAME_FULL} library")
|
||||
set(CPACK_COMPONENT_LIB_DESCRIPTION "Library used to run programs with ${CMAKE_PROJECT_NAME_FULL}")
|
||||
set(CPACK_COMPONENT_DEV_DISPLAY_NAME "${CMAKE_PROJECT_NAME_FULL} development")
|
||||
set(CPACK_COMPONENT_DEV_DESCRIPTION "Development files for use with ${CMAKE_PROJECT_NAME_FULL}")
|
||||
|
||||
if(WIN32 AND NOT UNIX)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(__arch "win64")
|
||||
else()
|
||||
set(__arch "win32")
|
||||
endif()
|
||||
mark_as_advanced(__arch)
|
||||
|
||||
set(CPACK_GENERATOR "WIX;ZIP;${CPACK_GENERATOR}" CACHE STRING "List of package generators")
|
||||
|
||||
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION}-${__arch}")
|
||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${VENDOR_INSTALL_ROOT}/${CMAKE_PROJECT_NAME_FULL}")
|
||||
|
||||
set(CPACK_WIX_LIGHT_EXTENSIONS "WixUtilExtension")
|
||||
set(CPACK_WIX_COMPONENT_INSTALL ON)
|
||||
set(CPACK_WIX_ROOT_FEATURE_TITLE "${CMAKE_PROJECT_NAME_FULL}")
|
||||
set(CPACK_WIX_PRODUCT_ICON "${PACKAGING_MODULE_DIR}/vortex.ico")
|
||||
# Bitmap (.bmp) of size 493x58px
|
||||
set(CPACK_WIX_UI_BANNER "${PACKAGING_MODULE_DIR}/banner.bmp")
|
||||
# Bitmap (.bmp) of size 493x312px
|
||||
set(CPACK_WIX_UI_DIALOG "${PACKAGING_MODULE_DIR}/dialog.png")
|
||||
set(CPACK_WIX_PROGRAM_MENU_FOLDER "${CPACK_PACKAGE_NAME_FULL}")
|
||||
set(CPACK_WIX_PATCH_FILE "${PACKAGING_MODULE_DIR}/examples.xml")
|
||||
set(CPACK_WIX_PROPERTY_ARPHELPLINK "http://www.adlinktech.com/support")
|
||||
set(CPACK_WIX_PROPERTY_ARPURLINFOABOUT "http://www.adlinktech.com/")
|
||||
set(CPACK_WIX_PROPERTY_ARPURLUPDATEINFO "http://www.adlinktech.com/")
|
||||
|
||||
# A constant GUID allows installers to replace existing installations that use the same GUID.
|
||||
set(CPACK_WIX_UPGRADE_GUID "1351F59A-972B-4624-A7F1-439381BFA41D")
|
||||
|
||||
include(InstallRequiredSystemLibraries)
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
# CMake prior to v3.6 messes up the name of the packages. >= v3.6 understands CPACK_RPM/DEBIAN_<component>_FILE_NAME
|
||||
cmake_minimum_required(VERSION 3.6)
|
||||
|
||||
set(CPACK_COMPONENTS_GROUPING "IGNORE")
|
||||
|
||||
# FIXME: Requiring lsb_release to be installed may be a viable option.
|
||||
|
||||
if(EXISTS "/etc/redhat-release")
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(__arch "x86_64")
|
||||
else()
|
||||
set(__arch "i686")
|
||||
endif()
|
||||
|
||||
set(CPACK_GENERATOR "RPM;TGZ;${CPACK_GENERATOR}" CACHE STRING "List of package generators")
|
||||
|
||||
set(CPACK_RPM_COMPONENT_INSTALL ON)
|
||||
# FIXME: The package file name must be updated to include the distribution.
|
||||
# See Fedora and Red Hat packaging guidelines for details.
|
||||
set(CPACK_RPM_LIB_PACKAGE_NAME "${CMAKE_PROJECT_NAME_DASHED}")
|
||||
set(CPACK_RPM_LIB_FILE_NAME "${CPACK_RPM_LIB_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${__arch}.rpm")
|
||||
set(CPACK_RPM_DEV_PACKAGE_NAME "${CPACK_RPM_LIB_PACKAGE_NAME}-devel")
|
||||
set(CPACK_RPM_DEV_FILE_NAME "${CPACK_RPM_DEV_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${__arch}.rpm")
|
||||
set(CPACK_RPM_DEV_PACKAGE_REQUIRES "${CPACK_RPM_LIB_PACKAGE_NAME} = ${CPACK_PACKAGE_VERSION}")
|
||||
elseif(EXISTS "/etc/debian_version")
|
||||
set(CPACK_DEB_COMPONENT_INSTALL ON)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(__arch "amd64")
|
||||
else()
|
||||
set(__arch "i386")
|
||||
endif()
|
||||
|
||||
set(CPACK_GENERATOR "DEB;TGZ;${CPACK_GENERATOR}" CACHE STRING "List of package generators")
|
||||
|
||||
string(TOLOWER "${CMAKE_PROJECT_NAME_DASHED}" CPACK_DEBIAN_LIB_PACKAGE_NAME)
|
||||
set(CPACK_DEBIAN_LIB_FILE_NAME "${CPACK_DEBIAN_LIB_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${__arch}.deb")
|
||||
set(CPACK_DEBIAN_DEV_PACKAGE_DEPENDS "${CPACK_DEBIAN_LIB_PACKAGE_NAME} (= ${CPACK_PACKAGE_VERSION}), libc6 (>= 2.23)")
|
||||
set(CPACK_DEBIAN_DEV_PACKAGE_NAME "${CPACK_DEBIAN_LIB_PACKAGE_NAME}-dev")
|
||||
set(CPACK_DEBIAN_DEV_FILE_NAME "${CPACK_DEBIAN_DEV_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${__arch}.deb")
|
||||
else()
|
||||
# Generic tgz package
|
||||
set(CPACK_GENERATOR "TGZ;${CPACK_GENERATOR}" CACHE STRING "List of package generators")
|
||||
endif()
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "VxWorks")
|
||||
# FIXME: Support for VxWorks packages must still be implemented (probably
|
||||
# just a compressed tarball)
|
||||
message(STATUS "Packaging for VxWorks is unsupported")
|
||||
endif()
|
||||
|
||||
# This must always be last!
|
||||
include(CPack)
|
||||
|
||||
|
|
@ -1,16 +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
|
||||
#
|
||||
@PACKAGE_INIT@
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@CMAKE_PROJECT_NAME@Targets.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/idlc/IdlcGenerate.cmake")
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 84 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 20 KiB |
|
|
@ -1,228 +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
|
||||
-->
|
||||
<!--
|
||||
Installing the Hello World! example at the USERPROFILE directory.
|
||||
-->
|
||||
|
||||
<CPackWiXPatch>
|
||||
<CPackWiXFragment Id="#PRODUCT">
|
||||
|
||||
<DirectoryRef Id="TARGETDIR">
|
||||
<Directory Id="PersonalFolder">
|
||||
<Directory Id="CYCLONEUSERDIR" Name="Cyclone DDS">
|
||||
<Directory Id="CM_DP_dev.usr.CycloneDDS.examples" Name="examples">
|
||||
<Directory Id="CM_DP_dev.usr.CycloneDDS.examples.helloworld" Name="helloworld">
|
||||
<Directory Id="CM_DP_dev.usr.CycloneDDS.examples.helloworld.vs" Name="vs"/>
|
||||
<Directory Id="CM_DP_dev.usr.CycloneDDS.examples.helloworld.generated" Name="generated"/>
|
||||
</Directory>
|
||||
<Directory Id="CM_DP_dev.usr.CycloneDDS.examples.roundtrip" Name="roundtrip" />
|
||||
<Directory Id="CM_DP_dev.usr.CycloneDDS.examples.throughput" Name="throughput" />
|
||||
</Directory>
|
||||
</Directory>
|
||||
</Directory>
|
||||
</DirectoryRef>
|
||||
|
||||
<Feature Id="UserWritableExampleFeature" Display="expand" Absent="disallow" ConfigurableDirectory="CYCLONEUSERDIR" Title="Cyclone DDS Examples" Description="Example code to getting started with DDS development." Level="1">
|
||||
<Feature Id="CM_C_usr" Title="Cyclone DDS Development Examples" Description="Example Development files for use with Cyclone DDS. Typically installed in the users 'Document' directory.">
|
||||
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.Launcher.ApplicationShortcut" />
|
||||
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.environment" />
|
||||
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.cmake.prefix.path" />
|
||||
<!-- helloworld -->
|
||||
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.remove" />
|
||||
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldData.idl" />
|
||||
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldData.sln" />
|
||||
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldPublisher.vcxproj" />
|
||||
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldSubscriber.vcxproj" />
|
||||
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldType.vcxproj" />
|
||||
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldData.c" />
|
||||
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldData.h" />
|
||||
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.directories.props" />
|
||||
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.publisher.c" />
|
||||
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.subscriber.c" />
|
||||
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.CMakeLists.txt" />
|
||||
<!-- roundtrip -->
|
||||
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.RoundTrip.idl" />
|
||||
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.ping.c" />
|
||||
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.pong.c" />
|
||||
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.CMakeLists.txt" />
|
||||
<!-- throughput -->
|
||||
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.throughput.Throughput.idl" />
|
||||
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.throughput.publisher.c" />
|
||||
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.throughput.subscriber.c" />
|
||||
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.throughput.CMakeLists.txt" />
|
||||
</Feature>
|
||||
</Feature>
|
||||
|
||||
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.remove" Directory="CYCLONEUSERDIR" Guid="">
|
||||
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="Remove.CM_CP_dev.usr.CycloneDDS.examples" Value="Remove.CM_CP_dev.usr.CycloneDDS.examples" KeyPath="yes" />
|
||||
|
||||
<!-- helloworld -->
|
||||
<RemoveFolder Id="Remove.CM_DP_dev.usr.CycloneDDS.examples.helloworld.vs" Directory="CM_DP_dev.usr.CycloneDDS.examples.helloworld.vs" On="uninstall"/>
|
||||
<RemoveFolder Id="Remove.CM_DP_dev.usr.CycloneDDS.examples.helloworld.generated" Directory="CM_DP_dev.usr.CycloneDDS.examples.helloworld.generated" On="uninstall"/>
|
||||
<RemoveFolder Id="Remove.CM_DP_dev.usr.CycloneDDS.examples.helloworld" Directory="CM_DP_dev.usr.CycloneDDS.examples.helloworld" On="uninstall"/>
|
||||
<!-- roundtrip -->
|
||||
<RemoveFolder Id="Remove.CM_DP_dev.usr.CycloneDDS.examples.roundtrip" Directory="CM_DP_dev.usr.CycloneDDS.examples.roundtrip" On="uninstall"/>
|
||||
<!-- throughput -->
|
||||
<RemoveFolder Id="Remove.CM_DP_dev.usr.CycloneDDS.examples.throughput" Directory="CM_DP_dev.usr.CycloneDDS.examples.throughput" On="uninstall"/>
|
||||
|
||||
<RemoveFolder Id="Remove.CM_DP_dev.usr.CycloneDDS.examples" Directory="CM_DP_dev.usr.CycloneDDS.examples" On="uninstall"/>
|
||||
<RemoveFolder Id="Remove.CM_DP_dev.usr.CycloneDDS" Directory="CYCLONEUSERDIR" On="uninstall"/>
|
||||
</Component>
|
||||
|
||||
<!-- Hello World - files -->
|
||||
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldData.idl" Directory="CM_DP_dev.usr.CycloneDDS.examples.helloworld" Guid="">
|
||||
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_FP_usr.usr.CycloneDDS.examples.helloworld.HelloWorldData.idl" Value="CM_FP_usr.usr.CycloneDDS.examples.helloworld.HelloWorldData.idl" KeyPath="yes" />
|
||||
<File Id="CM_FP_usr.usr.CycloneDDS.examples.helloworld.HelloWorldData.idl" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/helloworld/HelloWorldData.idl" KeyPath="no"/>
|
||||
</Component>
|
||||
|
||||
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldData.sln" Directory="CM_DP_dev.usr.CycloneDDS.examples.helloworld" Guid="">
|
||||
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_FP_usr.usr.CycloneDDS.examples.helloworld.HelloWorld.sln" Value="CM_FP_usr.usr.CycloneDDS.examples.helloworld.HelloWorld.sln" KeyPath="yes" />
|
||||
<File Id="CM_FP_usr.usr.CycloneDDS.examples.helloworld.HelloWorld.sln" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/helloworld/HelloWorld.sln" KeyPath="no"/>
|
||||
</Component>
|
||||
|
||||
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldPublisher.vcxproj" Directory="CM_DP_dev.usr.CycloneDDS.examples.helloworld.vs" Guid="">
|
||||
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldPublisher.vcxproj" Value="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldPublisher.vcxproj" KeyPath="yes" />
|
||||
<File Id="CM_FP_usr.usr.CycloneDDS.examples.helloworld.HelloWorldPublisher.vcxproj" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/helloworld/vs/HelloWorldPublisher.vcxproj" KeyPath="no"/>
|
||||
</Component>
|
||||
|
||||
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldSubscriber.vcxproj" Directory="CM_DP_dev.usr.CycloneDDS.examples.helloworld.vs" Guid="">
|
||||
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldSubscriber.vcxproj" Value="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldSubscriber.vcxproj" KeyPath="yes" />
|
||||
<File Id="CM_FP_usr.usr.CycloneDDS.examples.helloworld.HelloWorldSubscriber.vcxproj" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/helloworld/vs/HelloWorldSubscriber.vcxproj" KeyPath="no"/>
|
||||
</Component>
|
||||
|
||||
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldType.vcxproj" Directory="CM_DP_dev.usr.CycloneDDS.examples.helloworld.vs" Guid="">
|
||||
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldType.vcxproj" Value="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldType.vcxproj" KeyPath="yes" />
|
||||
<File Id="CM_FP_usr.usr.CycloneDDS.examples.helloworld.HelloWorldType.vcxproj" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/helloworld/vs/HelloWorldType.vcxproj" KeyPath="no"/>
|
||||
</Component>
|
||||
|
||||
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.directories.props" Directory="CM_DP_dev.usr.CycloneDDS.examples.helloworld.vs" Guid="">
|
||||
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.helloworld.directories.props" Value="CM_CP_dev.usr.CycloneDDS.examples.helloworld.directories.props" KeyPath="yes" />
|
||||
<File Id="CM_FP_usr.usr.CycloneDDS.examples.helloworld.directories.props" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/helloworld/vs/directories.props" KeyPath="no"/>
|
||||
</Component>
|
||||
|
||||
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldData.c" Directory="CM_DP_dev.usr.CycloneDDS.examples.helloworld.generated" Guid="">
|
||||
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldData.c" Value="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldData.c" KeyPath="yes" />
|
||||
<File Id="CM_FP_usr.usr.CycloneDDS.examples.helloworld.HelloWorldData.c" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/helloworld/generated/HelloWorldData.c" KeyPath="no"/>
|
||||
</Component>
|
||||
|
||||
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldData.h" Directory="CM_DP_dev.usr.CycloneDDS.examples.helloworld.generated" Guid="">
|
||||
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldData.h" Value="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldData.h" KeyPath="yes" />
|
||||
<File Id="CM_FP_usr.usr.CycloneDDS.examples.helloworld.HelloWorldData.h" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/helloworld/generated/HelloWorldData.h" KeyPath="no"/>
|
||||
</Component>
|
||||
|
||||
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.publisher.c" Directory="CM_DP_dev.usr.CycloneDDS.examples.helloworld" Guid="">
|
||||
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.helloworld.publisher.c" Value="CM_CP_dev.usr.CycloneDDS.examples.helloworld.publisher.c" KeyPath="yes" />
|
||||
<File Id="CM_FP_usr.usr.CycloneDDS.examples.helloworld.publisher.c" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/helloworld/publisher.c" KeyPath="no"/>
|
||||
</Component>
|
||||
|
||||
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.subscriber.c" Directory="CM_DP_dev.usr.CycloneDDS.examples.helloworld" Guid="">
|
||||
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.helloworld.subscriber.c" Value="CM_CP_dev.usr.CycloneDDS.examples.helloworld.subscriber.c" KeyPath="yes" />
|
||||
<File Id="CM_FP_usr.usr.CycloneDDS.examples.helloworld.subscriber.c" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/helloworld/subscriber.c" KeyPath="no"/>
|
||||
</Component>
|
||||
|
||||
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.CMakeLists.txt" Directory="CM_DP_dev.usr.CycloneDDS.examples.helloworld" Guid="">
|
||||
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.helloworld.CMakeLists.txt" Value="CM_CP_dev.usr.CycloneDDS.examples.helloworld.CMakeLists.txt" KeyPath="yes" />
|
||||
<File Id="CM_FP_usr.usr.CycloneDDS.examples.helloworld.CMakeLists.txt" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/helloworld/CMakeLists.txt" KeyPath="no"/>
|
||||
</Component>
|
||||
|
||||
<!-- RoundTrip - files -->
|
||||
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.CMakeLists.txt" Directory="CM_DP_dev.usr.CycloneDDS.examples.roundtrip" Guid="">
|
||||
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.CMakeLists.txt" Value="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.CMakeLists.txt" KeyPath="yes" />
|
||||
<File Id="CM_FP_usr.usr.CycloneDDS.examples.roundtrip.CMakeLists.txt" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/roundtrip/CMakeLists.txt" KeyPath="no"/>
|
||||
</Component>
|
||||
|
||||
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.RoundTrip.idl" Directory="CM_DP_dev.usr.CycloneDDS.examples.roundtrip" Guid="">
|
||||
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.RoundTrip.idl" Value="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.RoundTrip.idl" KeyPath="yes" />
|
||||
<File Id="CM_FP_usr.usr.CycloneDDS.examples.roundtrip.RoundTrip.idl" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/roundtrip/RoundTrip.idl" KeyPath="no"/>
|
||||
</Component>
|
||||
|
||||
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.ping.c" Directory="CM_DP_dev.usr.CycloneDDS.examples.roundtrip" Guid="">
|
||||
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.ping.c" Value="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.ping.c" KeyPath="yes" />
|
||||
<File Id="CM_FP_usr.usr.CycloneDDS.examples.roundtrip.ping.c" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/roundtrip/ping.c" KeyPath="no"/>
|
||||
</Component>
|
||||
|
||||
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.pong.c" Directory="CM_DP_dev.usr.CycloneDDS.examples.roundtrip" Guid="">
|
||||
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.pong.c" Value="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.pong.c" KeyPath="yes" />
|
||||
<File Id="CM_FP_usr.usr.CycloneDDS.examples.roundtrip.pong.c" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/roundtrip/pong.c" KeyPath="no"/>
|
||||
</Component>
|
||||
|
||||
<!-- Throughput - files -->
|
||||
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.throughput.CMakeLists.txt" Directory="CM_DP_dev.usr.CycloneDDS.examples.throughput" Guid="">
|
||||
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.throughput.CMakeLists.txt" Value="CM_CP_dev.usr.CycloneDDS.examples.throughput.CMakeLists.txt" KeyPath="yes" />
|
||||
<File Id="CM_FP_usr.usr.CycloneDDS.examples.throughput.CMakeLists.txt" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/throughput/CMakeLists.txt" KeyPath="no"/>
|
||||
</Component>
|
||||
|
||||
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.throughput.Throughput.idl" Directory="CM_DP_dev.usr.CycloneDDS.examples.throughput" Guid="">
|
||||
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.throughput.Throughput.idl" Value="CM_CP_dev.usr.CycloneDDS.examples.throughput.Throughput.idl" KeyPath="yes" />
|
||||
<File Id="CM_FP_usr.usr.CycloneDDS.examples.throughput.Throughput.idl" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/throughput/Throughput.idl" KeyPath="no"/>
|
||||
</Component>
|
||||
|
||||
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.throughput.publisher.c" Directory="CM_DP_dev.usr.CycloneDDS.examples.throughput" Guid="">
|
||||
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.throughput.publisher.c" Value="CM_CP_dev.usr.CycloneDDS.examples.throughput.publisher.c" KeyPath="yes" />
|
||||
<File Id="CM_FP_usr.usr.CycloneDDS.examples.throughput.publisher.c" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/throughput/publisher.c" KeyPath="no"/>
|
||||
</Component>
|
||||
|
||||
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.throughput.subscriber.c" Directory="CM_DP_dev.usr.CycloneDDS.examples.throughput" Guid="">
|
||||
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.throughput.subscriber.c" Value="CM_CP_dev.usr.CycloneDDS.examples.throughput.subscriber.c" KeyPath="yes" />
|
||||
<File Id="CM_FP_usr.usr.CycloneDDS.examples.throughput.subscriber.c" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/throughput/subscriber.c" KeyPath="no"/>
|
||||
</Component>
|
||||
|
||||
<!-- Add the location of the ddsc.dll to the system path -->
|
||||
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.environment" Directory="CYCLONEUSERDIR" Guid="">
|
||||
<!-- CreateFolder and RegistryValue are needed to keep Wix happy -->
|
||||
<CreateFolder Directory="CYCLONEUSERDIR"/>
|
||||
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.environment" Value="CM_CP_dev.usr.CycloneDDS.environment" KeyPath="yes" />
|
||||
<Environment Action="set" Id="CycloneDDSPath" Name="PATH" Part="last" Permanent="yes" System="yes" Value="[INSTALL_ROOT]bin"/>
|
||||
</Component>
|
||||
|
||||
<Component Id="CM_CP_dev.usr.CycloneDDS.cmake.prefix.path" Directory="CYCLONEUSERDIR" Guid="">
|
||||
<!-- CreateFolder and RegistryValue are needed to keep Wix happy -->
|
||||
<CreateFolder Directory="CYCLONEUSERDIR"/>
|
||||
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.cmake.prefix.path" Value="CM_CP_dev.usr.CycloneDDS.cmake.prefix.path" KeyPath="yes" />
|
||||
<Environment Action="set" Id="CMakePrefixPath" Name="CMAKE_PREFIX_PATH" Permanent="no" Value="[INSTALL_ROOT]share/CycloneDDS"/>
|
||||
</Component>
|
||||
|
||||
<!-- Offer the user the ability the start the launcher -->
|
||||
<Property Id="WIXUI_EXITDIALOGOPTIONALTEXT" Value="After clicking Finish, the Vortex DDS Launcher will start (if indicated below). The Vortex DDS Laucher will help to get started with Cyclone DDS." />
|
||||
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOX" Value="1"/>
|
||||
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Start the Vortex DDS Launcher" />
|
||||
<Property Id="WixShellExecTarget" Value="[INSTALL_ROOT]/bin/vortexddslauncher.exe" />
|
||||
<CustomAction Id="CM_CA_dev.user.CycloneDDS.Launcher.Launch" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
|
||||
|
||||
<UI>
|
||||
<UIRef Id="$(var.CPACK_WIX_UI_REF)" />
|
||||
<Publish Dialog="ExitDialog" Control="Finish" Event="DoAction" Value="CM_CA_dev.user.CycloneDDS.Launcher.Launch">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
|
||||
</UI>
|
||||
|
||||
<!-- Create start-menu -->
|
||||
<DirectoryRef Id="TARGETDIR">
|
||||
<Directory Id="ProgramMenuFolder">
|
||||
<Directory Id="ApplicationProgramsFolder" Name="Cyclone DDS"/>
|
||||
</Directory>
|
||||
</DirectoryRef>
|
||||
<DirectoryRef Id="ApplicationProgramsFolder">
|
||||
<Component Id="CM_CP_dev.usr.CycloneDDS.Launcher.ApplicationShortcut" Guid="C21831A3-FBCE-44D0-A098-A1F21FD4846F">
|
||||
<Shortcut Id="ApplicationStartMenuShortcut"
|
||||
Name="CycloneDDS Launcher"
|
||||
Directory="ApplicationProgramsFolder"
|
||||
Description="My Application Description"
|
||||
Target="[INSTALL_ROOT]/bin/vortexddslauncher.exe"
|
||||
Icon="ShortcutIcon"
|
||||
IconIndex="0">
|
||||
<Icon Id="ShortcutIcon" SourceFile="$(var.CPACK_WIX_PRODUCT_ICON)" />
|
||||
</Shortcut>
|
||||
<RemoveFolder Id="CleanUpShortCut" Directory="ApplicationProgramsFolder" On="uninstall"/>
|
||||
<RegistryValue Root="HKCU" Key="Software\AdLink" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
|
||||
</Component>
|
||||
</DirectoryRef>
|
||||
</CPackWiXFragment>
|
||||
</CPackWiXPatch>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 30 KiB |
|
|
@ -1,213 +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
|
||||
#
|
||||
|
||||
#
|
||||
# CMake Platform file for VxWorks
|
||||
#
|
||||
# This file will be used as platform file if CMAKE_SYSTEM_NAME is defined
|
||||
# as VxWorks in the toolchain file.
|
||||
#
|
||||
# Most information is resolved by analyzing the absolute location of the
|
||||
# compiler on the file system, but can be overridden if required.
|
||||
#
|
||||
# Setting CMAKE_SYSTEM_PROCESSOR is mandatory. The variable should be set to
|
||||
# e.g. ARMARCH* if the target architecture is arm.
|
||||
#
|
||||
# NOTES:
|
||||
# * For now support for VxWorks Diab compiler will NOT be implemented.
|
||||
# * If certain settings are not explicitly defined, this platform file will
|
||||
# try to deduce it from the installation path. It will, however, not go out
|
||||
# of it's way to validate and cross-reference settings.
|
||||
#
|
||||
# https://cmake.org/Wiki/CMake_Cross_Compiling
|
||||
#
|
||||
|
||||
if((NOT "${CMAKE_GENERATOR}" MATCHES "Makefiles") AND
|
||||
(NOT "${CMAKE_GENERATOR}" MATCHES "Ninja"))
|
||||
message(FATAL_ERROR "Cross compilation for VxWorks is not supported for "
|
||||
"${CMAKE_GENERATOR}")
|
||||
endif()
|
||||
|
||||
set(WIND_PROCESSOR_TYPE_PATTERN ".*(cc|c\\+\\+)(arm|mips|pentium|ppc).*")
|
||||
set(WIND_HOST_TYPE_PATTERN "^x86-(linux2|win32)$")
|
||||
set(WIND_PLATFORM_PATTERN "^[0-9\.]+-vxworks-([0-9\.]+)$")
|
||||
|
||||
# Try to deduce the system architecture from either CMAKE_C_COMPILER or
|
||||
# CMAKE_CXX_COMPILER (one of which must be specified).
|
||||
#
|
||||
# Path examples:
|
||||
# <WindRiver>/gnu/4.3.3-vxworks-6.9/x86-linux2/bin
|
||||
# <WindRiver>/gnu/4.1.2-vxworks-6.8/x86-win32/bin
|
||||
foreach(COMPILER CMAKE_C_COMPILER CMAKE_CXX_COMPILER)
|
||||
if("${${COMPILER}}" MATCHES "${WIND_PROCESSOR_TYPE_PATTERN}")
|
||||
string(
|
||||
REGEX REPLACE
|
||||
"${WIND_PROCESSOR_TYPE_PATTERN}" "\\2"
|
||||
PROCESSOR_TYPE
|
||||
${${COMPILER}})
|
||||
if(NOT WIND_PROCESSOR_TYPE)
|
||||
set(WIND_PROCESSOR_TYPE ${PROCESSOR_TYPE})
|
||||
endif()
|
||||
|
||||
get_filename_component(COMPILER_NAME "${${COMPILER}}" NAME)
|
||||
if((NOT "${COMPILER_NAME}" STREQUAL "${${COMPILER}}") AND
|
||||
(NOT "${COMPILER_DIRECTORY}"))
|
||||
get_filename_component(
|
||||
COMPILER_PATH "${${COMPILER}}" REALPATH)
|
||||
get_filename_component(
|
||||
COMPILER_DIRECTORY "${COMPILER_PATH}" DIRECTORY)
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "${COMPILER} did not conform to the expected "
|
||||
"executable format. i.e. it did not end with "
|
||||
"arm, mips, pentium, or ppc.")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
|
||||
get_filename_component(C_COMPILER_NAME "${CMAKE_C_COMPILER}" NAME)
|
||||
get_filename_component(CXX_COMPILER_NAME "${CMAKE_CXX_COMPILER}" NAME)
|
||||
|
||||
# Ideally the location of the compiler should be resolved at this, but invoke
|
||||
# find_program as a last resort.
|
||||
if(NOT COMPILER_DIRECTORY)
|
||||
find_program(
|
||||
COMPILER_PATH NAMES "${C_COMPILER_NAME}" "${CXX_COMPILER_NAME}")
|
||||
if(COMPILER_PATH)
|
||||
get_filename_component(
|
||||
COMPILER_DIRECTORY "${COMPILER_PATH}" COMPILER_PATH)
|
||||
else()
|
||||
# The compiler must be successfully be detected by now.
|
||||
message(FATAL_ERROR "Could not determine location of compiler path.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
get_filename_component(basename "${COMPILER_DIRECTORY}" NAME)
|
||||
get_filename_component(basedir "${COMPILER_DIRECTORY}" DIRECTORY)
|
||||
while(basename)
|
||||
if("${basename}" MATCHES "${WIND_PLATFORM_PATTERN}")
|
||||
string(
|
||||
REGEX REPLACE "${WIND_PLATFORM_PATTERN}" "\\1" version ${basename})
|
||||
if(NOT CMAKE_SYSTEM_VERSION)
|
||||
set(CMAKE_SYSTEM_VERSION ${version})
|
||||
endif()
|
||||
|
||||
# The current base directory may be the WindRiver directory depending
|
||||
# on wether a "gnu" directory exists or not, but that is evaluated in
|
||||
# the next iteration.
|
||||
set(WIND_HOME "${basedir}")
|
||||
set(WIND_PLATFORM "${basename}")
|
||||
elseif(CMAKE_SYSTEM_VERSION AND WIND_HOME AND WIND_HOST_TYPE)
|
||||
# The "gnu" directory may not be part of the path. If it is, strip it.
|
||||
if("${basename}" STREQUAL "gnu")
|
||||
set(WIND_HOME "${basedir}")
|
||||
endif()
|
||||
break()
|
||||
elseif("${basename}" MATCHES "${WIND_HOST_TYPE_PATTERN}")
|
||||
set(WIND_HOST_TYPE "${basename}")
|
||||
endif()
|
||||
|
||||
get_filename_component(basename ${basedir} NAME)
|
||||
get_filename_component(basedir ${basedir} DIRECTORY)
|
||||
endwhile()
|
||||
|
||||
|
||||
# VxWorks commands require the WIND_BASE environment variable, so this script
|
||||
# will support it too. If the environment variable is not set, the necessary
|
||||
# path information is deduced from the compiler path.
|
||||
if(NOT WIND_BASE)
|
||||
set(WIND_BASE $ENV{WIND_BASE})
|
||||
endif()
|
||||
|
||||
if(NOT WIND_BASE)
|
||||
set(WIND_BASE "${WIND_HOME}/vxworks-${CMAKE_SYSTEM_VERSION}")
|
||||
endif()
|
||||
|
||||
# Verify the location WIND_BASE references actually exists.
|
||||
if(NOT EXISTS ${WIND_BASE})
|
||||
message(FATAL_ERROR "VxWorks base directory ${WIND_BASE} does not exist, "
|
||||
"please ensure the toolchain information is correct.")
|
||||
elseif(NOT ENV{WIND_BASE})
|
||||
# WIND_BASE environment variable must be exported during generation
|
||||
# otherwise compiler tests will fail.
|
||||
set(ENV{WIND_BASE} "${WIND_BASE}")
|
||||
endif()
|
||||
|
||||
|
||||
if(NOT CMAKE_C_COMPILER_VERSION)
|
||||
execute_process(
|
||||
COMMAND "${CMAKE_C_COMPILER}" -dumpversion
|
||||
OUTPUT_VARIABLE CMAKE_C_COMPILER_VERSION)
|
||||
string(STRIP "${CMAKE_C_COMPILER_VERSION}" CMAKE_C_COMPILER_VERSION)
|
||||
message(STATUS "VxWorks C compiler version ${CMAKE_C_COMPILER_VERSION}")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_CXX_COMPILER_VERSION)
|
||||
execute_process(
|
||||
COMMAND "${CMAKE_CXX_COMPILER}" -dumpversion
|
||||
OUTPUT_VARIABLE CMAKE_CXX_COMPILER_VERSION)
|
||||
string(STRIP "${CMAKE_CXX_COMPILER_VERSION}" CMAKE_CXX_COMPILER_VERSION)
|
||||
message(STATUS "VxWorks CXX compiler version ${CMAKE_C_COMPILER_VERSION}")
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_COMPILER_ID GNU)
|
||||
set(CMAKE_CXX_COMPILER_ID GNU)
|
||||
|
||||
|
||||
# CMAKE_SOURCE_DIR does not resolve to the actual source directory because
|
||||
# platform files are processed to early on in the process.
|
||||
set(ROOT "${CMAKE_MODULE_PATH}/../")
|
||||
|
||||
if(WIN32)
|
||||
set(CMAKE_C_COMPILER_LAUNCHER "${CMAKE_BINARY_DIR}/launch-c.bat")
|
||||
set(CMAKE_CXX_COMPILER_LAUNCHER "${CMAKE_BINARY_DIR}/launch-cxx.bat")
|
||||
configure_file(
|
||||
"${ROOT}/launch-c.bat.in" "${CMAKE_C_COMPILER_LAUNCHER}" @ONLY)
|
||||
configure_file(
|
||||
"${ROOT}/launch-cxx.bat.in" "${CMAKE_CXX_COMPILER_LAUNCHER}" @ONLY)
|
||||
else()
|
||||
# Check if a directory like lmapi-* exists (VxWorks 6.9) and append it to
|
||||
# LD_LIBRARY_PATH.
|
||||
file(GLOB WIND_LMAPI LIST_DIRECTORIES true "${WIND_HOME}/lmapi-*")
|
||||
if(WIND_LMAPI)
|
||||
set(WIND_LMAPI "${WIND_LMAPI}/${WIND_HOST_TYPE}/lib")
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_COMPILER_LAUNCHER "${CMAKE_BINARY_DIR}/launch-c")
|
||||
set(CMAKE_CXX_COMPILER_LAUNCHER "${CMAKE_BINARY_DIR}/launch-cxx")
|
||||
configure_file(
|
||||
"${ROOT}/launch-c.in" "${CMAKE_C_COMPILER_LAUNCHER}" @ONLY)
|
||||
configure_file(
|
||||
"${ROOT}/launch-cxx.in" "${CMAKE_CXX_COMPILER_LAUNCHER}" @ONLY)
|
||||
execute_process(COMMAND chmod a+rx "${CMAKE_C_COMPILER_LAUNCHER}")
|
||||
execute_process(COMMAND chmod a+rx "${CMAKE_CXX_COMPILER_LAUNCHER}")
|
||||
endif()
|
||||
|
||||
|
||||
set(WIND_INCLUDE_DIRECTORY "${WIND_BASE}/target/h")
|
||||
|
||||
# Versions before 6.8 have a different path for common libs.
|
||||
if("${CMAKE_SYSTEM_VERSION}" VERSION_GREATER "6.8")
|
||||
set(WIND_LIBRARY_DIRECTORY "${WIND_BASE}/target/lib/usr/lib/${WIND_PROCESSOR_TYPE}/${CMAKE_SYSTEM_PROCESSOR}/common")
|
||||
else()
|
||||
set(WIND_LIBRARY_DIRECTORY "${WIND_BASE}/target/usr/lib/${WIND_PROCESSOR_TYPE}/${CMAKE_SYSTEM_PROCESSOR}/common")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${WIND_LIBRARY_DIRECTORY}")
|
||||
message(FATAL_ERROR "${CMAKE_SYSTEM_PROCESSOR} is not part of the "
|
||||
"${WIND_PROCESSOR_TYPE} processor family.")
|
||||
endif()
|
||||
|
||||
include_directories(BEFORE SYSTEM "${WIND_INCLUDE_DIRECTORY}")
|
||||
link_directories("${WIND_LIBRARY_DIRECTORY}")
|
||||
|
||||
|
|
@ -1,134 +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
|
||||
#
|
||||
|
||||
#
|
||||
# This script will run all tests and generates various coverage reports.
|
||||
#
|
||||
# Example usage:
|
||||
# $ cmake -DCOVERAGE_SETTINGS=<cham bld>/CoverageSettings.cmake -P <cham src>/cmake/scripts/CoverageConvenience.cmake
|
||||
# If you start the scripts while in <cham bld> then you don't have to provide the COVERAGE_SETTINGS file.
|
||||
#
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
# Get Coverage configuration file
|
||||
if(NOT COVERAGE_SETTINGS)
|
||||
set(COVERAGE_SETTINGS ${CMAKE_CURRENT_BINARY_DIR}/CoverageSettings.cmake)
|
||||
endif()
|
||||
include(${COVERAGE_SETTINGS})
|
||||
|
||||
message(STATUS "Config file: ${COVERAGE_SETTINGS}")
|
||||
message(STATUS "Source directory: ${COVERAGE_SOURCE_DIR}")
|
||||
message(STATUS "Test directory: ${COVERAGE_RUN_DIR}")
|
||||
message(STATUS "Output directory: ${COVERAGE_OUTPUT_DIR}")
|
||||
|
||||
set(COVERAGE_SCRIPTS_DIR "${COVERAGE_SOURCE_DIR}/cmake/scripts")
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Detect generators
|
||||
#
|
||||
###############################################################################
|
||||
set(GENERATE_COVERAGE TRUE)
|
||||
if(GENERATE_COVERAGE)
|
||||
find_program(GCOV_PATH gcov PARENT_SCOPE)
|
||||
if(NOT GCOV_PATH)
|
||||
set(GENERATE_COVERAGE FALSE)
|
||||
message(STATUS "[SKIP] Coverage generators - gcov (could not find gcov)")
|
||||
endif()
|
||||
endif()
|
||||
if(GENERATE_COVERAGE)
|
||||
message(STATUS "[ OK ] Coverage generators - gcov")
|
||||
endif()
|
||||
|
||||
set(GENERATE_COVERAGE_HTML TRUE)
|
||||
if(GENERATE_COVERAGE_HTML)
|
||||
find_program(LCOV_PATH lcov PARENT_SCOPE)
|
||||
if(NOT LCOV_PATH)
|
||||
set(GENERATE_COVERAGE_HTML FALSE)
|
||||
message(STATUS "[SKIP] Coverage generators - HTML (could not find lcov)")
|
||||
endif()
|
||||
endif()
|
||||
if(GENERATE_COVERAGE_HTML)
|
||||
find_program(GENHTML_PATH genhtml PARENT_SCOPE)
|
||||
if(NOT GENHTML_PATH)
|
||||
set(GENERATE_COVERAGE_HTML FALSE)
|
||||
message(STATUS "[SKIP] Coverage generators - HTML (could not find genhtml)")
|
||||
endif()
|
||||
endif()
|
||||
if(GENERATE_COVERAGE_HTML)
|
||||
message(STATUS "[ OK ] Coverage generators - HTML (lcov and genhtml)")
|
||||
endif()
|
||||
|
||||
set(GENERATE_COVERAGE_COBERTURA TRUE)
|
||||
if(GENERATE_COVERAGE_COBERTURA)
|
||||
find_program(GCOVR_PATH gcovr PARENT_SCOPE)
|
||||
if(NOT GCOVR_PATH)
|
||||
set(GENERATE_COVERAGE_COBERTURA FALSE)
|
||||
message(STATUS "[SKIP] Coverage generators - Cobertura (could not find gcovr)")
|
||||
endif()
|
||||
endif()
|
||||
if(GENERATE_COVERAGE_COBERTURA)
|
||||
message(STATUS "[ OK ] Coverage generators - Cobertura (gcovr)")
|
||||
endif()
|
||||
|
||||
if(NOT GENERATE_COVERAGE)
|
||||
message(FATAL_ERROR "Could not find the main coverage generator 'gcov'")
|
||||
elseif(NOT GENERATE_COVERAGE_HTML AND NOT GENERATE_COVERAGE_COBERTURA)
|
||||
message(FATAL_ERROR "Could not find either of the two coverage report generators")
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Setup environment
|
||||
#
|
||||
###############################################################################
|
||||
message(STATUS "Setup environment")
|
||||
if(GENERATE_COVERAGE_HTML)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -DCOVERAGE_SETTINGS=${COVERAGE_SETTINGS} -P ${COVERAGE_SCRIPTS_DIR}/CoveragePreHtml.cmake
|
||||
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
|
||||
endif()
|
||||
if(GENERATE_COVERAGE_COBERTURA)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -DCOVERAGE_SETTINGS=${COVERAGE_SETTINGS} -P ${COVERAGE_SCRIPTS_DIR}/CoveragePreCobertura.cmake
|
||||
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Generate coverage results by running all the tests
|
||||
#
|
||||
###############################################################################
|
||||
message(STATUS "Run all test to get coverage")
|
||||
execute_process(COMMAND ctest ${COVERAGE_QUIET_FLAG} -T test
|
||||
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
|
||||
execute_process(COMMAND ctest ${COVERAGE_QUIET_FLAG} -T coverage
|
||||
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
|
||||
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Generate coverage reports
|
||||
#
|
||||
###############################################################################
|
||||
if(GENERATE_COVERAGE_HTML)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -DCOVERAGE_SETTINGS=${COVERAGE_SETTINGS} -P ${COVERAGE_SCRIPTS_DIR}/CoveragePostHtml.cmake
|
||||
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
|
||||
endif()
|
||||
if(GENERATE_COVERAGE_COBERTURA)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -DCOVERAGE_SETTINGS=${COVERAGE_SETTINGS} -P ${COVERAGE_SCRIPTS_DIR}/CoveragePostCobertura.cmake
|
||||
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
|
||||
endif()
|
||||
|
||||
|
|
@ -1,52 +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
|
||||
#
|
||||
|
||||
#
|
||||
# This script assumes that all test have been run and gcov results are available.
|
||||
# It will generate the Cobertura output from the gcov results.
|
||||
#
|
||||
# Example usage:
|
||||
# $ cmake -DCOVERAGE_SETTINGS=<cham bld>/CoverageSettings.cmake -P <cham src>/cmake/scripts/CoveragePreCobertura.cmake
|
||||
# $ ctest -T test
|
||||
# $ ctest -T coverage
|
||||
# $ ctest -DCOVERAGE_SETTINGS=<cham bld>/CoverageSettings.cmake -P <cham src>/cmake/scripts/CoveragePostCobertura.cmake
|
||||
# If you start the scripts while in <cham bld> then you don't have to provide the COVERAGE_SETTINGS file.
|
||||
#
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
# Get Coverage configuration file
|
||||
if(NOT COVERAGE_SETTINGS)
|
||||
set(COVERAGE_SETTINGS ${CMAKE_CURRENT_BINARY_DIR}/CoverageSettings.cmake)
|
||||
endif()
|
||||
include(${COVERAGE_SETTINGS})
|
||||
|
||||
# Some debug
|
||||
#message(STATUS "Config file: ${COVERAGE_SETTINGS}")
|
||||
#message(STATUS "Source directory: ${COVERAGE_SOURCE_DIR}")
|
||||
#message(STATUS "Test directory: ${COVERAGE_RUN_DIR}")
|
||||
#message(STATUS "Output directory: ${COVERAGE_OUTPUT_DIR}")
|
||||
|
||||
# Find gcovr to generate Cobertura results
|
||||
find_program(GCOVR_PATH gcovr PARENT_SCOPE)
|
||||
if(NOT GCOVR_PATH)
|
||||
message(FATAL_ERROR "Could not find gcovr to generate Cobertura coverage.")
|
||||
endif()
|
||||
|
||||
# Create location to put the result file.
|
||||
file(MAKE_DIRECTORY ${COVERAGE_OUTPUT_DIR})
|
||||
|
||||
execute_process(COMMAND ${GCOVR_PATH} -x -r ${COVERAGE_SOURCE_DIR} -e ".*/${COVERAGE_EXCLUDE_TESTS}/.*" -e ".*/${COVERAGE_EXCLUDE_EXAMPLES}/.*" -e ".*/${COVERAGE_EXCLUDE_BUILD_SUPPORT}/.*" -o ${COVERAGE_OUTPUT_DIR}/cobertura.xml
|
||||
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
|
||||
|
||||
|
||||
message(STATUS "The Cobertura report can be found here: ${COVERAGE_OUTPUT_DIR}/cobertura.xml")
|
||||
|
||||
|
|
@ -1,71 +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
|
||||
#
|
||||
|
||||
#
|
||||
# This script assumes that all test have been run and gcov results are available.
|
||||
# It will generate the HTML output from the gcov results.
|
||||
#
|
||||
# Example usage:
|
||||
# $ cmake -DCOVERAGE_SETTINGS=<cham bld>/CoverageSettings.cmake -P <cham src>/cmake/scripts/CoveragePreHtml.cmake
|
||||
# $ ctest -T test
|
||||
# $ ctest -T coverage
|
||||
# $ ctest -DCOVERAGE_SETTINGS=<cham bld>/CoverageSettings.cmake -P <cham src>/cmake/scripts/CoveragePostHtml.cmake
|
||||
# If you start the scripts while in <cham bld> then you don't have to provide the COVERAGE_SETTINGS file.
|
||||
#
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
# Get Coverage configuration file
|
||||
if(NOT COVERAGE_SETTINGS)
|
||||
set(COVERAGE_SETTINGS ${CMAKE_CURRENT_BINARY_DIR}/CoverageSettings.cmake)
|
||||
endif()
|
||||
include(${COVERAGE_SETTINGS})
|
||||
|
||||
# Some debug
|
||||
#message(STATUS "Config file: ${COVERAGE_SETTINGS}")
|
||||
#message(STATUS "Source directory: ${COVERAGE_SOURCE_DIR}")
|
||||
#message(STATUS "Test directory: ${COVERAGE_RUN_DIR}")
|
||||
#message(STATUS "Output directory: ${COVERAGE_OUTPUT_DIR}")
|
||||
|
||||
# Find tools to generate HTML coverage results
|
||||
find_program(LCOV_PATH lcov PARENT_SCOPE)
|
||||
if(NOT LCOV_PATH)
|
||||
message(FATAL_ERROR "Could not find lcov to generate HTML coverage.")
|
||||
endif()
|
||||
find_program(GENHTML_PATH genhtml PARENT_SCOPE)
|
||||
if(NOT GENHTML_PATH)
|
||||
message(FATAL_ERROR "Could not find genhtml to generate HTML coverage.")
|
||||
endif()
|
||||
|
||||
# Create location to put the result file.
|
||||
file(MAKE_DIRECTORY ${COVERAGE_OUTPUT_DIR})
|
||||
set(COVERAGE_HTML_OUTPUT "${COVERAGE_OUTPUT_DIR}/html")
|
||||
file(MAKE_DIRECTORY ${COVERAGE_HTML_OUTPUT})
|
||||
|
||||
# Setup tmp analysis files
|
||||
set(COVERAGE_INFO "${COVERAGE_HTML_OUTPUT}/coverage_html.info")
|
||||
set(COVERAGE_CLEANED "${COVERAGE_INFO}.cleaned")
|
||||
|
||||
# Execute lcov and genhtml commands to get HTML results
|
||||
execute_process(COMMAND ${LCOV_PATH} ${COVERAGE_QUIET_FLAG} --directory . --capture --output-file ${COVERAGE_INFO}
|
||||
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
|
||||
execute_process(COMMAND ${LCOV_PATH} ${COVERAGE_QUIET_FLAG} --remove ${COVERAGE_INFO} "${COVERAGE_EXCLUDE_TESTS}/*" "${COVERAGE_EXCLUDE_EXAMPLES}/*" "${COVERAGE_EXCLUDE_BUILD_SUPPORT}/*" "/usr/*" --output-file ${COVERAGE_CLEANED}
|
||||
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
|
||||
execute_process(COMMAND ${GENHTML_PATH} ${COVERAGE_QUIET_FLAG} -o ${COVERAGE_HTML_OUTPUT} ${COVERAGE_CLEANED}
|
||||
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
|
||||
|
||||
# Remove tmp analysis files
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${COVERAGE_INFO} ${COVERAGE_CLEANED}
|
||||
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
|
||||
|
||||
|
||||
message(STATUS "The HTML coverage report can be found here: ${COVERAGE_HTML_OUTPUT}/index.html")
|
||||
|
||||
|
|
@ -1,30 +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
|
||||
#
|
||||
|
||||
#
|
||||
# This script assumes that it is called before all tests are run and gcov results are available.
|
||||
# It can be used to setup the environment needed to get proper Cobertura coverage results.
|
||||
#
|
||||
# Example usage:
|
||||
# $ cmake -DCOVERAGE_SETTINGS=<cham bld>/CoverageSettings.cmake -P <cham src>/cmake/scripts/CoveragePreCobertura.cmake
|
||||
# $ ctest -T test
|
||||
# $ ctest -T coverage
|
||||
# $ ctest -DCOVERAGE_SETTINGS=<cham bld>/CoverageSettings.cmake -P <cham src>/cmake/scripts/CoveragePostCobertura.cmake
|
||||
# If you start the scripts while in <cham bld> then you don't have to provide the COVERAGE_SETTINGS file.
|
||||
#
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
#
|
||||
# Nothing to do really.
|
||||
# This is just added to provide consistency between Coverage scripts.
|
||||
#
|
||||
|
||||
|
|
@ -1,52 +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
|
||||
#
|
||||
|
||||
#
|
||||
# This script assumes that it is called before all tests are run and gcov results are available.
|
||||
# It can be used to setup the environment needed to get proper HTML coverage results.
|
||||
#
|
||||
# Example usage:
|
||||
# $ cmake -DCOVERAGE_SETTINGS=<cham bld>/CoverageSettings.cmake -P <cham src>/cmake/scripts/CoveragePreHtml.cmake
|
||||
# $ ctest -T test
|
||||
# $ ctest -T coverage
|
||||
# $ ctest -DCOVERAGE_SETTINGS=<cham bld>/CoverageSettings.cmake -P <cham src>/cmake/scripts/CoveragePostHtml.cmake
|
||||
# If you start the scripts while in <cham bld> then you don't have to provide the COVERAGE_SETTINGS file.
|
||||
#
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
# Get Coverage configuration file
|
||||
if(NOT COVERAGE_SETTINGS)
|
||||
set(COVERAGE_SETTINGS ${CMAKE_CURRENT_BINARY_DIR}/CoverageSettings.cmake)
|
||||
endif()
|
||||
include(${COVERAGE_SETTINGS})
|
||||
|
||||
# Some debug
|
||||
#message(STATUS "Config file: ${COVERAGE_SETTINGS}")
|
||||
#message(STATUS "Source directory: ${COVERAGE_SOURCE_DIR}")
|
||||
#message(STATUS "Test directory: ${COVERAGE_RUN_DIR}")
|
||||
#message(STATUS "Output directory: ${COVERAGE_OUTPUT_DIR}")
|
||||
|
||||
# Find tools to generate HTML coverage results
|
||||
find_program(LCOV_PATH lcov PARENT_SCOPE)
|
||||
if(NOT LCOV_PATH)
|
||||
message(FATAL_ERROR "Could not find lcov to generate HTML coverage.")
|
||||
endif()
|
||||
find_program(GENHTML_PATH genhtml PARENT_SCOPE)
|
||||
if(NOT GENHTML_PATH)
|
||||
message(FATAL_ERROR "Could not find genhtml to generate HTML coverage.")
|
||||
endif()
|
||||
|
||||
# Reset LCOV environment
|
||||
execute_process(COMMAND ${LCOV_PATH} ${COVERAGE_QUIET_FLAG} --directory . --zerocounters
|
||||
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
|
||||
|
||||
|
||||
|
|
@ -1,33 +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
|
||||
#
|
||||
set(CMAKE_SYSTEM_NAME VxWorks)
|
||||
set(CMAKE_SYSTEM_PROCESSOR PENTIUM4)
|
||||
|
||||
set(WIND_HOME "/path/to/WindRiver")
|
||||
set(WIND_PROCESSOR_TYPE "pentium")
|
||||
|
||||
# Binaries are named e.g. ccpentium or ccarm
|
||||
set(CMAKE_C_COMPILER ${WIND_HOME}/gnu/4.3.3-vxworks-6.9/x86-linux2/bin/cc${WIND_PROCESSOR_TYPE})
|
||||
set(CMAKE_CXX_COMPILER ${WIND_HOME}/gnu/4.3.3-vxworks-6.9/x86-linux2/bin/c++${WIND_PROCESSOR_TYPE})
|
||||
set(CMAKE_AR ${WIND_HOME}/gnu/4.3.3-vxworks-6.9/x86-linux2/bin/ar${WIND_PROCESSOR_TYPE})
|
||||
|
||||
set(WIND_PROGRAM_PATH ${WIND_HOME}/vxworks-6.9/host/x86-linux2/bin;${WIND_BASE}/gnu/4.3.3-vxworks-6.9/x86-linux2/bin)
|
||||
set(WIND_LIBRARY_PATH ${WIND_HOME}/target/lib/${WIND_PROCESSOR_TYPE}/${CMAKE_SYSTEM_PROCESSOR}/common)
|
||||
set(WIND_INCLUDE_PATH ${WIND_HOME}/vxworks-6.9/target/h)
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH ${WIND_PROGRAM_PATH};${WIND_LIBRARY_PATH};${WIND_INCLUDE_PATH})
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
|
||||
|
|
@ -19,22 +19,27 @@ FUNCTION(PREPEND var prefix)
|
|||
SET(${var} "${listVar}" PARENT_SCOPE)
|
||||
ENDFUNCTION(PREPEND)
|
||||
|
||||
option(DDSC_SHARED "Build DDSC as a shared library" ON)
|
||||
|
||||
if(DDSC_SHARED AND ((NOT DEFINED BUILD_SHARED_LIBS) OR BUILD_SHARED_LIBS))
|
||||
# BUILD_SHARED_LIBS is set to off by for example VxWorks DKM environment
|
||||
add_library(ddsc SHARED "")
|
||||
if (BUILD_SHARED_LIBS OR NOT DEFINED BUILD_SHARED_LIBS)
|
||||
add_library(ddsc SHARED)
|
||||
else()
|
||||
if(DDSC_SHARED)
|
||||
message(STATUS "Option DDSC_SHARED ignored. Only static libraries supported on this platform.")
|
||||
endif()
|
||||
add_library(ddsc "")
|
||||
add_library(ddsc)
|
||||
endif()
|
||||
|
||||
add_definitions(-DDDSI_INCLUDE_NETWORK_PARTITIONS -DDDSI_INCLUDE_SSM)
|
||||
|
||||
option(DDSC_ENABLE_OPENSSL "Enable openssl support" ON)
|
||||
if(DDSC_ENABLE_OPENSSL)
|
||||
# OpenSSL is huge, raising the RSS by 1MB or so, and moreover find_package(OpenSSL) causes
|
||||
# trouble on some older CMake versions that otherwise work fine, so provide an option to avoid
|
||||
# all OpenSSL related things.
|
||||
#
|
||||
# Historically the option was DDSC_ENABLE_OPENSSL so make some allowance for those who are
|
||||
# currently relying on it.
|
||||
option(ENABLE_SSL "Enable openssl support" ON)
|
||||
option(DDSC_ENABLE_OPENSSL "Deprecated: please use ENABLE_SSL instead" ON)
|
||||
if(NOT DDSC_ENABLE_OPENSSL)
|
||||
message(ERROR "DDSC_ENABLE_OPENSSL is deprecated, please use ENABLE_SSL instead")
|
||||
set(ENABLE_SSL OFF)
|
||||
endif()
|
||||
if(ENABLE_SSL)
|
||||
find_package(OpenSSL)
|
||||
if(OPENSSL_FOUND)
|
||||
add_definitions(-DDDSI_INCLUDE_SSL)
|
||||
|
|
@ -42,8 +47,9 @@ if(DDSC_ENABLE_OPENSSL)
|
|||
if(CMAKE_GENERATOR MATCHES "Visual Studio")
|
||||
set_target_properties(ddsc PROPERTIES LINK_FLAGS "/ignore:4099")
|
||||
endif()
|
||||
message(STATUS "Building with OpenSSL support")
|
||||
else()
|
||||
message(FATAL_ERROR "To build without openssl support, set DDSC_ENABLE_OPENSSL to OFF")
|
||||
message(STATUS "Building without OpenSSL support")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
@ -51,7 +57,6 @@ include(ddsi/CMakeLists.txt)
|
|||
include(ddsc/CMakeLists.txt)
|
||||
|
||||
target_link_libraries(ddsc PRIVATE ddsrt security_api)
|
||||
|
||||
target_compile_definitions(
|
||||
ddsc PUBLIC
|
||||
$<BUILD_INTERFACE:$<TARGET_PROPERTY:ddsrt,INTERFACE_COMPILE_DEFINITIONS>>)
|
||||
|
|
@ -76,4 +81,21 @@ install(
|
|||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib
|
||||
)
|
||||
|
||||
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/xtests")
|
||||
if(BUILD_IDLC)
|
||||
add_subdirectory(xtests)
|
||||
endif()
|
||||
|
||||
if(BUILD_DOCS)
|
||||
set(DOXYGEN_GENERATE_HTML NO)
|
||||
set(DOXYGEN_GENERATE_XML YES)
|
||||
set(DOXYGEN_EXCLUDE_PATTERNS "*/tests/*")
|
||||
set(DOXYGEN_MACRO_EXPANSION YES)
|
||||
set(DOXYGEN_PREDEFINED
|
||||
"__restrict="
|
||||
"__attribute__="
|
||||
"__declspec(x)="
|
||||
"DDS_EXPORT="
|
||||
"DDS_DEPRECATED_EXPORT=")
|
||||
find_package(Doxygen REQUIRED)
|
||||
doxygen_add_docs(ddsc_api_docs "ddsc/include")
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -19,12 +19,13 @@ PREPEND(srcs_ddsc "${CMAKE_CURRENT_LIST_DIR}/src"
|
|||
dds_init.c
|
||||
dds_publisher.c
|
||||
dds_rhc.c
|
||||
dds_rhc_default.c
|
||||
dds_domain.c
|
||||
dds_instance.c
|
||||
dds_qos.c
|
||||
dds_handles.c
|
||||
dds_entity.c
|
||||
dds_key.c
|
||||
dds_matched.c
|
||||
dds_querycond.c
|
||||
dds_topic.c
|
||||
dds_listener.c
|
||||
|
|
@ -47,8 +48,8 @@ PREPEND(hdrs_public_ddsc "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include/dd
|
|||
ddsc/dds_public_impl.h
|
||||
ddsc/dds_public_listener.h
|
||||
ddsc/dds_public_qos.h
|
||||
ddsc/dds_public_qosdefs.h
|
||||
ddsc/dds_public_status.h
|
||||
ddsc/dds_public_stream.h
|
||||
)
|
||||
|
||||
PREPEND(hdrs_private_ddsc "${CMAKE_CURRENT_LIST_DIR}/src"
|
||||
|
|
@ -58,7 +59,6 @@ PREPEND(hdrs_private_ddsc "${CMAKE_CURRENT_LIST_DIR}/src"
|
|||
dds__handles.h
|
||||
dds__entity.h
|
||||
dds__init.h
|
||||
dds__key.h
|
||||
dds__listener.h
|
||||
dds__participant.h
|
||||
dds__publisher.h
|
||||
|
|
@ -68,6 +68,7 @@ PREPEND(hdrs_private_ddsc "${CMAKE_CURRENT_LIST_DIR}/src"
|
|||
dds__guardcond.h
|
||||
dds__reader.h
|
||||
dds__rhc.h
|
||||
dds__rhc_default.h
|
||||
dds__stream.h
|
||||
dds__subscriber.h
|
||||
dds__topic.h
|
||||
|
|
@ -77,6 +78,7 @@ PREPEND(hdrs_private_ddsc "${CMAKE_CURRENT_LIST_DIR}/src"
|
|||
dds__whc.h
|
||||
dds__whc_builtintopic.h
|
||||
dds__serdata_builtintopic.h
|
||||
dds__get_status.h
|
||||
)
|
||||
|
||||
generate_export_header(
|
||||
|
|
|
|||
|
|
@ -26,17 +26,10 @@
|
|||
|
||||
#include "dds/export.h"
|
||||
|
||||
/* TODO: Move to appropriate location */
|
||||
/**
|
||||
* Return code indicating success (DDS_RETCODE_OK) or failure. If a given
|
||||
* operation failed the value will be a unique error code and dds_err_nr() must
|
||||
* be used to extract the DDS_RETCODE_* value.
|
||||
*/
|
||||
typedef int32_t dds_return_t;
|
||||
/**
|
||||
* Handle to an entity. A valid entity handle will always have a positive
|
||||
* integer value. Should the value be negative, the value represents a unique
|
||||
* error code. dds_err_nr() can be used to extract the DDS_RETCODE_* value.
|
||||
* integer value. Should the value be negative, it is one of the DDS_RETCODE_*
|
||||
* error codes.
|
||||
*/
|
||||
typedef int32_t dds_entity_t;
|
||||
|
||||
|
|
@ -45,7 +38,6 @@ typedef int32_t dds_entity_t;
|
|||
#include "dds/ddsrt/time.h"
|
||||
#include "dds/ddsrt/retcode.h"
|
||||
#include "dds/ddsrt/log.h"
|
||||
#include "dds/ddsc/dds_public_stream.h"
|
||||
#include "dds/ddsc/dds_public_impl.h"
|
||||
#include "dds/ddsc/dds_public_alloc.h"
|
||||
#include "dds/ddsc/dds_public_qos.h"
|
||||
|
|
@ -87,7 +79,6 @@ DDS_EXPORT dds_domainid_t dds_domain_default (void);
|
|||
|
||||
/** @name Communication Status definitions
|
||||
@{**/
|
||||
/** Another topic exists with the same name but with different characteristics. */
|
||||
typedef enum dds_status_id {
|
||||
DDS_INCONSISTENT_TOPIC_STATUS_ID,
|
||||
DDS_OFFERED_DEADLINE_MISSED_STATUS_ID,
|
||||
|
|
@ -102,8 +93,9 @@ typedef enum dds_status_id {
|
|||
DDS_LIVELINESS_CHANGED_STATUS_ID,
|
||||
DDS_PUBLICATION_MATCHED_STATUS_ID,
|
||||
DDS_SUBSCRIPTION_MATCHED_STATUS_ID
|
||||
}
|
||||
dds_status_id_t;
|
||||
} dds_status_id_t;
|
||||
|
||||
/** Another topic exists with the same name but with different characteristics. */
|
||||
#define DDS_INCONSISTENT_TOPIC_STATUS (1u << DDS_INCONSISTENT_TOPIC_STATUS_ID)
|
||||
/** The deadline that the writer has committed through its deadline QoS policy was not respected for a specific instance. */
|
||||
#define DDS_OFFERED_DEADLINE_MISSED_STATUS (1u << DDS_OFFERED_DEADLINE_MISSED_STATUS_ID)
|
||||
|
|
@ -321,7 +313,7 @@ dds_delete(dds_entity_t entity);
|
|||
* For instance, it will return the Publisher that was used when
|
||||
* creating a DataWriter (when that DataWriter was provided here).
|
||||
*
|
||||
* @param[in] entity Entity from which to get its publisher.
|
||||
* @param[in] writer Entity from which to get its publisher.
|
||||
*
|
||||
* @returns A valid entity or an error code.
|
||||
*
|
||||
|
|
@ -369,7 +361,7 @@ dds_get_subscriber(dds_entity_t entity);
|
|||
* For instance, it will return the DataReader that was used when
|
||||
* creating a ReadCondition (when that ReadCondition was provided here).
|
||||
*
|
||||
* @param[in] entity Entity from which to get its datareader.
|
||||
* @param[in] condition Entity from which to get its datareader.
|
||||
*
|
||||
* @returns A valid reader handle or an error code.
|
||||
*
|
||||
|
|
@ -510,7 +502,7 @@ dds_get_status_changes(dds_entity_t entity, uint32_t *status);
|
|||
* This operation returns the status enabled on the entity
|
||||
*
|
||||
* @param[in] entity Entity to get the status.
|
||||
* @param[out] status Status set on the entity.
|
||||
* @param[out] mask Mask of enabled statuses set on the entity.
|
||||
*
|
||||
* @returns A dds_return_t indicating success or failure.
|
||||
*
|
||||
|
|
@ -960,6 +952,8 @@ dds_create_topic(
|
|||
const dds_qos_t *qos,
|
||||
const dds_listener_t *listener);
|
||||
|
||||
struct ddsi_sertopic;
|
||||
struct nn_plist;
|
||||
/**
|
||||
* @brief Creates a new topic with arbitrary type handling.
|
||||
*
|
||||
|
|
@ -980,8 +974,6 @@ dds_create_topic(
|
|||
* Either participant, descriptor, name or qos is invalid.
|
||||
*/
|
||||
/* TODO: Check list of retcodes is complete. */
|
||||
struct ddsi_sertopic;
|
||||
struct nn_plist;
|
||||
DDS_EXPORT dds_entity_t
|
||||
dds_create_topic_arbitrary (
|
||||
dds_entity_t participant,
|
||||
|
|
@ -1224,7 +1216,7 @@ dds_create_reader(
|
|||
* @returns a status, 0 on success, TIMEOUT on timeout or a negative value to indicate error.
|
||||
*/
|
||||
/* TODO: Complete list of error codes */
|
||||
DDS_EXPORT int
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_reader_wait_for_historical_data(
|
||||
dds_entity_t reader,
|
||||
dds_duration_t max_wait);
|
||||
|
|
@ -1658,8 +1650,7 @@ dds_write_flush(dds_entity_t writer);
|
|||
* @brief Write a CDR serialized value of a data instance
|
||||
*
|
||||
* @param[in] writer The writer entity.
|
||||
* @param[in] cdr CDR serialized value to be written.
|
||||
* @param[in] size Size (in bytes) of CDR encoded data to be written.
|
||||
* @param[in] serdata CDR serialized value to be written.
|
||||
*
|
||||
* @returns A dds_return_t indicating success or failure.
|
||||
*/
|
||||
|
|
@ -2612,7 +2603,7 @@ dds_take_mask_wl(
|
|||
uint32_t maxs,
|
||||
uint32_t mask);
|
||||
|
||||
DDS_EXPORT int
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_takecdr(
|
||||
dds_entity_t reader_or_condition,
|
||||
struct ddsi_serdata **buf,
|
||||
|
|
@ -2906,7 +2897,7 @@ dds_read_next_wl(
|
|||
* the memory is released so that the buffer can be reused during a successive read/take operation.
|
||||
* When a condition is provided, the reader to which the condition belongs is looked up.
|
||||
*
|
||||
* @param[in] rd_or_cnd Reader or condition that belongs to a reader.
|
||||
* @param[in] reader_or_condition Reader or condition that belongs to a reader.
|
||||
* @param[in] buf An array of (pointers to) samples.
|
||||
* @param[in] bufsz The number of (pointers to) samples stored in buf.
|
||||
*
|
||||
|
|
@ -2948,7 +2939,7 @@ dds_instance_lookup(dds_entity_t entity, const void *data);
|
|||
/**
|
||||
* @brief This operation takes an instance handle and return a key-value corresponding to it.
|
||||
*
|
||||
* @param[in] entity Reader or writer entity.
|
||||
* @param[in] entity Reader, writer, readcondition or querycondition entity.
|
||||
* @param[in] inst Instance handle.
|
||||
* @param[out] data pointer to an instance, to which the key ID corresponding to the instance handle will be
|
||||
* returned, the sample in the instance should be ignored.
|
||||
|
|
@ -3070,6 +3061,140 @@ dds_triggered(dds_entity_t entity);
|
|||
DDS_EXPORT dds_entity_t
|
||||
dds_get_topic(dds_entity_t entity);
|
||||
|
||||
/**
|
||||
* @brief Get instance handles of the data readers matching a writer
|
||||
*
|
||||
* This operation fills the provided array with the instance handles
|
||||
* of the data readers that match the writer. On successful output,
|
||||
* the number of entries of "rds" set is the minimum of the return
|
||||
* value and the value of "nrds".
|
||||
*
|
||||
* @param[in] writer The writer.
|
||||
* @param[in] rds The array to be filled.
|
||||
* @param[in] nrds The size of the rds array, at most the first
|
||||
* nrds entries will be filled. rds = NULL and nrds = 0
|
||||
* is a valid way of determining the number of matched
|
||||
* readers, but inefficient compared to relying on the
|
||||
* matched publication status.
|
||||
*
|
||||
* @returns A dds_return_t indicating the number of matched readers
|
||||
* or failure. The return value may be larger than nrds
|
||||
* if there are more matching readers than the array can
|
||||
* hold.
|
||||
*
|
||||
* @retval >=0
|
||||
* The number of matching readers.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* The entity parameter is not valid or rds = NULL and
|
||||
* nrds > 0.
|
||||
* @retval DDS_RETCODE_ILLEGAL_OPERATION
|
||||
* The operation is invoked on an inappropriate object.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_get_matched_subscriptions (
|
||||
dds_entity_t writer,
|
||||
dds_instance_handle_t *rds,
|
||||
size_t nrds);
|
||||
|
||||
/**
|
||||
* @brief Get a description of a reader matched with the provided
|
||||
* writer
|
||||
*
|
||||
* This operation looks up the reader instance handle in the set of
|
||||
* readers matched with the specified writer, returning a freshly
|
||||
* allocated sample of the DCPSSubscription built-in topic if found,
|
||||
* and NULL if not. The caller is responsible for freeing the
|
||||
* memory allocated.
|
||||
*
|
||||
* This operation is similar to performing a read of the given
|
||||
* instance handle on a reader of the DCPSSubscription built-in
|
||||
* topic, but this operation additionally filters on whether the
|
||||
* reader is matched by the provided writer.
|
||||
*
|
||||
* @param[in] writer The writer.
|
||||
* @param[in] ih The instance handle of a reader.
|
||||
*
|
||||
* @returns A newly allocated sample containing the information on the
|
||||
* reader, or a NULL pointer for any kind of failure.
|
||||
*
|
||||
* @retval != NULL
|
||||
* The requested data
|
||||
* @retval NULL
|
||||
* The writer is not valid or ih is not an instance handle
|
||||
* of a matched reader.
|
||||
*/
|
||||
DDS_EXPORT dds_builtintopic_endpoint_t *
|
||||
dds_get_matched_subscription_data (
|
||||
dds_entity_t writer,
|
||||
dds_instance_handle_t ih);
|
||||
|
||||
/**
|
||||
* @brief Get instance handles of the data writers matching a reader
|
||||
*
|
||||
* This operation fills the provided array with the instance handles
|
||||
* of the data writers that match the reader. On successful output,
|
||||
* the number of entries of "wrs" set is the minimum of the return
|
||||
* value and the value of "nwrs".
|
||||
*
|
||||
* @param[in] reader The reader.
|
||||
* @param[in] wrs The array to be filled.
|
||||
* @param[in] nwrs The size of the wrs array, at most the first
|
||||
* nwrs entries will be filled. wrs = NULL and wrds = 0
|
||||
* is a valid way of determining the number of matched
|
||||
* readers, but inefficient compared to relying on the
|
||||
* matched publication status.
|
||||
*
|
||||
* @returns A dds_return_t indicating the number of matched writers
|
||||
* or failure. The return value may be larger than nwrs
|
||||
* if there are more matching writers than the array can
|
||||
* hold.
|
||||
*
|
||||
* @retval >=0
|
||||
* The number of matching writers.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* The entity parameter is not valid or wrs = NULL and
|
||||
* nwrs > 0.
|
||||
* @retval DDS_RETCODE_ILLEGAL_OPERATION
|
||||
* The operation is invoked on an inappropriate object.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_get_matched_publications (
|
||||
dds_entity_t reader,
|
||||
dds_instance_handle_t *wrs,
|
||||
size_t nwrs);
|
||||
|
||||
/**
|
||||
* @brief Get a description of a writer matched with the provided
|
||||
* reader
|
||||
*
|
||||
* This operation looks up the writer instance handle in the set of
|
||||
* writers matched with the specified reader, returning a freshly
|
||||
* allocated sample of the DCPSPublication built-in topic if found,
|
||||
* and NULL if not. The caller is responsible for freeing the
|
||||
* memory allocated.
|
||||
*
|
||||
* This operation is similar to performing a read of the given
|
||||
* instance handle on a reader of the DCPSPublication built-in
|
||||
* topic, but this operation additionally filters on whether the
|
||||
* writer is matched by the provided reader.
|
||||
*
|
||||
* @param[in] reader The reader.
|
||||
* @param[in] ih The instance handle of a writer.
|
||||
*
|
||||
* @returns A newly allocated sample containing the information on the
|
||||
* writer, or a NULL pointer for any kind of failure.
|
||||
*
|
||||
* @retval != NULL
|
||||
* The requested data
|
||||
* @retval NULL
|
||||
* The reader is not valid or ih is not an instance handle
|
||||
* of a matched writer.
|
||||
*/
|
||||
DDS_EXPORT dds_builtintopic_endpoint_t *
|
||||
dds_get_matched_publication_data (
|
||||
dds_entity_t reader,
|
||||
dds_instance_handle_t ih);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -54,20 +54,6 @@ typedef struct dds_allocator
|
|||
}
|
||||
dds_allocator_t;
|
||||
|
||||
DDS_EXPORT void dds_set_allocator (const dds_allocator_t * __restrict n, dds_allocator_t * __restrict o);
|
||||
|
||||
typedef struct dds_aligned_allocator
|
||||
{
|
||||
/* size is a multiple of align, align is a power of 2 no less than
|
||||
the machine's page size, returned pointer MUST be aligned to at
|
||||
least align. */
|
||||
void * (*alloc) (size_t size, size_t align);
|
||||
void (*free) (size_t size, void *ptr);
|
||||
}
|
||||
dds_aligned_allocator_t;
|
||||
|
||||
DDS_EXPORT void dds_set_aligned_allocator (const dds_aligned_allocator_t * __restrict n, dds_aligned_allocator_t * __restrict o);
|
||||
|
||||
DDS_EXPORT void * dds_alloc (size_t size);
|
||||
DDS_EXPORT void * dds_realloc (void * ptr, size_t size);
|
||||
DDS_EXPORT void * dds_realloc_zero (void * ptr, size_t size);
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ** DEPRECATED ** */
|
||||
|
||||
/* Error masks for returned status values */
|
||||
|
||||
#define DDS_ERR_NR_MASK 0x000000ff
|
||||
|
|
@ -37,13 +39,13 @@ extern "C" {
|
|||
/* Error code handling functions */
|
||||
|
||||
/** Macro to extract error number */
|
||||
#define dds_err_nr(e) ((-(e)) & DDS_ERR_NR_MASK)
|
||||
#define dds_err_nr(e) (e)
|
||||
|
||||
/** Macro to extract line number */
|
||||
#define dds_err_line(e) (((-(e)) & DDS_ERR_LINE_MASK) >> 8)
|
||||
#define dds_err_line(e) (0)
|
||||
|
||||
/** Macro to extract file identifier */
|
||||
#define dds_err_file_id(e) (((-(e)) & DDS_ERR_FILE_ID_MASK) >> 22)
|
||||
#define dds_err_file_id(e) (0)
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,9 +21,10 @@
|
|||
#ifndef DDS_IMPL_H
|
||||
#define DDS_IMPL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "dds/export.h"
|
||||
#include "dds/ddsc/dds_public_alloc.h"
|
||||
#include "dds/ddsc/dds_public_stream.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
|
|
@ -38,8 +39,6 @@ typedef struct dds_sequence
|
|||
}
|
||||
dds_sequence_t;
|
||||
|
||||
#define DDS_LENGTH_UNLIMITED -1
|
||||
|
||||
typedef struct dds_key_descriptor
|
||||
{
|
||||
const char * m_name;
|
||||
|
|
@ -71,6 +70,7 @@ dds_topic_descriptor_t;
|
|||
|
||||
#define DDS_TOPIC_NO_OPTIMIZE 0x0001
|
||||
#define DDS_TOPIC_FIXED_KEY 0x0002
|
||||
#define DDS_TOPIC_CONTAINS_UNION 0x0004
|
||||
|
||||
/*
|
||||
Masks for read condition, read, take: there is only one mask here,
|
||||
|
|
@ -92,116 +92,145 @@ dds_topic_descriptor_t;
|
|||
|
||||
#define DDS_ANY_STATE (DDS_ANY_SAMPLE_STATE | DDS_ANY_VIEW_STATE | DDS_ANY_INSTANCE_STATE)
|
||||
|
||||
#define DDS_DOMAIN_DEFAULT -1
|
||||
#define DDS_DOMAIN_DEFAULT ((uint32_t) 0xffffffffu)
|
||||
#define DDS_HANDLE_NIL 0
|
||||
#define DDS_ENTITY_NIL 0
|
||||
|
||||
typedef enum dds_entity_kind
|
||||
{
|
||||
DDS_KIND_DONTCARE = 0x00000000,
|
||||
DDS_KIND_TOPIC = 0x01000000,
|
||||
DDS_KIND_PARTICIPANT = 0x02000000,
|
||||
DDS_KIND_READER = 0x03000000,
|
||||
DDS_KIND_WRITER = 0x04000000,
|
||||
DDS_KIND_SUBSCRIBER = 0x05000000,
|
||||
DDS_KIND_PUBLISHER = 0x06000000,
|
||||
DDS_KIND_COND_READ = 0x07000000,
|
||||
DDS_KIND_COND_QUERY = 0x08000000,
|
||||
DDS_KIND_COND_GUARD = 0x09000000,
|
||||
DDS_KIND_WAITSET = 0x0A000000
|
||||
}
|
||||
dds_entity_kind_t;
|
||||
DDS_KIND_DONTCARE,
|
||||
DDS_KIND_TOPIC,
|
||||
DDS_KIND_PARTICIPANT,
|
||||
DDS_KIND_READER,
|
||||
DDS_KIND_WRITER,
|
||||
DDS_KIND_SUBSCRIBER,
|
||||
DDS_KIND_PUBLISHER,
|
||||
DDS_KIND_COND_READ,
|
||||
DDS_KIND_COND_QUERY,
|
||||
DDS_KIND_COND_GUARD,
|
||||
DDS_KIND_WAITSET
|
||||
} dds_entity_kind_t;
|
||||
|
||||
/* Handles are opaque pointers to implementation types */
|
||||
typedef uint64_t dds_instance_handle_t;
|
||||
typedef int32_t dds_domainid_t;
|
||||
typedef uint32_t dds_domainid_t;
|
||||
|
||||
|
||||
/* Topic encoding instruction types */
|
||||
|
||||
#define DDS_OP_RTS 0x00000000
|
||||
#define DDS_OP_ADR 0x01000000
|
||||
#define DDS_OP_JSR 0x02000000
|
||||
#define DDS_OP_JEQ 0x03000000
|
||||
enum dds_stream_opcode {
|
||||
/* return from subroutine, exits top-level
|
||||
[RTS, 0, 0, 0] */
|
||||
DDS_OP_RTS = 0x00 << 24,
|
||||
/* data field
|
||||
[ADR, nBY, 0, k] [offset]
|
||||
[ADR, STR, 0, k] [offset]
|
||||
[ADR, BST, 0, k] [offset] [bound]
|
||||
[ADR, SEQ, nBY, 0] [offset]
|
||||
[ADR, SEQ, STR, 0] [offset]
|
||||
[ADR, SEQ, BST, 0] [offset] [bound]
|
||||
[ADR, SEQ, s, 0] [offset] [elem-size] [next-insn, elem-insn]
|
||||
where s = {SEQ,ARR,UNI,STU}
|
||||
[ADR, ARR, nBY, k] [offset] [alen]
|
||||
[ADR, ARR, STR, 0] [offset] [alen]
|
||||
[ADR, ARR, BST, 0] [offset] [alen] [0] [bound]
|
||||
[ADR, ARR, s, 0] [offset] [alen] [next-insn, elem-insn] [elem-size]
|
||||
where s = {SEQ,ARR,UNI,STU}
|
||||
[ADR, UNI, d, z] [offset] [alen] [next-insn, cases]
|
||||
where
|
||||
d = discriminant type of {1BY,2BY,4BY}
|
||||
z = default present/not present (DDS_OP_FLAG_DEF)
|
||||
offset = discriminant offset
|
||||
followed by alen case labels: in JEQ format
|
||||
note: [ADR, STU, ...] is illegal
|
||||
where
|
||||
s = subtype
|
||||
k = key/not key (DDS_OP_FLAG_KEY)
|
||||
[offset] = field offset from start of element in memory
|
||||
[elem-size] = element size in memory
|
||||
[bound] = string bound + 1
|
||||
[alen] = array length, number of cases
|
||||
[next-insn] = (unsigned 16 bits) offset to instruction for next field, from start of insn
|
||||
[elem-insn] = (unsigned 16 bits) offset to first instruction for element, from start of insn
|
||||
[cases] = (unsigned 16 bits) offset to first case label, from start of insn
|
||||
*/
|
||||
DDS_OP_ADR = 0x01 << 24,
|
||||
/* jump-to-subroutine (apparently not used at the moment)
|
||||
[JSR, 0, e]
|
||||
where
|
||||
e = (signed 16 bits) offset to first instruction in subroutine, from start of insn
|
||||
instruction sequence must end in RTS, execution resumes at instruction
|
||||
following JSR */
|
||||
DDS_OP_JSR = 0x02 << 24,
|
||||
/* union case
|
||||
[JEQ, nBY, 0] [disc] [offset]
|
||||
[JEQ, STR, 0] [disc] [offset]
|
||||
[JEQ, s, e] [disc] [offset]
|
||||
where
|
||||
s = subtype other than {nBY,STR}
|
||||
e = (unsigned 16 bits) offset to first instruction for case, from start of insn
|
||||
instruction sequence must end in RTS, at which point executes continues
|
||||
at the next field's instruction as specified by the union */
|
||||
DDS_OP_JEQ = 0x03 << 24
|
||||
};
|
||||
|
||||
/* Core type flags
|
||||
|
||||
1BY : One byte simple type
|
||||
2BY : Two byte simple type
|
||||
4BY : Four byte simple type
|
||||
8BY : Eight byte simple type
|
||||
STR : String
|
||||
BST : Bounded string
|
||||
SEQ : Sequence
|
||||
ARR : Array
|
||||
UNI : Union
|
||||
STU : Struct
|
||||
*/
|
||||
|
||||
#define DDS_OP_VAL_1BY 0x01
|
||||
#define DDS_OP_VAL_2BY 0x02
|
||||
#define DDS_OP_VAL_4BY 0x03
|
||||
#define DDS_OP_VAL_8BY 0x04
|
||||
#define DDS_OP_VAL_STR 0x05
|
||||
#define DDS_OP_VAL_BST 0x06
|
||||
#define DDS_OP_VAL_SEQ 0x07
|
||||
#define DDS_OP_VAL_ARR 0x08
|
||||
#define DDS_OP_VAL_UNI 0x09
|
||||
#define DDS_OP_VAL_STU 0x0a
|
||||
|
||||
#define DDS_OP_TYPE_1BY (DDS_OP_VAL_1BY << 16)
|
||||
#define DDS_OP_TYPE_2BY (DDS_OP_VAL_2BY << 16)
|
||||
#define DDS_OP_TYPE_4BY (DDS_OP_VAL_4BY << 16)
|
||||
#define DDS_OP_TYPE_8BY (DDS_OP_VAL_8BY << 16)
|
||||
#define DDS_OP_TYPE_STR (DDS_OP_VAL_STR << 16)
|
||||
#define DDS_OP_TYPE_SEQ (DDS_OP_VAL_SEQ << 16)
|
||||
#define DDS_OP_TYPE_ARR (DDS_OP_VAL_ARR << 16)
|
||||
#define DDS_OP_TYPE_UNI (DDS_OP_VAL_UNI << 16)
|
||||
#define DDS_OP_TYPE_STU (DDS_OP_VAL_STU << 16)
|
||||
#define DDS_OP_TYPE_BST (DDS_OP_VAL_BST << 16)
|
||||
enum dds_stream_typecode {
|
||||
DDS_OP_VAL_1BY = 0x01, /* one byte simple type (char, octet, boolean) */
|
||||
DDS_OP_VAL_2BY = 0x02, /* two byte simple type ((unsigned) short) */
|
||||
DDS_OP_VAL_4BY = 0x03, /* four byte simple type ((unsigned) long, enums, float) */
|
||||
DDS_OP_VAL_8BY = 0x04, /* eight byte simple type ((unsigned) long long, double) */
|
||||
DDS_OP_VAL_STR = 0x05, /* string */
|
||||
DDS_OP_VAL_BST = 0x06, /* bounded string */
|
||||
DDS_OP_VAL_SEQ = 0x07, /* sequence */
|
||||
DDS_OP_VAL_ARR = 0x08, /* array */
|
||||
DDS_OP_VAL_UNI = 0x09, /* union */
|
||||
DDS_OP_VAL_STU = 0x0a /* struct */
|
||||
};
|
||||
|
||||
/* primary type code for DDS_OP_ADR, DDS_OP_JEQ */
|
||||
enum dds_stream_typecode_primary {
|
||||
DDS_OP_TYPE_1BY = DDS_OP_VAL_1BY << 16,
|
||||
DDS_OP_TYPE_2BY = DDS_OP_VAL_2BY << 16,
|
||||
DDS_OP_TYPE_4BY = DDS_OP_VAL_4BY << 16,
|
||||
DDS_OP_TYPE_8BY = DDS_OP_VAL_8BY << 16,
|
||||
DDS_OP_TYPE_STR = DDS_OP_VAL_STR << 16,
|
||||
DDS_OP_TYPE_BST = DDS_OP_VAL_BST << 16,
|
||||
DDS_OP_TYPE_SEQ = DDS_OP_VAL_SEQ << 16,
|
||||
DDS_OP_TYPE_ARR = DDS_OP_VAL_ARR << 16,
|
||||
DDS_OP_TYPE_UNI = DDS_OP_VAL_UNI << 16,
|
||||
DDS_OP_TYPE_STU = DDS_OP_VAL_STU << 16
|
||||
};
|
||||
#define DDS_OP_TYPE_BOO DDS_OP_TYPE_1BY
|
||||
|
||||
/* sub-type code:
|
||||
- encodes element type for DDS_OP_TYPE_{SEQ,ARR},
|
||||
- discriminant type for DDS_OP_TYPE_UNI */
|
||||
enum dds_stream_typecode_subtype {
|
||||
DDS_OP_SUBTYPE_1BY = DDS_OP_VAL_1BY << 8,
|
||||
DDS_OP_SUBTYPE_2BY = DDS_OP_VAL_2BY << 8,
|
||||
DDS_OP_SUBTYPE_4BY = DDS_OP_VAL_4BY << 8,
|
||||
DDS_OP_SUBTYPE_8BY = DDS_OP_VAL_8BY << 8,
|
||||
DDS_OP_SUBTYPE_STR = DDS_OP_VAL_STR << 8,
|
||||
DDS_OP_SUBTYPE_BST = DDS_OP_VAL_BST << 8,
|
||||
DDS_OP_SUBTYPE_SEQ = DDS_OP_VAL_SEQ << 8,
|
||||
DDS_OP_SUBTYPE_ARR = DDS_OP_VAL_ARR << 8,
|
||||
DDS_OP_SUBTYPE_UNI = DDS_OP_VAL_UNI << 8,
|
||||
DDS_OP_SUBTYPE_STU = DDS_OP_VAL_STU << 8
|
||||
};
|
||||
#define DDS_OP_SUBTYPE_BOO DDS_OP_SUBTYPE_1BY
|
||||
|
||||
#define DDS_OP_SUBTYPE_1BY (DDS_OP_VAL_1BY << 8)
|
||||
#define DDS_OP_SUBTYPE_2BY (DDS_OP_VAL_2BY << 8)
|
||||
#define DDS_OP_SUBTYPE_4BY (DDS_OP_VAL_4BY << 8)
|
||||
#define DDS_OP_SUBTYPE_8BY (DDS_OP_VAL_8BY << 8)
|
||||
#define DDS_OP_SUBTYPE_STR (DDS_OP_VAL_STR << 8)
|
||||
#define DDS_OP_SUBTYPE_SEQ (DDS_OP_VAL_SEQ << 8)
|
||||
#define DDS_OP_SUBTYPE_ARR (DDS_OP_VAL_ARR << 8)
|
||||
#define DDS_OP_SUBTYPE_UNI (DDS_OP_VAL_UNI << 8)
|
||||
#define DDS_OP_SUBTYPE_STU (DDS_OP_VAL_STU << 8)
|
||||
#define DDS_OP_SUBTYPE_BST (DDS_OP_VAL_BST << 8)
|
||||
|
||||
#define DDS_OP_FLAG_KEY 0x01
|
||||
#define DDS_OP_FLAG_DEF 0x02
|
||||
#define DDS_OP_FLAG_KEY 0x01 /* key field: applicable to {1,2,4,8}BY, STR, BST, ARR-of-{1,2,4,8}BY */
|
||||
#define DDS_OP_FLAG_DEF 0x02 /* union has a default case (for DDS_OP_ADR | DDS_OP_TYPE_UNI) */
|
||||
|
||||
/**
|
||||
* Description : Enable or disable write batching. Overrides default configuration
|
||||
* setting for write batching (DDSI2E/Internal/WriteBatch).
|
||||
* setting for write batching (Internal/WriteBatch).
|
||||
*
|
||||
* Arguments :
|
||||
* -# enable Enables or disables write batching for all writers.
|
||||
*/
|
||||
DDS_EXPORT void dds_write_set_batch (bool enable);
|
||||
|
||||
/**
|
||||
* Description : Install tcp/ssl and encryption support. Depends on openssl.
|
||||
*
|
||||
* Arguments :
|
||||
* -# None
|
||||
*/
|
||||
DDS_EXPORT void dds_ssl_plugin (void);
|
||||
|
||||
/**
|
||||
* Description : Install client durability support. Depends on OSPL server.
|
||||
*
|
||||
* Arguments :
|
||||
* -# None
|
||||
*/
|
||||
DDS_EXPORT void dds_durability_plugin (void);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -21,131 +21,12 @@
|
|||
#define DDS_QOS_H
|
||||
|
||||
#include "dds/export.h"
|
||||
#include "dds/ddsc/dds_public_qosdefs.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* QoS identifiers */
|
||||
/** @name QoS identifiers
|
||||
@{**/
|
||||
#define DDS_INVALID_QOS_POLICY_ID 0
|
||||
#define DDS_USERDATA_QOS_POLICY_ID 1
|
||||
#define DDS_DURABILITY_QOS_POLICY_ID 2
|
||||
#define DDS_PRESENTATION_QOS_POLICY_ID 3
|
||||
#define DDS_DEADLINE_QOS_POLICY_ID 4
|
||||
#define DDS_LATENCYBUDGET_QOS_POLICY_ID 5
|
||||
#define DDS_OWNERSHIP_QOS_POLICY_ID 6
|
||||
#define DDS_OWNERSHIPSTRENGTH_QOS_POLICY_ID 7
|
||||
#define DDS_LIVELINESS_QOS_POLICY_ID 8
|
||||
#define DDS_TIMEBASEDFILTER_QOS_POLICY_ID 9
|
||||
#define DDS_PARTITION_QOS_POLICY_ID 10
|
||||
#define DDS_RELIABILITY_QOS_POLICY_ID 11
|
||||
#define DDS_DESTINATIONORDER_QOS_POLICY_ID 12
|
||||
#define DDS_HISTORY_QOS_POLICY_ID 13
|
||||
#define DDS_RESOURCELIMITS_QOS_POLICY_ID 14
|
||||
#define DDS_ENTITYFACTORY_QOS_POLICY_ID 15
|
||||
#define DDS_WRITERDATALIFECYCLE_QOS_POLICY_ID 16
|
||||
#define DDS_READERDATALIFECYCLE_QOS_POLICY_ID 17
|
||||
#define DDS_TOPICDATA_QOS_POLICY_ID 18
|
||||
#define DDS_GROUPDATA_QOS_POLICY_ID 19
|
||||
#define DDS_TRANSPORTPRIORITY_QOS_POLICY_ID 20
|
||||
#define DDS_LIFESPAN_QOS_POLICY_ID 21
|
||||
#define DDS_DURABILITYSERVICE_QOS_POLICY_ID 22
|
||||
/** @}*/
|
||||
|
||||
|
||||
/* QoS structure is opaque */
|
||||
/** QoS structure */
|
||||
typedef struct nn_xqos dds_qos_t;
|
||||
|
||||
/** Durability QoS: Applies to Topic, DataReader, DataWriter */
|
||||
typedef enum dds_durability_kind
|
||||
{
|
||||
DDS_DURABILITY_VOLATILE,
|
||||
DDS_DURABILITY_TRANSIENT_LOCAL,
|
||||
DDS_DURABILITY_TRANSIENT,
|
||||
DDS_DURABILITY_PERSISTENT
|
||||
}
|
||||
dds_durability_kind_t;
|
||||
|
||||
/** History QoS: Applies to Topic, DataReader, DataWriter */
|
||||
typedef enum dds_history_kind
|
||||
{
|
||||
DDS_HISTORY_KEEP_LAST,
|
||||
DDS_HISTORY_KEEP_ALL
|
||||
}
|
||||
dds_history_kind_t;
|
||||
|
||||
/** Ownership QoS: Applies to Topic, DataReader, DataWriter */
|
||||
typedef enum dds_ownership_kind
|
||||
{
|
||||
DDS_OWNERSHIP_SHARED,
|
||||
DDS_OWNERSHIP_EXCLUSIVE
|
||||
}
|
||||
dds_ownership_kind_t;
|
||||
|
||||
/** Liveliness QoS: Applies to Topic, DataReader, DataWriter */
|
||||
typedef enum dds_liveliness_kind
|
||||
{
|
||||
DDS_LIVELINESS_AUTOMATIC,
|
||||
DDS_LIVELINESS_MANUAL_BY_PARTICIPANT,
|
||||
DDS_LIVELINESS_MANUAL_BY_TOPIC
|
||||
}
|
||||
dds_liveliness_kind_t;
|
||||
|
||||
/** Reliability QoS: Applies to Topic, DataReader, DataWriter */
|
||||
typedef enum dds_reliability_kind
|
||||
{
|
||||
DDS_RELIABILITY_BEST_EFFORT,
|
||||
DDS_RELIABILITY_RELIABLE
|
||||
}
|
||||
dds_reliability_kind_t;
|
||||
|
||||
/** DestinationOrder QoS: Applies to Topic, DataReader, DataWriter */
|
||||
typedef enum dds_destination_order_kind
|
||||
{
|
||||
DDS_DESTINATIONORDER_BY_RECEPTION_TIMESTAMP,
|
||||
DDS_DESTINATIONORDER_BY_SOURCE_TIMESTAMP
|
||||
}
|
||||
dds_destination_order_kind_t;
|
||||
|
||||
/** History QoS: Applies to Topic, DataReader, DataWriter */
|
||||
typedef struct dds_history_qospolicy
|
||||
{
|
||||
dds_history_kind_t kind;
|
||||
int32_t depth;
|
||||
}
|
||||
dds_history_qospolicy_t;
|
||||
|
||||
/** ResourceLimits QoS: Applies to Topic, DataReader, DataWriter */
|
||||
typedef struct dds_resource_limits_qospolicy
|
||||
{
|
||||
int32_t max_samples;
|
||||
int32_t max_instances;
|
||||
int32_t max_samples_per_instance;
|
||||
}
|
||||
dds_resource_limits_qospolicy_t;
|
||||
|
||||
/** Presentation QoS: Applies to Publisher, Subscriber */
|
||||
typedef enum dds_presentation_access_scope_kind
|
||||
{
|
||||
DDS_PRESENTATION_INSTANCE,
|
||||
DDS_PRESENTATION_TOPIC,
|
||||
DDS_PRESENTATION_GROUP
|
||||
}
|
||||
dds_presentation_access_scope_kind_t;
|
||||
|
||||
/** Ignore-local QoS: Applies to DataReader, DataWriter */
|
||||
typedef enum dds_ignorelocal_kind
|
||||
{
|
||||
DDS_IGNORELOCAL_NONE,
|
||||
DDS_IGNORELOCAL_PARTICIPANT,
|
||||
DDS_IGNORELOCAL_PROCESS
|
||||
}
|
||||
dds_ignorelocal_kind_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Allocate memory and initialize default QoS-policies
|
||||
*
|
||||
|
|
@ -212,8 +93,8 @@ dds_qos_merge (dds_qos_t * __restrict dst, const dds_qos_t * __restrict src);
|
|||
*
|
||||
* Policies are copied from src to dst, unless src already has the policy set to a non-default value.
|
||||
*
|
||||
* @param[in,out] dst - Pointer to the destination qos structure
|
||||
* @param[in] src - Pointer to the source qos structure
|
||||
* @param[in,out] a - Pointer to the destination qos structure
|
||||
* @param[in] b - Pointer to the source qos structure
|
||||
*/
|
||||
DDS_EXPORT bool
|
||||
dds_qos_equal (const dds_qos_t * __restrict a, const dds_qos_t * __restrict b);
|
||||
|
|
@ -448,7 +329,7 @@ dds_qset_destination_order (
|
|||
* @brief Set the writer data-lifecycle policy of a qos structure
|
||||
*
|
||||
* @param[in,out] qos - Pointer to a dds_qos_t structure that will store the policy
|
||||
* @param[in] autodispose_unregistered_instances - Automatic disposal of unregistered instances
|
||||
* @param[in] autodispose - Automatic disposal of unregistered instances
|
||||
*/
|
||||
DDS_EXPORT void
|
||||
dds_qset_writer_data_lifecycle (dds_qos_t * __restrict qos, bool autodispose);
|
||||
|
|
@ -493,7 +374,8 @@ dds_qset_durability_service (
|
|||
* @param[in,out] qos - Pointer to a dds_qos_t structure that will store the policy
|
||||
* @param[in] ignore - True if readers and writers owned by the same participant should be ignored
|
||||
*/
|
||||
DDS_EXPORT void dds_qset_ignorelocal (
|
||||
DDS_EXPORT void
|
||||
dds_qset_ignorelocal (
|
||||
dds_qos_t * __restrict qos,
|
||||
dds_ignorelocal_kind_t ignore);
|
||||
|
||||
|
|
@ -738,7 +620,7 @@ dds_qget_destination_order (
|
|||
* @brief Get the writer data-lifecycle qos policy
|
||||
*
|
||||
* @param[in] qos - Pointer to a dds_qos_t structure storing the policy
|
||||
* @param[in,out] autodispose_unregistered_instances - Pointer that will store the autodispose unregistered instances enable value
|
||||
* @param[in,out] autodispose - Pointer that will store the autodispose unregistered instances enable value
|
||||
*
|
||||
* @returns - false iff any of the arguments is invalid or the qos is not present in the qos object
|
||||
*/
|
||||
|
|
|
|||
132
src/core/ddsc/include/dds/ddsc/dds_public_qosdefs.h
Normal file
132
src/core/ddsc/include/dds/ddsc/dds_public_qosdefs.h
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
* 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 QoS API
|
||||
*
|
||||
* This header file defines the public API of QoS and Policies in the
|
||||
* Eclipse Cyclone DDS C language binding.
|
||||
*/
|
||||
#ifndef DDS_QOSDEFS_H
|
||||
#define DDS_QOSDEFS_H
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DDS_LENGTH_UNLIMITED -1
|
||||
|
||||
/** QoS identifiers */
|
||||
typedef enum dds_qos_policy_id {
|
||||
DDS_INVALID_QOS_POLICY_ID,
|
||||
DDS_USERDATA_QOS_POLICY_ID,
|
||||
DDS_DURABILITY_QOS_POLICY_ID,
|
||||
DDS_PRESENTATION_QOS_POLICY_ID,
|
||||
DDS_DEADLINE_QOS_POLICY_ID,
|
||||
DDS_LATENCYBUDGET_QOS_POLICY_ID,
|
||||
DDS_OWNERSHIP_QOS_POLICY_ID,
|
||||
DDS_OWNERSHIPSTRENGTH_QOS_POLICY_ID,
|
||||
DDS_LIVELINESS_QOS_POLICY_ID,
|
||||
DDS_TIMEBASEDFILTER_QOS_POLICY_ID,
|
||||
DDS_PARTITION_QOS_POLICY_ID,
|
||||
DDS_RELIABILITY_QOS_POLICY_ID,
|
||||
DDS_DESTINATIONORDER_QOS_POLICY_ID,
|
||||
DDS_HISTORY_QOS_POLICY_ID,
|
||||
DDS_RESOURCELIMITS_QOS_POLICY_ID,
|
||||
DDS_ENTITYFACTORY_QOS_POLICY_ID,
|
||||
DDS_WRITERDATALIFECYCLE_QOS_POLICY_ID,
|
||||
DDS_READERDATALIFECYCLE_QOS_POLICY_ID,
|
||||
DDS_TOPICDATA_QOS_POLICY_ID,
|
||||
DDS_GROUPDATA_QOS_POLICY_ID,
|
||||
DDS_TRANSPORTPRIORITY_QOS_POLICY_ID,
|
||||
DDS_LIFESPAN_QOS_POLICY_ID,
|
||||
DDS_DURABILITYSERVICE_QOS_POLICY_ID
|
||||
} dds_qos_policy_id_t;
|
||||
|
||||
/* QoS structure is opaque */
|
||||
/** QoS structure */
|
||||
typedef struct dds_qos dds_qos_t;
|
||||
|
||||
/** Durability QoS: Applies to Topic, DataReader, DataWriter */
|
||||
typedef enum dds_durability_kind
|
||||
{
|
||||
DDS_DURABILITY_VOLATILE,
|
||||
DDS_DURABILITY_TRANSIENT_LOCAL,
|
||||
DDS_DURABILITY_TRANSIENT,
|
||||
DDS_DURABILITY_PERSISTENT
|
||||
}
|
||||
dds_durability_kind_t;
|
||||
|
||||
/** History QoS: Applies to Topic, DataReader, DataWriter */
|
||||
typedef enum dds_history_kind
|
||||
{
|
||||
DDS_HISTORY_KEEP_LAST,
|
||||
DDS_HISTORY_KEEP_ALL
|
||||
}
|
||||
dds_history_kind_t;
|
||||
|
||||
/** Ownership QoS: Applies to Topic, DataReader, DataWriter */
|
||||
typedef enum dds_ownership_kind
|
||||
{
|
||||
DDS_OWNERSHIP_SHARED,
|
||||
DDS_OWNERSHIP_EXCLUSIVE
|
||||
}
|
||||
dds_ownership_kind_t;
|
||||
|
||||
/** Liveliness QoS: Applies to Topic, DataReader, DataWriter */
|
||||
typedef enum dds_liveliness_kind
|
||||
{
|
||||
DDS_LIVELINESS_AUTOMATIC,
|
||||
DDS_LIVELINESS_MANUAL_BY_PARTICIPANT,
|
||||
DDS_LIVELINESS_MANUAL_BY_TOPIC
|
||||
}
|
||||
dds_liveliness_kind_t;
|
||||
|
||||
/** Reliability QoS: Applies to Topic, DataReader, DataWriter */
|
||||
typedef enum dds_reliability_kind
|
||||
{
|
||||
DDS_RELIABILITY_BEST_EFFORT,
|
||||
DDS_RELIABILITY_RELIABLE
|
||||
}
|
||||
dds_reliability_kind_t;
|
||||
|
||||
/** DestinationOrder QoS: Applies to Topic, DataReader, DataWriter */
|
||||
typedef enum dds_destination_order_kind
|
||||
{
|
||||
DDS_DESTINATIONORDER_BY_RECEPTION_TIMESTAMP,
|
||||
DDS_DESTINATIONORDER_BY_SOURCE_TIMESTAMP
|
||||
}
|
||||
dds_destination_order_kind_t;
|
||||
|
||||
/** Presentation QoS: Applies to Publisher, Subscriber */
|
||||
typedef enum dds_presentation_access_scope_kind
|
||||
{
|
||||
DDS_PRESENTATION_INSTANCE,
|
||||
DDS_PRESENTATION_TOPIC,
|
||||
DDS_PRESENTATION_GROUP
|
||||
}
|
||||
dds_presentation_access_scope_kind_t;
|
||||
|
||||
/** Ignore-local QoS: Applies to DataReader, DataWriter */
|
||||
typedef enum dds_ignorelocal_kind
|
||||
{
|
||||
DDS_IGNORELOCAL_NONE,
|
||||
DDS_IGNORELOCAL_PARTICIPANT,
|
||||
DDS_IGNORELOCAL_PROCESS
|
||||
}
|
||||
dds_ignorelocal_kind_t;
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -185,7 +185,7 @@ dds_inconsistent_topic_status_t;
|
|||
* @param[out] status The pointer to \ref DCPS_Status_InconsistentTopic to get the status
|
||||
*
|
||||
* @returns 0 - Success
|
||||
* @returns <0 - Failure (use dds_err_nr() to get error value).
|
||||
* @returns <0 - Failure
|
||||
*
|
||||
* @retval DDS_RETCODE_ERROR
|
||||
* An internal error has occurred.
|
||||
|
|
@ -212,7 +212,7 @@ dds_get_inconsistent_topic_status (
|
|||
* @param[out] status The pointer to \ref DCPS_Status_PublicationMatched to get the status
|
||||
*
|
||||
* @returns 0 - Success
|
||||
* @returns <0 - Failure (use dds_err_nr() to get error value).
|
||||
* @returns <0 - Failure
|
||||
*
|
||||
* @retval DDS_RETCODE_ERROR
|
||||
* An internal error has occurred.
|
||||
|
|
@ -239,7 +239,7 @@ dds_get_publication_matched_status (
|
|||
* @param[out] status The pointer to \ref DCPS_Status_LivelinessLost to get the status
|
||||
*
|
||||
* @returns 0 - Success
|
||||
* @returns <0 - Failure (use dds_err_nr() to get error value).
|
||||
* @returns <0 - Failure
|
||||
*
|
||||
* @retval DDS_RETCODE_ERROR
|
||||
* An internal error has occurred.
|
||||
|
|
@ -266,7 +266,7 @@ dds_get_liveliness_lost_status (
|
|||
* @param[out] status The pointer to \ref DCPS_Status_OfferedDeadlineMissed to get the status
|
||||
*
|
||||
* @returns 0 - Success
|
||||
* @returns <0 - Failure (use dds_err_nr() to get error value).
|
||||
* @returns <0 - Failure
|
||||
*
|
||||
* @retval DDS_RETCODE_ERROR
|
||||
* An internal error has occurred.
|
||||
|
|
@ -293,7 +293,7 @@ dds_get_offered_deadline_missed_status(
|
|||
* @param[out] status The pointer to \ref DCPS_Status_OfferedIncompatibleQoS to get the status
|
||||
*
|
||||
* @returns 0 - Success
|
||||
* @returns <0 - Failure (use dds_err_nr() to get error value).
|
||||
* @returns <0 - Failure
|
||||
*
|
||||
* @retval DDS_RETCODE_ERROR
|
||||
* An internal error has occurred.
|
||||
|
|
@ -320,7 +320,7 @@ dds_get_offered_incompatible_qos_status (
|
|||
* @param[out] status The pointer to \ref DCPS_Status_SubscriptionMatched to get the status
|
||||
*
|
||||
* @returns 0 - Success
|
||||
* @returns <0 - Failure (use dds_err_nr() to get error value).
|
||||
* @returns <0 - Failure
|
||||
*
|
||||
* @retval DDS_RETCODE_ERROR
|
||||
* An internal error has occurred.
|
||||
|
|
@ -347,7 +347,7 @@ dds_get_subscription_matched_status (
|
|||
* @param[out] status The pointer to \ref DCPS_Status_LivelinessChanged to get the status
|
||||
*
|
||||
* @returns 0 - Success
|
||||
* @returns <0 - Failure (use dds_err_nr() to get error value).
|
||||
* @returns <0 - Failure
|
||||
*
|
||||
* @retval DDS_RETCODE_ERROR
|
||||
* An internal error has occurred.
|
||||
|
|
@ -374,7 +374,7 @@ dds_get_liveliness_changed_status (
|
|||
* @param[out] status The pointer to \ref DCPS_Status_SampleRejected to get the status
|
||||
*
|
||||
* @returns 0 - Success
|
||||
* @returns <0 - Failure (use dds_err_nr() to get error value).
|
||||
* @returns <0 - Failure
|
||||
*
|
||||
* @retval DDS_RETCODE_ERROR
|
||||
* An internal error has occurred.
|
||||
|
|
|
|||
|
|
@ -1,108 +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
|
||||
*/
|
||||
|
||||
/** @file
|
||||
*
|
||||
* @brief DDS C Stream API
|
||||
*
|
||||
* This header file defines the public API of the Streams in the
|
||||
* Eclipse Cyclone DDS C language binding.
|
||||
*/
|
||||
#ifndef DDS_STREAM_H
|
||||
#define DDS_STREAM_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "dds/export.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct dds_sequence;
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint8_t * p8;
|
||||
uint16_t * p16;
|
||||
uint32_t * p32;
|
||||
uint64_t * p64;
|
||||
float * pf;
|
||||
double * pd;
|
||||
void * pv;
|
||||
}
|
||||
dds_uptr_t;
|
||||
|
||||
typedef struct dds_stream
|
||||
{
|
||||
dds_uptr_t m_buffer; /* Union of pointers to start of buffer */
|
||||
uint32_t m_size; /* Buffer size */
|
||||
uint32_t m_index; /* Read/write offset from start of buffer */
|
||||
bool m_endian; /* Endian: big (false) or little (true) */
|
||||
bool m_failed; /* Attempt made to read beyond end of buffer */
|
||||
}
|
||||
dds_stream_t;
|
||||
|
||||
#define DDS_STREAM_BE false
|
||||
#define DDS_STREAM_LE true
|
||||
|
||||
DDS_EXPORT dds_stream_t * dds_stream_create (uint32_t size);
|
||||
DDS_EXPORT dds_stream_t * dds_stream_from_buffer (const void *buf, size_t sz, int bswap);
|
||||
DDS_EXPORT void dds_stream_delete (dds_stream_t * st);
|
||||
DDS_EXPORT void dds_stream_fini (dds_stream_t * st);
|
||||
DDS_EXPORT void dds_stream_reset (dds_stream_t * st);
|
||||
DDS_EXPORT void dds_stream_init (dds_stream_t * st, uint32_t size);
|
||||
DDS_EXPORT void dds_stream_grow (dds_stream_t * st, uint32_t size);
|
||||
DDS_EXPORT bool dds_stream_endian (void);
|
||||
|
||||
struct dds_topic_descriptor;
|
||||
DDS_EXPORT void dds_stream_read_sample_w_desc (dds_stream_t * is, void * data, const struct dds_topic_descriptor * desc);
|
||||
DDS_EXPORT bool dds_stream_read_bool (dds_stream_t * is);
|
||||
DDS_EXPORT uint8_t dds_stream_read_uint8 (dds_stream_t * is);
|
||||
DDS_EXPORT uint16_t dds_stream_read_uint16 (dds_stream_t * is);
|
||||
DDS_EXPORT uint32_t dds_stream_read_uint32 (dds_stream_t * is);
|
||||
DDS_EXPORT uint64_t dds_stream_read_uint64 (dds_stream_t * is);
|
||||
DDS_EXPORT float dds_stream_read_float (dds_stream_t * is);
|
||||
DDS_EXPORT double dds_stream_read_double (dds_stream_t * is);
|
||||
DDS_EXPORT char * dds_stream_read_string (dds_stream_t * is);
|
||||
DDS_EXPORT void dds_stream_read_buffer (dds_stream_t * is, uint8_t * buffer, uint32_t len);
|
||||
|
||||
inline char dds_stream_read_char (dds_stream_t *is) { return (char) dds_stream_read_uint8 (is); }
|
||||
inline int8_t dds_stream_read_int8 (dds_stream_t *is) { return (int8_t) dds_stream_read_uint8 (is); }
|
||||
inline int16_t dds_stream_read_int16 (dds_stream_t *is) { return (int16_t) dds_stream_read_uint16 (is); }
|
||||
inline int32_t dds_stream_read_int32 (dds_stream_t *is) { return (int32_t) dds_stream_read_uint32 (is); }
|
||||
inline int64_t dds_stream_read_int64 (dds_stream_t *is) { return (int64_t) dds_stream_read_uint64 (is); }
|
||||
|
||||
DDS_EXPORT void dds_stream_write_bool (dds_stream_t * os, bool val);
|
||||
DDS_EXPORT void dds_stream_write_uint8 (dds_stream_t * os, uint8_t val);
|
||||
DDS_EXPORT void dds_stream_write_uint16 (dds_stream_t * os, uint16_t val);
|
||||
DDS_EXPORT void dds_stream_write_uint32 (dds_stream_t * os, uint32_t val);
|
||||
DDS_EXPORT void dds_stream_write_uint64 (dds_stream_t * os, uint64_t val);
|
||||
DDS_EXPORT void dds_stream_write_float (dds_stream_t * os, float val);
|
||||
DDS_EXPORT void dds_stream_write_double (dds_stream_t * os, double val);
|
||||
DDS_EXPORT void dds_stream_write_string (dds_stream_t * os, const char * val);
|
||||
DDS_EXPORT void dds_stream_write_buffer (dds_stream_t * os, uint32_t len, const uint8_t * buffer);
|
||||
DDS_EXPORT void *dds_stream_address (dds_stream_t * s);
|
||||
DDS_EXPORT void *dds_stream_alignto (dds_stream_t * s, uint32_t a);
|
||||
|
||||
inline void dds_stream_write_char (dds_stream_t * os, char val) { dds_stream_write_uint8 (os, (uint8_t) val); }
|
||||
inline void dds_stream_write_int8 (dds_stream_t * os, int8_t val) { dds_stream_write_uint8 (os, (uint8_t) val); }
|
||||
inline void dds_stream_write_int16 (dds_stream_t * os, int16_t val) { dds_stream_write_uint16 (os, (uint16_t) val); }
|
||||
inline void dds_stream_write_int32 (dds_stream_t * os, int32_t val) { dds_stream_write_uint32 (os, (uint32_t) val); }
|
||||
inline void dds_stream_write_int64 (dds_stream_t * os, int64_t val) { dds_stream_write_uint64 (os, (uint64_t) val); }
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
#ifndef _DDS_BUILTIN_H_
|
||||
#define _DDS_BUILTIN_H_
|
||||
|
||||
#include "dds/ddsi/q_time.h"
|
||||
#include "dds/ddsi/ddsi_builtin_topic_if.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C"
|
||||
|
|
@ -20,24 +20,19 @@ extern "C"
|
|||
#endif
|
||||
|
||||
/* Get actual topic in related participant related to topic 'id'. */
|
||||
dds_entity_t dds__get_builtin_topic ( dds_entity_t e, dds_entity_t topic);
|
||||
dds_entity_t dds__get_builtin_topic (dds_entity_t e, dds_entity_t topic);
|
||||
|
||||
/* Subscriber singleton within related participant. */
|
||||
dds_entity_t dds__get_builtin_subscriber(dds_entity_t e);
|
||||
dds_entity_t dds__get_builtin_subscriber (dds_entity_t e);
|
||||
|
||||
/* Checks whether the reader QoS is valid for use with built-in topic TOPIC */
|
||||
bool dds__validate_builtin_reader_qos(dds_entity_t topic, const dds_qos_t *qos);
|
||||
bool dds__validate_builtin_reader_qos (const dds_domain *dom, dds_entity_t topic, const dds_qos_t *qos);
|
||||
|
||||
void dds__builtin_init (struct dds_domain *dom);
|
||||
void dds__builtin_fini (struct dds_domain *dom);
|
||||
|
||||
struct entity_common;
|
||||
struct nn_guid;
|
||||
struct ddsi_tkmap_instance;
|
||||
|
||||
void dds__builtin_init (void);
|
||||
void dds__builtin_fini (void);
|
||||
bool dds__builtin_is_visible (nn_entityid_t entityid, bool onlylocal, nn_vendorid_t vendorid);
|
||||
struct ddsi_tkmap_instance *dds__builtin_get_tkmap_entry (const struct nn_guid *guid);
|
||||
struct ddsi_serdata *dds__builtin_make_sample (const struct entity_common *e, nn_wctime_t timestamp, bool alive);
|
||||
void dds__builtin_write (const struct entity_common *e, nn_wctime_t timestamp, bool alive);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,11 +18,9 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern DDS_EXPORT const ddsrt_avl_treedef_t dds_domaintree_def;
|
||||
|
||||
DDS_EXPORT dds_domain * dds_domain_create (dds_domainid_t id);
|
||||
DDS_EXPORT void dds_domain_free (dds_domain * domain);
|
||||
DDS_EXPORT dds_domain * dds_domain_find_locked (dds_domainid_t id);
|
||||
DDS_EXPORT dds_return_t dds_domain_create (dds_domain **domain_out, dds_domainid_t id);
|
||||
DDS_EXPORT void dds_domain_free (dds_domain *domain);
|
||||
DDS_EXPORT dds_domain *dds_domain_find_locked (dds_domainid_t id);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,20 +26,22 @@ dds_entity_init(
|
|||
dds_entity_kind_t kind,
|
||||
dds_qos_t * qos,
|
||||
const dds_listener_t *listener,
|
||||
uint32_t mask);
|
||||
status_mask_t mask);
|
||||
|
||||
DDS_EXPORT void
|
||||
dds_entity_add_ref(dds_entity *e);
|
||||
dds_entity_register_child (
|
||||
dds_entity *parent,
|
||||
dds_entity *child);
|
||||
|
||||
DDS_EXPORT void
|
||||
dds_entity_add_ref_nolock(dds_entity *e);
|
||||
dds_entity_add_ref_locked(dds_entity *e);
|
||||
|
||||
#define DEFINE_ENTITY_LOCK_UNLOCK(qualifier_, type_, kind_) \
|
||||
qualifier_ dds_retcode_t type_##_lock (dds_entity_t hdl, type_ **x) \
|
||||
qualifier_ dds_return_t type_##_lock (dds_entity_t hdl, type_ **x) \
|
||||
{ \
|
||||
dds_retcode_t rc; \
|
||||
dds_return_t rc; \
|
||||
dds_entity *e; \
|
||||
if ((rc = dds_entity_lock (hdl, kind_, &e)) != DDS_RETCODE_OK) \
|
||||
if ((rc = dds_entity_lock (hdl, kind_, &e)) < 0) \
|
||||
return rc; \
|
||||
*x = (type_ *) e; \
|
||||
return DDS_RETCODE_OK; \
|
||||
|
|
@ -50,7 +52,7 @@ dds_entity_add_ref_nolock(dds_entity *e);
|
|||
dds_entity_unlock (&x->m_entity); \
|
||||
}
|
||||
#define DECL_ENTITY_LOCK_UNLOCK(qualifier_, type_) \
|
||||
qualifier_ dds_retcode_t type_##_lock (dds_entity_t hdl, type_ **x); \
|
||||
qualifier_ dds_return_t type_##_lock (dds_entity_t hdl, type_ **x); \
|
||||
qualifier_ void type_##_unlock (type_ *x);
|
||||
|
||||
DDS_EXPORT inline dds_entity *dds_entity_from_handle_link (struct dds_handle_link *hdllink) {
|
||||
|
|
@ -61,33 +63,30 @@ DDS_EXPORT inline bool dds_entity_is_enabled (const dds_entity *e) {
|
|||
return (e->m_flags & DDS_ENTITY_ENABLED) != 0;
|
||||
}
|
||||
|
||||
DDS_EXPORT void dds_entity_status_set (dds_entity *e, uint32_t t);
|
||||
DDS_EXPORT void dds_entity_status_set (dds_entity *e, status_mask_t t);
|
||||
DDS_EXPORT void dds_entity_trigger_set (dds_entity *e, uint32_t t);
|
||||
|
||||
DDS_EXPORT inline void dds_entity_status_reset (dds_entity *e, uint32_t t) {
|
||||
e->m_trigger &= ~t;
|
||||
}
|
||||
|
||||
DDS_EXPORT inline bool dds_entity_status_match (const dds_entity *e, uint32_t t) {
|
||||
return (e->m_trigger & t) != 0;
|
||||
DDS_EXPORT inline void dds_entity_status_reset (dds_entity *e, status_mask_t t) {
|
||||
ddsrt_atomic_and32 (&e->m_status.m_status_and_mask, SAM_ENABLED_MASK | (status_mask_t) ~t);
|
||||
}
|
||||
|
||||
DDS_EXPORT inline dds_entity_kind_t dds_entity_kind (const dds_entity *e) {
|
||||
return e->m_kind;
|
||||
}
|
||||
|
||||
DDS_EXPORT void dds_entity_status_signal (dds_entity *e);
|
||||
DDS_EXPORT void dds_entity_status_signal (dds_entity *e, uint32_t status);
|
||||
|
||||
DDS_EXPORT void dds_entity_invoke_listener (const dds_entity *entity, enum dds_status_id which, const void *vst);
|
||||
|
||||
DDS_EXPORT dds_retcode_t
|
||||
dds_entity_claim (
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_entity_pin (
|
||||
dds_entity_t hdl,
|
||||
dds_entity **eptr);
|
||||
|
||||
DDS_EXPORT void dds_entity_release (
|
||||
DDS_EXPORT void dds_entity_unpin (
|
||||
dds_entity *e);
|
||||
|
||||
DDS_EXPORT dds_retcode_t
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_entity_lock(
|
||||
dds_entity_t hdl,
|
||||
dds_entity_kind_t kind,
|
||||
|
|
@ -96,27 +95,17 @@ dds_entity_lock(
|
|||
DDS_EXPORT void
|
||||
dds_entity_unlock(dds_entity *e);
|
||||
|
||||
DDS_EXPORT dds_retcode_t
|
||||
dds_entity_observer_register_nl(
|
||||
dds_entity *observed,
|
||||
dds_entity_t observer,
|
||||
dds_entity_callback cb);
|
||||
|
||||
DDS_EXPORT dds_retcode_t
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_entity_observer_register(
|
||||
dds_entity_t observed,
|
||||
dds_entity_t observer,
|
||||
dds_entity_callback cb);
|
||||
|
||||
DDS_EXPORT dds_retcode_t
|
||||
dds_entity_observer_unregister_nl(
|
||||
dds_entity *observed,
|
||||
dds_entity_t observer);
|
||||
dds_entity *observer,
|
||||
dds_entity_callback cb,
|
||||
dds_entity_delete_callback delete_cb);
|
||||
|
||||
DDS_EXPORT dds_retcode_t
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_entity_observer_unregister(
|
||||
dds_entity_t observed,
|
||||
dds_entity_t observer);
|
||||
dds_entity *observed,
|
||||
dds_entity *observer);
|
||||
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_delete_impl(
|
||||
|
|
|
|||
56
src/core/ddsc/src/dds__get_status.h
Normal file
56
src/core/ddsc/src/dds__get_status.h
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright(c) 2019 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_GET_STATUS_H_
|
||||
#define _DDS_GET_STATUS_H_
|
||||
|
||||
#include "dds/ddsrt/countargs.h"
|
||||
|
||||
#define DDS_GET_STATUS_LOCKED_RESET_1(status_, reset0_) \
|
||||
(ent->m_##status_##_status.reset0_ = 0);
|
||||
#define DDS_GET_STATUS_LOCKED_RESET_2(status_, reset0_, reset1_) \
|
||||
(ent->m_##status_##_status.reset0_ = 0); \
|
||||
(ent->m_##status_##_status.reset1_ = 0);
|
||||
#define DDS_GET_STATUS_LOCKED_RESET_MSVC_WORKAROUND(x) x
|
||||
#define DDS_GET_STATUS_LOCKED_RESET_N1(n_, status_, ...) \
|
||||
DDS_GET_STATUS_LOCKED_RESET_MSVC_WORKAROUND (DDS_GET_STATUS_LOCKED_RESET_##n_ (status_, __VA_ARGS__))
|
||||
#define DDS_GET_STATUS_LOCKED_RESET_N(n_, status_, ...) DDS_GET_STATUS_LOCKED_RESET_N1 (n_, status_, __VA_ARGS__)
|
||||
|
||||
#define DDS_GET_STATUS_LOCKED(ent_type_, status_, STATUS_, ...) \
|
||||
static void dds_get_##status_##_status_locked (dds_##ent_type_ *ent, dds_##status_##_status_t *status) \
|
||||
{ \
|
||||
if (status) \
|
||||
*status = ent->m_##status_##_status; \
|
||||
if (ddsrt_atomic_ld32 (&ent->m_entity.m_status.m_status_and_mask) & (DDS_##STATUS_##_STATUS << SAM_ENABLED_SHIFT)) { \
|
||||
do { DDS_GET_STATUS_LOCKED_RESET_N (DDSRT_COUNT_ARGS (__VA_ARGS__), status_, __VA_ARGS__) } while (0); \
|
||||
dds_entity_status_reset (&ent->m_entity, DDS_##STATUS_##_STATUS); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define DDS_GET_STATUS_COMMON(ent_type_, status_) \
|
||||
dds_return_t dds_get_##status_##_status (dds_entity_t entity, dds_##status_##_status_t *status) \
|
||||
{ \
|
||||
dds_##ent_type_ *ent; \
|
||||
dds_return_t ret; \
|
||||
if ((ret = dds_##ent_type_##_lock (entity, &ent)) != DDS_RETCODE_OK) \
|
||||
return ret; \
|
||||
ddsrt_mutex_lock (&ent->m_entity.m_observers_lock); \
|
||||
dds_get_##status_##_status_locked (ent, status); \
|
||||
ddsrt_mutex_unlock (&ent->m_entity.m_observers_lock); \
|
||||
dds_##ent_type_##_unlock (ent); \
|
||||
return DDS_RETCODE_OK; \
|
||||
}
|
||||
|
||||
#define DDS_GET_STATUS(ent_type_, status_, STATUS_, ...) \
|
||||
DDS_GET_STATUS_LOCKED (ent_type_, status_, STATUS_, __VA_ARGS__) \
|
||||
DDS_GET_STATUS_COMMON (ent_type_, status_)
|
||||
|
||||
#endif
|
||||
|
|
@ -78,7 +78,7 @@ struct dds_handle_link {
|
|||
* Initialize handleserver singleton.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_handle_server_init(void (*free_via_gc) (void *x));
|
||||
dds_handle_server_init(void);
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -145,13 +145,13 @@ dds_handle_delete(
|
|||
* Returns OK when succeeded.
|
||||
*/
|
||||
DDS_EXPORT int32_t
|
||||
dds_handle_claim(
|
||||
dds_handle_pin(
|
||||
dds_handle_t hdl,
|
||||
struct dds_handle_link **entity);
|
||||
|
||||
|
||||
DDS_EXPORT void
|
||||
dds_handle_claim_inc(
|
||||
dds_handle_repin(
|
||||
struct dds_handle_link *link);
|
||||
|
||||
|
||||
|
|
@ -159,7 +159,7 @@ dds_handle_claim_inc(
|
|||
* The active claims count is decreased.
|
||||
*/
|
||||
DDS_EXPORT void
|
||||
dds_handle_release(
|
||||
dds_handle_unpin(
|
||||
struct dds_handle_link *link);
|
||||
|
||||
|
||||
|
|
@ -177,6 +177,9 @@ dds_handle_is_closed(
|
|||
struct dds_handle_link *link);
|
||||
|
||||
|
||||
DDS_EXPORT void dds_handle_add_ref (struct dds_handle_link *link);
|
||||
DDS_EXPORT bool dds_handle_drop_ref (struct dds_handle_link *link);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -18,9 +18,6 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
dds_return_t
|
||||
dds__check_domain(dds_domainid_t domain);
|
||||
|
||||
/**
|
||||
*Description : Initialization function, called from main. This operation
|
||||
*initializes all the required DDS resources,
|
||||
|
|
@ -30,8 +27,7 @@ dds__check_domain(dds_domainid_t domain);
|
|||
*Arguments :
|
||||
*-# Returns 0 on success or a non-zero error status
|
||||
**/
|
||||
dds_return_t
|
||||
dds_init(dds_domainid_t domain);
|
||||
dds_return_t dds_init (void);
|
||||
|
||||
/* Finalization function, called from main */
|
||||
|
||||
|
|
@ -42,16 +38,7 @@ dds_init(dds_domainid_t domain);
|
|||
*Arguments :
|
||||
*-# None
|
||||
**/
|
||||
void
|
||||
dds_fini(void);
|
||||
|
||||
/**
|
||||
* Description : Function that provides the explicit ID of default domain
|
||||
* It should be called after DDS initialization.
|
||||
* @return Valid domain id. Undetermined behaviour if DDS is not initialized.
|
||||
*/
|
||||
dds_domainid_t dds_domain_default (void);
|
||||
|
||||
void dds_fini (void);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,24 +12,43 @@
|
|||
#ifndef _DDS_QOS_H_
|
||||
#define _DDS_QOS_H_
|
||||
|
||||
#include "dds__entity.h"
|
||||
#include "dds/ddsi/q_xqos.h"
|
||||
#include "dds/ddsi/q_time.h"
|
||||
#include "dds/ddsi/q_plist.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
bool validate_deadline_and_timebased_filter (const nn_duration_t deadline, const nn_duration_t minimum_separation);
|
||||
bool validate_entityfactory_qospolicy (const nn_entity_factory_qospolicy_t * entityfactory);
|
||||
bool validate_octetseq (const nn_octetseq_t* seq);
|
||||
bool validate_partition_qospolicy (const nn_partition_qospolicy_t * partition);
|
||||
bool validate_reliability_qospolicy (const nn_reliability_qospolicy_t * reliability);
|
||||
bool validate_stringseq (const nn_stringseq_t* seq);
|
||||
#define DDS_TOPIC_QOS_MASK \
|
||||
(QP_TOPIC_DATA | QP_DURABILITY | QP_DURABILITY_SERVICE | \
|
||||
QP_DEADLINE | QP_LATENCY_BUDGET | QP_OWNERSHIP | QP_LIVELINESS | \
|
||||
QP_RELIABILITY | QP_TRANSPORT_PRIORITY | QP_LIFESPAN | \
|
||||
QP_DESTINATION_ORDER | QP_HISTORY | QP_RESOURCE_LIMITS)
|
||||
|
||||
bool dds_qos_validate_common (const dds_qos_t *qos);
|
||||
dds_return_t dds_qos_validate_mutable_common (const dds_qos_t *qos);
|
||||
#define DDS_PARTICIPANT_QOS_MASK \
|
||||
(QP_USER_DATA | QP_PRISMTECH_ENTITY_FACTORY | QP_CYCLONE_IGNORELOCAL)
|
||||
|
||||
#define DDS_PUBLISHER_QOS_MASK \
|
||||
(QP_PARTITION | QP_PRESENTATION | QP_GROUP_DATA | \
|
||||
QP_PRISMTECH_ENTITY_FACTORY | QP_CYCLONE_IGNORELOCAL)
|
||||
|
||||
#define DDS_READER_QOS_MASK \
|
||||
(QP_USER_DATA | QP_DURABILITY | QP_DEADLINE | QP_LATENCY_BUDGET | \
|
||||
QP_OWNERSHIP | QP_LIVELINESS | QP_TIME_BASED_FILTER | \
|
||||
QP_RELIABILITY | QP_DESTINATION_ORDER | QP_HISTORY | \
|
||||
QP_RESOURCE_LIMITS | QP_PRISMTECH_READER_DATA_LIFECYCLE | \
|
||||
QP_CYCLONE_IGNORELOCAL)
|
||||
|
||||
#define DDS_SUBSCRIBER_QOS_MASK \
|
||||
(QP_PARTITION | QP_PRESENTATION | QP_GROUP_DATA | \
|
||||
QP_PRISMTECH_ENTITY_FACTORY | QP_CYCLONE_IGNORELOCAL)
|
||||
|
||||
#define DDS_WRITER_QOS_MASK \
|
||||
(QP_USER_DATA | QP_DURABILITY | QP_DURABILITY_SERVICE | QP_DEADLINE | \
|
||||
QP_LATENCY_BUDGET | QP_OWNERSHIP | QP_OWNERSHIP_STRENGTH | \
|
||||
QP_LIVELINESS | QP_RELIABILITY | QP_TRANSPORT_PRIORITY | \
|
||||
QP_LIFESPAN | QP_DESTINATION_ORDER | QP_HISTORY | \
|
||||
QP_RESOURCE_LIMITS | QP_PRISMTECH_WRITER_DATA_LIFECYCLE | \
|
||||
QP_CYCLONE_IGNORELOCAL)
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,60 +12,81 @@
|
|||
#ifndef _DDS_RHC_H_
|
||||
#define _DDS_RHC_H_
|
||||
|
||||
#include "dds/ddsrt/static_assert.h"
|
||||
#include "dds/ddsi/q_rhc.h"
|
||||
#include "dds__types.h" /* for dds_readcond */
|
||||
|
||||
#define NO_STATE_MASK_SET (DDS_ANY_STATE + 1)
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct rhc;
|
||||
struct nn_xqos;
|
||||
struct ddsi_serdata;
|
||||
struct ddsi_tkmap_instance;
|
||||
struct proxy_writer_info;
|
||||
struct dds_rhc;
|
||||
|
||||
DDS_EXPORT struct rhc *dds_rhc_new (dds_reader *reader, const struct ddsi_sertopic *topic);
|
||||
DDS_EXPORT void dds_rhc_free (struct rhc *rhc);
|
||||
typedef int (*dds_rhc_read_t) (struct dds_rhc *rhc, bool lock, void **values, dds_sample_info_t *info_seq, uint32_t max_samples, uint32_t mask, dds_instance_handle_t handle, struct dds_readcond *cond);
|
||||
typedef int (*dds_rhc_take_t) (struct dds_rhc *rhc, bool lock, void **values, dds_sample_info_t *info_seq, uint32_t max_samples, uint32_t mask, dds_instance_handle_t handle, struct dds_readcond *cond);
|
||||
typedef int (*dds_rhc_takecdr_t) (struct dds_rhc *rhc, bool lock, struct ddsi_serdata **values, dds_sample_info_t *info_seq, uint32_t max_samples, uint32_t sample_states, uint32_t view_states, uint32_t instance_states, dds_instance_handle_t handle);
|
||||
|
||||
DDS_EXPORT uint32_t dds_rhc_lock_samples (struct rhc *rhc);
|
||||
typedef bool (*dds_rhc_add_readcondition_t) (struct dds_readcond *cond);
|
||||
typedef void (*dds_rhc_remove_readcondition_t) (struct dds_readcond *cond);
|
||||
|
||||
DDS_EXPORT bool dds_rhc_store (struct rhc * __restrict rhc, const struct proxy_writer_info * __restrict pwr_info, struct ddsi_serdata * __restrict sample, struct ddsi_tkmap_instance * __restrict tk);
|
||||
DDS_EXPORT void dds_rhc_unregister_wr (struct rhc * __restrict rhc, const struct proxy_writer_info * __restrict pwr_info);
|
||||
DDS_EXPORT void dds_rhc_relinquish_ownership (struct rhc * __restrict rhc, const uint64_t wr_iid);
|
||||
typedef uint32_t (*dds_rhc_lock_samples_t) (struct dds_rhc *rhc);
|
||||
|
||||
DDS_EXPORT int
|
||||
dds_rhc_read(
|
||||
struct rhc *rhc,
|
||||
bool lock,
|
||||
void ** values,
|
||||
dds_sample_info_t *info_seq,
|
||||
uint32_t max_samples,
|
||||
uint32_t mask,
|
||||
dds_instance_handle_t handle,
|
||||
dds_readcond *cond);
|
||||
DDS_EXPORT int
|
||||
dds_rhc_take(
|
||||
struct rhc *rhc,
|
||||
bool lock,
|
||||
void ** values,
|
||||
dds_sample_info_t *info_seq,
|
||||
uint32_t max_samples,
|
||||
uint32_t mask,
|
||||
dds_instance_handle_t handle,
|
||||
dds_readcond *cond);
|
||||
struct dds_rhc_ops {
|
||||
/* A copy of DDSI rhc ops comes first so we can use either interface without
|
||||
additional indirections */
|
||||
struct rhc_ops rhc_ops;
|
||||
dds_rhc_read_t read;
|
||||
dds_rhc_take_t take;
|
||||
dds_rhc_takecdr_t takecdr;
|
||||
dds_rhc_add_readcondition_t add_readcondition;
|
||||
dds_rhc_remove_readcondition_t remove_readcondition;
|
||||
dds_rhc_lock_samples_t lock_samples;
|
||||
};
|
||||
|
||||
DDS_EXPORT void dds_rhc_set_qos (struct rhc * rhc, const struct nn_xqos * qos);
|
||||
struct dds_rhc {
|
||||
union {
|
||||
const struct dds_rhc_ops *ops;
|
||||
struct rhc rhc;
|
||||
} common;
|
||||
};
|
||||
|
||||
DDS_EXPORT bool dds_rhc_add_readcondition (dds_readcond * cond);
|
||||
DDS_EXPORT void dds_rhc_remove_readcondition (dds_readcond * cond);
|
||||
DDSRT_STATIC_ASSERT (offsetof (struct dds_rhc, common.ops) == offsetof (struct rhc, ops));
|
||||
|
||||
DDS_EXPORT int dds_rhc_takecdr
|
||||
(
|
||||
struct rhc *rhc, bool lock, struct ddsi_serdata **values, dds_sample_info_t *info_seq,
|
||||
uint32_t max_samples, unsigned sample_states,
|
||||
unsigned view_states, unsigned instance_states,
|
||||
dds_instance_handle_t handle
|
||||
);
|
||||
DDS_EXPORT inline bool dds_rhc_store (struct dds_rhc * __restrict rhc, const struct proxy_writer_info * __restrict pwr_info, struct ddsi_serdata * __restrict sample, struct ddsi_tkmap_instance * __restrict tk) {
|
||||
return rhc->common.ops->rhc_ops.store (&rhc->common.rhc, pwr_info, sample, tk);
|
||||
}
|
||||
DDS_EXPORT inline void dds_rhc_unregister_wr (struct dds_rhc * __restrict rhc, const struct proxy_writer_info * __restrict pwr_info) {
|
||||
rhc->common.ops->rhc_ops.unregister_wr (&rhc->common.rhc, pwr_info);
|
||||
}
|
||||
DDS_EXPORT inline void dds_rhc_relinquish_ownership (struct dds_rhc * __restrict rhc, const uint64_t wr_iid) {
|
||||
rhc->common.ops->rhc_ops.relinquish_ownership (&rhc->common.rhc, wr_iid);
|
||||
}
|
||||
DDS_EXPORT inline void dds_rhc_set_qos (struct dds_rhc *rhc, const struct dds_qos *qos) {
|
||||
rhc->common.ops->rhc_ops.set_qos (&rhc->common.rhc, qos);
|
||||
}
|
||||
DDS_EXPORT inline void dds_rhc_free (struct dds_rhc *rhc) {
|
||||
rhc->common.ops->rhc_ops.free (&rhc->common.rhc);
|
||||
}
|
||||
DDS_EXPORT inline int dds_rhc_read (struct dds_rhc *rhc, bool lock, void **values, dds_sample_info_t *info_seq, uint32_t max_samples, uint32_t mask, dds_instance_handle_t handle, struct dds_readcond *cond) {
|
||||
return (rhc->common.ops->read) (rhc, lock, values, info_seq, max_samples, mask, handle, cond);
|
||||
}
|
||||
DDS_EXPORT inline int dds_rhc_take (struct dds_rhc *rhc, bool lock, void **values, dds_sample_info_t *info_seq, uint32_t max_samples, uint32_t mask, dds_instance_handle_t handle, struct dds_readcond *cond) {
|
||||
return rhc->common.ops->take (rhc, lock, values, info_seq, max_samples, mask, handle, cond);
|
||||
}
|
||||
DDS_EXPORT inline int dds_rhc_takecdr (struct dds_rhc *rhc, bool lock, struct ddsi_serdata **values, dds_sample_info_t *info_seq, uint32_t max_samples, uint32_t sample_states, uint32_t view_states, uint32_t instance_states, dds_instance_handle_t handle) {
|
||||
return rhc->common.ops->takecdr (rhc, lock, values, info_seq, max_samples, sample_states, view_states, instance_states, handle);
|
||||
}
|
||||
DDS_EXPORT inline bool dds_rhc_add_readcondition (struct dds_readcond *cond) {
|
||||
return cond->m_rhc->common.ops->add_readcondition (cond);
|
||||
}
|
||||
DDS_EXPORT inline void dds_rhc_remove_readcondition (struct dds_readcond *cond) {
|
||||
cond->m_rhc->common.ops->remove_readcondition (cond);
|
||||
}
|
||||
DDS_EXPORT inline uint32_t dds_rhc_lock_samples (struct dds_rhc *rhc) {
|
||||
return rhc->common.ops->lock_samples (rhc);
|
||||
}
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,25 +9,20 @@
|
|||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#ifndef _DDS_KEY_H_
|
||||
#define _DDS_KEY_H_
|
||||
|
||||
#include "dds__types.h"
|
||||
|
||||
struct dds_key_hash;
|
||||
#ifndef _DDS_RHC_DEFAULT_H_
|
||||
#define _DDS_RHC_DEFAULT_H_
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void dds_key_md5 (struct dds_key_hash * kh);
|
||||
struct dds_rhc;
|
||||
struct dds_reader;
|
||||
struct ddsi_sertopic;
|
||||
struct q_globals;
|
||||
|
||||
void dds_key_gen
|
||||
(
|
||||
const dds_topic_descriptor_t * const desc,
|
||||
struct dds_key_hash * kh,
|
||||
const char * sample
|
||||
);
|
||||
DDS_EXPORT struct dds_rhc *dds_rhc_default_new_xchecks (dds_reader *reader, struct q_globals *gv, const struct ddsi_sertopic *topic, bool xchecks);
|
||||
DDS_EXPORT struct dds_rhc *dds_rhc_default_new (struct dds_reader *reader, const struct ddsi_sertopic *topic);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
|
|
@ -24,7 +24,7 @@ struct ddsi_serdata_builtintopic {
|
|||
struct ddsi_serdata c;
|
||||
nn_guid_t key;
|
||||
dds_instance_handle_t pphandle;
|
||||
nn_xqos_t xqos;
|
||||
dds_qos_t xqos;
|
||||
};
|
||||
|
||||
enum ddsi_sertopic_builtintopic_type {
|
||||
|
|
@ -33,15 +33,17 @@ enum ddsi_sertopic_builtintopic_type {
|
|||
DSBT_WRITER
|
||||
};
|
||||
|
||||
struct q_globals;
|
||||
struct ddsi_sertopic_builtintopic {
|
||||
struct ddsi_sertopic c;
|
||||
enum ddsi_sertopic_builtintopic_type type;
|
||||
struct q_globals *gv;
|
||||
};
|
||||
|
||||
extern const struct ddsi_sertopic_ops ddsi_sertopic_ops_builtintopic;
|
||||
extern const struct ddsi_serdata_ops ddsi_serdata_ops_builtintopic;
|
||||
|
||||
struct ddsi_sertopic *new_sertopic_builtintopic (enum ddsi_sertopic_builtintopic_type type, const char *name, const char *typename);
|
||||
struct ddsi_sertopic *new_sertopic_builtintopic (enum ddsi_sertopic_builtintopic_type type, const char *name, const char *typename, struct q_globals *gv);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,47 +19,46 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
void dds_stream_write_sample
|
||||
(
|
||||
dds_stream_t * os,
|
||||
const void * data,
|
||||
const struct ddsi_sertopic_default * topic
|
||||
);
|
||||
void dds_stream_read_sample
|
||||
(
|
||||
dds_stream_t * is,
|
||||
void * data,
|
||||
const struct ddsi_sertopic_default * topic
|
||||
);
|
||||
typedef struct dds_istream {
|
||||
const unsigned char *m_buffer;
|
||||
uint32_t m_size; /* Buffer size */
|
||||
uint32_t m_index; /* Read/write offset from start of buffer */
|
||||
} dds_istream_t;
|
||||
|
||||
size_t dds_stream_check_optimize (const dds_topic_descriptor_t * desc);
|
||||
void dds_stream_from_serdata_default (dds_stream_t * s, const struct ddsi_serdata_default *d);
|
||||
void dds_stream_add_to_serdata_default (dds_stream_t * s, struct ddsi_serdata_default **d);
|
||||
typedef struct dds_ostream {
|
||||
unsigned char *m_buffer;
|
||||
uint32_t m_size; /* Buffer size */
|
||||
uint32_t m_index; /* Read/write offset from start of buffer */
|
||||
} dds_ostream_t;
|
||||
|
||||
void dds_stream_write_key (dds_stream_t * os, const char * sample, const struct ddsi_sertopic_default * topic);
|
||||
uint32_t dds_stream_extract_key (dds_stream_t *is, dds_stream_t *os, const uint32_t *ops, const bool just_key);
|
||||
void dds_stream_read_key
|
||||
(
|
||||
dds_stream_t * is,
|
||||
char * sample,
|
||||
const dds_topic_descriptor_t * desc
|
||||
);
|
||||
void dds_stream_read_keyhash
|
||||
(
|
||||
dds_stream_t * is,
|
||||
dds_key_hash_t * kh,
|
||||
const dds_topic_descriptor_t * desc,
|
||||
const bool just_key
|
||||
);
|
||||
char * dds_stream_reuse_string
|
||||
(
|
||||
dds_stream_t * is,
|
||||
char * str,
|
||||
const uint32_t bound
|
||||
);
|
||||
DDS_EXPORT void dds_stream_swap (void * buff, uint32_t size, uint32_t num);
|
||||
typedef struct dds_ostreamBE {
|
||||
dds_ostream_t x;
|
||||
} dds_ostreamBE_t;
|
||||
|
||||
extern const uint32_t dds_op_size[5];
|
||||
DDS_EXPORT void dds_ostream_init (dds_ostream_t * __restrict st, uint32_t size);
|
||||
DDS_EXPORT void dds_ostream_fini (dds_ostream_t * __restrict st);
|
||||
DDS_EXPORT void dds_ostreamBE_init (dds_ostreamBE_t * __restrict st, uint32_t size);
|
||||
DDS_EXPORT void dds_ostreamBE_fini (dds_ostreamBE_t * __restrict st);
|
||||
|
||||
bool dds_stream_normalize (void * __restrict data, uint32_t size, bool bswap, const struct ddsi_sertopic_default * __restrict topic, bool just_key);
|
||||
|
||||
void dds_stream_write_sample (dds_ostream_t * __restrict os, const void * __restrict data, const struct ddsi_sertopic_default * __restrict topic);
|
||||
void dds_stream_read_sample (dds_istream_t * __restrict is, void * __restrict data, const struct ddsi_sertopic_default * __restrict topic);
|
||||
|
||||
size_t dds_stream_check_optimize (const dds_topic_descriptor_t * __restrict desc);
|
||||
void dds_istream_from_serdata_default (dds_istream_t * __restrict s, const struct ddsi_serdata_default * __restrict d);
|
||||
void dds_ostream_from_serdata_default (dds_ostream_t * __restrict s, struct ddsi_serdata_default * __restrict d);
|
||||
void dds_ostream_add_to_serdata_default (dds_ostream_t * __restrict s, struct ddsi_serdata_default ** __restrict d);
|
||||
void dds_ostreamBE_from_serdata_default (dds_ostreamBE_t * __restrict s, struct ddsi_serdata_default * __restrict d);
|
||||
void dds_ostreamBE_add_to_serdata_default (dds_ostreamBE_t * __restrict s, struct ddsi_serdata_default ** __restrict d);
|
||||
|
||||
void dds_stream_write_key (dds_ostream_t * __restrict os, const char * __restrict sample, const struct ddsi_sertopic_default * __restrict topic);
|
||||
void dds_stream_write_keyBE (dds_ostreamBE_t * __restrict os, const char * __restrict sample, const struct ddsi_sertopic_default * __restrict topic);
|
||||
void dds_stream_extract_key_from_data (dds_istream_t * __restrict is, dds_ostream_t * __restrict os, const struct ddsi_sertopic_default * __restrict topic);
|
||||
void dds_stream_extract_keyBE_from_data (dds_istream_t * __restrict is, dds_ostreamBE_t * __restrict os, const struct ddsi_sertopic_default * __restrict topic);
|
||||
void dds_stream_extract_keyhash (dds_istream_t * __restrict is, dds_keyhash_t * __restrict kh, const struct ddsi_sertopic_default * __restrict topic, const bool just_key);
|
||||
|
||||
void dds_stream_read_key (dds_istream_t * __restrict is, char * __restrict sample, const struct ddsi_sertopic_default * __restrict topic);
|
||||
|
||||
/* For marshalling op code handling */
|
||||
|
||||
|
|
@ -70,14 +69,14 @@ extern const uint32_t dds_op_size[5];
|
|||
#define DDS_OP_FLAGS_MASK 0x000000ff
|
||||
#define DDS_JEQ_TYPE_MASK 0x00ff0000
|
||||
|
||||
#define DDS_OP(o) ((o) & DDS_OP_MASK)
|
||||
#define DDS_OP_TYPE(o) (((o) & DDS_OP_TYPE_MASK) >> 16)
|
||||
#define DDS_OP_SUBTYPE(o) (((o) & DDS_OP_SUBTYPE_MASK) >> 8)
|
||||
#define DDS_OP_FLAGS(o) ((o) & DDS_OP_FLAGS_MASK)
|
||||
#define DDS_OP(o) ((enum dds_stream_opcode) ((o) & DDS_OP_MASK))
|
||||
#define DDS_OP_TYPE(o) ((enum dds_stream_typecode) (((o) & DDS_OP_TYPE_MASK) >> 16))
|
||||
#define DDS_OP_SUBTYPE(o) ((enum dds_stream_typecode) (((o) & DDS_OP_SUBTYPE_MASK) >> 8))
|
||||
#define DDS_OP_FLAGS(o) ((o) & DDS_OP_FLAGS_MASK)
|
||||
#define DDS_OP_ADR_JSR(o) ((o) & DDS_OP_JMP_MASK)
|
||||
#define DDS_OP_JUMP(o) ((int16_t) ((o) & DDS_OP_JMP_MASK))
|
||||
#define DDS_OP_JUMP(o) ((int16_t) ((o) & DDS_OP_JMP_MASK))
|
||||
#define DDS_OP_ADR_JMP(o) ((o) >> 16)
|
||||
#define DDS_JEQ_TYPE(o) (((o) & DDS_JEQ_TYPE_MASK) >> 16)
|
||||
#define DDS_JEQ_TYPE(o) ((enum dds_stream_typecode) (((o) & DDS_JEQ_TYPE_MASK) >> 16))
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ DEFINE_ENTITY_LOCK_UNLOCK(inline, dds_subscriber, DDS_KIND_SUBSCRIBER)
|
|||
|
||||
dds_entity_t
|
||||
dds__create_subscriber_l(
|
||||
struct dds_entity *participant, /* entity-lock must be held */
|
||||
struct dds_participant *participant, /* entity-lock must be held */
|
||||
const dds_qos_t *qos,
|
||||
const dds_listener_t *listener);
|
||||
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ extern "C" {
|
|||
|
||||
DEFINE_ENTITY_LOCK_UNLOCK(inline, dds_topic, DDS_KIND_TOPIC)
|
||||
|
||||
DDS_EXPORT struct ddsi_sertopic * dds_topic_lookup (dds_domain * domain, const char * name);
|
||||
DDS_EXPORT void dds_topic_free (dds_domainid_t domainid, struct ddsi_sertopic * st);
|
||||
DDS_EXPORT struct ddsi_sertopic * dds_topic_lookup (dds_domain * domain, const char * name) ddsrt_nonnull_all;
|
||||
DDS_EXPORT void dds_topic_free (dds_domainid_t domainid, struct ddsi_sertopic * st) ddsrt_nonnull_all;
|
||||
|
||||
#ifndef DDS_TOPIC_INTERN_FILTER_FN_DEFINED
|
||||
#define DDS_TOPIC_INTERN_FILTER_FN_DEFINED
|
||||
|
|
|
|||
|
|
@ -17,7 +17,9 @@
|
|||
#include "dds/dds.h"
|
||||
#include "dds/ddsrt/sync.h"
|
||||
#include "dds/ddsi/q_rtps.h"
|
||||
#include "dds/ddsi/q_globals.h"
|
||||
#include "dds/ddsrt/avl.h"
|
||||
#include "dds/ddsi/ddsi_builtin_topic_if.h"
|
||||
#include "dds__handles.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
|
|
@ -39,12 +41,11 @@ struct dds_statuscond;
|
|||
struct ddsi_sertopic;
|
||||
struct rhc;
|
||||
|
||||
/* Internal entity status flags */
|
||||
|
||||
#define DDS_INTERNAL_STATUS_MASK (0xFF000000u)
|
||||
|
||||
#define DDS_WAITSET_TRIGGER_STATUS (0x01000000u)
|
||||
#define DDS_DELETING_STATUS (0x02000000u)
|
||||
typedef uint16_t status_mask_t;
|
||||
typedef ddsrt_atomic_uint32_t status_and_enabled_t;
|
||||
#define SAM_STATUS_MASK 0xffffu
|
||||
#define SAM_ENABLED_MASK 0xffff0000u
|
||||
#define SAM_ENABLED_SHIFT 16
|
||||
|
||||
/* This can be used when polling for various states.
|
||||
* Obviously, it is encouraged to use condition variables and such. But
|
||||
|
|
@ -92,96 +93,143 @@ struct dds_listener {
|
|||
#define DDS_ENTITY_ENABLED 0x0001u
|
||||
#define DDS_ENTITY_IMPLICIT 0x0002u
|
||||
|
||||
typedef struct dds_domain
|
||||
{
|
||||
typedef struct dds_domain {
|
||||
/* FIXME: protected by dds_global.lock -- for now */
|
||||
ddsrt_avl_node_t m_node;
|
||||
dds_domainid_t m_id;
|
||||
ddsrt_avl_tree_t m_topics;
|
||||
ddsrt_avl_tree_t m_ppants;
|
||||
uint32_t m_refc;
|
||||
}
|
||||
dds_domain;
|
||||
struct cfgst *cfgst;
|
||||
|
||||
struct ddsi_sertopic *builtin_participant_topic;
|
||||
struct ddsi_sertopic *builtin_reader_topic;
|
||||
struct ddsi_sertopic *builtin_writer_topic;
|
||||
|
||||
struct local_orphan_writer *builtintopic_writer_participant;
|
||||
struct local_orphan_writer *builtintopic_writer_publications;
|
||||
struct local_orphan_writer *builtintopic_writer_subscriptions;
|
||||
|
||||
struct ddsi_builtin_topic_interface btif;
|
||||
struct q_globals gv;
|
||||
} dds_domain;
|
||||
|
||||
struct dds_entity;
|
||||
typedef struct dds_entity_deriver {
|
||||
/* Close can be used to terminate (blocking) actions on a entity before actually deleting it. */
|
||||
dds_return_t (*close)(struct dds_entity *e);
|
||||
/* Delete is used to actually free the entity. */
|
||||
dds_return_t (*delete)(struct dds_entity *e);
|
||||
dds_return_t (*set_qos)(struct dds_entity *e, const dds_qos_t *qos, bool enabled);
|
||||
dds_return_t (*validate_status)(uint32_t mask);
|
||||
dds_return_t (*get_instance_hdl)(struct dds_entity *e, dds_instance_handle_t *i);
|
||||
}
|
||||
dds_entity_deriver;
|
||||
/* Close can be used to terminate (blocking) actions on a entity before actually deleting it. */
|
||||
dds_return_t (*close)(struct dds_entity *e) ddsrt_nonnull_all;
|
||||
/* Delete is used to actually free the entity. */
|
||||
dds_return_t (*delete)(struct dds_entity *e) ddsrt_nonnull_all;
|
||||
dds_return_t (*set_qos)(struct dds_entity *e, const dds_qos_t *qos, bool enabled) ddsrt_nonnull_all;
|
||||
dds_return_t (*validate_status)(uint32_t mask);
|
||||
} dds_entity_deriver;
|
||||
|
||||
typedef void (*dds_entity_callback)(dds_entity_t observer, dds_entity_t observed, uint32_t status);
|
||||
typedef void (*dds_entity_callback)(struct dds_entity *observer, dds_entity_t observed, uint32_t status);
|
||||
typedef void (*dds_entity_delete_callback)(struct dds_entity *observer, dds_entity_t observed);
|
||||
|
||||
typedef struct dds_entity_observer
|
||||
{
|
||||
dds_entity_callback m_cb;
|
||||
dds_entity_t m_observer;
|
||||
struct dds_entity_observer *m_next;
|
||||
}
|
||||
dds_entity_observer;
|
||||
typedef struct dds_entity_observer {
|
||||
dds_entity_callback m_cb;
|
||||
dds_entity_delete_callback m_delete_cb;
|
||||
struct dds_entity *m_observer;
|
||||
struct dds_entity_observer *m_next;
|
||||
} dds_entity_observer;
|
||||
|
||||
typedef struct dds_entity
|
||||
{
|
||||
struct dds_handle_link m_hdllink;
|
||||
dds_entity_kind_t m_kind;
|
||||
dds_entity_deriver m_deriver;
|
||||
uint32_t m_refc;
|
||||
struct dds_entity * m_next;
|
||||
struct dds_entity * m_parent;
|
||||
struct dds_entity * m_children;
|
||||
struct dds_entity * m_participant;
|
||||
struct dds_domain * m_domain;
|
||||
dds_qos_t * m_qos;
|
||||
dds_domainid_t m_domainid;
|
||||
nn_guid_t m_guid;
|
||||
uint32_t m_flags;
|
||||
typedef struct dds_entity {
|
||||
struct dds_handle_link m_hdllink; /* handle is constant, cnt_flags private to dds_handle.c */
|
||||
dds_entity_kind_t m_kind; /* constant */
|
||||
struct dds_entity *m_next; /* [m_mutex] */
|
||||
struct dds_entity *m_parent; /* constant */
|
||||
ddsrt_avl_node_t m_avlnode_child; /* [m_mutex of m_parent] */
|
||||
ddsrt_avl_tree_t m_children; /* [m_mutex] tree on m_iid using m_avlnode_child */
|
||||
struct dds_entity *m_participant; /* constant */
|
||||
struct dds_domain *m_domain; /* constant */
|
||||
dds_qos_t *m_qos; /* [m_mutex] */
|
||||
nn_guid_t m_guid; /* unique (if not 0) and constant; FIXME: set during creation, but possibly after becoming visible */
|
||||
dds_instance_handle_t m_iid; /* unique for all time, constant; FIXME: like GUID */
|
||||
uint32_t m_flags; /* [m_mutex] */
|
||||
|
||||
/* Allowed:
|
||||
- locking parent->...->m_mutex while holding m_mutex
|
||||
- locking topic::m_mutex while holding {publisher,subscriber}::m_mutex
|
||||
(no hierarchical relationship there)
|
||||
- locking topic::m_mutex while holding {reader,writer}::m_mutex
|
||||
- locking observers_lock while holding m_mutex
|
||||
*/
|
||||
ddsrt_mutex_t m_mutex;
|
||||
ddsrt_cond_t m_cond;
|
||||
|
||||
ddsrt_mutex_t m_observers_lock;
|
||||
union {
|
||||
status_and_enabled_t m_status_and_mask; /* for most entities */
|
||||
ddsrt_atomic_uint32_t m_trigger; /* for conditions & waitsets */
|
||||
} m_status;
|
||||
|
||||
ddsrt_mutex_t m_observers_lock; /* locking parent->...->m_observers_lock while holding it is allowed */
|
||||
ddsrt_cond_t m_observers_cond;
|
||||
dds_listener_t m_listener;
|
||||
uint32_t m_trigger;
|
||||
uint32_t m_status_enable;
|
||||
uint32_t m_cb_count;
|
||||
dds_entity_observer *m_observers;
|
||||
}
|
||||
dds_entity;
|
||||
dds_listener_t m_listener; /* [m_observers_lock] */
|
||||
uint32_t m_cb_count; /* [m_observers_lock] */
|
||||
dds_entity_observer *m_observers; /* [m_observers_lock] */
|
||||
} dds_entity;
|
||||
|
||||
extern const ddsrt_avl_treedef_t dds_topictree_def;
|
||||
extern const ddsrt_avl_treedef_t dds_entity_children_td;
|
||||
|
||||
typedef struct dds_subscriber
|
||||
{
|
||||
struct dds_entity m_entity;
|
||||
extern const struct dds_entity_deriver dds_entity_deriver_topic;
|
||||
extern const struct dds_entity_deriver dds_entity_deriver_participant;
|
||||
extern const struct dds_entity_deriver dds_entity_deriver_reader;
|
||||
extern const struct dds_entity_deriver dds_entity_deriver_writer;
|
||||
extern const struct dds_entity_deriver dds_entity_deriver_subscriber;
|
||||
extern const struct dds_entity_deriver dds_entity_deriver_publisher;
|
||||
extern const struct dds_entity_deriver dds_entity_deriver_readcondition;
|
||||
extern const struct dds_entity_deriver dds_entity_deriver_guardcondition;
|
||||
extern const struct dds_entity_deriver dds_entity_deriver_waitset;
|
||||
extern const struct dds_entity_deriver *dds_entity_deriver_table[];
|
||||
|
||||
dds_return_t dds_entity_deriver_dummy_close (struct dds_entity *e);
|
||||
dds_return_t dds_entity_deriver_dummy_delete (struct dds_entity *e);
|
||||
dds_return_t dds_entity_deriver_dummy_set_qos (struct dds_entity *e, const dds_qos_t *qos, bool enabled);
|
||||
dds_return_t dds_entity_deriver_dummy_validate_status (uint32_t mask);
|
||||
|
||||
|
||||
inline dds_return_t dds_entity_deriver_close (struct dds_entity *e) {
|
||||
return (dds_entity_deriver_table[e->m_kind]->close) (e);
|
||||
}
|
||||
dds_subscriber;
|
||||
|
||||
typedef struct dds_publisher
|
||||
{
|
||||
struct dds_entity m_entity;
|
||||
inline dds_return_t dds_entity_deriver_delete (struct dds_entity *e) {
|
||||
return dds_entity_deriver_table[e->m_kind]->delete (e);
|
||||
}
|
||||
inline dds_return_t dds_entity_deriver_set_qos (struct dds_entity *e, const dds_qos_t *qos, bool enabled) {
|
||||
return dds_entity_deriver_table[e->m_kind]->set_qos (e, qos, enabled);
|
||||
}
|
||||
inline dds_return_t dds_entity_deriver_validate_status (struct dds_entity *e, uint32_t mask) {
|
||||
return dds_entity_deriver_table[e->m_kind]->validate_status (mask);
|
||||
}
|
||||
inline bool dds_entity_supports_set_qos (struct dds_entity *e) {
|
||||
return dds_entity_deriver_table[e->m_kind]->set_qos != dds_entity_deriver_dummy_set_qos;
|
||||
}
|
||||
inline bool dds_entity_supports_validate_status (struct dds_entity *e) {
|
||||
return dds_entity_deriver_table[e->m_kind]->validate_status != dds_entity_deriver_dummy_validate_status;
|
||||
}
|
||||
dds_publisher;
|
||||
|
||||
typedef struct dds_participant
|
||||
{
|
||||
typedef struct dds_subscriber {
|
||||
struct dds_entity m_entity;
|
||||
} dds_subscriber;
|
||||
|
||||
typedef struct dds_publisher {
|
||||
struct dds_entity m_entity;
|
||||
} dds_publisher;
|
||||
|
||||
typedef struct dds_participant {
|
||||
struct dds_entity m_entity;
|
||||
struct dds_entity * m_dur_reader;
|
||||
struct dds_entity * m_dur_writer;
|
||||
dds_entity_t m_builtin_subscriber;
|
||||
}
|
||||
dds_participant;
|
||||
} dds_participant;
|
||||
|
||||
typedef struct dds_reader
|
||||
{
|
||||
typedef struct dds_reader {
|
||||
struct dds_entity m_entity;
|
||||
const struct dds_topic * m_topic;
|
||||
struct reader * m_rd;
|
||||
const struct dds_topic *m_topic;
|
||||
struct dds_rhc *m_rhc; /* aliases m_rd->rhc with a wider interface, FIXME: but m_rd owns it for resource management */
|
||||
struct reader *m_rd;
|
||||
bool m_data_on_readers;
|
||||
bool m_loan_out;
|
||||
void * m_loan;
|
||||
void *m_loan;
|
||||
uint32_t m_loan_size;
|
||||
|
||||
/* Status metrics */
|
||||
|
|
@ -192,16 +240,15 @@ typedef struct dds_reader
|
|||
dds_requested_incompatible_qos_status_t m_requested_incompatible_qos_status;
|
||||
dds_sample_lost_status_t m_sample_lost_status;
|
||||
dds_subscription_matched_status_t m_subscription_matched_status;
|
||||
}
|
||||
dds_reader;
|
||||
} dds_reader;
|
||||
|
||||
typedef struct dds_writer
|
||||
{
|
||||
typedef struct dds_writer {
|
||||
struct dds_entity m_entity;
|
||||
const struct dds_topic * m_topic;
|
||||
struct nn_xpack * m_xp;
|
||||
struct writer * m_wr;
|
||||
const struct dds_topic *m_topic;
|
||||
struct nn_xpack *m_xp;
|
||||
struct writer *m_wr;
|
||||
struct whc *m_whc; /* FIXME: ownership still with underlying DDSI writer (cos of DDSI built-in writers )*/
|
||||
bool whc_batch; /* FIXME: channels + latency budget */
|
||||
|
||||
/* Status metrics */
|
||||
|
||||
|
|
@ -209,84 +256,68 @@ typedef struct dds_writer
|
|||
dds_offered_deadline_missed_status_t m_offered_deadline_missed_status;
|
||||
dds_offered_incompatible_qos_status_t m_offered_incompatible_qos_status;
|
||||
dds_publication_matched_status_t m_publication_matched_status;
|
||||
}
|
||||
dds_writer;
|
||||
} dds_writer;
|
||||
|
||||
#ifndef DDS_TOPIC_INTERN_FILTER_FN_DEFINED
|
||||
#define DDS_TOPIC_INTERN_FILTER_FN_DEFINED
|
||||
typedef bool (*dds_topic_intern_filter_fn) (const void * sample, void *ctx);
|
||||
#endif
|
||||
|
||||
typedef struct dds_topic
|
||||
{
|
||||
typedef struct dds_topic {
|
||||
struct dds_entity m_entity;
|
||||
struct ddsi_sertopic * m_stopic;
|
||||
struct ddsi_sertopic *m_stopic;
|
||||
|
||||
dds_topic_intern_filter_fn filter_fn;
|
||||
void * filter_ctx;
|
||||
void *filter_ctx;
|
||||
|
||||
/* Status metrics */
|
||||
|
||||
dds_inconsistent_topic_status_t m_inconsistent_topic_status;
|
||||
}
|
||||
dds_topic;
|
||||
} dds_topic;
|
||||
|
||||
typedef uint32_t dds_querycond_mask_t;
|
||||
|
||||
typedef struct dds_readcond
|
||||
{
|
||||
typedef struct dds_readcond {
|
||||
dds_entity m_entity;
|
||||
struct rhc * m_rhc;
|
||||
struct dds_rhc *m_rhc;
|
||||
uint32_t m_qminv;
|
||||
uint32_t m_sample_states;
|
||||
uint32_t m_view_states;
|
||||
uint32_t m_instance_states;
|
||||
nn_guid_t m_rd_guid;
|
||||
struct dds_readcond * m_next;
|
||||
struct
|
||||
{
|
||||
dds_querycondition_filter_fn m_filter;
|
||||
dds_querycond_mask_t m_qcmask; /* condition mask in RHC*/
|
||||
struct dds_readcond *m_next;
|
||||
struct {
|
||||
dds_querycondition_filter_fn m_filter;
|
||||
dds_querycond_mask_t m_qcmask; /* condition mask in RHC*/
|
||||
} m_query;
|
||||
}
|
||||
dds_readcond;
|
||||
} dds_readcond;
|
||||
|
||||
typedef struct dds_guardcond
|
||||
{
|
||||
typedef struct dds_guardcond {
|
||||
dds_entity m_entity;
|
||||
}
|
||||
dds_guardcond;
|
||||
} dds_guardcond;
|
||||
|
||||
typedef struct dds_attachment
|
||||
{
|
||||
dds_entity *entity;
|
||||
dds_attach_t arg;
|
||||
struct dds_attachment* next;
|
||||
}
|
||||
dds_attachment;
|
||||
typedef struct dds_attachment {
|
||||
dds_entity *entity;
|
||||
dds_entity_t handle;
|
||||
dds_attach_t arg;
|
||||
} dds_attachment;
|
||||
|
||||
typedef struct dds_waitset
|
||||
{
|
||||
typedef struct dds_waitset {
|
||||
dds_entity m_entity;
|
||||
dds_attachment *observed;
|
||||
dds_attachment *triggered;
|
||||
}
|
||||
dds_waitset;
|
||||
size_t nentities; /* [m_entity.m_mutex] */
|
||||
size_t ntriggered; /* [m_entity.m_mutex] */
|
||||
dds_attachment *entities; /* [m_entity.m_mutex] 0 .. ntriggered are triggred, ntriggred .. nentities are not */
|
||||
} dds_waitset;
|
||||
|
||||
/* Globals */
|
||||
|
||||
typedef struct dds_globals
|
||||
{
|
||||
dds_domainid_t m_default_domain;
|
||||
typedef struct dds_globals {
|
||||
int32_t m_init_count;
|
||||
void (*m_dur_reader) (struct dds_reader * reader, struct rhc * rhc);
|
||||
int (*m_dur_wait) (struct dds_reader * reader, dds_duration_t timeout);
|
||||
void (*m_dur_init) (void);
|
||||
void (*m_dur_fini) (void);
|
||||
ddsrt_avl_tree_t m_domains;
|
||||
ddsrt_mutex_t m_mutex;
|
||||
}
|
||||
dds_globals;
|
||||
uint32_t threadmon_count;
|
||||
struct ddsi_threadmon *threadmon;
|
||||
} dds_globals;
|
||||
|
||||
DDS_EXPORT extern dds_globals dds_global;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct whc *whc_new (int is_transient_local, unsigned hdepth, unsigned tldepth);
|
||||
struct q_globals;
|
||||
struct whc *whc_new (struct q_globals *gv, int is_transient_local, uint32_t hdepth, uint32_t tldepth);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct whc *builtintopic_whc_new (enum ddsi_sertopic_builtintopic_type type);
|
||||
struct whc *builtintopic_whc_new (enum ddsi_sertopic_builtintopic_type type, const struct ephash *guid_hash);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ typedef enum {
|
|||
|
||||
dds_return_t dds_write_impl (dds_writer *wr, const void *data, dds_time_t tstamp, dds_write_action action);
|
||||
dds_return_t dds_writecdr_impl (dds_writer *wr, struct ddsi_serdata *d, dds_time_t tstamp, dds_write_action action);
|
||||
dds_return_t dds_writecdr_impl_lowlevel (struct writer *ddsi_wr, struct nn_xpack *xp, struct ddsi_serdata *d);
|
||||
dds_return_t dds_writecdr_impl_lowlevel (struct writer *ddsi_wr, struct nn_xpack *xp, struct ddsi_serdata *d, bool flush);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ void dds_string_free (char * str)
|
|||
dds_free (str);
|
||||
}
|
||||
|
||||
void dds_sample_free_contents (char * data, const uint32_t * ops)
|
||||
void dds_sample_free_contents (char *data, const uint32_t * ops)
|
||||
{
|
||||
uint32_t op;
|
||||
uint32_t type;
|
||||
|
|
@ -179,6 +179,8 @@ void dds_sample_free_contents (char * data, const uint32_t * ops)
|
|||
if (seq->_release)
|
||||
{
|
||||
dds_free (seq->_buffer);
|
||||
seq->_maximum = 0;
|
||||
seq->_length = 0;
|
||||
seq->_buffer = NULL;
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -11,14 +11,15 @@
|
|||
*/
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include "dds/ddsrt/string.h"
|
||||
#include "dds/ddsi/q_entity.h"
|
||||
#include "dds/ddsi/q_thread.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/q_globals.h"
|
||||
#include "dds/ddsi/q_plist.h" /* for nn_keyhash */
|
||||
#include "dds__init.h"
|
||||
#include "dds__qos.h"
|
||||
#include "dds__domain.h"
|
||||
#include "dds__participant.h"
|
||||
#include "dds__err.h"
|
||||
#include "dds__types.h"
|
||||
#include "dds__builtin.h"
|
||||
#include "dds__subscriber.h"
|
||||
|
|
@ -29,13 +30,6 @@
|
|||
#include "dds/ddsi/q_qosmatch.h"
|
||||
#include "dds/ddsi/ddsi_tkmap.h"
|
||||
|
||||
static struct ddsi_sertopic *builtin_participant_topic;
|
||||
static struct ddsi_sertopic *builtin_reader_topic;
|
||||
static struct ddsi_sertopic *builtin_writer_topic;
|
||||
static struct local_orphan_writer *builtintopic_writer_participant;
|
||||
static struct local_orphan_writer *builtintopic_writer_publications;
|
||||
static struct local_orphan_writer *builtintopic_writer_subscriptions;
|
||||
|
||||
static dds_qos_t *dds__create_builtin_qos (void)
|
||||
{
|
||||
const char *partition = "__BUILT-IN PARTITION__";
|
||||
|
|
@ -47,93 +41,87 @@ static dds_qos_t *dds__create_builtin_qos (void)
|
|||
return qos;
|
||||
}
|
||||
|
||||
void dds__builtin_init (void)
|
||||
dds_entity_t dds__get_builtin_topic (dds_entity_t entity, dds_entity_t topic)
|
||||
{
|
||||
dds_qos_t *qos = dds__create_builtin_qos ();
|
||||
|
||||
builtin_participant_topic = new_sertopic_builtintopic (DSBT_PARTICIPANT, "DCPSParticipant", "org::eclipse::cyclonedds::builtin::DCPSParticipant");
|
||||
builtin_reader_topic = new_sertopic_builtintopic (DSBT_READER, "DCPSSubscription", "org::eclipse::cyclonedds::builtin::DCPSSubscription");
|
||||
builtin_writer_topic = new_sertopic_builtintopic (DSBT_WRITER, "DCPSPublication", "org::eclipse::cyclonedds::builtin::DCPSPublication");
|
||||
|
||||
builtintopic_writer_participant = new_local_orphan_writer (to_entityid (NN_ENTITYID_SPDP_BUILTIN_PARTICIPANT_WRITER), builtin_participant_topic, qos, builtintopic_whc_new (DSBT_PARTICIPANT));
|
||||
builtintopic_writer_publications = new_local_orphan_writer (to_entityid (NN_ENTITYID_SEDP_BUILTIN_PUBLICATIONS_WRITER), builtin_writer_topic, qos, builtintopic_whc_new (DSBT_WRITER));
|
||||
builtintopic_writer_subscriptions = new_local_orphan_writer (to_entityid (NN_ENTITYID_SEDP_BUILTIN_SUBSCRIPTIONS_WRITER), builtin_reader_topic, qos, builtintopic_whc_new (DSBT_READER));
|
||||
|
||||
dds_delete_qos (qos);
|
||||
}
|
||||
|
||||
void dds__builtin_fini (void)
|
||||
{
|
||||
/* No more sources for builtin topic samples */
|
||||
thread_state_awake (lookup_thread_state ());
|
||||
delete_local_orphan_writer (builtintopic_writer_participant);
|
||||
delete_local_orphan_writer (builtintopic_writer_publications);
|
||||
delete_local_orphan_writer (builtintopic_writer_subscriptions);
|
||||
thread_state_asleep (lookup_thread_state ());
|
||||
|
||||
ddsi_sertopic_unref (builtin_participant_topic);
|
||||
ddsi_sertopic_unref (builtin_reader_topic);
|
||||
ddsi_sertopic_unref (builtin_writer_topic);
|
||||
}
|
||||
|
||||
dds_entity_t dds__get_builtin_topic (dds_entity_t e, dds_entity_t topic)
|
||||
{
|
||||
dds_entity_t pp;
|
||||
dds_entity_t tp;
|
||||
dds_return_t rc;
|
||||
dds_entity *e;
|
||||
|
||||
if ((pp = dds_get_participant (e)) <= 0)
|
||||
return pp;
|
||||
if ((rc = dds_entity_pin (entity, &e)) < 0)
|
||||
return rc;
|
||||
|
||||
struct ddsi_sertopic *sertopic;
|
||||
if (topic == DDS_BUILTIN_TOPIC_DCPSPARTICIPANT) {
|
||||
sertopic = builtin_participant_topic;
|
||||
} else if (topic == DDS_BUILTIN_TOPIC_DCPSPUBLICATION) {
|
||||
sertopic = builtin_writer_topic;
|
||||
} else if (topic == DDS_BUILTIN_TOPIC_DCPSSUBSCRIPTION) {
|
||||
sertopic = builtin_reader_topic;
|
||||
} else {
|
||||
assert (0);
|
||||
return DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER);
|
||||
switch (topic)
|
||||
{
|
||||
case DDS_BUILTIN_TOPIC_DCPSPARTICIPANT:
|
||||
sertopic = e->m_domain->builtin_participant_topic;
|
||||
break;
|
||||
case DDS_BUILTIN_TOPIC_DCPSPUBLICATION:
|
||||
sertopic = e->m_domain->builtin_writer_topic;
|
||||
break;
|
||||
case DDS_BUILTIN_TOPIC_DCPSSUBSCRIPTION:
|
||||
sertopic = e->m_domain->builtin_reader_topic;
|
||||
break;
|
||||
default:
|
||||
assert (0);
|
||||
dds_entity_unpin (e);
|
||||
return DDS_RETCODE_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
dds_qos_t *qos = dds__create_builtin_qos ();
|
||||
tp = dds_create_topic_arbitrary (pp, sertopic, qos, NULL, NULL);
|
||||
tp = dds_create_topic_arbitrary (e->m_participant->m_hdllink.hdl, sertopic, qos, NULL, NULL);
|
||||
dds_delete_qos (qos);
|
||||
dds_entity_unpin (e);
|
||||
return tp;
|
||||
}
|
||||
|
||||
static bool qos_has_resource_limits (const dds_qos_t *qos)
|
||||
{
|
||||
assert (qos->present & QP_RESOURCE_LIMITS);
|
||||
return (qos->resource_limits.max_samples != DDS_LENGTH_UNLIMITED ||
|
||||
qos->resource_limits.max_instances != DDS_LENGTH_UNLIMITED ||
|
||||
qos->resource_limits.max_samples_per_instance != DDS_LENGTH_UNLIMITED);
|
||||
}
|
||||
|
||||
bool dds__validate_builtin_reader_qos (dds_entity_t topic, const dds_qos_t *qos)
|
||||
bool dds__validate_builtin_reader_qos (const dds_domain *dom, dds_entity_t topic, const dds_qos_t *qos)
|
||||
{
|
||||
if (qos == NULL)
|
||||
/* default QoS inherited from topic is ok by definition */
|
||||
return true;
|
||||
else
|
||||
{
|
||||
/* failing writes on built-in topics are unwelcome complications, so we simply forbid the creation of
|
||||
a reader matching a built-in topics writer that has resource limits */
|
||||
/* failing writes on built-in topics are unwelcome complications, so we simply
|
||||
forbid the creation of a reader matching a built-in topics writer that has
|
||||
resource limits */
|
||||
struct local_orphan_writer *bwr;
|
||||
if (topic == DDS_BUILTIN_TOPIC_DCPSPARTICIPANT) {
|
||||
bwr = builtintopic_writer_participant;
|
||||
} else if (topic == DDS_BUILTIN_TOPIC_DCPSPUBLICATION) {
|
||||
bwr = builtintopic_writer_publications;
|
||||
} else if (topic == DDS_BUILTIN_TOPIC_DCPSSUBSCRIPTION) {
|
||||
bwr = builtintopic_writer_subscriptions;
|
||||
} else {
|
||||
assert (0);
|
||||
return false;
|
||||
switch (topic)
|
||||
{
|
||||
case DDS_BUILTIN_TOPIC_DCPSPARTICIPANT:
|
||||
bwr = dom->builtintopic_writer_participant;
|
||||
break;
|
||||
case DDS_BUILTIN_TOPIC_DCPSPUBLICATION:
|
||||
bwr = dom->builtintopic_writer_publications;
|
||||
break;
|
||||
case DDS_BUILTIN_TOPIC_DCPSSUBSCRIPTION:
|
||||
bwr = dom->builtintopic_writer_subscriptions;
|
||||
break;
|
||||
default:
|
||||
assert (0);
|
||||
return false;
|
||||
}
|
||||
return qos_match_p (qos, bwr->wr.xqos) && !qos_has_resource_limits (qos);
|
||||
|
||||
/* FIXME: DDSI-level readers, writers have topic, type name in their QoS, but
|
||||
DDSC-level ones don't and that gives an automatic mismatch when comparing
|
||||
the full QoS object ... Here the two have the same topic by construction
|
||||
so ignoring them in the comparison makes things work. The discrepancy
|
||||
should be addressed one day. */
|
||||
const uint64_t qmask = ~(QP_TOPIC_NAME | QP_TYPE_NAME);
|
||||
dds_qos_policy_id_t dummy;
|
||||
return qos_match_mask_p (qos, bwr->wr.xqos, qmask, &dummy) && !qos_has_resource_limits (qos);
|
||||
}
|
||||
}
|
||||
|
||||
static dds_entity_t dds__create_builtin_subscriber (dds_entity *participant)
|
||||
static dds_entity_t dds__create_builtin_subscriber (dds_participant *participant)
|
||||
{
|
||||
dds_qos_t *qos = dds__create_builtin_qos ();
|
||||
dds_entity_t sub = dds__create_subscriber_l (participant, qos, NULL);
|
||||
|
|
@ -154,27 +142,37 @@ dds_entity_t dds__get_builtin_subscriber (dds_entity_t e)
|
|||
return ret;
|
||||
|
||||
if (p->m_builtin_subscriber <= 0) {
|
||||
p->m_builtin_subscriber = dds__create_builtin_subscriber (&p->m_entity);
|
||||
p->m_builtin_subscriber = dds__create_builtin_subscriber (p);
|
||||
}
|
||||
sub = p->m_builtin_subscriber;
|
||||
dds_participant_unlock(p);
|
||||
return sub;
|
||||
}
|
||||
|
||||
bool dds__builtin_is_visible (nn_entityid_t entityid, bool onlylocal, nn_vendorid_t vendorid)
|
||||
static bool dds__builtin_is_builtintopic (const struct ddsi_sertopic *tp, void *vdomain)
|
||||
{
|
||||
return !(onlylocal || is_builtin_endpoint (entityid, vendorid));
|
||||
(void) vdomain;
|
||||
return tp->ops == &ddsi_sertopic_ops_builtintopic;
|
||||
}
|
||||
|
||||
struct ddsi_tkmap_instance *dds__builtin_get_tkmap_entry (const struct nn_guid *guid)
|
||||
static bool dds__builtin_is_visible (const nn_guid_t *guid, nn_vendorid_t vendorid, void *vdomain)
|
||||
{
|
||||
(void) vdomain;
|
||||
if (is_builtin_endpoint (guid->entityid, vendorid))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static struct ddsi_tkmap_instance *dds__builtin_get_tkmap_entry (const struct nn_guid *guid, void *vdomain)
|
||||
{
|
||||
struct dds_domain *domain = vdomain;
|
||||
struct ddsi_tkmap_instance *tk;
|
||||
struct ddsi_serdata *sd;
|
||||
struct nn_keyhash kh;
|
||||
memcpy (&kh, guid, sizeof (kh));
|
||||
/* any random builtin topic will do (provided it has a GUID for a key), because what matters is the "class" of the topic, not the actual topic; also, this is called early in the initialisation of the entity with this GUID, which simply causes serdata_from_keyhash to create a key-only serdata because the key lookup fails. */
|
||||
sd = ddsi_serdata_from_keyhash (builtin_participant_topic, &kh);
|
||||
tk = ddsi_tkmap_find (sd, false, true);
|
||||
sd = ddsi_serdata_from_keyhash (domain->builtin_participant_topic, &kh);
|
||||
tk = ddsi_tkmap_find (domain->gv.m_tkmap, sd, true);
|
||||
ddsi_serdata_unref (sd);
|
||||
return tk;
|
||||
}
|
||||
|
|
@ -182,6 +180,7 @@ struct ddsi_tkmap_instance *dds__builtin_get_tkmap_entry (const struct nn_guid *
|
|||
struct ddsi_serdata *dds__builtin_make_sample (const struct entity_common *e, nn_wctime_t timestamp, bool alive)
|
||||
{
|
||||
/* initialize to avoid gcc warning ultimately caused by C's horrible type system */
|
||||
struct dds_domain *dom = e->gv->builtin_topic_interface->arg;
|
||||
struct ddsi_sertopic *topic = NULL;
|
||||
struct ddsi_serdata *serdata;
|
||||
struct nn_keyhash keyhash;
|
||||
|
|
@ -189,15 +188,15 @@ struct ddsi_serdata *dds__builtin_make_sample (const struct entity_common *e, nn
|
|||
{
|
||||
case EK_PARTICIPANT:
|
||||
case EK_PROXY_PARTICIPANT:
|
||||
topic = builtin_participant_topic;
|
||||
topic = dom->builtin_participant_topic;
|
||||
break;
|
||||
case EK_WRITER:
|
||||
case EK_PROXY_WRITER:
|
||||
topic = builtin_writer_topic;
|
||||
topic = dom->builtin_writer_topic;
|
||||
break;
|
||||
case EK_READER:
|
||||
case EK_PROXY_READER:
|
||||
topic = builtin_reader_topic;
|
||||
topic = dom->builtin_reader_topic;
|
||||
break;
|
||||
}
|
||||
assert (topic != NULL);
|
||||
|
|
@ -208,9 +207,10 @@ struct ddsi_serdata *dds__builtin_make_sample (const struct entity_common *e, nn
|
|||
return serdata;
|
||||
}
|
||||
|
||||
void dds__builtin_write (const struct entity_common *e, nn_wctime_t timestamp, bool alive)
|
||||
static void dds__builtin_write (const struct entity_common *e, nn_wctime_t timestamp, bool alive, void *vdomain)
|
||||
{
|
||||
if (ddsi_plugin.builtintopic_is_visible (e->guid.entityid, e->onlylocal, get_entity_vendorid (e)))
|
||||
struct dds_domain *dom = vdomain;
|
||||
if (dds__builtin_is_visible (&e->guid, get_entity_vendorid (e), dom))
|
||||
{
|
||||
/* initialize to avoid gcc warning ultimately caused by C's horrible type system */
|
||||
struct local_orphan_writer *bwr = NULL;
|
||||
|
|
@ -220,17 +220,54 @@ void dds__builtin_write (const struct entity_common *e, nn_wctime_t timestamp, b
|
|||
{
|
||||
case EK_PARTICIPANT:
|
||||
case EK_PROXY_PARTICIPANT:
|
||||
bwr = builtintopic_writer_participant;
|
||||
bwr = dom->builtintopic_writer_participant;
|
||||
break;
|
||||
case EK_WRITER:
|
||||
case EK_PROXY_WRITER:
|
||||
bwr = builtintopic_writer_publications;
|
||||
bwr = dom->builtintopic_writer_publications;
|
||||
break;
|
||||
case EK_READER:
|
||||
case EK_PROXY_READER:
|
||||
bwr = builtintopic_writer_subscriptions;
|
||||
bwr = dom->builtintopic_writer_subscriptions;
|
||||
break;
|
||||
}
|
||||
dds_writecdr_impl_lowlevel (&bwr->wr, NULL, serdata);
|
||||
dds_writecdr_impl_lowlevel (&bwr->wr, NULL, serdata, true);
|
||||
}
|
||||
}
|
||||
|
||||
void dds__builtin_init (struct dds_domain *dom)
|
||||
{
|
||||
dds_qos_t *qos = dds__create_builtin_qos ();
|
||||
|
||||
dom->btif.arg = dom;
|
||||
dom->btif.builtintopic_get_tkmap_entry = dds__builtin_get_tkmap_entry;
|
||||
dom->btif.builtintopic_is_builtintopic = dds__builtin_is_builtintopic;
|
||||
dom->btif.builtintopic_is_visible = dds__builtin_is_visible;
|
||||
dom->btif.builtintopic_write = dds__builtin_write;
|
||||
dom->gv.builtin_topic_interface = &dom->btif;
|
||||
|
||||
dom->builtin_participant_topic = new_sertopic_builtintopic (DSBT_PARTICIPANT, "DCPSParticipant", "org::eclipse::cyclonedds::builtin::DCPSParticipant", &dom->gv);
|
||||
dom->builtin_reader_topic = new_sertopic_builtintopic (DSBT_READER, "DCPSSubscription", "org::eclipse::cyclonedds::builtin::DCPSSubscription", &dom->gv);
|
||||
dom->builtin_writer_topic = new_sertopic_builtintopic (DSBT_WRITER, "DCPSPublication", "org::eclipse::cyclonedds::builtin::DCPSPublication", &dom->gv);
|
||||
|
||||
const struct ephash *gh = dom->gv.guid_hash;
|
||||
dom->builtintopic_writer_participant = new_local_orphan_writer (&dom->gv, to_entityid (NN_ENTITYID_SPDP_BUILTIN_PARTICIPANT_WRITER), dom->builtin_participant_topic, qos, builtintopic_whc_new (DSBT_PARTICIPANT, gh));
|
||||
dom->builtintopic_writer_publications = new_local_orphan_writer (&dom->gv, to_entityid (NN_ENTITYID_SEDP_BUILTIN_PUBLICATIONS_WRITER), dom->builtin_writer_topic, qos, builtintopic_whc_new (DSBT_WRITER, gh));
|
||||
dom->builtintopic_writer_subscriptions = new_local_orphan_writer (&dom->gv, to_entityid (NN_ENTITYID_SEDP_BUILTIN_SUBSCRIPTIONS_WRITER), dom->builtin_reader_topic, qos, builtintopic_whc_new (DSBT_READER, gh));
|
||||
|
||||
dds_delete_qos (qos);
|
||||
}
|
||||
|
||||
void dds__builtin_fini (struct dds_domain *dom)
|
||||
{
|
||||
/* No more sources for builtin topic samples */
|
||||
thread_state_awake (lookup_thread_state (), &dom->gv);
|
||||
delete_local_orphan_writer (dom->builtintopic_writer_participant);
|
||||
delete_local_orphan_writer (dom->builtintopic_writer_publications);
|
||||
delete_local_orphan_writer (dom->builtintopic_writer_subscriptions);
|
||||
thread_state_asleep (lookup_thread_state ());
|
||||
|
||||
ddsi_sertopic_unref (dom->builtin_participant_topic);
|
||||
ddsi_sertopic_unref (dom->builtin_reader_topic);
|
||||
ddsi_sertopic_unref (dom->builtin_writer_topic);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,19 +15,14 @@
|
|||
#include "dds__entity.h"
|
||||
#include "dds__subscriber.h"
|
||||
#include "dds__publisher.h"
|
||||
#include "dds__err.h"
|
||||
|
||||
dds_return_t
|
||||
dds_begin_coherent(
|
||||
dds_entity_t entity)
|
||||
dds_return_t dds_begin_coherent (dds_entity_t entity)
|
||||
{
|
||||
static const dds_entity_kind_t kinds[] = { DDS_KIND_READER, DDS_KIND_WRITER, DDS_KIND_PUBLISHER, DDS_KIND_SUBSCRIBER };
|
||||
return dds_generic_unimplemented_operation_manykinds (entity, sizeof (kinds) / sizeof (kinds[0]), kinds);
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
dds_end_coherent(
|
||||
dds_entity_t entity)
|
||||
dds_return_t dds_end_coherent (dds_entity_t entity)
|
||||
{
|
||||
static const dds_entity_kind_t kinds[] = { DDS_KIND_READER, DDS_KIND_WRITER, DDS_KIND_PUBLISHER, DDS_KIND_SUBSCRIBER };
|
||||
return dds_generic_unimplemented_operation_manykinds (entity, sizeof (kinds) / sizeof (kinds[0]), kinds);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||
* Copyright(c) 2006 to 2019 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
|
||||
|
|
@ -9,51 +9,317 @@
|
|||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include "dds__domain.h"
|
||||
#include "dds/ddsi/ddsi_tkmap.h"
|
||||
#include <string.h>
|
||||
|
||||
static int dds_domain_compare (const int32_t * a, const int32_t * b)
|
||||
#include "dds/ddsrt/environ.h"
|
||||
#include "dds/ddsrt/process.h"
|
||||
#include "dds/ddsrt/heap.h"
|
||||
#include "dds__init.h"
|
||||
#include "dds__rhc.h"
|
||||
#include "dds__domain.h"
|
||||
#include "dds__builtin.h"
|
||||
#include "dds__whc_builtintopic.h"
|
||||
#include "dds/ddsi/ddsi_iid.h"
|
||||
#include "dds/ddsi/ddsi_tkmap.h"
|
||||
#include "dds/ddsi/ddsi_serdata.h"
|
||||
#include "dds/ddsi/ddsi_threadmon.h"
|
||||
#include "dds/ddsi/q_entity.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/q_gc.h"
|
||||
#include "dds/ddsi/q_globals.h"
|
||||
#include "dds/version.h"
|
||||
|
||||
static int dds_domain_compare (const void *va, const void *vb)
|
||||
{
|
||||
const dds_domainid_t *a = va;
|
||||
const dds_domainid_t *b = vb;
|
||||
return (*a == *b) ? 0 : (*a < *b) ? -1 : 1;
|
||||
}
|
||||
|
||||
const ddsrt_avl_treedef_t dds_domaintree_def = DDSRT_AVL_TREEDEF_INITIALIZER
|
||||
(
|
||||
offsetof (dds_domain, m_node),
|
||||
offsetof (dds_domain, m_id),
|
||||
(int (*) (const void *, const void *)) dds_domain_compare,
|
||||
0
|
||||
);
|
||||
static const ddsrt_avl_treedef_t dds_domaintree_def = DDSRT_AVL_TREEDEF_INITIALIZER (
|
||||
offsetof (dds_domain, m_node), offsetof (dds_domain, m_id), dds_domain_compare, 0);
|
||||
|
||||
dds_domain * dds_domain_find_locked (dds_domainid_t id)
|
||||
static dds_return_t dds_domain_init (dds_domain *domain, dds_domainid_t domain_id)
|
||||
{
|
||||
dds_return_t ret = DDS_RETCODE_OK;
|
||||
char * uri = NULL;
|
||||
uint32_t len;
|
||||
|
||||
domain->gv.tstart = now ();
|
||||
domain->m_refc = 1;
|
||||
ddsrt_avl_init (&dds_topictree_def, &domain->m_topics);
|
||||
|
||||
/* | domain_id | domain id in config | result
|
||||
+-----------+---------------------+----------
|
||||
| DEFAULT | any (or absent) | 0
|
||||
| DEFAULT | n | n
|
||||
| n | any (or absent) | n
|
||||
| n | m = n | n
|
||||
| n | m /= n | n, entire config ignored
|
||||
|
||||
Config models:
|
||||
1: <CycloneDDS>
|
||||
<Domain id="X">...</Domain>
|
||||
<Domain .../>
|
||||
</CycloneDDS>
|
||||
where ... is all that can today be set in children of CycloneDDS
|
||||
with the exception of the id
|
||||
2: <CycloneDDS>
|
||||
<Domain><Id>X</Id></Domain>
|
||||
...
|
||||
</CycloneDDS>
|
||||
legacy form, domain id must be the first element in the file with
|
||||
a value (if nothing has been set previously, it a warning is good
|
||||
enough) */
|
||||
|
||||
(void) ddsrt_getenv ("CYCLONEDDS_URI", &uri);
|
||||
domain->cfgst = config_init (uri, &domain->gv.config, domain_id);
|
||||
if (domain->cfgst == NULL)
|
||||
{
|
||||
DDS_ILOG (DDS_LC_CONFIG, domain_id, "Failed to parse configuration XML file %s\n", uri);
|
||||
ret = DDS_RETCODE_ERROR;
|
||||
goto fail_config;
|
||||
}
|
||||
|
||||
assert (domain_id == DDS_DOMAIN_DEFAULT || domain_id == domain->gv.config.domainId);
|
||||
domain->m_id = domain->gv.config.domainId;
|
||||
|
||||
if (rtps_config_prep (&domain->gv, domain->cfgst) != 0)
|
||||
{
|
||||
DDS_ILOG (DDS_LC_CONFIG, domain->m_id, "Failed to configure RTPS\n");
|
||||
ret = DDS_RETCODE_ERROR;
|
||||
goto fail_rtps_config;
|
||||
}
|
||||
|
||||
if (rtps_init (&domain->gv) < 0)
|
||||
{
|
||||
DDS_ILOG (DDS_LC_CONFIG, domain->m_id, "Failed to initialize RTPS\n");
|
||||
ret = DDS_RETCODE_ERROR;
|
||||
goto fail_rtps_init;
|
||||
}
|
||||
|
||||
/* Start monitoring the liveliness of threads if this is the first
|
||||
domain to configured to do so. */
|
||||
if (domain->gv.config.liveliness_monitoring)
|
||||
{
|
||||
if (dds_global.threadmon_count++ == 0)
|
||||
{
|
||||
/* FIXME: configure settings */
|
||||
dds_global.threadmon = ddsi_threadmon_new (DDS_MSECS (333), true);
|
||||
if (dds_global.threadmon == NULL)
|
||||
{
|
||||
DDS_ILOG (DDS_LC_CONFIG, domain->m_id, "Failed to create a thread liveliness monitor\n");
|
||||
ret = DDS_RETCODE_OUT_OF_RESOURCES;
|
||||
goto fail_threadmon_new;
|
||||
}
|
||||
/* FIXME: thread properties */
|
||||
if (ddsi_threadmon_start (dds_global.threadmon, "threadmon") < 0)
|
||||
{
|
||||
DDS_ILOG (DDS_LC_ERROR, domain->m_id, "Failed to start the thread liveliness monitor\n");
|
||||
ret = DDS_RETCODE_ERROR;
|
||||
goto fail_threadmon_start;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dds__builtin_init (domain);
|
||||
|
||||
/* Set additional default participant properties */
|
||||
|
||||
char progname[50] = "UNKNOWN"; /* FIXME: once retrieving process names is back in */
|
||||
char hostname[64];
|
||||
domain->gv.default_local_plist_pp.process_id = (unsigned) ddsrt_getpid();
|
||||
domain->gv.default_local_plist_pp.present |= PP_PRISMTECH_PROCESS_ID;
|
||||
domain->gv.default_local_plist_pp.exec_name = dds_string_alloc(32);
|
||||
(void) snprintf (domain->gv.default_local_plist_pp.exec_name, 32, "CycloneDDS: %u", domain->gv.default_local_plist_pp.process_id);
|
||||
len = (uint32_t) (13 + strlen (domain->gv.default_local_plist_pp.exec_name));
|
||||
domain->gv.default_local_plist_pp.present |= PP_PRISMTECH_EXEC_NAME;
|
||||
if (ddsrt_gethostname (hostname, sizeof (hostname)) == DDS_RETCODE_OK)
|
||||
{
|
||||
domain->gv.default_local_plist_pp.node_name = dds_string_dup (hostname);
|
||||
domain->gv.default_local_plist_pp.present |= PP_PRISMTECH_NODE_NAME;
|
||||
}
|
||||
domain->gv.default_local_plist_pp.entity_name = dds_alloc (len);
|
||||
(void) snprintf (domain->gv.default_local_plist_pp.entity_name, len, "%s<%u>", progname, domain->gv.default_local_plist_pp.process_id);
|
||||
domain->gv.default_local_plist_pp.present |= PP_ENTITY_NAME;
|
||||
|
||||
if (rtps_start (&domain->gv) < 0)
|
||||
{
|
||||
DDS_ILOG (DDS_LC_CONFIG, domain->m_id, "Failed to start RTPS\n");
|
||||
ret = DDS_RETCODE_ERROR;
|
||||
goto fail_rtps_start;
|
||||
}
|
||||
|
||||
if (domain->gv.config.liveliness_monitoring)
|
||||
ddsi_threadmon_register_domain (dds_global.threadmon, &domain->gv);
|
||||
return DDS_RETCODE_OK;
|
||||
|
||||
rtps_stop (&domain->gv);
|
||||
fail_rtps_start:
|
||||
if (domain->gv.config.liveliness_monitoring && dds_global.threadmon_count == 1)
|
||||
ddsi_threadmon_stop (dds_global.threadmon);
|
||||
fail_threadmon_start:
|
||||
if (domain->gv.config.liveliness_monitoring && --dds_global.threadmon_count == 0)
|
||||
{
|
||||
ddsi_threadmon_free (dds_global.threadmon);
|
||||
dds_global.threadmon = NULL;
|
||||
}
|
||||
fail_threadmon_new:
|
||||
rtps_fini (&domain->gv);
|
||||
fail_rtps_init:
|
||||
fail_rtps_config:
|
||||
config_fini (domain->cfgst);
|
||||
fail_config:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void dds_domain_fini (struct dds_domain *domain)
|
||||
{
|
||||
rtps_stop (&domain->gv);
|
||||
dds__builtin_fini (domain);
|
||||
|
||||
if (domain->gv.config.liveliness_monitoring)
|
||||
ddsi_threadmon_unregister_domain (dds_global.threadmon, &domain->gv);
|
||||
|
||||
rtps_fini (&domain->gv);
|
||||
|
||||
ddsrt_mutex_lock (&dds_global.m_mutex);
|
||||
if (domain->gv.config.liveliness_monitoring && --dds_global.threadmon_count == 0)
|
||||
{
|
||||
ddsi_threadmon_stop (dds_global.threadmon);
|
||||
ddsi_threadmon_free (dds_global.threadmon);
|
||||
}
|
||||
ddsrt_mutex_unlock (&dds_global.m_mutex);
|
||||
|
||||
config_fini (domain->cfgst);
|
||||
}
|
||||
|
||||
dds_domain *dds_domain_find_locked (dds_domainid_t id)
|
||||
{
|
||||
return ddsrt_avl_lookup (&dds_domaintree_def, &dds_global.m_domains, &id);
|
||||
}
|
||||
|
||||
dds_domain * dds_domain_create (dds_domainid_t id)
|
||||
dds_return_t dds_domain_create (dds_domain **domain_out, dds_domainid_t id)
|
||||
{
|
||||
dds_domain * domain;
|
||||
struct dds_domain *dom = NULL;
|
||||
dds_return_t ret;
|
||||
|
||||
ddsrt_mutex_lock (&dds_global.m_mutex);
|
||||
domain = dds_domain_find_locked (id);
|
||||
if (domain == NULL)
|
||||
|
||||
/* FIXME: hack around default domain ids, not yet being able to handle multiple domains simultaneously */
|
||||
if (id != DDS_DOMAIN_DEFAULT)
|
||||
{
|
||||
domain = dds_alloc (sizeof (*domain));
|
||||
domain->m_id = id;
|
||||
ddsrt_avl_init (&dds_topictree_def, &domain->m_topics);
|
||||
ddsrt_avl_insert (&dds_domaintree_def, &dds_global.m_domains, domain);
|
||||
if ((dom = dds_domain_find_locked (id)) == NULL)
|
||||
ret = DDS_RETCODE_NOT_FOUND;
|
||||
else
|
||||
ret = DDS_RETCODE_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((dom = ddsrt_avl_find_min (&dds_domaintree_def, &dds_global.m_domains)) != NULL)
|
||||
ret = DDS_RETCODE_OK;
|
||||
else
|
||||
ret = DDS_RETCODE_NOT_FOUND;
|
||||
}
|
||||
|
||||
switch (ret)
|
||||
{
|
||||
case DDS_RETCODE_OK:
|
||||
dom->m_refc++;
|
||||
*domain_out = dom;
|
||||
break;
|
||||
case DDS_RETCODE_NOT_FOUND:
|
||||
dom = dds_alloc (sizeof (*dom));
|
||||
if ((ret = dds_domain_init (dom, id)) < 0)
|
||||
dds_free (dom);
|
||||
else
|
||||
{
|
||||
ddsrt_avl_insert (&dds_domaintree_def, &dds_global.m_domains, dom);
|
||||
*domain_out = dom;
|
||||
}
|
||||
break;
|
||||
case DDS_RETCODE_PRECONDITION_NOT_MET:
|
||||
DDS_ILOG (DDS_LC_ERROR, id, "Inconsistent domain configuration detected: domain on configuration: %"PRIu32", domain %"PRIu32"\n", dom->m_id, id);
|
||||
break;
|
||||
}
|
||||
domain->m_refc++;
|
||||
ddsrt_mutex_unlock (&dds_global.m_mutex);
|
||||
return domain;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void dds_domain_free (dds_domain * domain)
|
||||
void dds_domain_free (dds_domain *domain)
|
||||
{
|
||||
ddsrt_mutex_lock (&dds_global.m_mutex);
|
||||
if (--domain->m_refc == 0)
|
||||
if (--domain->m_refc != 0)
|
||||
{
|
||||
ddsrt_mutex_unlock (&dds_global.m_mutex);
|
||||
}
|
||||
else
|
||||
{
|
||||
ddsrt_avl_delete (&dds_domaintree_def, &dds_global.m_domains, domain);
|
||||
ddsrt_mutex_unlock (&dds_global.m_mutex);
|
||||
dds_domain_fini (domain);
|
||||
dds_free (domain);
|
||||
}
|
||||
ddsrt_mutex_unlock (&dds_global.m_mutex);
|
||||
}
|
||||
|
||||
#include "dds__entity.h"
|
||||
static void pushdown_set_batch (struct dds_entity *e, bool enable)
|
||||
{
|
||||
/* e is pinned, no locks held */
|
||||
dds_instance_handle_t last_iid = 0;
|
||||
struct dds_entity *c;
|
||||
ddsrt_mutex_lock (&e->m_mutex);
|
||||
while ((c = ddsrt_avl_lookup_succ (&dds_entity_children_td, &e->m_children, &last_iid)) != NULL)
|
||||
{
|
||||
struct dds_entity *x;
|
||||
last_iid = c->m_iid;
|
||||
if (dds_entity_pin (c->m_hdllink.hdl, &x) < 0)
|
||||
continue;
|
||||
assert (x == c);
|
||||
ddsrt_mutex_unlock (&e->m_mutex);
|
||||
if (c->m_kind == DDS_KIND_PARTICIPANT)
|
||||
pushdown_set_batch (c, enable);
|
||||
else if (c->m_kind == DDS_KIND_WRITER)
|
||||
{
|
||||
struct dds_writer *w = (struct dds_writer *) c;
|
||||
w->whc_batch = enable;
|
||||
}
|
||||
ddsrt_mutex_lock (&e->m_mutex);
|
||||
dds_entity_unpin (c);
|
||||
}
|
||||
ddsrt_mutex_unlock (&e->m_mutex);
|
||||
}
|
||||
|
||||
void dds_write_set_batch (bool enable)
|
||||
{
|
||||
/* FIXME: get channels + latency budget working and get rid of this; in the mean time, any ugly hack will do. */
|
||||
struct dds_domain *dom;
|
||||
dds_domainid_t next_id = 0;
|
||||
dds_init ();
|
||||
ddsrt_mutex_lock (&dds_global.m_mutex);
|
||||
while ((dom = ddsrt_avl_lookup_succ_eq (&dds_domaintree_def, &dds_global.m_domains, &next_id)) != NULL)
|
||||
{
|
||||
/* Must be sure that the compiler doesn't reload curr_id from dom->m_id */
|
||||
dds_domainid_t curr_id = *((volatile dds_domainid_t *) &dom->m_id);
|
||||
next_id = curr_id + 1;
|
||||
dom->gv.config.whc_batch = enable;
|
||||
|
||||
dds_instance_handle_t last_iid = 0;
|
||||
struct dds_entity *e;
|
||||
while (dom && (e = ddsrt_avl_lookup_succ (&dds_entity_children_td, &dom->m_ppants, &last_iid)) != NULL)
|
||||
{
|
||||
struct dds_entity *x;
|
||||
last_iid = e->m_iid;
|
||||
if (dds_entity_pin (e->m_hdllink.hdl, &x) < 0)
|
||||
continue;
|
||||
assert (x == e);
|
||||
ddsrt_mutex_unlock (&dds_global.m_mutex);
|
||||
pushdown_set_batch (e, enable);
|
||||
ddsrt_mutex_lock (&dds_global.m_mutex);
|
||||
dds_entity_unpin (e);
|
||||
dom = ddsrt_avl_lookup (&dds_domaintree_def, &dds_global.m_domains, &curr_id);
|
||||
}
|
||||
}
|
||||
ddsrt_mutex_unlock (&dds_global.m_mutex);
|
||||
dds_fini ();
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -14,24 +14,33 @@
|
|||
#include "dds__reader.h"
|
||||
#include "dds__guardcond.h"
|
||||
#include "dds__participant.h"
|
||||
#include "dds__err.h"
|
||||
#include "dds/ddsi/ddsi_iid.h"
|
||||
#include "dds/ddsi/q_ephash.h"
|
||||
#include "dds/ddsi/q_entity.h"
|
||||
#include "dds/ddsi/q_thread.h"
|
||||
|
||||
DECL_ENTITY_LOCK_UNLOCK(extern inline, dds_guardcond)
|
||||
DECL_ENTITY_LOCK_UNLOCK (extern inline, dds_guardcond)
|
||||
|
||||
const struct dds_entity_deriver dds_entity_deriver_guardcondition = {
|
||||
.close = dds_entity_deriver_dummy_close,
|
||||
.delete = dds_entity_deriver_dummy_delete,
|
||||
.set_qos = dds_entity_deriver_dummy_set_qos,
|
||||
.validate_status = dds_entity_deriver_dummy_validate_status
|
||||
};
|
||||
|
||||
dds_entity_t dds_create_guardcondition (dds_entity_t participant)
|
||||
{
|
||||
dds_participant *pp;
|
||||
dds_retcode_t rc;
|
||||
dds_return_t rc;
|
||||
|
||||
if ((rc = dds_participant_lock (participant, &pp)) != DDS_RETCODE_OK)
|
||||
return DDS_ERRNO (rc);
|
||||
return rc;
|
||||
else
|
||||
{
|
||||
dds_guardcond * gcond = dds_alloc (sizeof (*gcond));
|
||||
dds_guardcond *gcond = dds_alloc (sizeof (*gcond));
|
||||
dds_entity_t hdl = dds_entity_init (&gcond->m_entity, &pp->m_entity, DDS_KIND_COND_GUARD, NULL, NULL, 0);
|
||||
gcond->m_entity.m_iid = ddsi_iid_gen ();
|
||||
dds_entity_register_child (&pp->m_entity, &gcond->m_entity);
|
||||
dds_participant_unlock (pp);
|
||||
return hdl;
|
||||
}
|
||||
|
|
@ -40,18 +49,16 @@ dds_entity_t dds_create_guardcondition (dds_entity_t participant)
|
|||
dds_return_t dds_set_guardcondition (dds_entity_t condition, bool triggered)
|
||||
{
|
||||
dds_guardcond *gcond;
|
||||
dds_retcode_t rc;
|
||||
dds_return_t rc;
|
||||
|
||||
if ((rc = dds_guardcond_lock (condition, &gcond)) != DDS_RETCODE_OK)
|
||||
return DDS_ERRNO (DDS_RETCODE_BAD_PARAMETER);
|
||||
return rc;
|
||||
else
|
||||
{
|
||||
ddsrt_mutex_lock (&gcond->m_entity.m_observers_lock);
|
||||
if (triggered)
|
||||
dds_entity_status_set (&gcond->m_entity, DDS_WAITSET_TRIGGER_STATUS);
|
||||
dds_entity_trigger_set (&gcond->m_entity, 1);
|
||||
else
|
||||
dds_entity_status_reset (&gcond->m_entity, DDS_WAITSET_TRIGGER_STATUS);
|
||||
ddsrt_mutex_unlock (&gcond->m_entity.m_observers_lock);
|
||||
ddsrt_atomic_st32 (&gcond->m_entity.m_status.m_trigger, 0);
|
||||
dds_guardcond_unlock (gcond);
|
||||
return DDS_RETCODE_OK;
|
||||
}
|
||||
|
|
@ -60,19 +67,17 @@ dds_return_t dds_set_guardcondition (dds_entity_t condition, bool triggered)
|
|||
dds_return_t dds_read_guardcondition (dds_entity_t condition, bool *triggered)
|
||||
{
|
||||
dds_guardcond *gcond;
|
||||
dds_retcode_t rc;
|
||||
dds_return_t rc;
|
||||
|
||||
if (triggered == NULL)
|
||||
return DDS_ERRNO (DDS_RETCODE_BAD_PARAMETER);
|
||||
return DDS_RETCODE_BAD_PARAMETER;
|
||||
|
||||
*triggered = false;
|
||||
if ((rc = dds_guardcond_lock (condition, &gcond)) != DDS_RETCODE_OK)
|
||||
return DDS_ERRNO (DDS_RETCODE_BAD_PARAMETER);
|
||||
return rc;
|
||||
else
|
||||
{
|
||||
ddsrt_mutex_lock (&gcond->m_entity.m_observers_lock);
|
||||
*triggered = dds_entity_status_match (&gcond->m_entity, DDS_WAITSET_TRIGGER_STATUS);
|
||||
ddsrt_mutex_unlock (&gcond->m_entity.m_observers_lock);
|
||||
*triggered = (ddsrt_atomic_ld32 (&gcond->m_entity.m_status.m_trigger) != 0);
|
||||
dds_guardcond_unlock (gcond);
|
||||
return DDS_RETCODE_OK;
|
||||
}
|
||||
|
|
@ -81,20 +86,17 @@ dds_return_t dds_read_guardcondition (dds_entity_t condition, bool *triggered)
|
|||
dds_return_t dds_take_guardcondition (dds_entity_t condition, bool *triggered)
|
||||
{
|
||||
dds_guardcond *gcond;
|
||||
dds_retcode_t rc;
|
||||
dds_return_t rc;
|
||||
|
||||
if (triggered == NULL)
|
||||
return DDS_ERRNO (DDS_RETCODE_BAD_PARAMETER);
|
||||
return DDS_RETCODE_BAD_PARAMETER;
|
||||
|
||||
*triggered = false;
|
||||
if ((rc = dds_guardcond_lock (condition, &gcond)) != DDS_RETCODE_OK)
|
||||
return DDS_ERRNO (DDS_RETCODE_BAD_PARAMETER);
|
||||
return rc;
|
||||
else
|
||||
{
|
||||
ddsrt_mutex_lock (&gcond->m_entity.m_observers_lock);
|
||||
*triggered = dds_entity_status_match (&gcond->m_entity, DDS_WAITSET_TRIGGER_STATUS);
|
||||
dds_entity_status_reset (&gcond->m_entity, DDS_WAITSET_TRIGGER_STATUS);
|
||||
ddsrt_mutex_unlock (&gcond->m_entity.m_observers_lock);
|
||||
*triggered = (ddsrt_atomic_and32_ov (&gcond->m_entity.m_status.m_trigger, 0) != 0);
|
||||
dds_guardcond_unlock (gcond);
|
||||
return DDS_RETCODE_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
#include "dds/ddsi/q_thread.h"
|
||||
#include "dds__handles.h"
|
||||
#include "dds__types.h"
|
||||
#include "dds__err.h"
|
||||
|
||||
/* FIXME: this code isn't really correct when USE_CHH is set:
|
||||
- the DDS entity code doesn't really play by the awake/asleep mechanism
|
||||
|
|
@ -29,7 +28,19 @@
|
|||
#define USE_CHH 0
|
||||
|
||||
#define HDL_FLAG_CLOSED (0x80000000u)
|
||||
#define HDL_COUNT_MASK (0x00ffffffu)
|
||||
|
||||
/* ref count: # outstanding references to this handle/object (not so sure it is
|
||||
ideal to have a one-to-one mapping between the two, but that is what the rest
|
||||
of the code assumes at the moment); so this limits one to having, e.g., no
|
||||
more than 64k endpoints referencing the same topic */
|
||||
#define HDL_REFCOUNT_MASK (0x0ffff000u)
|
||||
#define HDL_REFCOUNT_UNIT (0x00001000u)
|
||||
#define HDL_REFCOUNT_SHIFT 12
|
||||
|
||||
/* pin count: # concurrent operations, so allowing up to 4096 threads had better
|
||||
be enough ... */
|
||||
#define HDL_PINCOUNT_MASK (0x00000fffu)
|
||||
#define HDL_PINCOUNT_UNIT (0x00000001u)
|
||||
|
||||
/* Maximum number of handles is INT32_MAX - 1, but as the allocator relies on a
|
||||
random generator for finding a free one, the time spent in the dds_handle_create
|
||||
|
|
@ -65,13 +76,12 @@ static int handle_equal (const void *va, const void *vb)
|
|||
return a->hdl == b->hdl;
|
||||
}
|
||||
|
||||
dds_return_t dds_handle_server_init (void (*free_via_gc) (void *x))
|
||||
dds_return_t dds_handle_server_init (void)
|
||||
{
|
||||
#if USE_CHH
|
||||
handles.ht = ddsrt_chh_new (128, handle_hash, handle_equal, free_via_gc);
|
||||
#else
|
||||
handles.ht = ddsrt_hh_new (128, handle_hash, handle_equal);
|
||||
(void) free_via_gc;
|
||||
#endif
|
||||
handles.count = 0;
|
||||
ddsrt_mutex_init (&handles.lock);
|
||||
|
|
@ -106,7 +116,7 @@ static bool hhadd (struct ddsrt_hh *ht, void *elem) { return ddsrt_hh_add (ht, e
|
|||
#endif
|
||||
static dds_handle_t dds_handle_create_int (struct dds_handle_link *link)
|
||||
{
|
||||
ddsrt_atomic_st32 (&link->cnt_flags, 0);
|
||||
ddsrt_atomic_st32 (&link->cnt_flags, HDL_REFCOUNT_UNIT);
|
||||
do {
|
||||
do {
|
||||
link->hdl = (int32_t) (ddsrt_random () & INT32_MAX);
|
||||
|
|
@ -128,7 +138,7 @@ dds_handle_t dds_handle_create (struct dds_handle_link *link)
|
|||
if (handles.count == MAX_HANDLES)
|
||||
{
|
||||
ddsrt_mutex_unlock (&handles.lock);
|
||||
ret = DDS_ERRNO (DDS_RETCODE_OUT_OF_RESOURCES);
|
||||
ret = DDS_RETCODE_OUT_OF_RESOURCES;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -160,11 +170,12 @@ int32_t dds_handle_delete (struct dds_handle_link *link, dds_duration_t timeout)
|
|||
#endif
|
||||
assert (ddsrt_atomic_ld32 (&link->cnt_flags) & HDL_FLAG_CLOSED);
|
||||
ddsrt_mutex_lock (&handles.lock);
|
||||
if ((ddsrt_atomic_ld32 (&link->cnt_flags) & HDL_COUNT_MASK) != 0)
|
||||
if ((ddsrt_atomic_ld32 (&link->cnt_flags) & HDL_PINCOUNT_MASK) != 0)
|
||||
{
|
||||
/* FIXME: */
|
||||
/* FIXME: there is no sensible solution when this times out, so it must
|
||||
never do that ... */
|
||||
const dds_time_t abstimeout = dds_time () + timeout;
|
||||
while ((ddsrt_atomic_ld32 (&link->cnt_flags) & HDL_COUNT_MASK) != 0)
|
||||
while ((ddsrt_atomic_ld32 (&link->cnt_flags) & HDL_PINCOUNT_MASK) != 0)
|
||||
{
|
||||
if (!ddsrt_cond_waituntil (&handles.cond, &handles.lock, abstimeout))
|
||||
{
|
||||
|
|
@ -189,7 +200,7 @@ int32_t dds_handle_delete (struct dds_handle_link *link, dds_duration_t timeout)
|
|||
return DDS_RETCODE_OK;
|
||||
}
|
||||
|
||||
int32_t dds_handle_claim (dds_handle_t hdl, struct dds_handle_link **link)
|
||||
int32_t dds_handle_pin (dds_handle_t hdl, struct dds_handle_link **link)
|
||||
{
|
||||
#if USE_CHH
|
||||
struct thread_state1 * const ts1 = lookup_thread_state ();
|
||||
|
|
@ -197,7 +208,7 @@ int32_t dds_handle_claim (dds_handle_t hdl, struct dds_handle_link **link)
|
|||
struct dds_handle_link dummy = { .hdl = hdl };
|
||||
int32_t rc;
|
||||
/* it makes sense to check here for initialization: the first thing any operation
|
||||
(other than create_participant) does is to call dds_handle_claim on the supplied
|
||||
(other than create_participant) does is to call dds_handle_pin on the supplied
|
||||
entity, so checking here whether the library has been initialised helps avoid
|
||||
crashes if someone forgets to create a participant (or allows a program to
|
||||
continue after failing to create one).
|
||||
|
|
@ -229,7 +240,7 @@ int32_t dds_handle_claim (dds_handle_t hdl, struct dds_handle_link **link)
|
|||
rc = DDS_RETCODE_BAD_PARAMETER;
|
||||
break;
|
||||
}
|
||||
} while (!ddsrt_atomic_cas32 (&(*link)->cnt_flags, cnt_flags, cnt_flags + 1));
|
||||
} while (!ddsrt_atomic_cas32 (&(*link)->cnt_flags, cnt_flags, cnt_flags + HDL_PINCOUNT_UNIT));
|
||||
}
|
||||
#if USE_CHH
|
||||
thread_state_asleep (ts1);
|
||||
|
|
@ -239,16 +250,18 @@ int32_t dds_handle_claim (dds_handle_t hdl, struct dds_handle_link **link)
|
|||
return rc;
|
||||
}
|
||||
|
||||
void dds_handle_claim_inc (struct dds_handle_link *link)
|
||||
void dds_handle_repin (struct dds_handle_link *link)
|
||||
{
|
||||
DDSRT_STATIC_ASSERT (HDL_PINCOUNT_UNIT == 1);
|
||||
uint32_t x = ddsrt_atomic_inc32_nv (&link->cnt_flags);
|
||||
assert (!(x & HDL_FLAG_CLOSED));
|
||||
(void) x;
|
||||
}
|
||||
|
||||
void dds_handle_release (struct dds_handle_link *link)
|
||||
void dds_handle_unpin (struct dds_handle_link *link)
|
||||
{
|
||||
if (ddsrt_atomic_dec32_ov (&link->cnt_flags) == (HDL_FLAG_CLOSED | 1))
|
||||
DDSRT_STATIC_ASSERT (HDL_PINCOUNT_UNIT == 1);
|
||||
if ((ddsrt_atomic_dec32_ov (&link->cnt_flags) & (HDL_FLAG_CLOSED | HDL_PINCOUNT_MASK)) == (HDL_FLAG_CLOSED | HDL_PINCOUNT_UNIT))
|
||||
{
|
||||
ddsrt_mutex_lock (&handles.lock);
|
||||
ddsrt_cond_broadcast (&handles.cond);
|
||||
|
|
@ -256,6 +269,25 @@ void dds_handle_release (struct dds_handle_link *link)
|
|||
}
|
||||
}
|
||||
|
||||
void dds_handle_add_ref (struct dds_handle_link *link)
|
||||
{
|
||||
ddsrt_atomic_add32 (&link->cnt_flags, HDL_REFCOUNT_UNIT);
|
||||
}
|
||||
|
||||
bool dds_handle_drop_ref (struct dds_handle_link *link)
|
||||
{
|
||||
assert ((ddsrt_atomic_ld32 (&link->cnt_flags) & HDL_REFCOUNT_MASK) != 0);
|
||||
uint32_t old, new;
|
||||
do {
|
||||
old = ddsrt_atomic_ld32 (&link->cnt_flags);
|
||||
if ((old & HDL_REFCOUNT_MASK) != HDL_REFCOUNT_UNIT)
|
||||
new = old - HDL_REFCOUNT_UNIT;
|
||||
else
|
||||
new = (old - HDL_REFCOUNT_UNIT) | HDL_FLAG_CLOSED;
|
||||
} while (!ddsrt_atomic_cas32 (&link->cnt_flags, old, new));
|
||||
return (new & HDL_REFCOUNT_MASK) == 0;
|
||||
}
|
||||
|
||||
bool dds_handle_is_closed (struct dds_handle_link *link)
|
||||
{
|
||||
return (ddsrt_atomic_ld32 (&link->cnt_flags) & HDL_FLAG_CLOSED) != 0;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
#include "dds__init.h"
|
||||
#include "dds__rhc.h"
|
||||
#include "dds__domain.h"
|
||||
#include "dds__err.h"
|
||||
#include "dds__builtin.h"
|
||||
#include "dds__whc_builtintopic.h"
|
||||
#include "dds/ddsi/ddsi_iid.h"
|
||||
|
|
@ -36,271 +35,58 @@
|
|||
#define DOMAIN_ID_MIN 0
|
||||
#define DOMAIN_ID_MAX 230
|
||||
|
||||
struct q_globals gv;
|
||||
dds_globals dds_global;
|
||||
|
||||
dds_globals dds_global = { .m_default_domain = DDS_DOMAIN_DEFAULT };
|
||||
static struct cfgst * dds_cfgst = NULL;
|
||||
|
||||
static void free_via_gc_cb (struct gcreq *gcreq)
|
||||
dds_return_t dds_init (void)
|
||||
{
|
||||
void *bs = gcreq->arg;
|
||||
gcreq_free (gcreq);
|
||||
ddsrt_free (bs);
|
||||
}
|
||||
dds_return_t ret;
|
||||
|
||||
static void free_via_gc (void *bs)
|
||||
{
|
||||
struct gcreq *gcreq = gcreq_new (gv.gcreq_queue, free_via_gc_cb);
|
||||
gcreq->arg = bs;
|
||||
gcreq_enqueue (gcreq);
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
dds_init(dds_domainid_t domain)
|
||||
{
|
||||
dds_return_t ret = DDS_RETCODE_OK;
|
||||
char * uri = NULL;
|
||||
char progname[50] = "UNKNOWN"; /* FIXME: once retrieving process names is back in */
|
||||
char hostname[64];
|
||||
uint32_t len;
|
||||
ddsrt_mutex_t *init_mutex;
|
||||
|
||||
/* Be sure the DDS lifecycle resources are initialized. */
|
||||
ddsrt_init();
|
||||
init_mutex = ddsrt_get_singleton_mutex();
|
||||
|
||||
ddsrt_mutex_lock(init_mutex);
|
||||
|
||||
dds_global.m_init_count++;
|
||||
if (dds_global.m_init_count > 1)
|
||||
ddsrt_init ();
|
||||
ddsrt_mutex_t * const init_mutex = ddsrt_get_singleton_mutex ();
|
||||
ddsrt_mutex_lock (init_mutex);
|
||||
if (dds_global.m_init_count++ != 0)
|
||||
{
|
||||
goto skip;
|
||||
ddsrt_mutex_unlock (init_mutex);
|
||||
return DDS_RETCODE_OK;
|
||||
}
|
||||
|
||||
gv.tstart = now ();
|
||||
gv.exception = false;
|
||||
ddsrt_mutex_init (&dds_global.m_mutex);
|
||||
thread_states_init_static();
|
||||
ddsi_iid_init ();
|
||||
thread_states_init_static ();
|
||||
thread_states_init (64);
|
||||
upgrade_main_thread ();
|
||||
|
||||
(void)ddsrt_getenv (DDS_PROJECT_NAME_NOSPACE_CAPS"_URI", &uri);
|
||||
dds_cfgst = config_init (uri);
|
||||
if (dds_cfgst == NULL)
|
||||
if (dds_handle_server_init () != DDS_RETCODE_OK)
|
||||
{
|
||||
DDS_LOG(DDS_LC_CONFIG, "Failed to parse configuration XML file %s\n", uri);
|
||||
ret = DDS_ERRNO(DDS_RETCODE_ERROR);
|
||||
goto fail_config;
|
||||
}
|
||||
|
||||
/* if a domain id was explicitly given, check & fix up the configuration */
|
||||
if (domain != DDS_DOMAIN_DEFAULT)
|
||||
{
|
||||
if (domain < 0 || domain > 230)
|
||||
{
|
||||
DDS_ERROR("requested domain id %"PRId32" is out of range\n", domain);
|
||||
ret = DDS_ERRNO(DDS_RETCODE_ERROR);
|
||||
goto fail_config_domainid;
|
||||
}
|
||||
else if (config.domainId.isdefault)
|
||||
{
|
||||
config.domainId.value = domain;
|
||||
}
|
||||
else if (domain != config.domainId.value)
|
||||
{
|
||||
DDS_ERROR("requested domain id %"PRId32" is inconsistent with configured value %"PRId32"\n", domain, config.domainId.value);
|
||||
ret = DDS_ERRNO(DDS_RETCODE_ERROR);
|
||||
goto fail_config_domainid;
|
||||
}
|
||||
}
|
||||
|
||||
/* The config.domainId can change internally in DDSI. So, remember what the
|
||||
* main configured domain id is. */
|
||||
dds_global.m_default_domain = config.domainId.value;
|
||||
|
||||
if (rtps_config_prep(dds_cfgst) != 0)
|
||||
{
|
||||
DDS_LOG(DDS_LC_CONFIG, "Failed to configure RTPS\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_ERROR);
|
||||
goto fail_rtps_config;
|
||||
}
|
||||
|
||||
upgrade_main_thread();
|
||||
ddsrt_avl_init(&dds_domaintree_def, &dds_global.m_domains);
|
||||
|
||||
/* Start monitoring the liveliness of all threads. */
|
||||
if (!config.liveliness_monitoring)
|
||||
gv.threadmon = NULL;
|
||||
else
|
||||
{
|
||||
gv.threadmon = ddsi_threadmon_new ();
|
||||
if (gv.threadmon == NULL)
|
||||
{
|
||||
DDS_ERROR("Failed to create a thread monitor\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_OUT_OF_RESOURCES);
|
||||
goto fail_threadmon_new;
|
||||
}
|
||||
}
|
||||
|
||||
if (rtps_init () < 0)
|
||||
{
|
||||
DDS_LOG(DDS_LC_CONFIG, "Failed to initialize RTPS\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_ERROR);
|
||||
goto fail_rtps_init;
|
||||
}
|
||||
|
||||
if (dds_handle_server_init (free_via_gc) != DDS_RETCODE_OK)
|
||||
{
|
||||
DDS_ERROR("Failed to initialize internal handle server\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_ERROR);
|
||||
DDS_ERROR ("Failed to initialize internal handle server\n");
|
||||
ret = DDS_RETCODE_ERROR;
|
||||
goto fail_handleserver;
|
||||
}
|
||||
|
||||
dds__builtin_init ();
|
||||
|
||||
if (rtps_start () < 0)
|
||||
{
|
||||
DDS_LOG(DDS_LC_CONFIG, "Failed to start RTPS\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_ERROR);
|
||||
goto fail_rtps_start;
|
||||
}
|
||||
|
||||
if (gv.threadmon && ddsi_threadmon_start(gv.threadmon) < 0)
|
||||
{
|
||||
DDS_ERROR("Failed to start the servicelease\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_ERROR);
|
||||
goto fail_threadmon_start;
|
||||
}
|
||||
|
||||
/* Set additional default participant properties */
|
||||
|
||||
gv.default_plist_pp.process_id = (unsigned)ddsrt_getpid();
|
||||
gv.default_plist_pp.present |= PP_PRISMTECH_PROCESS_ID;
|
||||
gv.default_plist_pp.exec_name = dds_string_alloc(32);
|
||||
(void) snprintf(gv.default_plist_pp.exec_name, 32, "%s: %u", DDS_PROJECT_NAME, gv.default_plist_pp.process_id);
|
||||
len = (uint32_t) (13 + strlen(gv.default_plist_pp.exec_name));
|
||||
gv.default_plist_pp.present |= PP_PRISMTECH_EXEC_NAME;
|
||||
if (ddsrt_gethostname(hostname, sizeof(hostname)) == DDS_RETCODE_OK)
|
||||
{
|
||||
gv.default_plist_pp.node_name = dds_string_dup(hostname);
|
||||
gv.default_plist_pp.present |= PP_PRISMTECH_NODE_NAME;
|
||||
}
|
||||
gv.default_plist_pp.entity_name = dds_alloc(len);
|
||||
(void) snprintf(gv.default_plist_pp.entity_name, len, "%s<%u>", progname,
|
||||
gv.default_plist_pp.process_id);
|
||||
gv.default_plist_pp.present |= PP_ENTITY_NAME;
|
||||
|
||||
skip:
|
||||
ddsrt_mutex_unlock(init_mutex);
|
||||
ddsrt_mutex_unlock (init_mutex);
|
||||
return DDS_RETCODE_OK;
|
||||
|
||||
fail_threadmon_start:
|
||||
if (gv.threadmon)
|
||||
ddsi_threadmon_stop (gv.threadmon);
|
||||
dds_handle_server_fini();
|
||||
fail_handleserver:
|
||||
rtps_stop ();
|
||||
fail_rtps_start:
|
||||
dds__builtin_fini ();
|
||||
rtps_fini ();
|
||||
fail_rtps_init:
|
||||
if (gv.threadmon)
|
||||
{
|
||||
ddsi_threadmon_free (gv.threadmon);
|
||||
gv.threadmon = NULL;
|
||||
}
|
||||
fail_threadmon_new:
|
||||
downgrade_main_thread ();
|
||||
thread_states_fini();
|
||||
fail_rtps_config:
|
||||
fail_config_domainid:
|
||||
dds_global.m_default_domain = DDS_DOMAIN_DEFAULT;
|
||||
config_fini (dds_cfgst);
|
||||
dds_cfgst = NULL;
|
||||
fail_config:
|
||||
ddsrt_mutex_destroy (&dds_global.m_mutex);
|
||||
dds_global.m_init_count--;
|
||||
ddsrt_mutex_unlock(init_mutex);
|
||||
ddsrt_fini();
|
||||
ddsrt_mutex_unlock (init_mutex);
|
||||
ddsrt_fini ();
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern void dds_fini (void)
|
||||
{
|
||||
ddsrt_mutex_t *init_mutex;
|
||||
init_mutex = ddsrt_get_singleton_mutex();
|
||||
ddsrt_mutex_lock(init_mutex);
|
||||
assert(dds_global.m_init_count > 0);
|
||||
dds_global.m_init_count--;
|
||||
if (dds_global.m_init_count == 0)
|
||||
ddsrt_mutex_t * const init_mutex = ddsrt_get_singleton_mutex ();
|
||||
ddsrt_mutex_lock (init_mutex);
|
||||
assert (dds_global.m_init_count > 0);
|
||||
if (--dds_global.m_init_count == 0)
|
||||
{
|
||||
if (gv.threadmon)
|
||||
ddsi_threadmon_stop (gv.threadmon);
|
||||
dds_handle_server_fini();
|
||||
rtps_stop ();
|
||||
dds__builtin_fini ();
|
||||
rtps_fini ();
|
||||
if (gv.threadmon)
|
||||
ddsi_threadmon_free (gv.threadmon);
|
||||
gv.threadmon = NULL;
|
||||
dds_handle_server_fini ();
|
||||
downgrade_main_thread ();
|
||||
thread_states_fini ();
|
||||
|
||||
config_fini (dds_cfgst);
|
||||
dds_cfgst = NULL;
|
||||
ddsi_iid_fini ();
|
||||
ddsrt_mutex_destroy (&dds_global.m_mutex);
|
||||
dds_global.m_default_domain = DDS_DOMAIN_DEFAULT;
|
||||
}
|
||||
ddsrt_mutex_unlock(init_mutex);
|
||||
ddsrt_fini();
|
||||
}
|
||||
|
||||
static int dds__init_plugin (void)
|
||||
{
|
||||
if (dds_global.m_dur_init) (dds_global.m_dur_init) ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void dds__fini_plugin (void)
|
||||
{
|
||||
if (dds_global.m_dur_fini) (dds_global.m_dur_fini) ();
|
||||
}
|
||||
|
||||
void ddsi_plugin_init (void)
|
||||
{
|
||||
ddsi_plugin.init_fn = dds__init_plugin;
|
||||
ddsi_plugin.fini_fn = dds__fini_plugin;
|
||||
|
||||
ddsi_plugin.builtintopic_is_visible = dds__builtin_is_visible;
|
||||
ddsi_plugin.builtintopic_get_tkmap_entry = dds__builtin_get_tkmap_entry;
|
||||
ddsi_plugin.builtintopic_write = dds__builtin_write;
|
||||
|
||||
ddsi_plugin.rhc_plugin.rhc_free_fn = dds_rhc_free;
|
||||
ddsi_plugin.rhc_plugin.rhc_store_fn = dds_rhc_store;
|
||||
ddsi_plugin.rhc_plugin.rhc_unregister_wr_fn = dds_rhc_unregister_wr;
|
||||
ddsi_plugin.rhc_plugin.rhc_relinquish_ownership_fn = dds_rhc_relinquish_ownership;
|
||||
ddsi_plugin.rhc_plugin.rhc_set_qos_fn = dds_rhc_set_qos;
|
||||
}
|
||||
|
||||
//provides explicit default domain id.
|
||||
dds_domainid_t dds_domain_default (void)
|
||||
{
|
||||
return dds_global.m_default_domain;
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
dds__check_domain(
|
||||
dds_domainid_t domain)
|
||||
{
|
||||
dds_return_t ret = DDS_RETCODE_OK;
|
||||
/* If domain is default: use configured id. */
|
||||
if (domain != DDS_DOMAIN_DEFAULT)
|
||||
{
|
||||
/* Specific domain has to be the same as the configured domain. */
|
||||
if (domain != dds_global.m_default_domain)
|
||||
{
|
||||
DDS_ERROR("Inconsistent domain configuration detected: domain on "
|
||||
"configuration: %"PRId32", domain %"PRId32"\n", dds_global.m_default_domain, domain);
|
||||
ret = DDS_ERRNO(DDS_RETCODE_ERROR);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
ddsrt_mutex_unlock (init_mutex);
|
||||
ddsrt_fini ();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,421 +17,308 @@
|
|||
#include "dds__write.h"
|
||||
#include "dds__writer.h"
|
||||
#include "dds__rhc.h"
|
||||
#include "dds__err.h"
|
||||
#include "dds/ddsi/ddsi_tkmap.h"
|
||||
#include "dds/ddsi/ddsi_serdata.h"
|
||||
#include "dds/ddsi/q_entity.h"
|
||||
#include "dds/ddsi/q_thread.h"
|
||||
#include "dds/ddsi/q_globals.h"
|
||||
|
||||
dds_return_t
|
||||
dds_writedispose(
|
||||
dds_entity_t writer,
|
||||
const void *data)
|
||||
dds_return_t dds_writedispose (dds_entity_t writer, const void *data)
|
||||
{
|
||||
return dds_writedispose_ts(writer, data, dds_time());
|
||||
return dds_writedispose_ts (writer, data, dds_time ());
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
dds_dispose(
|
||||
dds_entity_t writer,
|
||||
const void *data)
|
||||
dds_return_t dds_dispose (dds_entity_t writer, const void *data)
|
||||
{
|
||||
return dds_dispose_ts(writer, data, dds_time());
|
||||
return dds_dispose_ts (writer, data, dds_time ());
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
dds_dispose_ih(
|
||||
dds_entity_t writer,
|
||||
dds_instance_handle_t handle)
|
||||
dds_return_t dds_dispose_ih (dds_entity_t writer, dds_instance_handle_t handle)
|
||||
{
|
||||
return dds_dispose_ih_ts(writer, handle, dds_time());
|
||||
return dds_dispose_ih_ts (writer, handle, dds_time ());
|
||||
}
|
||||
|
||||
static struct ddsi_tkmap_instance*
|
||||
dds_instance_find(
|
||||
const dds_topic *topic,
|
||||
const void *data,
|
||||
const bool create)
|
||||
static struct ddsi_tkmap_instance *dds_instance_find (const dds_topic *topic, const void *data, const bool create)
|
||||
{
|
||||
struct ddsi_serdata *sd = ddsi_serdata_from_sample (topic->m_stopic, SDK_KEY, data);
|
||||
struct ddsi_tkmap_instance * inst = ddsi_tkmap_find (sd, false, create);
|
||||
ddsi_serdata_unref (sd);
|
||||
return inst;
|
||||
struct ddsi_serdata *sd = ddsi_serdata_from_sample (topic->m_stopic, SDK_KEY, data);
|
||||
struct ddsi_tkmap_instance *inst = ddsi_tkmap_find (topic->m_entity.m_domain->gv.m_tkmap, sd, create);
|
||||
ddsi_serdata_unref (sd);
|
||||
return inst;
|
||||
}
|
||||
|
||||
static void
|
||||
dds_instance_remove(
|
||||
const dds_topic *topic,
|
||||
const void *data,
|
||||
dds_instance_handle_t handle)
|
||||
static void dds_instance_remove (struct dds_domain *dom, const dds_topic *topic, const void *data, dds_instance_handle_t handle)
|
||||
{
|
||||
struct ddsi_tkmap_instance * inst;
|
||||
|
||||
if (handle != DDS_HANDLE_NIL)
|
||||
{
|
||||
inst = ddsi_tkmap_find_by_id (gv.m_tkmap, handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
assert (data);
|
||||
inst = dds_instance_find (topic, data, false);
|
||||
}
|
||||
if (inst)
|
||||
{
|
||||
ddsi_tkmap_instance_unref (inst);
|
||||
}
|
||||
struct ddsi_tkmap_instance *inst;
|
||||
if (handle != DDS_HANDLE_NIL)
|
||||
inst = ddsi_tkmap_find_by_id (dom->gv.m_tkmap, handle);
|
||||
else
|
||||
{
|
||||
assert (data);
|
||||
inst = dds_instance_find (topic, data, false);
|
||||
}
|
||||
if (inst)
|
||||
{
|
||||
ddsi_tkmap_instance_unref (dom->gv.m_tkmap, inst);
|
||||
}
|
||||
}
|
||||
|
||||
static const dds_topic *dds_instance_info (dds_entity *e)
|
||||
dds_return_t dds_register_instance (dds_entity_t writer, dds_instance_handle_t *handle, const void *data)
|
||||
{
|
||||
const dds_topic *topic;
|
||||
switch (dds_entity_kind (e))
|
||||
{
|
||||
case DDS_KIND_READER:
|
||||
topic = ((dds_reader*) e)->m_topic;
|
||||
break;
|
||||
case DDS_KIND_WRITER:
|
||||
topic = ((dds_writer*) e)->m_topic;
|
||||
break;
|
||||
default:
|
||||
assert (0);
|
||||
topic = NULL;
|
||||
}
|
||||
return topic;
|
||||
}
|
||||
struct thread_state1 * const ts1 = lookup_thread_state ();
|
||||
dds_writer *wr;
|
||||
dds_return_t ret;
|
||||
|
||||
static const dds_topic * dds_instance_info_by_hdl (dds_entity_t e)
|
||||
{
|
||||
const dds_topic * topic = NULL;
|
||||
dds_retcode_t rc;
|
||||
dds_entity *w_or_r;
|
||||
if (data == NULL || handle == NULL)
|
||||
return DDS_RETCODE_BAD_PARAMETER;
|
||||
|
||||
rc = dds_entity_lock(e, DDS_KIND_WRITER, &w_or_r);
|
||||
if (rc == DDS_RETCODE_ILLEGAL_OPERATION)
|
||||
{
|
||||
rc = dds_entity_lock(e, DDS_KIND_READER, &w_or_r);
|
||||
}
|
||||
if (rc != DDS_RETCODE_OK)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
topic = dds_instance_info(w_or_r);
|
||||
dds_entity_unlock(w_or_r);
|
||||
return topic;
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
dds_register_instance(
|
||||
dds_entity_t writer,
|
||||
dds_instance_handle_t *handle,
|
||||
const void *data)
|
||||
{
|
||||
struct thread_state1 * const ts1 = lookup_thread_state ();
|
||||
struct ddsi_tkmap_instance * inst;
|
||||
dds_writer *wr;
|
||||
dds_return_t ret;
|
||||
dds_retcode_t rc;
|
||||
|
||||
if(data == NULL){
|
||||
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER);
|
||||
goto err;
|
||||
}
|
||||
if(handle == NULL){
|
||||
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER);
|
||||
goto err;
|
||||
}
|
||||
rc = dds_writer_lock(writer, &wr);
|
||||
if (rc != DDS_RETCODE_OK) {
|
||||
ret = DDS_ERRNO(rc);
|
||||
goto err;
|
||||
}
|
||||
thread_state_awake (ts1);
|
||||
inst = dds_instance_find (wr->m_topic, data, true);
|
||||
if(inst != NULL){
|
||||
*handle = inst->m_iid;
|
||||
ret = DDS_RETCODE_OK;
|
||||
} else {
|
||||
ret = DDS_ERRNO(DDS_RETCODE_ERROR);
|
||||
}
|
||||
thread_state_asleep (ts1);
|
||||
dds_writer_unlock(wr);
|
||||
err:
|
||||
if ((ret = dds_writer_lock (writer, &wr)) != DDS_RETCODE_OK)
|
||||
return ret;
|
||||
|
||||
thread_state_awake (ts1, &wr->m_entity.m_domain->gv);
|
||||
struct ddsi_tkmap_instance * const inst = dds_instance_find (wr->m_topic, data, true);
|
||||
if (inst == NULL)
|
||||
ret = DDS_RETCODE_ERROR;
|
||||
else
|
||||
{
|
||||
*handle = inst->m_iid;
|
||||
ret = DDS_RETCODE_OK;
|
||||
}
|
||||
thread_state_asleep (ts1);
|
||||
dds_writer_unlock (wr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
dds_unregister_instance(
|
||||
dds_entity_t writer,
|
||||
const void *data)
|
||||
dds_return_t dds_unregister_instance (dds_entity_t writer, const void *data)
|
||||
{
|
||||
return dds_unregister_instance_ts (writer, data, dds_time());
|
||||
return dds_unregister_instance_ts (writer, data, dds_time ());
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
dds_unregister_instance_ih(
|
||||
dds_entity_t writer,
|
||||
dds_instance_handle_t handle)
|
||||
dds_return_t dds_unregister_instance_ih (dds_entity_t writer, dds_instance_handle_t handle)
|
||||
{
|
||||
return dds_unregister_instance_ih_ts(writer, handle, dds_time());
|
||||
return dds_unregister_instance_ih_ts (writer, handle, dds_time ());
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
dds_unregister_instance_ts(
|
||||
dds_entity_t writer,
|
||||
const void *data,
|
||||
dds_time_t timestamp)
|
||||
dds_return_t dds_unregister_instance_ts (dds_entity_t writer, const void *data, dds_time_t timestamp)
|
||||
{
|
||||
struct thread_state1 * const ts1 = lookup_thread_state ();
|
||||
dds_return_t ret = DDS_RETCODE_OK;
|
||||
dds_retcode_t rc;
|
||||
bool autodispose = true;
|
||||
dds_write_action action = DDS_WR_ACTION_UNREGISTER;
|
||||
dds_writer *wr;
|
||||
struct thread_state1 * const ts1 = lookup_thread_state ();
|
||||
dds_return_t ret;
|
||||
bool autodispose = true;
|
||||
dds_write_action action = DDS_WR_ACTION_UNREGISTER;
|
||||
dds_writer *wr;
|
||||
|
||||
if (data == NULL){
|
||||
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER);
|
||||
goto err;
|
||||
}
|
||||
if(timestamp < 0){
|
||||
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER);
|
||||
goto err;
|
||||
}
|
||||
rc = dds_writer_lock(writer, &wr);
|
||||
if (rc != DDS_RETCODE_OK) {
|
||||
ret = DDS_ERRNO(rc);
|
||||
goto err;
|
||||
}
|
||||
if (data == NULL || timestamp < 0)
|
||||
return DDS_RETCODE_BAD_PARAMETER;
|
||||
|
||||
if (wr->m_entity.m_qos) {
|
||||
dds_qget_writer_data_lifecycle (wr->m_entity.m_qos, &autodispose);
|
||||
}
|
||||
thread_state_awake (ts1);
|
||||
if (autodispose) {
|
||||
dds_instance_remove (wr->m_topic, data, DDS_HANDLE_NIL);
|
||||
action |= DDS_WR_DISPOSE_BIT;
|
||||
}
|
||||
ret = dds_write_impl (wr, data, timestamp, action);
|
||||
thread_state_asleep (ts1);
|
||||
dds_writer_unlock(wr);
|
||||
err:
|
||||
if ((ret = dds_writer_lock (writer, &wr)) != DDS_RETCODE_OK)
|
||||
return ret;
|
||||
|
||||
if (wr->m_entity.m_qos)
|
||||
dds_qget_writer_data_lifecycle (wr->m_entity.m_qos, &autodispose);
|
||||
|
||||
thread_state_awake (ts1, &wr->m_entity.m_domain->gv);
|
||||
if (autodispose)
|
||||
{
|
||||
dds_instance_remove (wr->m_entity.m_domain, wr->m_topic, data, DDS_HANDLE_NIL);
|
||||
action |= DDS_WR_DISPOSE_BIT;
|
||||
}
|
||||
ret = dds_write_impl (wr, data, timestamp, action);
|
||||
thread_state_asleep (ts1);
|
||||
dds_writer_unlock (wr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
dds_unregister_instance_ih_ts(
|
||||
dds_entity_t writer,
|
||||
dds_instance_handle_t handle,
|
||||
dds_time_t timestamp)
|
||||
dds_return_t dds_unregister_instance_ih_ts (dds_entity_t writer, dds_instance_handle_t handle, dds_time_t timestamp)
|
||||
{
|
||||
struct thread_state1 * const ts1 = lookup_thread_state ();
|
||||
dds_return_t ret = DDS_RETCODE_OK;
|
||||
dds_retcode_t rc;
|
||||
bool autodispose = true;
|
||||
dds_write_action action = DDS_WR_ACTION_UNREGISTER;
|
||||
dds_writer *wr;
|
||||
struct ddsi_tkmap_instance *tk;
|
||||
struct thread_state1 * const ts1 = lookup_thread_state ();
|
||||
dds_return_t ret = DDS_RETCODE_OK;
|
||||
bool autodispose = true;
|
||||
dds_write_action action = DDS_WR_ACTION_UNREGISTER;
|
||||
dds_writer *wr;
|
||||
struct ddsi_tkmap_instance *tk;
|
||||
|
||||
rc = dds_writer_lock(writer, &wr);
|
||||
if (rc != DDS_RETCODE_OK) {
|
||||
ret = DDS_ERRNO(rc);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (wr->m_entity.m_qos) {
|
||||
dds_qget_writer_data_lifecycle (wr->m_entity.m_qos, &autodispose);
|
||||
}
|
||||
if (autodispose) {
|
||||
dds_instance_remove (wr->m_topic, NULL, handle);
|
||||
action |= DDS_WR_DISPOSE_BIT;
|
||||
}
|
||||
|
||||
thread_state_awake (ts1);
|
||||
tk = ddsi_tkmap_find_by_id (gv.m_tkmap, handle);
|
||||
if (tk) {
|
||||
struct ddsi_sertopic *tp = wr->m_topic->m_stopic;
|
||||
void *sample = ddsi_sertopic_alloc_sample (tp);
|
||||
ddsi_serdata_topicless_to_sample (tp, tk->m_sample, sample, NULL, NULL);
|
||||
ddsi_tkmap_instance_unref (tk);
|
||||
ret = dds_write_impl (wr, sample, timestamp, action);
|
||||
ddsi_sertopic_free_sample (tp, sample, DDS_FREE_ALL);
|
||||
} else {
|
||||
ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
}
|
||||
thread_state_asleep (ts1);
|
||||
dds_writer_unlock(wr);
|
||||
err:
|
||||
if ((ret = dds_writer_lock (writer, &wr)) != DDS_RETCODE_OK)
|
||||
return ret;
|
||||
|
||||
if (wr->m_entity.m_qos)
|
||||
dds_qget_writer_data_lifecycle (wr->m_entity.m_qos, &autodispose);
|
||||
|
||||
thread_state_awake (ts1, &wr->m_entity.m_domain->gv);
|
||||
if (autodispose)
|
||||
{
|
||||
dds_instance_remove (wr->m_entity.m_domain, wr->m_topic, NULL, handle);
|
||||
action |= DDS_WR_DISPOSE_BIT;
|
||||
}
|
||||
if ((tk = ddsi_tkmap_find_by_id (wr->m_entity.m_domain->gv.m_tkmap, handle)) == NULL)
|
||||
ret = DDS_RETCODE_PRECONDITION_NOT_MET;
|
||||
else
|
||||
{
|
||||
struct ddsi_sertopic *tp = wr->m_topic->m_stopic;
|
||||
void *sample = ddsi_sertopic_alloc_sample (tp);
|
||||
ddsi_serdata_topicless_to_sample (tp, tk->m_sample, sample, NULL, NULL);
|
||||
ddsi_tkmap_instance_unref (wr->m_entity.m_domain->gv.m_tkmap, tk);
|
||||
ret = dds_write_impl (wr, sample, timestamp, action);
|
||||
ddsi_sertopic_free_sample (tp, sample, DDS_FREE_ALL);
|
||||
}
|
||||
thread_state_asleep (ts1);
|
||||
dds_writer_unlock (wr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
dds_writedispose_ts(
|
||||
dds_entity_t writer,
|
||||
const void *data,
|
||||
dds_time_t timestamp)
|
||||
dds_return_t dds_writedispose_ts (dds_entity_t writer, const void *data, dds_time_t timestamp)
|
||||
{
|
||||
struct thread_state1 * const ts1 = lookup_thread_state ();
|
||||
dds_return_t ret;
|
||||
dds_retcode_t rc;
|
||||
dds_writer *wr;
|
||||
|
||||
rc = dds_writer_lock(writer, &wr);
|
||||
if (rc == DDS_RETCODE_OK) {
|
||||
thread_state_awake (ts1);
|
||||
ret = dds_write_impl (wr, data, timestamp, DDS_WR_ACTION_WRITE_DISPOSE);
|
||||
if (ret == DDS_RETCODE_OK) {
|
||||
dds_instance_remove (wr->m_topic, data, DDS_HANDLE_NIL);
|
||||
}
|
||||
thread_state_asleep (ts1);
|
||||
dds_writer_unlock(wr);
|
||||
} else {
|
||||
ret = DDS_ERRNO(rc);
|
||||
}
|
||||
struct thread_state1 * const ts1 = lookup_thread_state ();
|
||||
dds_return_t ret;
|
||||
dds_writer *wr;
|
||||
|
||||
if ((ret = dds_writer_lock (writer, &wr)) != DDS_RETCODE_OK)
|
||||
return ret;
|
||||
|
||||
thread_state_awake (ts1, &wr->m_entity.m_domain->gv);
|
||||
if ((ret = dds_write_impl (wr, data, timestamp, DDS_WR_ACTION_WRITE_DISPOSE)) == DDS_RETCODE_OK)
|
||||
dds_instance_remove (wr->m_entity.m_domain, wr->m_topic, data, DDS_HANDLE_NIL);
|
||||
thread_state_asleep (ts1);
|
||||
dds_writer_unlock (wr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static dds_return_t
|
||||
dds_dispose_impl(
|
||||
dds_writer *wr,
|
||||
const void *data,
|
||||
dds_instance_handle_t handle,
|
||||
dds_time_t timestamp)
|
||||
static dds_return_t dds_dispose_impl (dds_writer *wr, const void *data, dds_instance_handle_t handle, dds_time_t timestamp) ddsrt_nonnull_all;
|
||||
|
||||
static dds_return_t dds_dispose_impl (dds_writer *wr, const void *data, dds_instance_handle_t handle, dds_time_t timestamp)
|
||||
{
|
||||
dds_return_t ret;
|
||||
assert(thread_is_awake ());
|
||||
assert(wr);
|
||||
ret = dds_write_impl(wr, data, timestamp, DDS_WR_ACTION_DISPOSE);
|
||||
if (ret == DDS_RETCODE_OK) {
|
||||
dds_instance_remove (wr->m_topic, data, handle);
|
||||
}
|
||||
dds_return_t ret;
|
||||
assert (thread_is_awake ());
|
||||
if ((ret = dds_write_impl (wr, data, timestamp, DDS_WR_ACTION_DISPOSE)) == DDS_RETCODE_OK)
|
||||
dds_instance_remove (wr->m_entity.m_domain, wr->m_topic, data, handle);
|
||||
return ret;
|
||||
}
|
||||
|
||||
dds_return_t dds_dispose_ts (dds_entity_t writer, const void *data, dds_time_t timestamp)
|
||||
{
|
||||
struct thread_state1 * const ts1 = lookup_thread_state ();
|
||||
dds_return_t ret;
|
||||
dds_writer *wr;
|
||||
|
||||
if (data == NULL)
|
||||
return DDS_RETCODE_BAD_PARAMETER;
|
||||
|
||||
if ((ret = dds_writer_lock (writer, &wr)) != DDS_RETCODE_OK)
|
||||
return ret;
|
||||
|
||||
thread_state_awake (ts1, &wr->m_entity.m_domain->gv);
|
||||
ret = dds_dispose_impl (wr, data, DDS_HANDLE_NIL, timestamp);
|
||||
thread_state_asleep (ts1);
|
||||
dds_writer_unlock(wr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
dds_dispose_ts(
|
||||
dds_entity_t writer,
|
||||
const void *data,
|
||||
dds_time_t timestamp)
|
||||
dds_return_t dds_dispose_ih_ts (dds_entity_t writer, dds_instance_handle_t handle, dds_time_t timestamp)
|
||||
{
|
||||
struct thread_state1 * const ts1 = lookup_thread_state ();
|
||||
dds_return_t ret;
|
||||
dds_retcode_t rc;
|
||||
dds_writer *wr;
|
||||
|
||||
rc = dds_writer_lock(writer, &wr);
|
||||
if (rc == DDS_RETCODE_OK) {
|
||||
thread_state_awake (ts1);
|
||||
ret = dds_dispose_impl(wr, data, DDS_HANDLE_NIL, timestamp);
|
||||
thread_state_asleep (ts1);
|
||||
dds_writer_unlock(wr);
|
||||
} else {
|
||||
ret = DDS_ERRNO(rc);
|
||||
}
|
||||
struct thread_state1 * const ts1 = lookup_thread_state ();
|
||||
dds_return_t ret;
|
||||
dds_writer *wr;
|
||||
|
||||
if ((ret = dds_writer_lock (writer, &wr)) != DDS_RETCODE_OK)
|
||||
return ret;
|
||||
|
||||
struct ddsi_tkmap_instance *tk;
|
||||
thread_state_awake (ts1, &wr->m_entity.m_domain->gv);
|
||||
if ((tk = ddsi_tkmap_find_by_id (wr->m_entity.m_domain->gv.m_tkmap, handle)) == NULL)
|
||||
ret = DDS_RETCODE_PRECONDITION_NOT_MET;
|
||||
else
|
||||
{
|
||||
struct ddsi_sertopic *tp = wr->m_topic->m_stopic;
|
||||
void *sample = ddsi_sertopic_alloc_sample (tp);
|
||||
ddsi_serdata_topicless_to_sample (tp, tk->m_sample, sample, NULL, NULL);
|
||||
ddsi_tkmap_instance_unref (wr->m_entity.m_domain->gv.m_tkmap, tk);
|
||||
ret = dds_dispose_impl (wr, sample, handle, timestamp);
|
||||
ddsi_sertopic_free_sample (tp, sample, DDS_FREE_ALL);
|
||||
}
|
||||
thread_state_asleep (ts1);
|
||||
dds_writer_unlock (wr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
dds_dispose_ih_ts(
|
||||
dds_entity_t writer,
|
||||
dds_instance_handle_t handle,
|
||||
dds_time_t timestamp)
|
||||
dds_instance_handle_t dds_lookup_instance (dds_entity_t entity, const void *data)
|
||||
{
|
||||
struct thread_state1 * const ts1 = lookup_thread_state ();
|
||||
dds_return_t ret;
|
||||
dds_retcode_t rc;
|
||||
dds_writer *wr;
|
||||
struct thread_state1 * const ts1 = lookup_thread_state ();
|
||||
dds_instance_handle_t ih = DDS_HANDLE_NIL;
|
||||
const dds_topic *topic;
|
||||
struct ddsi_serdata *sd;
|
||||
dds_entity *w_or_r;
|
||||
|
||||
rc = dds_writer_lock(writer, &wr);
|
||||
if (rc == DDS_RETCODE_OK) {
|
||||
struct ddsi_tkmap_instance *tk;
|
||||
thread_state_awake (ts1);
|
||||
if ((tk = ddsi_tkmap_find_by_id (gv.m_tkmap, handle)) != NULL) {
|
||||
struct ddsi_sertopic *tp = wr->m_topic->m_stopic;
|
||||
void *sample = ddsi_sertopic_alloc_sample (tp);
|
||||
ddsi_serdata_topicless_to_sample (tp, tk->m_sample, sample, NULL, NULL);
|
||||
ddsi_tkmap_instance_unref (tk);
|
||||
ret = dds_dispose_impl (wr, sample, handle, timestamp);
|
||||
ddsi_sertopic_free_sample (tp, sample, DDS_FREE_ALL);
|
||||
} else {
|
||||
ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
}
|
||||
thread_state_asleep (ts1);
|
||||
dds_writer_unlock(wr);
|
||||
} else {
|
||||
ret = DDS_ERRNO(rc);
|
||||
}
|
||||
if (data == NULL)
|
||||
return DDS_HANDLE_NIL;
|
||||
|
||||
if (dds_entity_lock (entity, DDS_KIND_DONTCARE, &w_or_r) < 0)
|
||||
return DDS_HANDLE_NIL;
|
||||
switch (dds_entity_kind (w_or_r))
|
||||
{
|
||||
case DDS_KIND_WRITER:
|
||||
topic = ((dds_writer *) w_or_r)->m_topic;
|
||||
break;
|
||||
case DDS_KIND_READER:
|
||||
topic = ((dds_reader *) w_or_r)->m_topic;
|
||||
break;
|
||||
default:
|
||||
dds_entity_unlock (w_or_r);
|
||||
return DDS_HANDLE_NIL;
|
||||
}
|
||||
|
||||
thread_state_awake (ts1, &w_or_r->m_domain->gv);
|
||||
sd = ddsi_serdata_from_sample (topic->m_stopic, SDK_KEY, data);
|
||||
ih = ddsi_tkmap_lookup (w_or_r->m_domain->gv.m_tkmap, sd);
|
||||
ddsi_serdata_unref (sd);
|
||||
thread_state_asleep (ts1);
|
||||
dds_entity_unlock (w_or_r);
|
||||
return ih;
|
||||
}
|
||||
|
||||
dds_instance_handle_t dds_instance_lookup (dds_entity_t entity, const void *data)
|
||||
{
|
||||
return dds_lookup_instance (entity, data);
|
||||
}
|
||||
|
||||
dds_return_t dds_instance_get_key (dds_entity_t entity, dds_instance_handle_t ih, void *data)
|
||||
{
|
||||
struct thread_state1 * const ts1 = lookup_thread_state ();
|
||||
dds_return_t ret;
|
||||
const dds_topic *topic;
|
||||
struct ddsi_tkmap_instance *tk;
|
||||
dds_entity *e;
|
||||
|
||||
if (data == NULL)
|
||||
return DDS_RETCODE_BAD_PARAMETER;
|
||||
|
||||
if ((ret = dds_entity_lock (entity, DDS_KIND_DONTCARE, &e)) < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
dds_instance_handle_t
|
||||
dds_lookup_instance(
|
||||
dds_entity_t entity,
|
||||
const void *data)
|
||||
{
|
||||
struct thread_state1 * const ts1 = lookup_thread_state ();
|
||||
dds_instance_handle_t ih = DDS_HANDLE_NIL;
|
||||
const dds_topic * topic;
|
||||
struct ddsi_tkmap * map = gv.m_tkmap;
|
||||
struct ddsi_serdata *sd;
|
||||
|
||||
if(data == NULL){
|
||||
goto err;
|
||||
}
|
||||
|
||||
topic = dds_instance_info_by_hdl (entity);
|
||||
if (topic) {
|
||||
thread_state_awake (ts1);
|
||||
sd = ddsi_serdata_from_sample (topic->m_stopic, SDK_KEY, data);
|
||||
ih = ddsi_tkmap_lookup (map, sd);
|
||||
ddsi_serdata_unref (sd);
|
||||
thread_state_asleep (ts1);
|
||||
}
|
||||
err:
|
||||
return ih;
|
||||
}
|
||||
|
||||
dds_instance_handle_t
|
||||
dds_instance_lookup (
|
||||
dds_entity_t entity,
|
||||
const void *data)
|
||||
{
|
||||
return dds_lookup_instance(entity, data);
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
dds_instance_get_key(
|
||||
dds_entity_t entity,
|
||||
dds_instance_handle_t ih,
|
||||
void *data)
|
||||
{
|
||||
struct thread_state1 * const ts1 = lookup_thread_state ();
|
||||
dds_return_t ret;
|
||||
const dds_topic * topic;
|
||||
struct ddsi_tkmap_instance * tk;
|
||||
|
||||
if(data == NULL){
|
||||
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);
|
||||
goto err;
|
||||
}
|
||||
thread_state_awake (ts1);
|
||||
if ((tk = ddsi_tkmap_find_by_id(gv.m_tkmap, ih)) != NULL) {
|
||||
ddsi_sertopic_zero_sample (topic->m_stopic, data);
|
||||
ddsi_serdata_topicless_to_sample (topic->m_stopic, tk->m_sample, data, NULL, NULL);
|
||||
ddsi_tkmap_instance_unref (tk);
|
||||
ret = DDS_RETCODE_OK;
|
||||
} else {
|
||||
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
thread_state_asleep (ts1);
|
||||
err:
|
||||
return ret;
|
||||
switch (dds_entity_kind (e))
|
||||
{
|
||||
case DDS_KIND_WRITER:
|
||||
topic = ((dds_writer *) e)->m_topic;
|
||||
break;
|
||||
case DDS_KIND_READER:
|
||||
topic = ((dds_reader *) e)->m_topic;
|
||||
break;
|
||||
case DDS_KIND_COND_READ:
|
||||
case DDS_KIND_COND_QUERY:
|
||||
topic = ((dds_reader *) e->m_parent)->m_topic;
|
||||
break;
|
||||
default:
|
||||
dds_entity_unlock (e);
|
||||
return DDS_RETCODE_ILLEGAL_OPERATION;
|
||||
}
|
||||
|
||||
thread_state_awake (ts1, &e->m_domain->gv);
|
||||
if ((tk = ddsi_tkmap_find_by_id (e->m_domain->gv.m_tkmap, ih)) == NULL)
|
||||
ret = DDS_RETCODE_BAD_PARAMETER;
|
||||
else
|
||||
{
|
||||
ddsi_sertopic_zero_sample (topic->m_stopic, data);
|
||||
ddsi_serdata_topicless_to_sample (topic->m_stopic, tk->m_sample, data, NULL, NULL);
|
||||
ddsi_tkmap_instance_unref (e->m_domain->gv.m_tkmap, tk);
|
||||
ret = DDS_RETCODE_OK;
|
||||
}
|
||||
thread_state_asleep (ts1);
|
||||
dds_entity_unlock (e);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,126 +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 <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "dds/ddsrt/md5.h"
|
||||
#include "dds__key.h"
|
||||
#include "dds__stream.h"
|
||||
#include "dds/ddsi/ddsi_serdata.h"
|
||||
#include "dds/ddsi/q_bswap.h"
|
||||
|
||||
#ifndef NDEBUG
|
||||
static bool keyhash_is_reset(const dds_key_hash_t *kh)
|
||||
{
|
||||
return !kh->m_set;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
dds_key_gen: Generates key and keyhash for a sample.
|
||||
See section 9.6.3.3 of DDSI spec.
|
||||
*/
|
||||
|
||||
static void dds_key_gen_stream (const dds_topic_descriptor_t * const desc, dds_stream_t *os, const char *sample)
|
||||
{
|
||||
const char * src;
|
||||
const uint32_t * op;
|
||||
uint32_t i;
|
||||
uint32_t len = 0;
|
||||
|
||||
for (i = 0; i < desc->m_nkeys; i++)
|
||||
{
|
||||
op = desc->m_ops + desc->m_keys[i].m_index;
|
||||
src = sample + op[1];
|
||||
assert ((*op & DDS_OP_FLAG_KEY) && ((DDS_OP_MASK & *op) == DDS_OP_ADR));
|
||||
|
||||
switch (DDS_OP_TYPE (*op))
|
||||
{
|
||||
case DDS_OP_VAL_1BY:
|
||||
{
|
||||
dds_stream_write_uint8 (os, *((const uint8_t *) src));
|
||||
break;
|
||||
}
|
||||
case DDS_OP_VAL_2BY:
|
||||
{
|
||||
dds_stream_write_uint16 (os, *((const uint16_t *) src));
|
||||
break;
|
||||
}
|
||||
case DDS_OP_VAL_4BY:
|
||||
{
|
||||
dds_stream_write_uint32 (os, *((const uint32_t *) src));
|
||||
break;
|
||||
}
|
||||
case DDS_OP_VAL_8BY:
|
||||
{
|
||||
dds_stream_write_uint64 (os, *((const uint64_t *) src));
|
||||
break;
|
||||
}
|
||||
case DDS_OP_VAL_STR:
|
||||
{
|
||||
src = *((char**) src);
|
||||
}
|
||||
/* FALLS THROUGH */
|
||||
case DDS_OP_VAL_BST:
|
||||
{
|
||||
len = (uint32_t) (strlen (src) + 1);
|
||||
dds_stream_write_uint32 (os, len);
|
||||
dds_stream_write_buffer (os, len, (const uint8_t *) src);
|
||||
break;
|
||||
}
|
||||
case DDS_OP_VAL_ARR:
|
||||
{
|
||||
uint32_t size = dds_op_size[DDS_OP_SUBTYPE (*op)];
|
||||
char *dst;
|
||||
len = size * op[2];
|
||||
dst = dds_stream_alignto (os, op[2]);
|
||||
dds_stream_write_buffer (os, len, (const uint8_t *) src);
|
||||
if (dds_stream_endian () && (size != 1u))
|
||||
dds_stream_swap (dst, size, op[2]);
|
||||
break;
|
||||
}
|
||||
default: assert (0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void dds_key_gen (const dds_topic_descriptor_t * const desc, dds_key_hash_t * kh, const char * sample)
|
||||
{
|
||||
assert(keyhash_is_reset(kh));
|
||||
|
||||
kh->m_set = 1;
|
||||
if (desc->m_nkeys == 0)
|
||||
kh->m_iskey = 1;
|
||||
else if (desc->m_flagset & DDS_TOPIC_FIXED_KEY)
|
||||
{
|
||||
dds_stream_t os;
|
||||
kh->m_iskey = 1;
|
||||
dds_stream_init(&os, 0);
|
||||
os.m_endian = 0;
|
||||
os.m_buffer.pv = kh->m_hash;
|
||||
os.m_size = 16;
|
||||
dds_key_gen_stream (desc, &os, sample);
|
||||
}
|
||||
else
|
||||
{
|
||||
dds_stream_t os;
|
||||
ddsrt_md5_state_t md5st;
|
||||
kh->m_iskey = 0;
|
||||
dds_stream_init(&os, 64);
|
||||
os.m_endian = 0;
|
||||
dds_key_gen_stream (desc, &os, sample);
|
||||
ddsrt_md5_init (&md5st);
|
||||
ddsrt_md5_append (&md5st, os.m_buffer.p8, os.m_index);
|
||||
ddsrt_md5_finish (&md5st, (unsigned char *) kh->m_hash);
|
||||
dds_stream_fini (&os);
|
||||
}
|
||||
}
|
||||
|
|
@ -207,324 +207,169 @@ void dds_merge_listener (dds_listener_t * __restrict dst, const dds_listener_t *
|
|||
|
||||
void dds_listener_merge (dds_listener_t * __restrict dst, const dds_listener_t * __restrict src)
|
||||
{
|
||||
dds_merge_listener(dst, src);
|
||||
dds_merge_listener (dst, src);
|
||||
}
|
||||
|
||||
/************************************************************************************************
|
||||
* Setters
|
||||
************************************************************************************************/
|
||||
|
||||
void
|
||||
dds_lset_data_available (dds_listener_t * __restrict listener, dds_on_data_available_fn callback)
|
||||
void dds_lset_data_available (dds_listener_t * __restrict listener, dds_on_data_available_fn callback)
|
||||
{
|
||||
if (listener) {
|
||||
listener->on_data_available = callback;
|
||||
} else {
|
||||
DDS_ERROR("Argument listener is NULL\n");
|
||||
}
|
||||
if (listener)
|
||||
listener->on_data_available = callback;
|
||||
}
|
||||
|
||||
void
|
||||
dds_lset_data_on_readers (dds_listener_t * __restrict listener, dds_on_data_on_readers_fn callback)
|
||||
void dds_lset_data_on_readers (dds_listener_t * __restrict listener, dds_on_data_on_readers_fn callback)
|
||||
{
|
||||
if (listener) {
|
||||
listener->on_data_on_readers = callback;
|
||||
} else {
|
||||
DDS_ERROR("Argument listener is NULL\n");
|
||||
}
|
||||
if (listener)
|
||||
listener->on_data_on_readers = callback;
|
||||
}
|
||||
|
||||
void
|
||||
dds_lset_inconsistent_topic (dds_listener_t * __restrict listener, dds_on_inconsistent_topic_fn callback)
|
||||
void dds_lset_inconsistent_topic (dds_listener_t * __restrict listener, dds_on_inconsistent_topic_fn callback)
|
||||
{
|
||||
if (listener) {
|
||||
listener->on_inconsistent_topic = callback;
|
||||
} else {
|
||||
DDS_ERROR("Argument listener is NULL\n");
|
||||
}
|
||||
if (listener)
|
||||
listener->on_inconsistent_topic = callback;
|
||||
}
|
||||
|
||||
void
|
||||
dds_lset_liveliness_changed (dds_listener_t * __restrict listener, dds_on_liveliness_changed_fn callback)
|
||||
void dds_lset_liveliness_changed (dds_listener_t * __restrict listener, dds_on_liveliness_changed_fn callback)
|
||||
{
|
||||
if (listener) {
|
||||
listener->on_liveliness_changed = callback;
|
||||
} else {
|
||||
DDS_ERROR("Argument listener is NULL\n");
|
||||
}
|
||||
if (listener)
|
||||
listener->on_liveliness_changed = callback;
|
||||
}
|
||||
|
||||
void
|
||||
dds_lset_liveliness_lost (dds_listener_t * __restrict listener, dds_on_liveliness_lost_fn callback)
|
||||
void dds_lset_liveliness_lost (dds_listener_t * __restrict listener, dds_on_liveliness_lost_fn callback)
|
||||
{
|
||||
if (listener) {
|
||||
listener->on_liveliness_lost = callback;
|
||||
} else {
|
||||
DDS_ERROR("Argument listener is NULL\n");
|
||||
}
|
||||
if (listener)
|
||||
listener->on_liveliness_lost = callback;
|
||||
}
|
||||
|
||||
void
|
||||
dds_lset_offered_deadline_missed (dds_listener_t * __restrict listener, dds_on_offered_deadline_missed_fn callback)
|
||||
void dds_lset_offered_deadline_missed (dds_listener_t * __restrict listener, dds_on_offered_deadline_missed_fn callback)
|
||||
{
|
||||
if (listener) {
|
||||
listener->on_offered_deadline_missed = callback;
|
||||
} else {
|
||||
DDS_ERROR("Argument listener is NULL\n");
|
||||
}
|
||||
if (listener)
|
||||
listener->on_offered_deadline_missed = callback;
|
||||
}
|
||||
|
||||
void
|
||||
dds_lset_offered_incompatible_qos (dds_listener_t * __restrict listener, dds_on_offered_incompatible_qos_fn callback)
|
||||
void dds_lset_offered_incompatible_qos (dds_listener_t * __restrict listener, dds_on_offered_incompatible_qos_fn callback)
|
||||
{
|
||||
if (listener) {
|
||||
listener->on_offered_incompatible_qos = callback;
|
||||
} else {
|
||||
DDS_ERROR("Argument listener is NULL\n");
|
||||
}
|
||||
if (listener)
|
||||
listener->on_offered_incompatible_qos = callback;
|
||||
}
|
||||
|
||||
void
|
||||
dds_lset_publication_matched (dds_listener_t * __restrict listener, dds_on_publication_matched_fn callback)
|
||||
void dds_lset_publication_matched (dds_listener_t * __restrict listener, dds_on_publication_matched_fn callback)
|
||||
{
|
||||
if (listener) {
|
||||
listener->on_publication_matched = callback;
|
||||
} else {
|
||||
DDS_ERROR("Argument listener is NULL");
|
||||
}
|
||||
if (listener)
|
||||
listener->on_publication_matched = callback;
|
||||
}
|
||||
|
||||
void
|
||||
dds_lset_requested_deadline_missed (dds_listener_t * __restrict listener, dds_on_requested_deadline_missed_fn callback)
|
||||
void dds_lset_requested_deadline_missed (dds_listener_t * __restrict listener, dds_on_requested_deadline_missed_fn callback)
|
||||
{
|
||||
if (listener) {
|
||||
listener->on_requested_deadline_missed = callback;
|
||||
} else {
|
||||
DDS_ERROR("Argument listener is NULL\n");
|
||||
}
|
||||
if (listener)
|
||||
listener->on_requested_deadline_missed = callback;
|
||||
}
|
||||
|
||||
void
|
||||
dds_lset_requested_incompatible_qos (dds_listener_t * __restrict listener, dds_on_requested_incompatible_qos_fn callback)
|
||||
void dds_lset_requested_incompatible_qos (dds_listener_t * __restrict listener, dds_on_requested_incompatible_qos_fn callback)
|
||||
{
|
||||
if (listener) {
|
||||
listener->on_requested_incompatible_qos = callback;
|
||||
} else {
|
||||
DDS_ERROR("Argument listener is NULL\n");
|
||||
}
|
||||
if (listener)
|
||||
listener->on_requested_incompatible_qos = callback;
|
||||
}
|
||||
|
||||
void
|
||||
dds_lset_sample_lost (dds_listener_t * __restrict listener, dds_on_sample_lost_fn callback)
|
||||
void dds_lset_sample_lost (dds_listener_t * __restrict listener, dds_on_sample_lost_fn callback)
|
||||
{
|
||||
if (listener) {
|
||||
listener->on_sample_lost = callback;
|
||||
} else {
|
||||
DDS_ERROR("Argument listener is NULL\n");
|
||||
}
|
||||
if (listener)
|
||||
listener->on_sample_lost = callback;
|
||||
}
|
||||
|
||||
void
|
||||
dds_lset_sample_rejected (dds_listener_t * __restrict listener, dds_on_sample_rejected_fn callback)
|
||||
void dds_lset_sample_rejected (dds_listener_t * __restrict listener, dds_on_sample_rejected_fn callback)
|
||||
{
|
||||
if (listener) {
|
||||
listener->on_sample_rejected = callback;
|
||||
} else {
|
||||
DDS_ERROR("Argument listener is NULL\n");
|
||||
}
|
||||
if (listener)
|
||||
listener->on_sample_rejected = callback;
|
||||
}
|
||||
|
||||
void
|
||||
dds_lset_subscription_matched (dds_listener_t * __restrict listener, dds_on_subscription_matched_fn callback)
|
||||
void dds_lset_subscription_matched (dds_listener_t * __restrict listener, dds_on_subscription_matched_fn callback)
|
||||
{
|
||||
if (listener) {
|
||||
listener->on_subscription_matched = callback;
|
||||
} else {
|
||||
DDS_ERROR("Argument listener is NULL\n");
|
||||
}
|
||||
if (listener)
|
||||
listener->on_subscription_matched = callback;
|
||||
}
|
||||
|
||||
/************************************************************************************************
|
||||
* Getters
|
||||
************************************************************************************************/
|
||||
|
||||
void
|
||||
dds_lget_data_available (const dds_listener_t * __restrict listener, dds_on_data_available_fn *callback)
|
||||
void dds_lget_data_available (const dds_listener_t * __restrict listener, dds_on_data_available_fn *callback)
|
||||
{
|
||||
if(!callback){
|
||||
DDS_ERROR("Argument callback is NULL\n");
|
||||
return ;
|
||||
}
|
||||
if (!listener) {
|
||||
DDS_ERROR("Argument listener is NULL\n");
|
||||
return ;
|
||||
}
|
||||
*callback = listener->on_data_available;
|
||||
if (callback != NULL)
|
||||
*callback = listener ? listener->on_data_available : 0;
|
||||
}
|
||||
|
||||
void
|
||||
dds_lget_data_on_readers (const dds_listener_t * __restrict listener, dds_on_data_on_readers_fn *callback)
|
||||
void dds_lget_data_on_readers (const dds_listener_t * __restrict listener, dds_on_data_on_readers_fn *callback)
|
||||
{
|
||||
if(!callback){
|
||||
DDS_ERROR("Argument callback is NULL\n");
|
||||
return ;
|
||||
}
|
||||
if (!listener) {
|
||||
DDS_ERROR("Argument listener is NULL\n");
|
||||
return ;
|
||||
}
|
||||
*callback = listener->on_data_on_readers;
|
||||
if (callback)
|
||||
*callback = listener ? listener->on_data_on_readers : 0;
|
||||
}
|
||||
|
||||
void dds_lget_inconsistent_topic (const dds_listener_t * __restrict listener, dds_on_inconsistent_topic_fn *callback)
|
||||
{
|
||||
if(!callback){
|
||||
DDS_ERROR("Argument callback is NULL\n");
|
||||
return ;
|
||||
}
|
||||
if (!listener) {
|
||||
DDS_ERROR("Argument listener is NULL\n");
|
||||
return ;
|
||||
}
|
||||
*callback = listener->on_inconsistent_topic;
|
||||
if (callback)
|
||||
*callback = listener ? listener->on_inconsistent_topic : 0;
|
||||
}
|
||||
|
||||
void
|
||||
dds_lget_liveliness_changed (const dds_listener_t * __restrict listener, dds_on_liveliness_changed_fn *callback)
|
||||
void dds_lget_liveliness_changed (const dds_listener_t * __restrict listener, dds_on_liveliness_changed_fn *callback)
|
||||
{
|
||||
if(!callback){
|
||||
DDS_ERROR("Argument callback is NULL\n");
|
||||
return ;
|
||||
}
|
||||
if (!listener) {
|
||||
DDS_ERROR("Argument listener is NULL\n");
|
||||
return ;
|
||||
}
|
||||
*callback = listener->on_liveliness_changed;
|
||||
if (callback)
|
||||
*callback = listener ? listener->on_liveliness_changed : 0;
|
||||
}
|
||||
|
||||
void
|
||||
dds_lget_liveliness_lost (const dds_listener_t * __restrict listener, dds_on_liveliness_lost_fn *callback)
|
||||
void dds_lget_liveliness_lost (const dds_listener_t * __restrict listener, dds_on_liveliness_lost_fn *callback)
|
||||
{
|
||||
if(!callback){
|
||||
DDS_ERROR("Argument callback is NULL\n");
|
||||
return ;
|
||||
}
|
||||
if (!listener) {
|
||||
DDS_ERROR("Argument listener is NULL\n");
|
||||
return ;
|
||||
}
|
||||
*callback = listener->on_liveliness_lost;
|
||||
if (callback)
|
||||
*callback = listener ? listener->on_liveliness_lost : 0;
|
||||
}
|
||||
|
||||
void
|
||||
dds_lget_offered_deadline_missed (const dds_listener_t * __restrict listener, dds_on_offered_deadline_missed_fn *callback)
|
||||
void dds_lget_offered_deadline_missed (const dds_listener_t * __restrict listener, dds_on_offered_deadline_missed_fn *callback)
|
||||
{
|
||||
if(!callback){
|
||||
DDS_ERROR("Argument callback is NULL\n");
|
||||
return ;
|
||||
}
|
||||
if (!listener) {
|
||||
DDS_ERROR("Argument listener is NULL\n");
|
||||
return ;
|
||||
}
|
||||
*callback = listener->on_offered_deadline_missed;
|
||||
if (callback)
|
||||
*callback = listener ? listener->on_offered_deadline_missed : 0;
|
||||
}
|
||||
|
||||
void
|
||||
dds_lget_offered_incompatible_qos (const dds_listener_t * __restrict listener, dds_on_offered_incompatible_qos_fn *callback)
|
||||
void dds_lget_offered_incompatible_qos (const dds_listener_t * __restrict listener, dds_on_offered_incompatible_qos_fn *callback)
|
||||
{
|
||||
if(!callback){
|
||||
DDS_ERROR("Argument callback is NULL\n");
|
||||
return ;
|
||||
}
|
||||
if (!listener) {
|
||||
DDS_ERROR("Argument listener is NULL\n");
|
||||
return ;
|
||||
}
|
||||
*callback = listener->on_offered_incompatible_qos;
|
||||
if (callback)
|
||||
*callback = listener ? listener->on_offered_incompatible_qos : 0;
|
||||
}
|
||||
|
||||
void
|
||||
dds_lget_publication_matched (const dds_listener_t * __restrict listener, dds_on_publication_matched_fn *callback)
|
||||
void dds_lget_publication_matched (const dds_listener_t * __restrict listener, dds_on_publication_matched_fn *callback)
|
||||
{
|
||||
if(!callback){
|
||||
DDS_ERROR("Argument callback is NULL\n");
|
||||
return ;
|
||||
}
|
||||
if (!listener) {
|
||||
DDS_ERROR("Argument listener is NULL\n");
|
||||
return ;
|
||||
}
|
||||
*callback = listener->on_publication_matched;
|
||||
if (callback)
|
||||
*callback = listener ? listener->on_publication_matched : 0;
|
||||
}
|
||||
|
||||
void
|
||||
dds_lget_requested_deadline_missed (const dds_listener_t * __restrict listener, dds_on_requested_deadline_missed_fn *callback)
|
||||
void dds_lget_requested_deadline_missed (const dds_listener_t * __restrict listener, dds_on_requested_deadline_missed_fn *callback)
|
||||
{
|
||||
if(!callback) {
|
||||
DDS_ERROR("Argument callback is NULL\n");
|
||||
return ;
|
||||
}
|
||||
if (!listener) {
|
||||
DDS_ERROR("Argument listener is NULL\n");
|
||||
return ;
|
||||
}
|
||||
*callback = listener->on_requested_deadline_missed;
|
||||
if (callback)
|
||||
*callback = listener ? listener->on_requested_deadline_missed : 0;
|
||||
}
|
||||
|
||||
void
|
||||
dds_lget_requested_incompatible_qos (const dds_listener_t * __restrict listener, dds_on_requested_incompatible_qos_fn *callback)
|
||||
void dds_lget_requested_incompatible_qos (const dds_listener_t * __restrict listener, dds_on_requested_incompatible_qos_fn *callback)
|
||||
{
|
||||
if(!callback) {
|
||||
DDS_ERROR("Argument callback is NULL\n");
|
||||
return ;
|
||||
}
|
||||
if (!listener) {
|
||||
DDS_ERROR("Argument listener is NULL\n");
|
||||
return ;
|
||||
}
|
||||
*callback = listener->on_requested_incompatible_qos;
|
||||
if (callback)
|
||||
*callback = listener ? listener->on_requested_incompatible_qos : 0;
|
||||
}
|
||||
|
||||
void
|
||||
dds_lget_sample_lost (const dds_listener_t *__restrict listener, dds_on_sample_lost_fn *callback)
|
||||
void dds_lget_sample_lost (const dds_listener_t *__restrict listener, dds_on_sample_lost_fn *callback)
|
||||
{
|
||||
if(!callback) {
|
||||
DDS_ERROR("Argument callback is NULL\n");
|
||||
return ;
|
||||
}
|
||||
if (!listener) {
|
||||
DDS_ERROR("Argument listener is NULL\n");
|
||||
return ;
|
||||
}
|
||||
*callback = listener->on_sample_lost;
|
||||
if (callback)
|
||||
*callback = listener ? listener->on_sample_lost : 0;
|
||||
}
|
||||
|
||||
void
|
||||
dds_lget_sample_rejected (const dds_listener_t *__restrict listener, dds_on_sample_rejected_fn *callback)
|
||||
void dds_lget_sample_rejected (const dds_listener_t *__restrict listener, dds_on_sample_rejected_fn *callback)
|
||||
{
|
||||
if(!callback) {
|
||||
DDS_ERROR("Argument callback is NULL\n");
|
||||
return ;
|
||||
}
|
||||
if (!listener) {
|
||||
DDS_ERROR("Argument listener is NULL\n");
|
||||
return ;
|
||||
}
|
||||
*callback = listener->on_sample_rejected;
|
||||
if (callback)
|
||||
*callback = listener ? listener->on_sample_rejected : 0;
|
||||
}
|
||||
|
||||
void
|
||||
dds_lget_subscription_matched (const dds_listener_t * __restrict listener, dds_on_subscription_matched_fn *callback)
|
||||
void dds_lget_subscription_matched (const dds_listener_t * __restrict listener, dds_on_subscription_matched_fn *callback)
|
||||
{
|
||||
if(!callback) {
|
||||
DDS_ERROR("Argument callback is NULL\n");
|
||||
return ;
|
||||
}
|
||||
if (!listener) {
|
||||
DDS_ERROR("Argument listener is NULL\n");
|
||||
return ;
|
||||
}
|
||||
*callback = listener->on_subscription_matched;
|
||||
if (callback)
|
||||
*callback = listener ? listener->on_subscription_matched : 0;
|
||||
}
|
||||
|
|
|
|||
223
src/core/ddsc/src/dds_matched.c
Normal file
223
src/core/ddsc/src/dds_matched.c
Normal file
|
|
@ -0,0 +1,223 @@
|
|||
/*
|
||||
* Copyright(c) 2019 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 <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "dds/dds.h"
|
||||
#include "dds/version.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/q_globals.h"
|
||||
#include "dds/ddsi/q_entity.h"
|
||||
#include "dds/ddsi/q_thread.h"
|
||||
#include "dds/ddsi/q_bswap.h"
|
||||
#include "dds__writer.h"
|
||||
#include "dds__reader.h"
|
||||
#include "dds__topic.h"
|
||||
|
||||
dds_return_t dds_get_matched_subscriptions (dds_entity_t writer, dds_instance_handle_t *rds, size_t nrds)
|
||||
{
|
||||
dds_writer *wr;
|
||||
dds_return_t rc;
|
||||
if (rds == NULL && nrds > 0)
|
||||
return DDS_RETCODE_BAD_PARAMETER;
|
||||
if ((rc = dds_writer_lock (writer, &wr)) != DDS_RETCODE_OK)
|
||||
return rc;
|
||||
else
|
||||
{
|
||||
const struct ephash *gh = wr->m_entity.m_domain->gv.guid_hash;
|
||||
const int32_t nrds_max = (nrds > INT32_MAX) ? INT32_MAX : (int32_t) nrds;
|
||||
int32_t nrds_act = 0;
|
||||
ddsrt_avl_iter_t it;
|
||||
/* FIXME: this ought not be so tightly coupled to the lower layer */
|
||||
thread_state_awake (lookup_thread_state (), &wr->m_entity.m_domain->gv);
|
||||
ddsrt_mutex_lock (&wr->m_wr->e.lock);
|
||||
for (const struct wr_prd_match *m = ddsrt_avl_iter_first (&wr_readers_treedef, &wr->m_wr->readers, &it);
|
||||
m != NULL;
|
||||
m = ddsrt_avl_iter_next (&it))
|
||||
{
|
||||
struct proxy_reader *prd;
|
||||
if ((prd = ephash_lookup_proxy_reader_guid (gh, &m->prd_guid)) != NULL)
|
||||
{
|
||||
if (nrds_act < nrds_max)
|
||||
rds[nrds_act] = prd->e.iid;
|
||||
nrds_act++;
|
||||
}
|
||||
}
|
||||
for (const struct wr_rd_match *m = ddsrt_avl_iter_first (&wr_local_readers_treedef, &wr->m_wr->local_readers, &it);
|
||||
m != NULL;
|
||||
m = ddsrt_avl_iter_next (&it))
|
||||
{
|
||||
struct reader *rd;
|
||||
if ((rd = ephash_lookup_reader_guid (gh, &m->rd_guid)) != NULL)
|
||||
{
|
||||
if (nrds_act < nrds_max)
|
||||
rds[nrds_act] = rd->e.iid;
|
||||
nrds_act++;
|
||||
}
|
||||
}
|
||||
ddsrt_mutex_unlock (&wr->m_wr->e.lock);
|
||||
thread_state_asleep (lookup_thread_state ());
|
||||
dds_writer_unlock (wr);
|
||||
return nrds_act;
|
||||
}
|
||||
}
|
||||
|
||||
dds_return_t dds_get_matched_publications (dds_entity_t reader, dds_instance_handle_t *wrs, size_t nwrs)
|
||||
{
|
||||
dds_reader *rd;
|
||||
dds_return_t rc;
|
||||
if (wrs == NULL && nwrs > 0)
|
||||
return DDS_RETCODE_BAD_PARAMETER;
|
||||
if ((rc = dds_reader_lock (reader, &rd)) != DDS_RETCODE_OK)
|
||||
return rc;
|
||||
else
|
||||
{
|
||||
const struct ephash *gh = rd->m_entity.m_domain->gv.guid_hash;
|
||||
const int32_t nwrs_max = (nwrs > INT32_MAX) ? INT32_MAX : (int32_t) nwrs;
|
||||
int32_t nwrs_act = 0;
|
||||
ddsrt_avl_iter_t it;
|
||||
/* FIXME: this ought not be so tightly coupled to the lower layer */
|
||||
thread_state_awake (lookup_thread_state (), &rd->m_entity.m_domain->gv);
|
||||
ddsrt_mutex_lock (&rd->m_rd->e.lock);
|
||||
for (const struct rd_pwr_match *m = ddsrt_avl_iter_first (&rd_writers_treedef, &rd->m_rd->writers, &it);
|
||||
m != NULL;
|
||||
m = ddsrt_avl_iter_next (&it))
|
||||
{
|
||||
struct proxy_writer *pwr;
|
||||
if ((pwr = ephash_lookup_proxy_writer_guid (gh, &m->pwr_guid)) != NULL)
|
||||
{
|
||||
if (nwrs_act < nwrs_max)
|
||||
wrs[nwrs_act] = pwr->e.iid;
|
||||
nwrs_act++;
|
||||
}
|
||||
}
|
||||
for (const struct rd_wr_match *m = ddsrt_avl_iter_first (&rd_local_writers_treedef, &rd->m_rd->local_writers, &it);
|
||||
m != NULL;
|
||||
m = ddsrt_avl_iter_next (&it))
|
||||
{
|
||||
struct writer *wr;
|
||||
if ((wr = ephash_lookup_writer_guid (gh, &m->wr_guid)) != NULL)
|
||||
{
|
||||
if (nwrs_act < nwrs_max)
|
||||
wrs[nwrs_act] = wr->e.iid;
|
||||
nwrs_act++;
|
||||
}
|
||||
}
|
||||
ddsrt_mutex_unlock (&rd->m_rd->e.lock);
|
||||
thread_state_asleep (lookup_thread_state ());
|
||||
dds_reader_unlock (rd);
|
||||
return nwrs_act;
|
||||
}
|
||||
}
|
||||
|
||||
static dds_builtintopic_endpoint_t *make_builtintopic_endpoint (const nn_guid_t *guid, const nn_guid_t *ppguid, dds_instance_handle_t ppiid, const dds_qos_t *qos)
|
||||
{
|
||||
dds_builtintopic_endpoint_t *ep;
|
||||
nn_guid_t tmp;
|
||||
ep = dds_alloc (sizeof (*ep));
|
||||
tmp = nn_hton_guid (*guid);
|
||||
memcpy (&ep->key, &tmp, sizeof (ep->key));
|
||||
ep->participant_instance_handle = ppiid;
|
||||
tmp = nn_hton_guid (*ppguid);
|
||||
memcpy (&ep->participant_key, &tmp, sizeof (ep->participant_key));
|
||||
ep->qos = dds_create_qos ();
|
||||
nn_xqos_mergein_missing (ep->qos, qos, ~(QP_TOPIC_NAME | QP_TYPE_NAME));
|
||||
ep->topic_name = dds_string_dup (qos->topic_name);
|
||||
ep->type_name = dds_string_dup (qos->type_name);
|
||||
return ep;
|
||||
}
|
||||
|
||||
dds_builtintopic_endpoint_t *dds_get_matched_subscription_data (dds_entity_t writer, dds_instance_handle_t ih)
|
||||
{
|
||||
dds_writer *wr;
|
||||
dds_return_t rc;
|
||||
if ((rc = dds_writer_lock (writer, &wr)) != DDS_RETCODE_OK)
|
||||
return NULL;
|
||||
else
|
||||
{
|
||||
const struct ephash *gh = wr->m_entity.m_domain->gv.guid_hash;
|
||||
dds_builtintopic_endpoint_t *ret = NULL;
|
||||
ddsrt_avl_iter_t it;
|
||||
/* FIXME: this ought not be so tightly coupled to the lower layer, and not be so inefficient besides */
|
||||
thread_state_awake (lookup_thread_state (), &wr->m_entity.m_domain->gv);
|
||||
ddsrt_mutex_lock (&wr->m_wr->e.lock);
|
||||
for (const struct wr_prd_match *m = ddsrt_avl_iter_first (&wr_readers_treedef, &wr->m_wr->readers, &it);
|
||||
m != NULL && ret == NULL;
|
||||
m = ddsrt_avl_iter_next (&it))
|
||||
{
|
||||
struct proxy_reader *prd;
|
||||
if ((prd = ephash_lookup_proxy_reader_guid (gh, &m->prd_guid)) != NULL)
|
||||
{
|
||||
if (prd->e.iid == ih)
|
||||
ret = make_builtintopic_endpoint (&prd->e.guid, &prd->c.proxypp->e.guid, prd->c.proxypp->e.iid, prd->c.xqos);
|
||||
}
|
||||
}
|
||||
for (const struct wr_rd_match *m = ddsrt_avl_iter_first (&wr_local_readers_treedef, &wr->m_wr->local_readers, &it);
|
||||
m != NULL && ret == NULL;
|
||||
m = ddsrt_avl_iter_next (&it))
|
||||
{
|
||||
struct reader *rd;
|
||||
if ((rd = ephash_lookup_reader_guid (gh, &m->rd_guid)) != NULL)
|
||||
{
|
||||
if (rd->e.iid == ih)
|
||||
ret = make_builtintopic_endpoint (&rd->e.guid, &rd->c.pp->e.guid, rd->c.pp->e.iid, rd->xqos);
|
||||
}
|
||||
}
|
||||
ddsrt_mutex_unlock (&wr->m_wr->e.lock);
|
||||
thread_state_asleep (lookup_thread_state ());
|
||||
dds_writer_unlock (wr);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
dds_builtintopic_endpoint_t *dds_get_matched_publication_data (dds_entity_t reader, dds_instance_handle_t ih)
|
||||
{
|
||||
dds_reader *rd;
|
||||
dds_return_t rc;
|
||||
if ((rc = dds_reader_lock (reader, &rd)) != DDS_RETCODE_OK)
|
||||
return NULL;
|
||||
else
|
||||
{
|
||||
const struct ephash *gh = rd->m_entity.m_domain->gv.guid_hash;
|
||||
dds_builtintopic_endpoint_t *ret = NULL;
|
||||
ddsrt_avl_iter_t it;
|
||||
/* FIXME: this ought not be so tightly coupled to the lower layer, and not be so inefficient besides */
|
||||
thread_state_awake (lookup_thread_state (), &rd->m_entity.m_domain->gv);
|
||||
ddsrt_mutex_lock (&rd->m_rd->e.lock);
|
||||
for (const struct rd_pwr_match *m = ddsrt_avl_iter_first (&rd_writers_treedef, &rd->m_rd->writers, &it);
|
||||
m != NULL && ret == NULL;
|
||||
m = ddsrt_avl_iter_next (&it))
|
||||
{
|
||||
struct proxy_writer *pwr;
|
||||
if ((pwr = ephash_lookup_proxy_writer_guid (gh, &m->pwr_guid)) != NULL)
|
||||
{
|
||||
if (pwr->e.iid == ih)
|
||||
ret = make_builtintopic_endpoint (&pwr->e.guid, &pwr->c.proxypp->e.guid, pwr->c.proxypp->e.iid, pwr->c.xqos);
|
||||
}
|
||||
}
|
||||
for (const struct rd_wr_match *m = ddsrt_avl_iter_first (&rd_local_writers_treedef, &rd->m_rd->local_writers, &it);
|
||||
m != NULL && ret == NULL;
|
||||
m = ddsrt_avl_iter_next (&it))
|
||||
{
|
||||
struct writer *wr;
|
||||
if ((wr = ephash_lookup_writer_guid (gh, &m->wr_guid)) != NULL)
|
||||
{
|
||||
if (wr->e.iid == ih)
|
||||
ret = make_builtintopic_endpoint (&wr->e.guid, &wr->c.pp->e.guid, wr->c.pp->e.iid, wr->xqos);
|
||||
}
|
||||
}
|
||||
ddsrt_mutex_unlock (&rd->m_rd->e.lock);
|
||||
thread_state_asleep (lookup_thread_state ());
|
||||
dds_reader_unlock (rd);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
|
@ -15,267 +15,165 @@
|
|||
#include "dds/ddsi/q_entity.h"
|
||||
#include "dds/ddsi/q_thread.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/q_plist.h"
|
||||
#include "dds/ddsi/q_globals.h"
|
||||
#include "dds__init.h"
|
||||
#include "dds__qos.h"
|
||||
#include "dds__domain.h"
|
||||
#include "dds__participant.h"
|
||||
#include "dds__err.h"
|
||||
#include "dds__builtin.h"
|
||||
#include "dds__qos.h"
|
||||
|
||||
DECL_ENTITY_LOCK_UNLOCK(extern inline, dds_participant)
|
||||
DECL_ENTITY_LOCK_UNLOCK (extern inline, dds_participant)
|
||||
|
||||
#define DDS_PARTICIPANT_STATUS_MASK 0u
|
||||
#define DDS_PARTICIPANT_STATUS_MASK (0u)
|
||||
|
||||
/* List of created participants */
|
||||
|
||||
static dds_entity * dds_pp_head = NULL;
|
||||
|
||||
static dds_return_t
|
||||
dds_participant_status_validate(
|
||||
uint32_t mask)
|
||||
static dds_return_t dds_participant_status_validate (uint32_t mask)
|
||||
{
|
||||
dds_return_t ret = DDS_RETCODE_OK;
|
||||
|
||||
if (mask & ~(DDS_PARTICIPANT_STATUS_MASK)) {
|
||||
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
return ret;
|
||||
return (mask & ~DDS_PARTICIPANT_STATUS_MASK) ? DDS_RETCODE_BAD_PARAMETER : DDS_RETCODE_OK;
|
||||
}
|
||||
|
||||
static dds_return_t
|
||||
dds_participant_delete(
|
||||
dds_entity *e)
|
||||
static dds_return_t dds_participant_delete (dds_entity *e) ddsrt_nonnull_all;
|
||||
|
||||
static dds_return_t dds_participant_delete (dds_entity *e)
|
||||
{
|
||||
dds_entity *prev = NULL;
|
||||
dds_entity *iter;
|
||||
dds_return_t ret;
|
||||
assert (dds_entity_kind (e) == DDS_KIND_PARTICIPANT);
|
||||
|
||||
assert(e);
|
||||
assert(dds_entity_kind(e) == DDS_KIND_PARTICIPANT);
|
||||
thread_state_awake (lookup_thread_state (), &e->m_domain->gv);
|
||||
if ((ret = delete_participant (&e->m_domain->gv, &e->m_guid)) < 0)
|
||||
DDS_CERROR (&e->m_domain->gv.logconfig, "dds_participant_delete: internal error %"PRId32"\n", ret);
|
||||
ddsrt_mutex_lock (&dds_global.m_mutex);
|
||||
ddsrt_avl_delete (&dds_entity_children_td, &e->m_domain->m_ppants, e);
|
||||
ddsrt_mutex_unlock (&dds_global.m_mutex);
|
||||
thread_state_asleep (lookup_thread_state ());
|
||||
|
||||
thread_state_awake (lookup_thread_state ());
|
||||
/* Every dds_init needs a dds_fini. */
|
||||
dds_domain_free (e->m_domain);
|
||||
dds_fini ();
|
||||
return DDS_RETCODE_OK;
|
||||
}
|
||||
|
||||
dds_domain_free (e->m_domain);
|
||||
static dds_return_t dds_participant_qos_set (dds_entity *e, const dds_qos_t *qos, bool enabled)
|
||||
{
|
||||
/* note: e->m_qos is still the old one to allow for failure here */
|
||||
if (enabled)
|
||||
{
|
||||
struct participant *pp;
|
||||
thread_state_awake (lookup_thread_state (), &e->m_domain->gv);
|
||||
if ((pp = ephash_lookup_participant_guid (e->m_domain->gv.guid_hash, &e->m_guid)) != NULL)
|
||||
{
|
||||
nn_plist_t plist;
|
||||
nn_plist_init_empty (&plist);
|
||||
plist.qos.present = plist.qos.aliased = qos->present;
|
||||
plist.qos = *qos;
|
||||
update_participant_plist (pp, &plist);
|
||||
}
|
||||
thread_state_asleep (lookup_thread_state ());
|
||||
}
|
||||
return DDS_RETCODE_OK;
|
||||
}
|
||||
|
||||
const struct dds_entity_deriver dds_entity_deriver_participant = {
|
||||
.close = dds_entity_deriver_dummy_close,
|
||||
.delete = dds_participant_delete,
|
||||
.set_qos = dds_participant_qos_set,
|
||||
.validate_status = dds_participant_status_validate
|
||||
};
|
||||
|
||||
dds_entity_t dds_create_participant (const dds_domainid_t domain, const dds_qos_t *qos, const dds_listener_t *listener)
|
||||
{
|
||||
dds_domain *dom;
|
||||
dds_entity_t ret;
|
||||
nn_guid_t guid;
|
||||
dds_participant * pp;
|
||||
nn_plist_t plist;
|
||||
dds_qos_t *new_qos = NULL;
|
||||
|
||||
/* Make sure DDS instance is initialized. */
|
||||
if ((ret = dds_init ()) < 0)
|
||||
goto err_dds_init;
|
||||
|
||||
if ((ret = dds_domain_create (&dom, domain)) < 0)
|
||||
goto err_domain_create;
|
||||
|
||||
new_qos = dds_create_qos ();
|
||||
if (qos != NULL)
|
||||
nn_xqos_mergein_missing (new_qos, qos, DDS_PARTICIPANT_QOS_MASK);
|
||||
nn_xqos_mergein_missing (new_qos, &dom->gv.default_local_plist_pp.qos, ~(uint64_t)0);
|
||||
if ((ret = nn_xqos_valid (&dom->gv.logconfig, new_qos)) < 0)
|
||||
goto err_qos_validation;
|
||||
|
||||
/* Translate qos */
|
||||
nn_plist_init_empty (&plist);
|
||||
dds_merge_qos (&plist.qos, new_qos);
|
||||
|
||||
thread_state_awake (lookup_thread_state (), &dom->gv);
|
||||
ret = new_participant (&guid, &dom->gv, 0, &plist);
|
||||
thread_state_asleep (lookup_thread_state ());
|
||||
nn_plist_fini (&plist);
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = DDS_RETCODE_ERROR;
|
||||
goto err_new_participant;
|
||||
}
|
||||
|
||||
pp = dds_alloc (sizeof (*pp));
|
||||
if ((ret = dds_entity_init (&pp->m_entity, NULL, DDS_KIND_PARTICIPANT, new_qos, listener, DDS_PARTICIPANT_STATUS_MASK)) < 0)
|
||||
goto err_entity_init;
|
||||
|
||||
pp->m_entity.m_guid = guid;
|
||||
pp->m_entity.m_iid = get_entity_instance_id (&dom->gv, &guid);
|
||||
pp->m_entity.m_domain = dom;
|
||||
pp->m_builtin_subscriber = 0;
|
||||
|
||||
/* Add participant to extent */
|
||||
ddsrt_mutex_lock (&dds_global.m_mutex);
|
||||
ddsrt_avl_insert (&dds_entity_children_td, &dom->m_ppants, &pp->m_entity);
|
||||
ddsrt_mutex_unlock (&dds_global.m_mutex);
|
||||
return ret;
|
||||
|
||||
err_entity_init:
|
||||
dds_free (pp);
|
||||
err_new_participant:
|
||||
err_qos_validation:
|
||||
dds_delete_qos (new_qos);
|
||||
dds_domain_free (dom);
|
||||
err_domain_create:
|
||||
dds_fini ();
|
||||
err_dds_init:
|
||||
return ret;
|
||||
}
|
||||
|
||||
dds_entity_t dds_lookup_participant (dds_domainid_t domain_id, dds_entity_t *participants, size_t size)
|
||||
{
|
||||
if ((participants != NULL && (size <= 0 || size >= INT32_MAX)) || (participants == NULL && size != 0))
|
||||
return DDS_RETCODE_BAD_PARAMETER;
|
||||
|
||||
ddsrt_init ();
|
||||
ddsrt_mutex_t * const init_mutex = ddsrt_get_singleton_mutex ();
|
||||
|
||||
if (participants)
|
||||
participants[0] = 0;
|
||||
|
||||
dds_return_t ret = 0;
|
||||
ddsrt_mutex_lock (init_mutex);
|
||||
if (dds_global.m_init_count > 0)
|
||||
{
|
||||
struct dds_domain *dom;
|
||||
ddsrt_mutex_lock (&dds_global.m_mutex);
|
||||
iter = dds_pp_head;
|
||||
while (iter) {
|
||||
if (iter == e) {
|
||||
if (prev) {
|
||||
prev->m_next = iter->m_next;
|
||||
} else {
|
||||
dds_pp_head = iter->m_next;
|
||||
}
|
||||
break;
|
||||
}
|
||||
prev = iter;
|
||||
iter = iter->m_next;
|
||||
if ((dom = dds_domain_find_locked (domain_id)) != NULL)
|
||||
{
|
||||
ddsrt_avl_iter_t it;
|
||||
for (dds_entity *e = ddsrt_avl_iter_first (&dds_entity_children_td, &dom->m_ppants, &it); e != NULL; e = ddsrt_avl_iter_next (&it))
|
||||
{
|
||||
if ((size_t) ret < size)
|
||||
participants[ret] = e->m_hdllink.hdl;
|
||||
ret++;
|
||||
}
|
||||
}
|
||||
ddsrt_mutex_unlock (&dds_global.m_mutex);
|
||||
|
||||
assert (iter);
|
||||
|
||||
thread_state_asleep (lookup_thread_state ());
|
||||
|
||||
/* Every dds_init needs a dds_fini. */
|
||||
dds_fini();
|
||||
|
||||
return DDS_RETCODE_OK;
|
||||
}
|
||||
|
||||
static dds_return_t
|
||||
dds_participant_instance_hdl(
|
||||
dds_entity *e,
|
||||
dds_instance_handle_t *i)
|
||||
{
|
||||
assert(e);
|
||||
assert(i);
|
||||
*i = (dds_instance_handle_t)participant_instance_id(&e->m_guid);
|
||||
return DDS_RETCODE_OK;
|
||||
}
|
||||
|
||||
static dds_return_t
|
||||
dds_participant_qos_validate(
|
||||
const dds_qos_t *qos,
|
||||
bool enabled)
|
||||
{
|
||||
dds_return_t ret = DDS_RETCODE_OK;
|
||||
assert(qos);
|
||||
(void)enabled;
|
||||
|
||||
/* Check consistency. */
|
||||
if ((qos->present & QP_USER_DATA) && !validate_octetseq(&qos->user_data)) {
|
||||
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)) {
|
||||
DDS_ERROR("Prismtech entity factory QoS policy is inconsistent and caused an error\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static dds_return_t
|
||||
dds_participant_qos_set(
|
||||
dds_entity *e,
|
||||
const dds_qos_t *qos,
|
||||
bool enabled)
|
||||
{
|
||||
dds_return_t ret = dds_participant_qos_validate(qos, enabled);
|
||||
(void)e;
|
||||
if (ret == DDS_RETCODE_OK) {
|
||||
if (enabled) {
|
||||
/* TODO: CHAM-95: DDSI does not support changing QoS policies. */
|
||||
DDS_ERROR("Changing the participant QoS is not supported\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
dds_entity_t
|
||||
dds_create_participant(
|
||||
const dds_domainid_t domain,
|
||||
const dds_qos_t *qos,
|
||||
const dds_listener_t *listener)
|
||||
{
|
||||
int q_rc;
|
||||
dds_return_t ret;
|
||||
dds_entity_t e;
|
||||
nn_guid_t guid;
|
||||
dds_participant * pp;
|
||||
nn_plist_t plist;
|
||||
dds_qos_t * new_qos = NULL;
|
||||
|
||||
/* Make sure DDS instance is initialized. */
|
||||
ret = dds_init(domain);
|
||||
if (ret != DDS_RETCODE_OK) {
|
||||
e = (dds_entity_t)ret;
|
||||
goto fail_dds_init;
|
||||
}
|
||||
|
||||
/* Check domain id */
|
||||
ret = dds__check_domain (domain);
|
||||
if (ret != DDS_RETCODE_OK) {
|
||||
e = (dds_entity_t)ret;
|
||||
goto fail_domain_check;
|
||||
}
|
||||
|
||||
/* Validate qos */
|
||||
if (qos) {
|
||||
ret = dds_participant_qos_validate (qos, false);
|
||||
if (ret != DDS_RETCODE_OK) {
|
||||
e = (dds_entity_t)ret;
|
||||
goto fail_qos_validation;
|
||||
}
|
||||
new_qos = dds_create_qos ();
|
||||
/* Only returns failure when one of the qos args is NULL, which
|
||||
* is not the case here. */
|
||||
(void)dds_copy_qos(new_qos, qos);
|
||||
} else {
|
||||
/* Use default qos. */
|
||||
new_qos = dds_create_qos ();
|
||||
}
|
||||
|
||||
/* Translate qos */
|
||||
nn_plist_init_empty(&plist);
|
||||
dds_merge_qos (&plist.qos, new_qos);
|
||||
|
||||
thread_state_awake (lookup_thread_state ());
|
||||
q_rc = new_participant (&guid, 0, &plist);
|
||||
thread_state_asleep (lookup_thread_state ());
|
||||
nn_plist_fini (&plist);
|
||||
if (q_rc != 0) {
|
||||
DDS_ERROR("Internal error");
|
||||
e = DDS_ERRNO(DDS_RETCODE_ERROR);
|
||||
goto fail_new_participant;
|
||||
}
|
||||
|
||||
pp = dds_alloc (sizeof (*pp));
|
||||
e = dds_entity_init (&pp->m_entity, NULL, DDS_KIND_PARTICIPANT, new_qos, listener, DDS_PARTICIPANT_STATUS_MASK);
|
||||
if (e < 0) {
|
||||
goto fail_entity_init;
|
||||
}
|
||||
|
||||
pp->m_entity.m_guid = guid;
|
||||
pp->m_entity.m_domain = dds_domain_create (dds_domain_default());
|
||||
pp->m_entity.m_domainid = dds_domain_default();
|
||||
pp->m_entity.m_deriver.delete = dds_participant_delete;
|
||||
pp->m_entity.m_deriver.set_qos = dds_participant_qos_set;
|
||||
pp->m_entity.m_deriver.get_instance_hdl = dds_participant_instance_hdl;
|
||||
pp->m_entity.m_deriver.validate_status = dds_participant_status_validate;
|
||||
pp->m_builtin_subscriber = 0;
|
||||
|
||||
/* Add participant to extent */
|
||||
ddsrt_mutex_lock (&dds_global.m_mutex);
|
||||
pp->m_entity.m_next = dds_pp_head;
|
||||
dds_pp_head = &pp->m_entity;
|
||||
ddsrt_mutex_unlock (&dds_global.m_mutex);
|
||||
|
||||
return e;
|
||||
|
||||
fail_entity_init:
|
||||
dds_free(pp);
|
||||
fail_new_participant:
|
||||
dds_delete_qos(new_qos);
|
||||
fail_qos_validation:
|
||||
fail_domain_check:
|
||||
dds_fini();
|
||||
fail_dds_init:
|
||||
return e;
|
||||
}
|
||||
|
||||
dds_entity_t
|
||||
dds_lookup_participant(
|
||||
dds_domainid_t domain_id,
|
||||
dds_entity_t *participants,
|
||||
size_t size)
|
||||
{
|
||||
dds_return_t ret = 0;
|
||||
ddsrt_mutex_t *init_mutex;
|
||||
|
||||
/* Be sure the DDS lifecycle resources are initialized. */
|
||||
ddsrt_init();
|
||||
init_mutex = ddsrt_get_singleton_mutex();
|
||||
|
||||
if ((participants != NULL) && ((size <= 0) || (size >= INT32_MAX))) {
|
||||
DDS_ERROR("Array is given, but with invalid size\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER);
|
||||
goto err;
|
||||
}
|
||||
if ((participants == NULL) && (size != 0)) {
|
||||
DDS_ERROR("Size is given, but no array\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if(participants){
|
||||
participants[0] = 0;
|
||||
}
|
||||
|
||||
ddsrt_mutex_lock (init_mutex);
|
||||
|
||||
/* Check if dds is intialized. */
|
||||
if (dds_global.m_init_count > 0) {
|
||||
dds_entity* iter;
|
||||
ddsrt_mutex_lock (&dds_global.m_mutex);
|
||||
iter = dds_pp_head;
|
||||
while (iter) {
|
||||
if (iter->m_domainid == domain_id) {
|
||||
if ((size_t)ret < size) {
|
||||
participants[ret] = iter->m_hdllink.hdl;
|
||||
}
|
||||
ret++;
|
||||
}
|
||||
iter = iter->m_next;
|
||||
}
|
||||
ddsrt_mutex_unlock (&dds_global.m_mutex);
|
||||
}
|
||||
|
||||
ddsrt_mutex_unlock (init_mutex);
|
||||
|
||||
err:
|
||||
ddsrt_fini();
|
||||
return ret;
|
||||
}
|
||||
ddsrt_mutex_unlock (init_mutex);
|
||||
ddsrt_fini ();
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,179 +13,90 @@
|
|||
#include <string.h>
|
||||
#include "dds/ddsrt/misc.h"
|
||||
#include "dds__listener.h"
|
||||
#include "dds__participant.h"
|
||||
#include "dds__publisher.h"
|
||||
#include "dds__qos.h"
|
||||
#include "dds__err.h"
|
||||
#include "dds/ddsi/ddsi_iid.h"
|
||||
#include "dds/ddsi/q_entity.h"
|
||||
#include "dds/ddsi/q_globals.h"
|
||||
#include "dds/version.h"
|
||||
|
||||
DECL_ENTITY_LOCK_UNLOCK(extern inline, dds_publisher)
|
||||
DECL_ENTITY_LOCK_UNLOCK (extern inline, dds_publisher)
|
||||
|
||||
#define DDS_PUBLISHER_STATUS_MASK 0u
|
||||
#define DDS_PUBLISHER_STATUS_MASK (0u)
|
||||
|
||||
static dds_return_t
|
||||
dds_publisher_instance_hdl(
|
||||
dds_entity *e,
|
||||
dds_instance_handle_t *i)
|
||||
static dds_return_t dds_publisher_qos_set (dds_entity *e, const dds_qos_t *qos, bool enabled)
|
||||
{
|
||||
(void)e;
|
||||
(void)i;
|
||||
/* TODO: Get/generate proper handle. */
|
||||
DDS_ERROR("Getting publisher instance handle is not supported\n");
|
||||
return DDS_ERRNO(DDS_RETCODE_UNSUPPORTED);
|
||||
}
|
||||
|
||||
static dds_return_t
|
||||
dds_publisher_qos_validate(
|
||||
const dds_qos_t *qos,
|
||||
bool enabled)
|
||||
{
|
||||
dds_return_t ret = DDS_RETCODE_OK;
|
||||
assert(qos);
|
||||
|
||||
/* Check consistency. */
|
||||
if((qos->present & QP_GROUP_DATA) && !validate_octetseq(&qos->group_data)){
|
||||
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)){
|
||||
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)){
|
||||
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)){
|
||||
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. */
|
||||
DDS_ERROR("Presentation policy is immutable\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_IMMUTABLE_POLICY);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static dds_return_t
|
||||
dds_publisher_qos_set(
|
||||
dds_entity *e,
|
||||
const dds_qos_t *qos,
|
||||
bool enabled)
|
||||
{
|
||||
dds_return_t ret = dds_publisher_qos_validate(qos, enabled);
|
||||
(void)e;
|
||||
if (ret == DDS_RETCODE_OK) {
|
||||
if (enabled) {
|
||||
/* TODO: CHAM-95: DDSI does not support changing QoS policies. */
|
||||
DDS_ERROR(DDS_PROJECT_NAME" does not support changing QoS policies yet\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
/* note: e->m_qos is still the old one to allow for failure here */
|
||||
(void) e; (void) qos; (void) enabled;
|
||||
return DDS_RETCODE_OK;
|
||||
}
|
||||
|
||||
static dds_return_t dds_publisher_status_validate (uint32_t mask)
|
||||
{
|
||||
dds_return_t ret = DDS_RETCODE_OK;
|
||||
return (mask & ~DDS_PUBLISHER_STATUS_MASK) ? DDS_RETCODE_BAD_PARAMETER : DDS_RETCODE_OK;
|
||||
}
|
||||
|
||||
if (mask & ~(DDS_PUBLISHER_STATUS_MASK)) {
|
||||
DDS_ERROR("Invalid status mask\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
const struct dds_entity_deriver dds_entity_deriver_publisher = {
|
||||
.close = dds_entity_deriver_dummy_close,
|
||||
.delete = dds_entity_deriver_dummy_delete,
|
||||
.set_qos = dds_publisher_qos_set,
|
||||
.validate_status = dds_publisher_status_validate
|
||||
};
|
||||
|
||||
dds_entity_t dds_create_publisher (dds_entity_t participant, const dds_qos_t *qos, const dds_listener_t *listener)
|
||||
{
|
||||
dds_participant *par;
|
||||
dds_publisher *pub;
|
||||
dds_entity_t hdl;
|
||||
dds_qos_t *new_qos;
|
||||
dds_return_t ret;
|
||||
|
||||
if ((ret = dds_participant_lock (participant, &par)) != DDS_RETCODE_OK)
|
||||
return ret;
|
||||
|
||||
new_qos = dds_create_qos ();
|
||||
if (qos)
|
||||
nn_xqos_mergein_missing (new_qos, qos, DDS_PUBLISHER_QOS_MASK);
|
||||
nn_xqos_mergein_missing (new_qos, &par->m_entity.m_domain->gv.default_xqos_pub, ~(uint64_t)0);
|
||||
if ((ret = nn_xqos_valid (&par->m_entity.m_domain->gv.logconfig, new_qos)) != DDS_RETCODE_OK)
|
||||
{
|
||||
dds_participant_unlock (par);
|
||||
return ret;
|
||||
}
|
||||
|
||||
pub = dds_alloc (sizeof (*pub));
|
||||
hdl = dds_entity_init (&pub->m_entity, &par->m_entity, DDS_KIND_PUBLISHER, new_qos, listener, DDS_PUBLISHER_STATUS_MASK);
|
||||
pub->m_entity.m_iid = ddsi_iid_gen ();
|
||||
dds_entity_register_child (&par->m_entity, &pub->m_entity);
|
||||
dds_participant_unlock (par);
|
||||
return hdl;
|
||||
}
|
||||
|
||||
dds_entity_t
|
||||
dds_create_publisher(
|
||||
dds_entity_t participant,
|
||||
const dds_qos_t *qos,
|
||||
const dds_listener_t *listener)
|
||||
{
|
||||
dds_entity * par;
|
||||
dds_publisher * pub;
|
||||
dds_entity_t hdl;
|
||||
dds_qos_t * new_qos = NULL;
|
||||
dds_return_t ret;
|
||||
dds_retcode_t rc;
|
||||
|
||||
rc = dds_entity_lock(participant, DDS_KIND_PARTICIPANT, &par);
|
||||
if (rc != DDS_RETCODE_OK) {
|
||||
DDS_ERROR("Error occurred on locking participant\n");
|
||||
hdl = DDS_ERRNO(rc);
|
||||
goto lock_err;
|
||||
}
|
||||
|
||||
/* Validate qos */
|
||||
if (qos) {
|
||||
ret = dds_publisher_qos_validate(qos, false);
|
||||
if (ret != DDS_RETCODE_OK) {
|
||||
hdl = ret;
|
||||
goto qos_err;
|
||||
}
|
||||
new_qos = dds_create_qos ();
|
||||
/* Only returns failure when one of the qos args is NULL, which
|
||||
* is not the case here. */
|
||||
(void)dds_copy_qos(new_qos, qos);
|
||||
}
|
||||
|
||||
/* Create publisher */
|
||||
pub = dds_alloc (sizeof (*pub));
|
||||
hdl = dds_entity_init (&pub->m_entity, par, DDS_KIND_PUBLISHER, new_qos, listener, DDS_PUBLISHER_STATUS_MASK);
|
||||
pub->m_entity.m_deriver.set_qos = dds_publisher_qos_set;
|
||||
pub->m_entity.m_deriver.get_instance_hdl = dds_publisher_instance_hdl;
|
||||
pub->m_entity.m_deriver.validate_status = dds_publisher_status_validate;
|
||||
|
||||
qos_err:
|
||||
dds_entity_unlock(par);
|
||||
lock_err:
|
||||
return hdl;
|
||||
}
|
||||
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_suspend(
|
||||
dds_entity_t publisher)
|
||||
dds_return_t dds_suspend (dds_entity_t publisher)
|
||||
{
|
||||
return dds_generic_unimplemented_operation (publisher, DDS_KIND_PUBLISHER);
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
dds_resume(
|
||||
dds_entity_t publisher)
|
||||
dds_return_t dds_resume (dds_entity_t publisher)
|
||||
{
|
||||
return dds_generic_unimplemented_operation (publisher, DDS_KIND_PUBLISHER);
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
dds_wait_for_acks(
|
||||
dds_entity_t publisher_or_writer,
|
||||
dds_duration_t timeout)
|
||||
dds_return_t dds_wait_for_acks (dds_entity_t publisher_or_writer, dds_duration_t timeout)
|
||||
{
|
||||
if (timeout < 0)
|
||||
return DDS_ERRNO (DDS_RETCODE_BAD_PARAMETER);
|
||||
return DDS_RETCODE_BAD_PARAMETER;
|
||||
static const dds_entity_kind_t kinds[] = { DDS_KIND_WRITER, DDS_KIND_PUBLISHER };
|
||||
return dds_generic_unimplemented_operation_manykinds (publisher_or_writer, sizeof (kinds) / sizeof (kinds[0]), kinds);
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
dds_publisher_begin_coherent(
|
||||
dds_entity_t e)
|
||||
dds_return_t dds_publisher_begin_coherent (dds_entity_t publisher)
|
||||
{
|
||||
/* TODO: CHAM-124 Currently unsupported. */
|
||||
(void)e;
|
||||
DDS_ERROR("Using coherency to get a coherent data set is not being supported yet\n");
|
||||
return DDS_ERRNO(DDS_RETCODE_UNSUPPORTED);
|
||||
return dds_generic_unimplemented_operation (publisher, DDS_KIND_PUBLISHER);
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
dds_publisher_end_coherent(
|
||||
dds_entity_t e)
|
||||
dds_return_t dds_publisher_end_coherent (dds_entity_t publisher)
|
||||
{
|
||||
/* TODO: CHAM-124 Currently unsupported. */
|
||||
(void)e;
|
||||
DDS_ERROR("Using coherency to get a coherent data set is not being supported yet\n");
|
||||
return DDS_ERRNO(DDS_RETCODE_UNSUPPORTED);
|
||||
return dds_generic_unimplemented_operation (publisher, DDS_KIND_PUBLISHER);
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -18,36 +18,23 @@
|
|||
#include "dds__topic.h"
|
||||
#include "dds__querycond.h"
|
||||
#include "dds__readcond.h"
|
||||
#include "dds__err.h"
|
||||
#include "dds/ddsi/ddsi_serdata.h"
|
||||
#include "dds/ddsi/ddsi_sertopic.h"
|
||||
|
||||
DDS_EXPORT dds_entity_t
|
||||
dds_create_querycondition(
|
||||
dds_entity_t reader,
|
||||
uint32_t mask,
|
||||
dds_querycondition_filter_fn filter)
|
||||
dds_entity_t dds_create_querycondition (dds_entity_t reader, uint32_t mask, dds_querycondition_filter_fn filter)
|
||||
{
|
||||
dds_return_t rc;
|
||||
dds_reader *r;
|
||||
|
||||
if ((rc = dds_reader_lock (reader, &r)) != DDS_RETCODE_OK)
|
||||
return rc;
|
||||
else
|
||||
{
|
||||
dds_entity_t hdl;
|
||||
dds_retcode_t rc;
|
||||
dds_reader *r;
|
||||
|
||||
rc = dds_reader_lock(reader, &r);
|
||||
if (rc == DDS_RETCODE_OK) {
|
||||
dds_readcond *cond = dds_create_readcond(r, DDS_KIND_COND_QUERY, mask, filter);
|
||||
assert(cond);
|
||||
const bool success = (cond->m_entity.m_deriver.delete != 0);
|
||||
dds_reader_unlock(r);
|
||||
if (success) {
|
||||
hdl = cond->m_entity.m_hdllink.hdl;
|
||||
} else {
|
||||
dds_delete (cond->m_entity.m_hdllink.hdl);
|
||||
hdl = DDS_ERRNO(DDS_RETCODE_OUT_OF_RESOURCES);
|
||||
}
|
||||
} else {
|
||||
DDS_ERROR("Error occurred on locking reader\n");
|
||||
hdl = DDS_ERRNO(rc);
|
||||
}
|
||||
|
||||
dds_readcond *cond = dds_create_readcond (r, DDS_KIND_COND_QUERY, mask, filter);
|
||||
assert (cond);
|
||||
dds_reader_unlock (r);
|
||||
hdl = cond->m_entity.m_hdllink.hdl;
|
||||
return hdl;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -14,78 +14,75 @@
|
|||
#include "dds__readcond.h"
|
||||
#include "dds__rhc.h"
|
||||
#include "dds__entity.h"
|
||||
#include "dds__err.h"
|
||||
#include "dds/ddsi/ddsi_iid.h"
|
||||
#include "dds/ddsi/q_ephash.h"
|
||||
#include "dds/ddsi/q_entity.h"
|
||||
#include "dds/ddsi/q_thread.h"
|
||||
|
||||
static dds_return_t
|
||||
dds_readcond_delete(
|
||||
dds_entity *e)
|
||||
static dds_return_t dds_readcond_delete (dds_entity *e) ddsrt_nonnull_all;
|
||||
|
||||
static dds_return_t dds_readcond_delete (dds_entity *e)
|
||||
{
|
||||
dds_rhc_remove_readcondition((dds_readcond*)e);
|
||||
return DDS_RETCODE_OK;
|
||||
dds_rhc_remove_readcondition ((dds_readcond *) e);
|
||||
return DDS_RETCODE_OK;
|
||||
}
|
||||
|
||||
dds_readcond*
|
||||
dds_create_readcond(
|
||||
dds_reader *rd,
|
||||
dds_entity_kind_t kind,
|
||||
uint32_t mask,
|
||||
dds_querycondition_filter_fn filter)
|
||||
const struct dds_entity_deriver dds_entity_deriver_readcondition = {
|
||||
.close = dds_entity_deriver_dummy_close,
|
||||
.delete = dds_readcond_delete,
|
||||
.set_qos = dds_entity_deriver_dummy_set_qos,
|
||||
.validate_status = dds_entity_deriver_dummy_validate_status
|
||||
};
|
||||
|
||||
dds_readcond *dds_create_readcond (dds_reader *rd, dds_entity_kind_t kind, uint32_t mask, dds_querycondition_filter_fn filter)
|
||||
{
|
||||
dds_readcond * cond = dds_alloc(sizeof(*cond));
|
||||
assert((kind == DDS_KIND_COND_READ && filter == 0) || (kind == DDS_KIND_COND_QUERY && filter != 0));
|
||||
(void) dds_entity_init(&cond->m_entity, (dds_entity*)rd, kind, NULL, NULL, 0);
|
||||
cond->m_entity.m_deriver.delete = dds_readcond_delete;
|
||||
cond->m_rhc = rd->m_rd->rhc;
|
||||
cond->m_sample_states = mask & DDS_ANY_SAMPLE_STATE;
|
||||
cond->m_view_states = mask & DDS_ANY_VIEW_STATE;
|
||||
cond->m_instance_states = mask & DDS_ANY_INSTANCE_STATE;
|
||||
cond->m_rd_guid = rd->m_entity.m_guid;
|
||||
if (kind == DDS_KIND_COND_QUERY) {
|
||||
cond->m_query.m_filter = filter;
|
||||
cond->m_query.m_qcmask = 0;
|
||||
}
|
||||
if (!dds_rhc_add_readcondition (cond)) {
|
||||
/* FIXME: current entity management code can't deal with an error late in the creation of the
|
||||
entity because it doesn't allow deleting it again ... instead use a hack to signal a problem
|
||||
to the caller and let that one handle it. */
|
||||
cond->m_entity.m_deriver.delete = 0;
|
||||
}
|
||||
return cond;
|
||||
dds_readcond *cond = dds_alloc (sizeof (*cond));
|
||||
assert ((kind == DDS_KIND_COND_READ && filter == 0) || (kind == DDS_KIND_COND_QUERY && filter != 0));
|
||||
(void) dds_entity_init (&cond->m_entity, &rd->m_entity, kind, NULL, NULL, 0);
|
||||
cond->m_entity.m_iid = ddsi_iid_gen ();
|
||||
dds_entity_register_child (&rd->m_entity, &cond->m_entity);
|
||||
cond->m_rhc = rd->m_rhc;
|
||||
cond->m_sample_states = mask & DDS_ANY_SAMPLE_STATE;
|
||||
cond->m_view_states = mask & DDS_ANY_VIEW_STATE;
|
||||
cond->m_instance_states = mask & DDS_ANY_INSTANCE_STATE;
|
||||
cond->m_rd_guid = rd->m_entity.m_guid;
|
||||
if (kind == DDS_KIND_COND_QUERY)
|
||||
{
|
||||
cond->m_query.m_filter = filter;
|
||||
cond->m_query.m_qcmask = 0;
|
||||
}
|
||||
if (!dds_rhc_add_readcondition (cond))
|
||||
{
|
||||
/* FIXME: current entity management code can't deal with an error late in the creation of the
|
||||
entity because it doesn't allow deleting it again ... */
|
||||
abort();
|
||||
}
|
||||
return cond;
|
||||
}
|
||||
|
||||
dds_entity_t
|
||||
dds_create_readcondition(
|
||||
dds_entity_t reader,
|
||||
uint32_t mask)
|
||||
dds_entity_t dds_create_readcondition (dds_entity_t reader, uint32_t mask)
|
||||
{
|
||||
dds_reader *rd;
|
||||
dds_return_t rc;
|
||||
if ((rc = dds_reader_lock (reader, &rd)) != DDS_RETCODE_OK)
|
||||
return rc;
|
||||
else
|
||||
{
|
||||
dds_entity_t hdl;
|
||||
dds_reader * rd;
|
||||
dds_retcode_t rc;
|
||||
|
||||
rc = dds_reader_lock(reader, &rd);
|
||||
if (rc == DDS_RETCODE_OK) {
|
||||
dds_readcond *cond = dds_create_readcond(rd, DDS_KIND_COND_READ, mask, 0);
|
||||
assert(cond);
|
||||
assert(cond->m_entity.m_deriver.delete);
|
||||
hdl = cond->m_entity.m_hdllink.hdl;
|
||||
dds_reader_unlock(rd);
|
||||
} else {
|
||||
DDS_ERROR("Error occurred on locking reader\n");
|
||||
hdl = DDS_ERRNO(rc);
|
||||
}
|
||||
|
||||
dds_readcond *cond = dds_create_readcond(rd, DDS_KIND_COND_READ, mask, 0);
|
||||
assert (cond);
|
||||
hdl = cond->m_entity.m_hdllink.hdl;
|
||||
dds_reader_unlock (rd);
|
||||
return hdl;
|
||||
}
|
||||
}
|
||||
|
||||
dds_entity_t dds_get_datareader (dds_entity_t condition)
|
||||
{
|
||||
struct dds_entity *e;
|
||||
dds_retcode_t rc;
|
||||
if ((rc = dds_entity_claim (condition, &e)) != DDS_RETCODE_OK)
|
||||
return DDS_ERRNO (rc);
|
||||
dds_return_t rc;
|
||||
if ((rc = dds_entity_pin (condition, &e)) != DDS_RETCODE_OK)
|
||||
return rc;
|
||||
else
|
||||
{
|
||||
dds_entity_t rdh;
|
||||
|
|
@ -97,10 +94,10 @@ dds_entity_t dds_get_datareader (dds_entity_t condition)
|
|||
rdh = e->m_parent->m_hdllink.hdl;
|
||||
break;
|
||||
default:
|
||||
rdh = DDS_ERRNO (DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
rdh = DDS_RETCODE_ILLEGAL_OPERATION;
|
||||
break;
|
||||
}
|
||||
dds_entity_release (e);
|
||||
dds_entity_unpin (e);
|
||||
return rdh;
|
||||
}
|
||||
}
|
||||
|
|
@ -108,17 +105,17 @@ dds_entity_t dds_get_datareader (dds_entity_t condition)
|
|||
dds_return_t dds_get_mask (dds_entity_t condition, uint32_t *mask)
|
||||
{
|
||||
dds_entity *entity;
|
||||
dds_retcode_t rc;
|
||||
dds_return_t rc;
|
||||
|
||||
if (mask == NULL)
|
||||
return DDS_ERRNO (DDS_RETCODE_BAD_PARAMETER);
|
||||
return DDS_RETCODE_BAD_PARAMETER;
|
||||
|
||||
if ((rc = dds_entity_lock (condition, DDS_KIND_DONTCARE, &entity)) != DDS_RETCODE_OK)
|
||||
return DDS_ERRNO (rc);
|
||||
return rc;
|
||||
else if (dds_entity_kind (entity) != DDS_KIND_COND_READ && dds_entity_kind (entity) != DDS_KIND_COND_QUERY)
|
||||
{
|
||||
dds_entity_unlock (entity);
|
||||
return DDS_ERRNO (DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
return DDS_RETCODE_ILLEGAL_OPERATION;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,145 +13,80 @@
|
|||
#include <string.h>
|
||||
#include "dds/dds.h"
|
||||
#include "dds/version.h"
|
||||
#include "dds/ddsrt/static_assert.h"
|
||||
#include "dds__subscriber.h"
|
||||
#include "dds__reader.h"
|
||||
#include "dds__listener.h"
|
||||
#include "dds__qos.h"
|
||||
#include "dds__init.h"
|
||||
#include "dds__rhc.h"
|
||||
#include "dds__err.h"
|
||||
#include "dds__rhc_default.h"
|
||||
#include "dds__topic.h"
|
||||
#include "dds__get_status.h"
|
||||
#include "dds__qos.h"
|
||||
#include "dds/ddsi/q_entity.h"
|
||||
#include "dds/ddsi/q_thread.h"
|
||||
#include "dds/ddsi/q_globals.h"
|
||||
#include "dds__builtin.h"
|
||||
#include "dds/ddsi/ddsi_sertopic.h"
|
||||
|
||||
DECL_ENTITY_LOCK_UNLOCK(extern inline, dds_reader)
|
||||
DECL_ENTITY_LOCK_UNLOCK (extern inline, dds_reader)
|
||||
|
||||
#define DDS_READER_STATUS_MASK \
|
||||
DDS_SAMPLE_REJECTED_STATUS |\
|
||||
DDS_LIVELINESS_CHANGED_STATUS |\
|
||||
DDS_REQUESTED_DEADLINE_MISSED_STATUS |\
|
||||
DDS_REQUESTED_INCOMPATIBLE_QOS_STATUS |\
|
||||
DDS_DATA_AVAILABLE_STATUS |\
|
||||
DDS_SAMPLE_LOST_STATUS |\
|
||||
DDS_SUBSCRIPTION_MATCHED_STATUS
|
||||
(DDS_SAMPLE_REJECTED_STATUS |\
|
||||
DDS_LIVELINESS_CHANGED_STATUS |\
|
||||
DDS_REQUESTED_DEADLINE_MISSED_STATUS |\
|
||||
DDS_REQUESTED_INCOMPATIBLE_QOS_STATUS |\
|
||||
DDS_DATA_AVAILABLE_STATUS |\
|
||||
DDS_SAMPLE_LOST_STATUS |\
|
||||
DDS_SUBSCRIPTION_MATCHED_STATUS)
|
||||
|
||||
static dds_return_t
|
||||
dds_reader_instance_hdl(
|
||||
dds_entity *e,
|
||||
dds_instance_handle_t *i)
|
||||
static dds_return_t dds_reader_close (dds_entity *e) ddsrt_nonnull_all;
|
||||
|
||||
static dds_return_t dds_reader_close (dds_entity *e)
|
||||
{
|
||||
assert(e);
|
||||
assert(i);
|
||||
*i = (dds_instance_handle_t)reader_instance_id(&e->m_guid);
|
||||
return DDS_RETCODE_OK;
|
||||
dds_return_t ret = DDS_RETCODE_OK;
|
||||
thread_state_awake (lookup_thread_state (), &e->m_domain->gv);
|
||||
if (delete_reader (&e->m_domain->gv, &e->m_guid) != 0)
|
||||
ret = DDS_RETCODE_ERROR;
|
||||
thread_state_asleep (lookup_thread_state ());
|
||||
return ret;
|
||||
}
|
||||
|
||||
static dds_return_t
|
||||
dds_reader_close(
|
||||
dds_entity *e)
|
||||
static dds_return_t dds_reader_delete (dds_entity *e) ddsrt_nonnull_all;
|
||||
|
||||
static dds_return_t dds_reader_delete (dds_entity *e)
|
||||
{
|
||||
dds_retcode_t rc;
|
||||
dds_return_t ret = DDS_RETCODE_OK;
|
||||
dds_reader * const rd = (dds_reader *) e;
|
||||
dds_return_t ret;
|
||||
if ((ret = dds_delete (rd->m_topic->m_entity.m_hdllink.hdl)) == DDS_RETCODE_OK)
|
||||
{
|
||||
/* Delete an implicitly created parent; for normal ones, this is expected
|
||||
to fail with BAD_PARAMETER - FIXME: there must be a cleaner way */
|
||||
ret = dds_delete_impl (e->m_parent->m_hdllink.hdl, true);
|
||||
if (ret == DDS_RETCODE_BAD_PARAMETER)
|
||||
ret = DDS_RETCODE_OK;
|
||||
}
|
||||
dds_free (rd->m_loan);
|
||||
return ret;
|
||||
}
|
||||
|
||||
assert(e);
|
||||
|
||||
thread_state_awake (lookup_thread_state ());
|
||||
if (delete_reader(&e->m_guid) != 0) {
|
||||
DDS_ERROR("Internal error");
|
||||
rc = DDS_RETCODE_ERROR;
|
||||
ret = DDS_ERRNO(rc);
|
||||
}
|
||||
static dds_return_t dds_reader_qos_set (dds_entity *e, const dds_qos_t *qos, bool enabled)
|
||||
{
|
||||
/* note: e->m_qos is still the old one to allow for failure here */
|
||||
if (enabled)
|
||||
{
|
||||
struct reader *rd;
|
||||
thread_state_awake (lookup_thread_state (), &e->m_domain->gv);
|
||||
if ((rd = ephash_lookup_reader_guid (e->m_domain->gv.guid_hash, &e->m_guid)) != NULL)
|
||||
update_reader_qos (rd, qos);
|
||||
thread_state_asleep (lookup_thread_state ());
|
||||
return ret;
|
||||
}
|
||||
return DDS_RETCODE_OK;
|
||||
}
|
||||
|
||||
static dds_return_t
|
||||
dds_reader_delete(
|
||||
dds_entity *e)
|
||||
static dds_return_t dds_reader_status_validate (uint32_t mask)
|
||||
{
|
||||
dds_reader *rd = (dds_reader*)e;
|
||||
dds_return_t ret;
|
||||
assert(e);
|
||||
ret = dds_delete(rd->m_topic->m_entity.m_hdllink.hdl);
|
||||
if(ret == DDS_RETCODE_OK){
|
||||
ret = dds_delete_impl(e->m_parent->m_hdllink.hdl, true);
|
||||
if(dds_err_nr(ret) == DDS_RETCODE_BAD_PARAMETER){
|
||||
ret = DDS_RETCODE_OK;
|
||||
}
|
||||
}
|
||||
dds_free(rd->m_loan);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static dds_return_t
|
||||
dds_reader_qos_validate(
|
||||
const dds_qos_t *qos,
|
||||
bool enabled)
|
||||
{
|
||||
dds_return_t ret = DDS_RETCODE_OK;
|
||||
|
||||
assert(qos);
|
||||
|
||||
/* Check consistency. */
|
||||
if(!dds_qos_validate_common(qos)) {
|
||||
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))) {
|
||||
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)) {
|
||||
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)) {
|
||||
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)) {
|
||||
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))) {
|
||||
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);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static dds_return_t
|
||||
dds_reader_qos_set(
|
||||
dds_entity *e,
|
||||
const dds_qos_t *qos,
|
||||
bool enabled)
|
||||
{
|
||||
dds_return_t ret = dds_reader_qos_validate(qos, enabled);
|
||||
(void)e;
|
||||
if (ret == DDS_RETCODE_OK) {
|
||||
if (enabled) {
|
||||
/* TODO: CHAM-95: DDSI does not support changing QoS policies. */
|
||||
DDS_ERROR(DDS_PROJECT_NAME" does not support changing QoS policies\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static dds_return_t
|
||||
dds_reader_status_validate(
|
||||
uint32_t mask)
|
||||
{
|
||||
return (mask & ~(DDS_READER_STATUS_MASK)) ?
|
||||
DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER) :
|
||||
DDS_RETCODE_OK;
|
||||
return (mask & ~DDS_READER_STATUS_MASK) ? DDS_RETCODE_BAD_PARAMETER : DDS_RETCODE_OK;
|
||||
}
|
||||
|
||||
void dds_reader_data_available_cb (struct dds_reader *rd)
|
||||
|
|
@ -162,13 +97,11 @@ void dds_reader_data_available_cb (struct dds_reader *rd)
|
|||
overhead really matters. Otherwise, it is pretty much like
|
||||
dds_reader_status_cb. */
|
||||
|
||||
ddsrt_mutex_lock (&rd->m_entity.m_observers_lock);
|
||||
if (!(rd->m_entity.m_status_enable & DDS_DATA_AVAILABLE_STATUS))
|
||||
{
|
||||
ddsrt_mutex_unlock (&rd->m_entity.m_observers_lock);
|
||||
const bool data_av_enabled = (ddsrt_atomic_ld32 (&rd->m_entity.m_status.m_status_and_mask) & (DDS_DATA_AVAILABLE_STATUS << SAM_ENABLED_SHIFT));
|
||||
if (!data_av_enabled)
|
||||
return;
|
||||
}
|
||||
|
||||
ddsrt_mutex_lock (&rd->m_entity.m_observers_lock);
|
||||
while (rd->m_entity.m_cb_count > 0)
|
||||
ddsrt_cond_wait (&rd->m_entity.m_observers_cond, &rd->m_entity.m_observers_lock);
|
||||
rd->m_entity.m_cb_count++;
|
||||
|
|
@ -202,7 +135,6 @@ void dds_reader_data_available_cb (struct dds_reader *rd)
|
|||
else
|
||||
{
|
||||
dds_entity_status_set (&rd->m_entity, DDS_DATA_AVAILABLE_STATUS);
|
||||
|
||||
ddsrt_mutex_lock (&sub->m_observers_lock);
|
||||
dds_entity_status_set (sub, DDS_DATA_ON_READERS_STATUS);
|
||||
ddsrt_mutex_unlock (&sub->m_observers_lock);
|
||||
|
|
@ -222,7 +154,7 @@ void dds_reader_status_cb (void *ventity, const status_cb_data_t *data)
|
|||
{
|
||||
/* Release the initial claim that was done during the create. This
|
||||
* will indicate that further API deletion is now possible. */
|
||||
dds_handle_release (&entity->m_hdllink);
|
||||
dds_handle_unpin (&entity->m_hdllink);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -336,7 +268,7 @@ void dds_reader_status_cb (void *ventity, const status_cb_data_t *data)
|
|||
if (invoke)
|
||||
{
|
||||
ddsrt_mutex_unlock (&entity->m_observers_lock);
|
||||
dds_entity_invoke_listener(entity, status_id, vst);
|
||||
dds_entity_invoke_listener (entity, status_id, vst);
|
||||
ddsrt_mutex_lock (&entity->m_observers_lock);
|
||||
*reset[0] = 0;
|
||||
if (reset[1])
|
||||
|
|
@ -344,7 +276,7 @@ void dds_reader_status_cb (void *ventity, const status_cb_data_t *data)
|
|||
}
|
||||
else
|
||||
{
|
||||
dds_entity_status_set (entity, 1u << status_id);
|
||||
dds_entity_status_set (entity, (status_mask_t) (1u << status_id));
|
||||
}
|
||||
|
||||
entity->m_cb_count--;
|
||||
|
|
@ -352,174 +284,155 @@ void dds_reader_status_cb (void *ventity, const status_cb_data_t *data)
|
|||
ddsrt_mutex_unlock (&entity->m_observers_lock);
|
||||
}
|
||||
|
||||
dds_entity_t
|
||||
dds_create_reader(
|
||||
dds_entity_t participant_or_subscriber,
|
||||
dds_entity_t topic,
|
||||
const dds_qos_t *qos,
|
||||
const dds_listener_t *listener)
|
||||
const struct dds_entity_deriver dds_entity_deriver_reader = {
|
||||
.close = dds_reader_close,
|
||||
.delete = dds_reader_delete,
|
||||
.set_qos = dds_reader_qos_set,
|
||||
.validate_status = dds_reader_status_validate
|
||||
};
|
||||
|
||||
dds_entity_t dds_create_reader (dds_entity_t participant_or_subscriber, dds_entity_t topic, const dds_qos_t *qos, const dds_listener_t *listener)
|
||||
{
|
||||
dds_qos_t * rqos;
|
||||
dds_retcode_t rc;
|
||||
dds_subscriber * sub = NULL;
|
||||
dds_entity_t subscriber;
|
||||
dds_reader * rd;
|
||||
struct rhc * rhc;
|
||||
dds_topic * tp;
|
||||
dds_entity_t reader;
|
||||
dds_entity_t t;
|
||||
dds_return_t ret = DDS_RETCODE_OK;
|
||||
bool internal_topic;
|
||||
dds_qos_t *rqos;
|
||||
dds_subscriber *sub = NULL;
|
||||
dds_entity_t subscriber;
|
||||
dds_reader *rd;
|
||||
dds_topic *tp;
|
||||
dds_entity_t reader;
|
||||
dds_entity_t t;
|
||||
dds_return_t ret = DDS_RETCODE_OK;
|
||||
bool internal_topic;
|
||||
|
||||
switch (topic) {
|
||||
case DDS_BUILTIN_TOPIC_DCPSPARTICIPANT:
|
||||
case DDS_BUILTIN_TOPIC_DCPSTOPIC:
|
||||
case DDS_BUILTIN_TOPIC_DCPSPUBLICATION:
|
||||
case DDS_BUILTIN_TOPIC_DCPSSUBSCRIPTION:
|
||||
internal_topic = true;
|
||||
subscriber = dds__get_builtin_subscriber(participant_or_subscriber);
|
||||
t = dds__get_builtin_topic (subscriber, topic);
|
||||
break;
|
||||
switch (topic)
|
||||
{
|
||||
case DDS_BUILTIN_TOPIC_DCPSPARTICIPANT:
|
||||
case DDS_BUILTIN_TOPIC_DCPSTOPIC:
|
||||
case DDS_BUILTIN_TOPIC_DCPSPUBLICATION:
|
||||
case DDS_BUILTIN_TOPIC_DCPSSUBSCRIPTION:
|
||||
internal_topic = true;
|
||||
subscriber = dds__get_builtin_subscriber (participant_or_subscriber);
|
||||
t = dds__get_builtin_topic (subscriber, topic);
|
||||
break;
|
||||
|
||||
default: {
|
||||
dds_entity *p_or_s;
|
||||
if ((rc = dds_entity_claim (participant_or_subscriber, &p_or_s)) != DDS_RETCODE_OK) {
|
||||
return DDS_ERRNO (rc);
|
||||
}
|
||||
if (dds_entity_kind (p_or_s) == DDS_KIND_PARTICIPANT) {
|
||||
subscriber = dds_create_subscriber(participant_or_subscriber, qos, NULL);
|
||||
} else {
|
||||
subscriber = participant_or_subscriber;
|
||||
}
|
||||
dds_entity_release (p_or_s);
|
||||
internal_topic = false;
|
||||
t = topic;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
dds_entity *p_or_s;
|
||||
if ((ret = dds_entity_pin (participant_or_subscriber, &p_or_s)) != DDS_RETCODE_OK)
|
||||
return ret;
|
||||
if (dds_entity_kind (p_or_s) == DDS_KIND_PARTICIPANT)
|
||||
subscriber = dds_create_subscriber (participant_or_subscriber, qos, NULL);
|
||||
else
|
||||
subscriber = participant_or_subscriber;
|
||||
dds_entity_unpin (p_or_s);
|
||||
internal_topic = false;
|
||||
t = topic;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((rc = dds_subscriber_lock (subscriber, &sub)) != DDS_RETCODE_OK) {
|
||||
reader = DDS_ERRNO (rc);
|
||||
goto err_sub_lock;
|
||||
}
|
||||
if ((ret = dds_subscriber_lock (subscriber, &sub)) != DDS_RETCODE_OK)
|
||||
{
|
||||
reader = ret;
|
||||
goto err_sub_lock;
|
||||
}
|
||||
|
||||
if ((subscriber != participant_or_subscriber) && !internal_topic) {
|
||||
/* Delete implicit subscriber if reader creation fails */
|
||||
sub->m_entity.m_flags |= DDS_ENTITY_IMPLICIT;
|
||||
}
|
||||
if (subscriber != participant_or_subscriber && !internal_topic)
|
||||
{
|
||||
/* Delete implicit subscriber if reader creation fails */
|
||||
sub->m_entity.m_flags |= DDS_ENTITY_IMPLICIT;
|
||||
}
|
||||
|
||||
rc = dds_topic_lock(t, &tp);
|
||||
if (rc != DDS_RETCODE_OK) {
|
||||
DDS_ERROR("Error occurred on locking topic\n");
|
||||
reader = DDS_ERRNO(rc);
|
||||
goto err_tp_lock;
|
||||
}
|
||||
assert (tp->m_stopic);
|
||||
assert (sub->m_entity.m_domain == tp->m_entity.m_domain);
|
||||
if ((ret = dds_topic_lock (t, &tp)) != DDS_RETCODE_OK)
|
||||
{
|
||||
reader = ret;
|
||||
goto err_tp_lock;
|
||||
}
|
||||
assert (tp->m_stopic);
|
||||
/* FIXME: domain check */
|
||||
assert (sub->m_entity.m_domain == tp->m_entity.m_domain);
|
||||
|
||||
/* Merge qos from topic and subscriber */
|
||||
rqos = dds_create_qos ();
|
||||
if (qos) {
|
||||
/* Only returns failure when one of the qos args is NULL, which
|
||||
* is not the case here. */
|
||||
(void)dds_copy_qos(rqos, qos);
|
||||
}
|
||||
/* Merge qos from topic and subscriber, dds_copy_qos only fails when it is passed a null
|
||||
argument, but that isn't the case here */
|
||||
rqos = dds_create_qos ();
|
||||
if (qos)
|
||||
nn_xqos_mergein_missing (rqos, qos, DDS_READER_QOS_MASK);
|
||||
if (sub->m_entity.m_qos)
|
||||
nn_xqos_mergein_missing (rqos, sub->m_entity.m_qos, ~(uint64_t)0);
|
||||
if (tp->m_entity.m_qos)
|
||||
nn_xqos_mergein_missing (rqos, tp->m_entity.m_qos, ~(uint64_t)0);
|
||||
nn_xqos_mergein_missing (rqos, &sub->m_entity.m_domain->gv.default_xqos_rd, ~(uint64_t)0);
|
||||
|
||||
if(sub->m_entity.m_qos){
|
||||
dds_merge_qos (rqos, sub->m_entity.m_qos);
|
||||
}
|
||||
if ((ret = nn_xqos_valid (&sub->m_entity.m_domain->gv.logconfig, rqos)) != DDS_RETCODE_OK)
|
||||
{
|
||||
dds_delete_qos (rqos);
|
||||
reader = ret;
|
||||
goto err_bad_qos;
|
||||
}
|
||||
|
||||
if (tp->m_entity.m_qos) {
|
||||
dds_merge_qos (rqos, tp->m_entity.m_qos);
|
||||
/* Additional checks required for built-in topics: we don't want to
|
||||
run into a resource limit on a built-in topic, it is a needless
|
||||
complication */
|
||||
if (internal_topic && !dds__validate_builtin_reader_qos (tp->m_entity.m_domain, topic, rqos))
|
||||
{
|
||||
dds_delete_qos (rqos);
|
||||
reader = DDS_RETCODE_INCONSISTENT_POLICY;
|
||||
goto err_bad_qos;
|
||||
}
|
||||
|
||||
/* reset the following qos policies if set during topic qos merge as they aren't applicable for reader */
|
||||
rqos->present &= ~(QP_DURABILITY_SERVICE | QP_TRANSPORT_PRIORITY | QP_LIFESPAN);
|
||||
}
|
||||
nn_xqos_mergein_missing (rqos, &gv.default_xqos_rd);
|
||||
/* Create reader and associated read cache */
|
||||
rd = dds_alloc (sizeof (*rd));
|
||||
reader = dds_entity_init (&rd->m_entity, &sub->m_entity, DDS_KIND_READER, rqos, listener, DDS_READER_STATUS_MASK);
|
||||
rd->m_sample_rejected_status.last_reason = DDS_NOT_REJECTED;
|
||||
rd->m_topic = tp;
|
||||
rd->m_rhc = dds_rhc_default_new (rd, tp->m_stopic);
|
||||
dds_entity_add_ref_locked (&tp->m_entity);
|
||||
|
||||
ret = dds_reader_qos_validate (rqos, false);
|
||||
if (ret != 0) {
|
||||
dds_delete_qos(rqos);
|
||||
reader = ret;
|
||||
goto err_bad_qos;
|
||||
}
|
||||
/* Extra claim of this reader to make sure that the delete waits until DDSI
|
||||
has deleted its reader as well. This can be known through the callback. */
|
||||
dds_handle_repin (&rd->m_entity.m_hdllink);
|
||||
|
||||
/* Additional checks required for built-in topics */
|
||||
if (internal_topic && !dds__validate_builtin_reader_qos(topic, qos)) {
|
||||
dds_delete_qos(rqos);
|
||||
DDS_ERROR("Invalid QoS specified for built-in topic reader");
|
||||
reader = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY);
|
||||
goto err_bad_qos;
|
||||
}
|
||||
ddsrt_mutex_unlock (&tp->m_entity.m_mutex);
|
||||
ddsrt_mutex_unlock (&sub->m_entity.m_mutex);
|
||||
|
||||
/* Create reader and associated read cache */
|
||||
rd = dds_alloc (sizeof (*rd));
|
||||
reader = dds_entity_init (&rd->m_entity, &sub->m_entity, DDS_KIND_READER, rqos, listener, DDS_READER_STATUS_MASK);
|
||||
rd->m_sample_rejected_status.last_reason = DDS_NOT_REJECTED;
|
||||
rd->m_topic = tp;
|
||||
rhc = dds_rhc_new (rd, tp->m_stopic);
|
||||
dds_entity_add_ref_nolock (&tp->m_entity);
|
||||
rd->m_entity.m_deriver.close = dds_reader_close;
|
||||
rd->m_entity.m_deriver.delete = dds_reader_delete;
|
||||
rd->m_entity.m_deriver.set_qos = dds_reader_qos_set;
|
||||
rd->m_entity.m_deriver.validate_status = dds_reader_status_validate;
|
||||
rd->m_entity.m_deriver.get_instance_hdl = dds_reader_instance_hdl;
|
||||
thread_state_awake (lookup_thread_state (), &sub->m_entity.m_domain->gv);
|
||||
ret = new_reader (&rd->m_rd, &rd->m_entity.m_domain->gv, &rd->m_entity.m_guid, NULL, &sub->m_entity.m_participant->m_guid, tp->m_stopic, rqos, &rd->m_rhc->common.rhc, dds_reader_status_cb, rd);
|
||||
ddsrt_mutex_lock (&sub->m_entity.m_mutex);
|
||||
ddsrt_mutex_lock (&tp->m_entity.m_mutex);
|
||||
assert (ret == DDS_RETCODE_OK); /* FIXME: can be out-of-resources at the very least */
|
||||
thread_state_asleep (lookup_thread_state ());
|
||||
|
||||
rd->m_entity.m_iid = get_entity_instance_id (&rd->m_entity.m_domain->gv, &rd->m_entity.m_guid);
|
||||
dds_entity_register_child (&sub->m_entity, &rd->m_entity);
|
||||
|
||||
/* Extra claim of this reader to make sure that the delete waits until DDSI
|
||||
* has deleted its reader as well. This can be known through the callback. */
|
||||
dds_handle_claim_inc (&rd->m_entity.m_hdllink);
|
||||
dds_topic_unlock (tp);
|
||||
dds_subscriber_unlock (sub);
|
||||
|
||||
ddsrt_mutex_unlock(&tp->m_entity.m_mutex);
|
||||
ddsrt_mutex_unlock(&sub->m_entity.m_mutex);
|
||||
|
||||
thread_state_awake (lookup_thread_state ());
|
||||
ret = new_reader(&rd->m_rd, &rd->m_entity.m_guid, NULL, &sub->m_entity.m_participant->m_guid, tp->m_stopic,
|
||||
rqos, rhc, dds_reader_status_cb, rd);
|
||||
ddsrt_mutex_lock(&sub->m_entity.m_mutex);
|
||||
ddsrt_mutex_lock(&tp->m_entity.m_mutex);
|
||||
assert (ret == DDS_RETCODE_OK);
|
||||
thread_state_asleep (lookup_thread_state ());
|
||||
|
||||
/* For persistent data register reader with durability */
|
||||
if (dds_global.m_dur_reader && (rd->m_entity.m_qos->durability.kind > NN_TRANSIENT_LOCAL_DURABILITY_QOS)) {
|
||||
(dds_global.m_dur_reader) (rd, rhc);
|
||||
}
|
||||
dds_topic_unlock(tp);
|
||||
dds_subscriber_unlock(sub);
|
||||
|
||||
if (internal_topic) {
|
||||
/* If topic is builtin, then the topic entity is local and should
|
||||
* be deleted because the application won't. */
|
||||
dds_delete(t);
|
||||
}
|
||||
|
||||
return reader;
|
||||
if (internal_topic)
|
||||
{
|
||||
/* If topic is builtin, then the topic entity is local and should be deleted because the application won't. */
|
||||
dds_delete (t);
|
||||
}
|
||||
return reader;
|
||||
|
||||
err_bad_qos:
|
||||
dds_topic_unlock(tp);
|
||||
dds_topic_unlock (tp);
|
||||
err_tp_lock:
|
||||
dds_subscriber_unlock(sub);
|
||||
if((sub->m_entity.m_flags & DDS_ENTITY_IMPLICIT) != 0){
|
||||
(void)dds_delete(subscriber);
|
||||
}
|
||||
dds_subscriber_unlock (sub);
|
||||
if ((sub->m_entity.m_flags & DDS_ENTITY_IMPLICIT) != 0)
|
||||
(void) dds_delete (subscriber);
|
||||
err_sub_lock:
|
||||
if (internal_topic) {
|
||||
/* If topic is builtin, then the topic entity is local and should
|
||||
* be deleted because the application won't. */
|
||||
dds_delete(t);
|
||||
}
|
||||
return reader;
|
||||
if (internal_topic)
|
||||
dds_delete (t);
|
||||
return reader;
|
||||
}
|
||||
|
||||
void dds_reader_ddsi2direct (dds_entity_t entity, ddsi2direct_directread_cb_t cb, void *cbarg)
|
||||
{
|
||||
dds_entity *dds_entity;
|
||||
if (dds_entity_claim(entity, &dds_entity) != DDS_RETCODE_OK)
|
||||
if (dds_entity_pin (entity, &dds_entity) != DDS_RETCODE_OK)
|
||||
return;
|
||||
|
||||
if (dds_entity_kind (dds_entity) != DDS_KIND_READER)
|
||||
{
|
||||
dds_entity_release (dds_entity);
|
||||
dds_entity_unpin (dds_entity);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -536,7 +449,7 @@ void dds_reader_ddsi2direct (dds_entity_t entity, ddsi2direct_directread_cb_t cb
|
|||
while ((m = ddsrt_avl_lookup_succ_eq (&rd_writers_treedef, &rd->writers, &pwrguid)) != NULL)
|
||||
{
|
||||
/* have to be careful walking the tree -- pretty is different, but
|
||||
I want to check this before I write a lookup_succ function. */
|
||||
I want to check this before I write a lookup_succ function. */
|
||||
struct rd_pwr_match *m_next;
|
||||
nn_guid_t pwrguid_next;
|
||||
pwrguid = m->pwr_guid;
|
||||
|
|
@ -548,7 +461,7 @@ void dds_reader_ddsi2direct (dds_entity_t entity, ddsi2direct_directread_cb_t cb
|
|||
pwrguid_next.entityid.u = (pwrguid_next.entityid.u & ~(uint32_t)0xff) | NN_ENTITYID_KIND_WRITER_NO_KEY;
|
||||
}
|
||||
ddsrt_mutex_unlock (&rd->e.lock);
|
||||
if ((pwr = ephash_lookup_proxy_writer_guid (&pwrguid)) != NULL)
|
||||
if ((pwr = ephash_lookup_proxy_writer_guid (dds_entity->m_domain->gv.guid_hash, &pwrguid)) != NULL)
|
||||
{
|
||||
ddsrt_mutex_lock (&pwr->e.lock);
|
||||
pwr->ddsi2direct_cb = cb;
|
||||
|
|
@ -559,7 +472,7 @@ void dds_reader_ddsi2direct (dds_entity_t entity, ddsi2direct_directread_cb_t cb
|
|||
ddsrt_mutex_lock (&rd->e.lock);
|
||||
}
|
||||
ddsrt_mutex_unlock (&rd->e.lock);
|
||||
dds_entity_release (dds_entity);
|
||||
dds_entity_unpin (dds_entity);
|
||||
}
|
||||
|
||||
uint32_t dds_reader_lock_samples (dds_entity_t reader)
|
||||
|
|
@ -568,17 +481,18 @@ uint32_t dds_reader_lock_samples (dds_entity_t reader)
|
|||
uint32_t n;
|
||||
if (dds_reader_lock (reader, &rd) != DDS_RETCODE_OK)
|
||||
return 0;
|
||||
n = dds_rhc_lock_samples (rd->m_rd->rhc);
|
||||
n = dds_rhc_lock_samples (rd->m_rhc);
|
||||
dds_reader_unlock (rd);
|
||||
return n;
|
||||
}
|
||||
|
||||
int dds_reader_wait_for_historical_data (dds_entity_t reader, dds_duration_t max_wait)
|
||||
dds_return_t dds_reader_wait_for_historical_data (dds_entity_t reader, dds_duration_t max_wait)
|
||||
{
|
||||
dds_reader *rd;
|
||||
int ret;
|
||||
dds_return_t ret;
|
||||
(void) max_wait;
|
||||
if ((ret = dds_reader_lock (reader, &rd)) != DDS_RETCODE_OK)
|
||||
return DDS_ERRNO (ret);
|
||||
return ret;
|
||||
switch (rd->m_entity.m_qos->durability.kind)
|
||||
{
|
||||
case DDS_DURABILITY_VOLATILE:
|
||||
|
|
@ -588,7 +502,6 @@ int dds_reader_wait_for_historical_data (dds_entity_t reader, dds_duration_t max
|
|||
break;
|
||||
case DDS_DURABILITY_TRANSIENT:
|
||||
case DDS_DURABILITY_PERSISTENT:
|
||||
ret = (dds_global.m_dur_wait) (rd, max_wait);
|
||||
break;
|
||||
}
|
||||
dds_reader_unlock(rd);
|
||||
|
|
@ -598,9 +511,9 @@ int dds_reader_wait_for_historical_data (dds_entity_t reader, dds_duration_t max
|
|||
dds_entity_t dds_get_subscriber (dds_entity_t entity)
|
||||
{
|
||||
dds_entity *e;
|
||||
dds_retcode_t ret;
|
||||
if ((ret = dds_entity_claim (entity, &e)) != DDS_RETCODE_OK)
|
||||
return (dds_entity_t) DDS_ERRNO (ret);
|
||||
dds_return_t ret;
|
||||
if ((ret = dds_entity_pin (entity, &e)) != DDS_RETCODE_OK)
|
||||
return ret;
|
||||
else
|
||||
{
|
||||
dds_entity_t subh;
|
||||
|
|
@ -617,189 +530,21 @@ dds_entity_t dds_get_subscriber (dds_entity_t entity)
|
|||
subh = e->m_parent->m_parent->m_hdllink.hdl;
|
||||
break;
|
||||
default:
|
||||
subh = DDS_ERRNO (DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
subh = DDS_RETCODE_ILLEGAL_OPERATION;
|
||||
break;
|
||||
}
|
||||
dds_entity_release (e);
|
||||
dds_entity_unpin (e);
|
||||
return subh;
|
||||
}
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
dds_get_subscription_matched_status (
|
||||
dds_entity_t reader,
|
||||
dds_subscription_matched_status_t * status)
|
||||
{
|
||||
dds_retcode_t rc;
|
||||
dds_reader *rd;
|
||||
dds_return_t ret = DDS_RETCODE_OK;
|
||||
/* Reset sets everything (type) 0, including the reason field, verify that 0 is correct */
|
||||
DDSRT_STATIC_ASSERT ((int) DDS_NOT_REJECTED == 0);
|
||||
|
||||
rc = dds_reader_lock(reader, &rd);
|
||||
if (rc != DDS_RETCODE_OK) {
|
||||
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 */
|
||||
if (status) {
|
||||
*status = rd->m_subscription_matched_status;
|
||||
}
|
||||
ddsrt_mutex_lock (&rd->m_entity.m_observers_lock);
|
||||
if (rd->m_entity.m_status_enable & DDS_SUBSCRIPTION_MATCHED_STATUS) {
|
||||
rd->m_subscription_matched_status.total_count_change = 0;
|
||||
rd->m_subscription_matched_status.current_count_change = 0;
|
||||
dds_entity_status_reset(&rd->m_entity, DDS_SUBSCRIPTION_MATCHED_STATUS);
|
||||
}
|
||||
ddsrt_mutex_unlock (&rd->m_entity.m_observers_lock);
|
||||
dds_reader_unlock(rd);
|
||||
fail:
|
||||
return ret;
|
||||
}
|
||||
DDS_GET_STATUS (reader, subscription_matched, SUBSCRIPTION_MATCHED, total_count_change, current_count_change)
|
||||
DDS_GET_STATUS (reader, liveliness_changed, LIVELINESS_CHANGED, alive_count_change, not_alive_count_change)
|
||||
DDS_GET_STATUS (reader, sample_rejected, SAMPLE_REJECTED, total_count_change)
|
||||
DDS_GET_STATUS (reader, sample_lost, SAMPLE_LOST, total_count_change)
|
||||
DDS_GET_STATUS (reader, requested_deadline_missed, REQUESTED_DEADLINE_MISSED, total_count_change)
|
||||
DDS_GET_STATUS (reader, requested_incompatible_qos, REQUESTED_INCOMPATIBLE_QOS, total_count_change)
|
||||
|
||||
dds_return_t
|
||||
dds_get_liveliness_changed_status (
|
||||
dds_entity_t reader,
|
||||
dds_liveliness_changed_status_t * status)
|
||||
{
|
||||
dds_retcode_t rc;
|
||||
dds_reader *rd;
|
||||
dds_return_t ret = DDS_RETCODE_OK;
|
||||
|
||||
rc = dds_reader_lock(reader, &rd);
|
||||
if (rc != DDS_RETCODE_OK) {
|
||||
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 */
|
||||
if (status) {
|
||||
*status = rd->m_liveliness_changed_status;
|
||||
}
|
||||
ddsrt_mutex_lock (&rd->m_entity.m_observers_lock);
|
||||
if (rd->m_entity.m_status_enable & DDS_LIVELINESS_CHANGED_STATUS) {
|
||||
rd->m_liveliness_changed_status.alive_count_change = 0;
|
||||
rd->m_liveliness_changed_status.not_alive_count_change = 0;
|
||||
dds_entity_status_reset(&rd->m_entity, DDS_LIVELINESS_CHANGED_STATUS);
|
||||
}
|
||||
ddsrt_mutex_unlock (&rd->m_entity.m_observers_lock);
|
||||
dds_reader_unlock(rd);
|
||||
fail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
dds_return_t dds_get_sample_rejected_status (
|
||||
dds_entity_t reader,
|
||||
dds_sample_rejected_status_t * status)
|
||||
{
|
||||
dds_retcode_t rc;
|
||||
dds_reader *rd;
|
||||
dds_return_t ret = DDS_RETCODE_OK;
|
||||
|
||||
rc = dds_reader_lock(reader, &rd);
|
||||
if (rc != DDS_RETCODE_OK) {
|
||||
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 */
|
||||
if (status) {
|
||||
*status = rd->m_sample_rejected_status;
|
||||
}
|
||||
ddsrt_mutex_lock (&rd->m_entity.m_observers_lock);
|
||||
if (rd->m_entity.m_status_enable & DDS_SAMPLE_REJECTED_STATUS) {
|
||||
rd->m_sample_rejected_status.total_count_change = 0;
|
||||
rd->m_sample_rejected_status.last_reason = DDS_NOT_REJECTED;
|
||||
dds_entity_status_reset(&rd->m_entity, DDS_SAMPLE_REJECTED_STATUS);
|
||||
}
|
||||
ddsrt_mutex_unlock (&rd->m_entity.m_observers_lock);
|
||||
dds_reader_unlock(rd);
|
||||
fail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
dds_return_t dds_get_sample_lost_status (
|
||||
dds_entity_t reader,
|
||||
dds_sample_lost_status_t * status)
|
||||
{
|
||||
dds_retcode_t rc;
|
||||
dds_reader *rd;
|
||||
dds_return_t ret = DDS_RETCODE_OK;
|
||||
|
||||
rc = dds_reader_lock(reader, &rd);
|
||||
if (rc != DDS_RETCODE_OK) {
|
||||
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 */
|
||||
if (status) {
|
||||
*status = rd->m_sample_lost_status;
|
||||
}
|
||||
ddsrt_mutex_lock (&rd->m_entity.m_observers_lock);
|
||||
if (rd->m_entity.m_status_enable & DDS_SAMPLE_LOST_STATUS) {
|
||||
rd->m_sample_lost_status.total_count_change = 0;
|
||||
dds_entity_status_reset(&rd->m_entity, DDS_SAMPLE_LOST_STATUS);
|
||||
}
|
||||
ddsrt_mutex_unlock (&rd->m_entity.m_observers_lock);
|
||||
dds_reader_unlock(rd);
|
||||
fail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
dds_return_t dds_get_requested_deadline_missed_status (
|
||||
dds_entity_t reader,
|
||||
dds_requested_deadline_missed_status_t * status)
|
||||
{
|
||||
dds_retcode_t rc;
|
||||
dds_reader *rd;
|
||||
dds_return_t ret = DDS_RETCODE_OK;
|
||||
|
||||
rc = dds_reader_lock(reader, &rd);
|
||||
if (rc != DDS_RETCODE_OK) {
|
||||
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 */
|
||||
if (status) {
|
||||
*status = rd->m_requested_deadline_missed_status;
|
||||
}
|
||||
ddsrt_mutex_lock (&rd->m_entity.m_observers_lock);
|
||||
if (rd->m_entity.m_status_enable & DDS_REQUESTED_DEADLINE_MISSED_STATUS) {
|
||||
rd->m_requested_deadline_missed_status.total_count_change = 0;
|
||||
dds_entity_status_reset(&rd->m_entity, DDS_REQUESTED_DEADLINE_MISSED_STATUS);
|
||||
}
|
||||
ddsrt_mutex_unlock (&rd->m_entity.m_observers_lock);
|
||||
dds_reader_unlock(rd);
|
||||
fail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
dds_return_t dds_get_requested_incompatible_qos_status (
|
||||
dds_entity_t reader,
|
||||
dds_requested_incompatible_qos_status_t * status)
|
||||
{
|
||||
dds_retcode_t rc;
|
||||
dds_reader *rd;
|
||||
dds_return_t ret = DDS_RETCODE_OK;
|
||||
|
||||
rc = dds_reader_lock(reader, &rd);
|
||||
if (rc != DDS_RETCODE_OK) {
|
||||
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 */
|
||||
if (status) {
|
||||
*status = rd->m_requested_incompatible_qos_status;
|
||||
}
|
||||
ddsrt_mutex_lock (&rd->m_entity.m_observers_lock);
|
||||
if (rd->m_entity.m_status_enable & DDS_REQUESTED_INCOMPATIBLE_QOS_STATUS) {
|
||||
rd->m_requested_incompatible_qos_status.total_count_change = 0;
|
||||
dds_entity_status_reset(&rd->m_entity, DDS_REQUESTED_INCOMPATIBLE_QOS_STATUS);
|
||||
}
|
||||
ddsrt_mutex_unlock (&rd->m_entity.m_observers_lock);
|
||||
dds_reader_unlock(rd);
|
||||
fail:
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
2819
src/core/ddsc/src/dds_rhc_default.c
Normal file
2819
src/core/ddsc/src/dds_rhc_default.c
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -19,7 +19,7 @@
|
|||
#include "dds/ddsi/q_bswap.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/q_freelist.h"
|
||||
#include "dds__key.h"
|
||||
#include "dds/ddsi/q_plist.h"
|
||||
#include "dds__stream.h"
|
||||
#include "dds__serdata_builtintopic.h"
|
||||
#include "dds/ddsi/ddsi_tkmap.h"
|
||||
|
|
@ -126,16 +126,17 @@ static void from_entity_pwr (struct ddsi_serdata_builtintopic *d, const struct p
|
|||
assert (d->xqos.present & QP_TYPE_NAME);
|
||||
}
|
||||
|
||||
struct ddsi_serdata *ddsi_serdata_builtin_from_keyhash (const struct ddsi_sertopic *tpcmn, const nn_keyhash_t *keyhash)
|
||||
static struct ddsi_serdata *ddsi_serdata_builtin_from_keyhash (const struct ddsi_sertopic *tpcmn, const nn_keyhash_t *keyhash)
|
||||
{
|
||||
/* FIXME: not quite elegant to manage the creation of a serdata for a built-in topic via this function, but I also find it quite unelegant to let from_sample read straight from the underlying internal entity, and to_sample convert to the external format ... I could claim the internal entity is the "serialised form", but that forces wrapping it in a fragchain in one way or another, which, though possible, is also a bit lacking in elegance. */
|
||||
const struct ddsi_sertopic_builtintopic *tp = (const struct ddsi_sertopic_builtintopic *)tpcmn;
|
||||
/* keyhash must in host format (which the GUIDs always are internally) */
|
||||
const struct entity_common *entity = ephash_lookup_guid_untyped ((const nn_guid_t *) keyhash->value);
|
||||
struct entity_common *entity = ephash_lookup_guid_untyped (tp->gv->guid_hash, (const nn_guid_t *) keyhash->value);
|
||||
struct ddsi_serdata_builtintopic *d = serdata_builtin_new(tp, entity ? SDK_DATA : SDK_KEY);
|
||||
memcpy (&d->key, keyhash->value, sizeof (d->key));
|
||||
if (entity)
|
||||
{
|
||||
ddsrt_mutex_lock (&entity->qos_lock);
|
||||
switch (entity->kind)
|
||||
{
|
||||
case EK_PARTICIPANT:
|
||||
|
|
@ -163,6 +164,7 @@ struct ddsi_serdata *ddsi_serdata_builtin_from_keyhash (const struct ddsi_sertop
|
|||
from_entity_pwr (d, (const struct proxy_writer *) entity);
|
||||
break;
|
||||
}
|
||||
ddsrt_mutex_unlock (&entity->qos_lock);
|
||||
}
|
||||
return fix_serdata_builtin(d, tp->c.serdata_basehash);
|
||||
}
|
||||
|
|
@ -187,24 +189,16 @@ static char *dds_string_dup_reuse (char *old, const char *src)
|
|||
return memcpy (new, src, size);
|
||||
}
|
||||
|
||||
static dds_qos_t *dds_qos_from_xqos_reuse (dds_qos_t *old, const nn_xqos_t *src)
|
||||
static dds_qos_t *dds_qos_from_xqos_reuse (dds_qos_t *old, const dds_qos_t *src)
|
||||
{
|
||||
if (old == NULL)
|
||||
{
|
||||
old = ddsrt_malloc (sizeof (*old));
|
||||
nn_xqos_init_empty (old);
|
||||
old->present |= QP_TOPIC_NAME | QP_TYPE_NAME;
|
||||
nn_xqos_mergein_missing (old, src);
|
||||
old->present &= ~(QP_TOPIC_NAME | QP_TYPE_NAME);
|
||||
}
|
||||
else
|
||||
{
|
||||
nn_xqos_fini (old);
|
||||
nn_xqos_init_empty (old);
|
||||
old->present |= QP_TOPIC_NAME | QP_TYPE_NAME;
|
||||
nn_xqos_mergein_missing (old, src);
|
||||
old->present &= ~(QP_TOPIC_NAME | QP_TYPE_NAME);
|
||||
}
|
||||
nn_xqos_init_empty (old);
|
||||
nn_xqos_mergein_missing (old, src, ~(QP_TOPIC_NAME | QP_TYPE_NAME));
|
||||
return old;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,30 +26,18 @@
|
|||
|
||||
/* FIXME: sertopic /= ddstopic so a lot of stuff needs to be moved here from dds_topic.c and the free function needs to be implemented properly */
|
||||
|
||||
struct ddsi_sertopic *new_sertopic_builtintopic (enum ddsi_sertopic_builtintopic_type type, const char *name, const char *typename)
|
||||
struct ddsi_sertopic *new_sertopic_builtintopic (enum ddsi_sertopic_builtintopic_type type, const char *name, const char *typename, struct q_globals *gv)
|
||||
{
|
||||
struct ddsi_sertopic_builtintopic *tp = ddsrt_malloc (sizeof (*tp));
|
||||
tp->c.iid = ddsi_iid_gen();
|
||||
tp->c.name = dds_string_dup (name);
|
||||
tp->c.type_name = dds_string_dup (typename);
|
||||
const size_t name_typename_size = strlen (tp->c.name) + 1 + strlen (tp->c.type_name) + 1;
|
||||
tp->c.name_type_name = dds_alloc (name_typename_size);
|
||||
snprintf (tp->c.name_type_name, name_typename_size, "%s/%s", tp->c.name, tp->c.type_name);
|
||||
tp->c.ops = &ddsi_sertopic_ops_builtintopic;
|
||||
tp->c.serdata_ops = &ddsi_serdata_ops_builtintopic;
|
||||
tp->c.serdata_basehash = ddsi_sertopic_compute_serdata_basehash (tp->c.serdata_ops);
|
||||
tp->c.status_cb = 0;
|
||||
tp->c.status_cb_entity = NULL;
|
||||
ddsrt_atomic_st32 (&tp->c.refc, 1);
|
||||
ddsi_sertopic_init (&tp->c, name, typename, &ddsi_sertopic_ops_builtintopic, &ddsi_serdata_ops_builtintopic, false);
|
||||
tp->type = type;
|
||||
tp->gv = gv;
|
||||
return &tp->c;
|
||||
}
|
||||
|
||||
static void sertopic_builtin_free (struct ddsi_sertopic *tp)
|
||||
{
|
||||
ddsrt_free (tp->name_type_name);
|
||||
ddsrt_free (tp->name);
|
||||
ddsrt_free (tp->type_name);
|
||||
ddsi_sertopic_fini (tp);
|
||||
ddsrt_free (tp);
|
||||
}
|
||||
|
||||
|
|
@ -95,7 +83,7 @@ static void sertopic_builtin_realloc_samples (void **ptrs, const struct ddsi_ser
|
|||
{
|
||||
const struct ddsi_sertopic_builtintopic *tp = (const struct ddsi_sertopic_builtintopic *)sertopic_common;
|
||||
const size_t size = get_size (tp->type);
|
||||
char *new = dds_realloc (old, size * count);
|
||||
char *new = (oldcount == count) ? old : dds_realloc (old, size * count);
|
||||
if (new && count > oldcount)
|
||||
memset (new + size * oldcount, 0, size * (count - oldcount));
|
||||
for (size_t i = 0; i < count; i++)
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -11,203 +11,93 @@
|
|||
*/
|
||||
#include <string.h>
|
||||
#include "dds__listener.h"
|
||||
#include "dds__qos.h"
|
||||
#include "dds__err.h"
|
||||
#include "dds__participant.h"
|
||||
#include "dds__subscriber.h"
|
||||
#include "dds__qos.h"
|
||||
#include "dds/ddsi/ddsi_iid.h"
|
||||
#include "dds/ddsi/q_entity.h"
|
||||
#include "dds/ddsi/q_globals.h"
|
||||
#include "dds/ddsrt/heap.h"
|
||||
#include "dds/version.h"
|
||||
|
||||
DECL_ENTITY_LOCK_UNLOCK(extern inline, dds_subscriber)
|
||||
DECL_ENTITY_LOCK_UNLOCK (extern inline, dds_subscriber)
|
||||
|
||||
#define DDS_SUBSCRIBER_STATUS_MASK \
|
||||
DDS_DATA_ON_READERS_STATUS
|
||||
(DDS_DATA_ON_READERS_STATUS)
|
||||
|
||||
static dds_return_t
|
||||
dds_subscriber_instance_hdl(
|
||||
dds_entity *e,
|
||||
dds_instance_handle_t *i)
|
||||
static dds_return_t dds_subscriber_qos_set (dds_entity *e, const dds_qos_t *qos, bool enabled)
|
||||
{
|
||||
(void)e;
|
||||
(void)i;
|
||||
/* TODO: Get/generate proper handle. */
|
||||
DDS_ERROR("Generating subscriber instance handle is not supported");
|
||||
return DDS_ERRNO(DDS_RETCODE_UNSUPPORTED);
|
||||
/* note: e->m_qos is still the old one to allow for failure here */
|
||||
(void) e; (void) qos; (void) enabled;
|
||||
return DDS_RETCODE_OK;
|
||||
}
|
||||
|
||||
static dds_return_t
|
||||
dds__subscriber_qos_validate(
|
||||
const dds_qos_t *qos,
|
||||
bool enabled)
|
||||
static dds_return_t dds_subscriber_status_validate (uint32_t mask)
|
||||
{
|
||||
dds_return_t ret = DDS_RETCODE_OK;
|
||||
return (mask & ~DDS_SUBSCRIBER_STATUS_MASK) ? DDS_RETCODE_BAD_PARAMETER : DDS_RETCODE_OK;
|
||||
}
|
||||
|
||||
assert(qos);
|
||||
const struct dds_entity_deriver dds_entity_deriver_subscriber = {
|
||||
.close = dds_entity_deriver_dummy_close,
|
||||
.delete = dds_entity_deriver_dummy_delete,
|
||||
.set_qos = dds_subscriber_qos_set,
|
||||
.validate_status = dds_subscriber_status_validate
|
||||
};
|
||||
|
||||
if((qos->present & QP_GROUP_DATA) && !validate_octetseq(&qos->group_data)) {
|
||||
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)) {
|
||||
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)) {
|
||||
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)) {
|
||||
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. */
|
||||
DDS_ERROR("Presentation QoS policy is immutable\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_IMMUTABLE_POLICY);
|
||||
}
|
||||
dds_entity_t dds__create_subscriber_l (dds_participant *participant, const dds_qos_t *qos, const dds_listener_t *listener)
|
||||
{
|
||||
/* participant entity lock must be held */
|
||||
dds_subscriber *sub;
|
||||
dds_entity_t subscriber;
|
||||
dds_return_t ret;
|
||||
dds_qos_t *new_qos;
|
||||
|
||||
new_qos = dds_create_qos ();
|
||||
if (qos)
|
||||
nn_xqos_mergein_missing (new_qos, qos, DDS_SUBSCRIBER_QOS_MASK);
|
||||
nn_xqos_mergein_missing (new_qos, &participant->m_entity.m_domain->gv.default_xqos_sub, ~(uint64_t)0);
|
||||
if ((ret = nn_xqos_valid (&participant->m_entity.m_domain->gv.logconfig, new_qos)) != DDS_RETCODE_OK)
|
||||
{
|
||||
dds_delete_qos (new_qos);
|
||||
return ret;
|
||||
}
|
||||
|
||||
sub = dds_alloc (sizeof (*sub));
|
||||
subscriber = dds_entity_init (&sub->m_entity, &participant->m_entity, DDS_KIND_SUBSCRIBER, new_qos, listener, DDS_SUBSCRIBER_STATUS_MASK);
|
||||
sub->m_entity.m_iid = ddsi_iid_gen ();
|
||||
dds_entity_register_child (&participant->m_entity, &sub->m_entity);
|
||||
return subscriber;
|
||||
}
|
||||
|
||||
static dds_return_t
|
||||
dds_subscriber_qos_set(
|
||||
dds_entity *e,
|
||||
const dds_qos_t *qos,
|
||||
bool enabled)
|
||||
dds_entity_t dds_create_subscriber (dds_entity_t participant, const dds_qos_t *qos, const dds_listener_t *listener)
|
||||
{
|
||||
dds_return_t ret = dds__subscriber_qos_validate(qos, enabled);
|
||||
(void)e;
|
||||
if (ret == DDS_RETCODE_OK) {
|
||||
if (enabled) {
|
||||
/* TODO: CHAM-95: DDSI does not support changing QoS policies. */
|
||||
DDS_ERROR(DDS_PROJECT_NAME" does not support changing QoS policies yet\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED);
|
||||
}
|
||||
}
|
||||
dds_participant *par;
|
||||
dds_entity_t hdl;
|
||||
dds_return_t ret;
|
||||
if ((ret = dds_participant_lock (participant, &par)) != DDS_RETCODE_OK)
|
||||
return ret;
|
||||
hdl = dds__create_subscriber_l (par, qos, listener);
|
||||
dds_participant_unlock (par);
|
||||
return hdl;
|
||||
}
|
||||
|
||||
static dds_return_t
|
||||
dds_subscriber_status_validate(
|
||||
uint32_t mask)
|
||||
dds_return_t dds_notify_readers (dds_entity_t subscriber)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
dds_subscriber *sub;
|
||||
dds_return_t ret;
|
||||
if ((ret = dds_subscriber_lock (subscriber, &sub)) != DDS_RETCODE_OK)
|
||||
return ret;
|
||||
dds_subscriber_unlock (sub);
|
||||
return DDS_RETCODE_UNSUPPORTED;
|
||||
}
|
||||
|
||||
dds_entity_t
|
||||
dds__create_subscriber_l(
|
||||
dds_entity *participant, /* entity-lock must be held */
|
||||
const dds_qos_t *qos,
|
||||
const dds_listener_t *listener)
|
||||
dds_return_t dds_subscriber_begin_coherent (dds_entity_t e)
|
||||
{
|
||||
dds_subscriber * sub;
|
||||
dds_entity_t subscriber;
|
||||
dds_return_t ret;
|
||||
dds_qos_t * new_qos;
|
||||
|
||||
/* Validate qos */
|
||||
if (qos) {
|
||||
if ((ret = dds__subscriber_qos_validate(qos, false)) != DDS_RETCODE_OK) {
|
||||
goto err_param;
|
||||
}
|
||||
new_qos = dds_create_qos();
|
||||
/* Only returns failure when one of the qos args is NULL, which
|
||||
* is not the case here. */
|
||||
(void)dds_copy_qos(new_qos, qos);
|
||||
} else {
|
||||
new_qos = NULL;
|
||||
}
|
||||
|
||||
/* Create subscriber */
|
||||
sub = dds_alloc(sizeof(*sub));
|
||||
subscriber = dds_entity_init(&sub->m_entity, participant, DDS_KIND_SUBSCRIBER, new_qos, listener, DDS_SUBSCRIBER_STATUS_MASK);
|
||||
sub->m_entity.m_deriver.set_qos = dds_subscriber_qos_set;
|
||||
sub->m_entity.m_deriver.validate_status = dds_subscriber_status_validate;
|
||||
sub->m_entity.m_deriver.get_instance_hdl = dds_subscriber_instance_hdl;
|
||||
|
||||
return subscriber;
|
||||
|
||||
/* Error handling */
|
||||
err_param:
|
||||
return ret;
|
||||
return dds_generic_unimplemented_operation (e, DDS_KIND_SUBSCRIBER);
|
||||
}
|
||||
|
||||
dds_entity_t
|
||||
dds_create_subscriber(
|
||||
dds_entity_t participant,
|
||||
const dds_qos_t *qos,
|
||||
const dds_listener_t *listener)
|
||||
dds_return_t dds_subscriber_end_coherent (dds_entity_t e)
|
||||
{
|
||||
dds_entity * par;
|
||||
dds_entity_t hdl;
|
||||
dds_retcode_t errnr;
|
||||
|
||||
errnr = dds_entity_lock(participant, DDS_KIND_PARTICIPANT, &par);
|
||||
if (errnr != DDS_RETCODE_OK) {
|
||||
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);
|
||||
|
||||
return hdl;
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
dds_notify_readers(
|
||||
dds_entity_t subscriber)
|
||||
{
|
||||
dds_entity *iter;
|
||||
dds_entity *sub;
|
||||
dds_retcode_t errnr;
|
||||
dds_return_t ret;
|
||||
|
||||
errnr = dds_entity_lock(subscriber, DDS_KIND_SUBSCRIBER, &sub);
|
||||
if (errnr == DDS_RETCODE_OK) {
|
||||
errnr = DDS_RETCODE_UNSUPPORTED;
|
||||
DDS_ERROR("Unsupported operation\n");
|
||||
ret = DDS_ERRNO(errnr);
|
||||
iter = sub->m_children;
|
||||
while (iter) {
|
||||
ddsrt_mutex_lock(&iter->m_mutex);
|
||||
// TODO: check if reader has data available, call listener
|
||||
ddsrt_mutex_unlock(&iter->m_mutex);
|
||||
iter = iter->m_next;
|
||||
}
|
||||
dds_entity_unlock(sub);
|
||||
} else {
|
||||
DDS_ERROR("Error occurred on locking subscriber\n");
|
||||
ret = DDS_ERRNO(errnr);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
dds_subscriber_begin_coherent(
|
||||
dds_entity_t e)
|
||||
{
|
||||
/* TODO: CHAM-124 Currently unsupported. */
|
||||
(void)e;
|
||||
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
|
||||
dds_subscriber_end_coherent(
|
||||
dds_entity_t e)
|
||||
{
|
||||
/* TODO: CHAM-124 Currently unsupported. */
|
||||
(void)e;
|
||||
DDS_ERROR("Using coherency to get a coherent data set is not currently being supported\n");
|
||||
return DDS_ERRNO(DDS_RETCODE_UNSUPPORTED);
|
||||
return dds_generic_unimplemented_operation (e, DDS_KIND_SUBSCRIBER);
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -14,458 +14,304 @@
|
|||
#include "dds/ddsrt/heap.h"
|
||||
#include "dds/ddsrt/log.h"
|
||||
#include "dds__entity.h"
|
||||
#include "dds__participant.h"
|
||||
#include "dds__querycond.h"
|
||||
#include "dds__readcond.h"
|
||||
#include "dds__rhc.h"
|
||||
#include "dds__err.h"
|
||||
#include "dds/ddsi/ddsi_iid.h"
|
||||
|
||||
DEFINE_ENTITY_LOCK_UNLOCK(static, dds_waitset, DDS_KIND_WAITSET)
|
||||
DEFINE_ENTITY_LOCK_UNLOCK (static, dds_waitset, DDS_KIND_WAITSET)
|
||||
|
||||
static void
|
||||
dds_waitset_swap(
|
||||
dds_attachment **dst,
|
||||
dds_attachment **src,
|
||||
dds_attachment *prev,
|
||||
dds_attachment *idx)
|
||||
static bool is_triggered (struct dds_entity *e)
|
||||
{
|
||||
/* Remove from source. */
|
||||
if (prev == NULL) {
|
||||
*src = idx->next;
|
||||
} else {
|
||||
prev->next = idx->next;
|
||||
}
|
||||
|
||||
/* Add to destination. */
|
||||
idx->next = *dst;
|
||||
*dst = idx;
|
||||
bool t;
|
||||
switch (e->m_kind)
|
||||
{
|
||||
case DDS_KIND_COND_READ:
|
||||
case DDS_KIND_COND_QUERY:
|
||||
case DDS_KIND_COND_GUARD:
|
||||
case DDS_KIND_WAITSET:
|
||||
t = ddsrt_atomic_ld32 (&e->m_status.m_trigger) != 0;
|
||||
break;
|
||||
default:
|
||||
t = (ddsrt_atomic_ld32 (&e->m_status.m_status_and_mask) & SAM_STATUS_MASK) != 0;
|
||||
break;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
static dds_return_t
|
||||
dds_waitset_wait_impl(
|
||||
dds_entity_t waitset,
|
||||
dds_attach_t *xs,
|
||||
size_t nxs,
|
||||
dds_time_t abstimeout,
|
||||
dds_time_t tnow)
|
||||
static dds_return_t dds_waitset_wait_impl (dds_entity_t waitset, dds_attach_t *xs, size_t nxs, dds_time_t abstimeout)
|
||||
{
|
||||
dds_waitset *ws;
|
||||
dds_return_t ret;
|
||||
dds_retcode_t rc;
|
||||
dds_attachment *idx;
|
||||
dds_attachment *next;
|
||||
dds_attachment *prev;
|
||||
dds_waitset *ws;
|
||||
dds_return_t ret;
|
||||
|
||||
if ((xs == NULL) && (nxs != 0)){
|
||||
DDS_ERROR("A size was given, but no array\n");
|
||||
return DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER);
|
||||
if ((xs == NULL) != (nxs == 0))
|
||||
return DDS_RETCODE_BAD_PARAMETER;
|
||||
|
||||
/* Locking the waitset here will delay a possible deletion until it is
|
||||
* unlocked. Even when the related mutex is unlocked by a conditioned wait. */
|
||||
{
|
||||
dds_entity *ent;
|
||||
if ((ret = dds_entity_pin (waitset, &ent)) != DDS_RETCODE_OK)
|
||||
return ret;
|
||||
if (dds_entity_kind (ent) != DDS_KIND_WAITSET)
|
||||
{
|
||||
dds_entity_unpin (ent);
|
||||
return DDS_RETCODE_ILLEGAL_OPERATION;
|
||||
}
|
||||
if ((xs != NULL) && (nxs == 0)){
|
||||
DDS_ERROR("Array is given with an invalid size\n");
|
||||
return DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER);
|
||||
ws = (dds_waitset *) ent;
|
||||
}
|
||||
|
||||
/* Move any previously but no longer triggering entities back to the observed list */
|
||||
ddsrt_mutex_lock (&ws->m_entity.m_mutex);
|
||||
ws->ntriggered = 0;
|
||||
for (size_t i = 0; i < ws->nentities; i++)
|
||||
{
|
||||
if (is_triggered (ws->entities[i].entity))
|
||||
{
|
||||
dds_attachment tmp = ws->entities[i];
|
||||
ws->entities[i] = ws->entities[ws->ntriggered];
|
||||
ws->entities[ws->ntriggered++] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
/* Locking the waitset here will delay a possible deletion until it is
|
||||
* unlocked. Even when the related mutex is unlocked by a conditioned wait. */
|
||||
rc = dds_waitset_lock(waitset, &ws);
|
||||
if (rc == DDS_RETCODE_OK) {
|
||||
/* Check if any of any previous triggered entities has changed there status
|
||||
* and thus it trigger value could be false now. */
|
||||
idx = ws->triggered;
|
||||
prev = NULL;
|
||||
while (idx != NULL) {
|
||||
next = idx->next;
|
||||
if (idx->entity->m_trigger == 0) {
|
||||
/* Move observed entity to triggered list. */
|
||||
dds_waitset_swap(&(ws->observed), &(ws->triggered), prev, idx);
|
||||
} else {
|
||||
prev = idx;
|
||||
}
|
||||
idx = next;
|
||||
}
|
||||
/* Check if any of the entities have been triggered. */
|
||||
idx = ws->observed;
|
||||
prev = NULL;
|
||||
while (idx != NULL) {
|
||||
next = idx->next;
|
||||
if (idx->entity->m_trigger > 0) {
|
||||
/* Move observed entity to triggered list. */
|
||||
dds_waitset_swap(&(ws->triggered), &(ws->observed), prev, idx);
|
||||
} else {
|
||||
prev = idx;
|
||||
}
|
||||
idx = next;
|
||||
}
|
||||
/* Only wait/keep waiting when we have something to observe and there aren't any triggers yet. */
|
||||
while (ws->nentities > 0 && ws->ntriggered == 0)
|
||||
if (!ddsrt_cond_waituntil (&ws->m_entity.m_cond, &ws->m_entity.m_mutex, abstimeout))
|
||||
break;
|
||||
|
||||
/* Only wait/keep waiting when whe have something to observer and there aren't any triggers yet. */
|
||||
rc = DDS_RETCODE_OK;
|
||||
while ((ws->observed != NULL) && (ws->triggered == NULL) && (rc == DDS_RETCODE_OK)) {
|
||||
if (abstimeout == DDS_NEVER) {
|
||||
ddsrt_cond_wait(&ws->m_entity.m_cond, &ws->m_entity.m_mutex);
|
||||
} else if (abstimeout <= tnow) {
|
||||
rc = DDS_RETCODE_TIMEOUT;
|
||||
} else {
|
||||
dds_duration_t dt = abstimeout - tnow;
|
||||
(void)ddsrt_cond_waitfor(&ws->m_entity.m_cond, &ws->m_entity.m_mutex, dt);
|
||||
tnow = dds_time();
|
||||
}
|
||||
}
|
||||
ret = (int32_t) ws->ntriggered;
|
||||
for (size_t i = 0; i < ws->ntriggered && i < nxs; i++)
|
||||
xs[i] = ws->entities[i].arg;
|
||||
ddsrt_mutex_unlock (&ws->m_entity.m_mutex);
|
||||
dds_entity_unpin (&ws->m_entity);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Get number of triggered entities
|
||||
* - set attach array when needed
|
||||
* - swap them back to observed */
|
||||
if (rc == DDS_RETCODE_OK) {
|
||||
ret = 0;
|
||||
idx = ws->triggered;
|
||||
while (idx != NULL) {
|
||||
if ((uint32_t)ret < (uint32_t)nxs) {
|
||||
xs[ret] = idx->arg;
|
||||
}
|
||||
ret++;
|
||||
static dds_return_t dds_waitset_close (struct dds_entity *e)
|
||||
{
|
||||
/* deep in the process of deleting the entity, so this is the only thread */
|
||||
dds_waitset *ws = (dds_waitset *) e;
|
||||
for (size_t i = 0; i < ws->nentities; i++)
|
||||
(void) dds_entity_observer_unregister (ws->entities[i].entity, &ws->m_entity);
|
||||
return DDS_RETCODE_OK;
|
||||
}
|
||||
|
||||
next = idx->next;
|
||||
/* The idx is always the first in triggered, so no prev. */
|
||||
dds_waitset_swap(&(ws->observed), &(ws->triggered), NULL, idx);
|
||||
idx = next;
|
||||
}
|
||||
} else if (rc == DDS_RETCODE_TIMEOUT) {
|
||||
ret = 0;
|
||||
} else {
|
||||
DDS_ERROR("Internal error");
|
||||
ret = DDS_ERRNO(rc);
|
||||
}
|
||||
static dds_return_t dds_waitset_delete (struct dds_entity *e)
|
||||
{
|
||||
/* deep in the process of deleting the entity, so this is the only thread */
|
||||
dds_waitset *ws = (dds_waitset *) e;
|
||||
ddsrt_free (ws->entities);
|
||||
return DDS_RETCODE_OK;
|
||||
}
|
||||
|
||||
dds_waitset_unlock(ws);
|
||||
} else {
|
||||
DDS_ERROR("Error occurred on locking waitset\n");
|
||||
ret = DDS_ERRNO(rc);
|
||||
}
|
||||
const struct dds_entity_deriver dds_entity_deriver_waitset = {
|
||||
.close = dds_waitset_close,
|
||||
.delete = dds_waitset_delete,
|
||||
.set_qos = dds_entity_deriver_dummy_set_qos,
|
||||
.validate_status = dds_entity_deriver_dummy_validate_status
|
||||
};
|
||||
|
||||
dds_entity_t dds_create_waitset (dds_entity_t participant)
|
||||
{
|
||||
dds_entity_t hdl;
|
||||
dds_participant *par;
|
||||
dds_return_t rc;
|
||||
|
||||
if ((rc = dds_participant_lock (participant, &par)) != DDS_RETCODE_OK)
|
||||
return rc;
|
||||
|
||||
dds_waitset *waitset = dds_alloc (sizeof (*waitset));
|
||||
hdl = dds_entity_init (&waitset->m_entity, &par->m_entity, DDS_KIND_WAITSET, NULL, NULL, 0);
|
||||
waitset->m_entity.m_iid = ddsi_iid_gen ();
|
||||
dds_entity_register_child (&par->m_entity, &waitset->m_entity);
|
||||
waitset->nentities = 0;
|
||||
waitset->ntriggered = 0;
|
||||
waitset->entities = NULL;
|
||||
dds_participant_unlock (par);
|
||||
return hdl;
|
||||
}
|
||||
|
||||
dds_return_t dds_waitset_get_entities (dds_entity_t waitset, dds_entity_t *entities, size_t size)
|
||||
{
|
||||
dds_return_t ret;
|
||||
dds_waitset *ws;
|
||||
|
||||
if ((ret = dds_waitset_lock (waitset, &ws)) != DDS_RETCODE_OK)
|
||||
return ret;
|
||||
|
||||
if (entities != NULL)
|
||||
{
|
||||
for (size_t i = 0; i < ws->nentities && i < size; i++)
|
||||
entities[i] = ws->entities[i].handle;
|
||||
}
|
||||
ret = (int32_t) ws->nentities;
|
||||
dds_waitset_unlock (ws);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
dds_waitset_close_list(
|
||||
dds_attachment **list,
|
||||
dds_entity_t waitset)
|
||||
static void dds_waitset_remove (dds_waitset *ws, dds_entity_t observed)
|
||||
{
|
||||
dds_attachment *idx = *list;
|
||||
dds_attachment *next;
|
||||
while (idx != NULL) {
|
||||
next = idx->next;
|
||||
(void)dds_entity_observer_unregister(idx->entity->m_hdllink.hdl, waitset);
|
||||
ddsrt_free(idx);
|
||||
idx = next;
|
||||
size_t i;
|
||||
for (i = 0; i < ws->nentities; i++)
|
||||
if (ws->entities[i].handle == observed)
|
||||
break;
|
||||
if (i < ws->nentities)
|
||||
{
|
||||
if (i < ws->ntriggered)
|
||||
{
|
||||
ws->entities[i] = ws->entities[--ws->ntriggered];
|
||||
ws->entities[ws->ntriggered] = ws->entities[--ws->nentities];
|
||||
}
|
||||
*list = NULL;
|
||||
}
|
||||
|
||||
static bool
|
||||
dds_waitset_remove_from_list(
|
||||
dds_attachment **list,
|
||||
dds_entity_t observed)
|
||||
{
|
||||
dds_attachment *idx = *list;
|
||||
dds_attachment *prev = NULL;
|
||||
|
||||
while (idx != NULL) {
|
||||
if (idx->entity->m_hdllink.hdl == observed) {
|
||||
if (prev == NULL) {
|
||||
*list = idx->next;
|
||||
} else {
|
||||
prev->next = idx->next;
|
||||
}
|
||||
ddsrt_free(idx);
|
||||
|
||||
/* We're done. */
|
||||
return true;
|
||||
}
|
||||
prev = idx;
|
||||
idx = idx->next;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
dds_waitset_close(
|
||||
struct dds_entity *e)
|
||||
{
|
||||
dds_waitset *ws = (dds_waitset*)e;
|
||||
|
||||
dds_waitset_close_list(&ws->observed, e->m_hdllink.hdl);
|
||||
dds_waitset_close_list(&ws->triggered, e->m_hdllink.hdl);
|
||||
|
||||
/* Trigger waitset to wake up. */
|
||||
ddsrt_cond_broadcast(&e->m_cond);
|
||||
|
||||
return DDS_RETCODE_OK;
|
||||
}
|
||||
|
||||
DDS_EXPORT dds_entity_t
|
||||
dds_create_waitset(
|
||||
dds_entity_t participant)
|
||||
{
|
||||
dds_entity_t hdl;
|
||||
dds_entity *par;
|
||||
dds_retcode_t rc;
|
||||
|
||||
rc = dds_entity_lock(participant, DDS_KIND_PARTICIPANT, &par);
|
||||
if (rc == DDS_RETCODE_OK) {
|
||||
dds_waitset *waitset = dds_alloc(sizeof(*waitset));
|
||||
hdl = dds_entity_init(&waitset->m_entity, par, DDS_KIND_WAITSET, NULL, NULL, 0);
|
||||
waitset->m_entity.m_deriver.close = dds_waitset_close;
|
||||
waitset->observed = NULL;
|
||||
waitset->triggered = NULL;
|
||||
dds_entity_unlock(par);
|
||||
} else {
|
||||
hdl = DDS_ERRNO(rc);
|
||||
}
|
||||
|
||||
return hdl;
|
||||
}
|
||||
|
||||
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_waitset_get_entities(
|
||||
dds_entity_t waitset,
|
||||
dds_entity_t *entities,
|
||||
size_t size)
|
||||
{
|
||||
dds_return_t ret = 0;
|
||||
dds_retcode_t rc;
|
||||
dds_waitset *ws;
|
||||
|
||||
rc = dds_waitset_lock(waitset, &ws);
|
||||
if (rc == DDS_RETCODE_OK) {
|
||||
dds_attachment* iter;
|
||||
|
||||
iter = ws->observed;
|
||||
while (iter) {
|
||||
if (((size_t)ret < size) && (entities != NULL)) {
|
||||
entities[ret] = iter->entity->m_hdllink.hdl;
|
||||
}
|
||||
ret++;
|
||||
iter = iter->next;
|
||||
}
|
||||
|
||||
iter = ws->triggered;
|
||||
while (iter) {
|
||||
if (((size_t)ret < size) && (entities != NULL)) {
|
||||
entities[ret] = iter->entity->m_hdllink.hdl;
|
||||
}
|
||||
ret++;
|
||||
iter = iter->next;
|
||||
}
|
||||
dds_waitset_unlock(ws);
|
||||
} else {
|
||||
DDS_ERROR("Error occurred on locking waitset\n");
|
||||
ret = DDS_ERRNO(rc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
dds_waitset_move(
|
||||
dds_attachment **src,
|
||||
dds_attachment **dst,
|
||||
dds_entity_t entity)
|
||||
{
|
||||
dds_attachment *idx = *src;
|
||||
dds_attachment *prev = NULL;
|
||||
while (idx != NULL) {
|
||||
if (idx->entity->m_hdllink.hdl == entity) {
|
||||
/* Swap idx from src to dst. */
|
||||
dds_waitset_swap(dst, src, prev, idx);
|
||||
|
||||
/* We're done. */
|
||||
return;
|
||||
}
|
||||
prev = idx;
|
||||
idx = idx->next;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
dds_waitset_remove(
|
||||
dds_waitset *ws,
|
||||
dds_entity_t observed)
|
||||
{
|
||||
if (!dds_waitset_remove_from_list(&(ws->observed), observed)) {
|
||||
(void)dds_waitset_remove_from_list(&(ws->triggered), observed);
|
||||
else
|
||||
{
|
||||
ws->entities[i] = ws->entities[--ws->nentities];
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* This is called when the observed entity signals a status change. */
|
||||
void
|
||||
dds_waitset_observer(
|
||||
dds_entity_t observer,
|
||||
dds_entity_t observed,
|
||||
uint32_t status)
|
||||
static void dds_waitset_observer (dds_entity *ent, dds_entity_t observed, uint32_t status)
|
||||
{
|
||||
dds_waitset *ws;
|
||||
if (dds_waitset_lock(observer, &ws) == DDS_RETCODE_OK) {
|
||||
if (status & DDS_DELETING_STATUS) {
|
||||
/* Remove this observed entity, which is being deleted, from the waitset. */
|
||||
dds_waitset_remove(ws, observed);
|
||||
/* Our registration to this observed entity will be removed automatically. */
|
||||
} else if (status != 0) {
|
||||
/* Move observed entity to triggered list. */
|
||||
dds_waitset_move(&(ws->observed), &(ws->triggered), observed);
|
||||
} else {
|
||||
/* Remove observed entity from triggered list (which it possibly resides in). */
|
||||
dds_waitset_move(&(ws->triggered), &(ws->observed), observed);
|
||||
}
|
||||
/* Trigger waitset to wake up. */
|
||||
ddsrt_cond_broadcast(&ws->m_entity.m_cond);
|
||||
dds_waitset_unlock(ws);
|
||||
}
|
||||
assert (dds_entity_kind (ent) == DDS_KIND_WAITSET);
|
||||
dds_waitset *ws = (dds_waitset *) ent;
|
||||
(void) status;
|
||||
|
||||
ddsrt_mutex_lock (&ws->m_entity.m_mutex);
|
||||
/* Move observed entity to triggered list. */
|
||||
size_t i;
|
||||
for (i = 0; i < ws->nentities; i++)
|
||||
if (ws->entities[i].handle == observed)
|
||||
break;
|
||||
if (i < ws->nentities && i >= ws->ntriggered)
|
||||
{
|
||||
dds_attachment tmp = ws->entities[i];
|
||||
ws->entities[i] = ws->entities[ws->ntriggered];
|
||||
ws->entities[ws->ntriggered++] = tmp;
|
||||
}
|
||||
/* Trigger waitset to wake up. */
|
||||
ddsrt_cond_broadcast (&ws->m_entity.m_cond);
|
||||
ddsrt_mutex_unlock (&ws->m_entity.m_mutex);
|
||||
}
|
||||
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_waitset_attach(
|
||||
dds_entity_t waitset,
|
||||
dds_entity_t entity,
|
||||
dds_attach_t x)
|
||||
static void dds_waitset_delete_observer (dds_entity *ent, dds_entity_t observed)
|
||||
{
|
||||
dds_entity *e = NULL;
|
||||
dds_waitset *ws;
|
||||
dds_retcode_t rc;
|
||||
dds_return_t ret;
|
||||
assert (dds_entity_kind (ent) == DDS_KIND_WAITSET);
|
||||
dds_waitset *ws = (dds_waitset *) ent;
|
||||
ddsrt_mutex_lock (&ws->m_entity.m_mutex);
|
||||
/* Remove this observed entity, which is being deleted, from the waitset. */
|
||||
dds_waitset_remove (ws, observed);
|
||||
/* Our registration to this observed entity will be removed automatically. */
|
||||
/* Trigger waitset to wake up. */
|
||||
ddsrt_cond_broadcast (&ws->m_entity.m_cond);
|
||||
ddsrt_mutex_unlock (&ws->m_entity.m_mutex);
|
||||
}
|
||||
|
||||
rc = dds_waitset_lock(waitset, &ws);
|
||||
if (rc == DDS_RETCODE_OK) {
|
||||
if (waitset != entity) {
|
||||
rc = dds_entity_lock(entity, DDS_KIND_DONTCARE, &e);
|
||||
if (rc != DDS_RETCODE_OK) {
|
||||
e = NULL;
|
||||
}
|
||||
} else {
|
||||
e = &ws->m_entity;
|
||||
}
|
||||
|
||||
/* This will fail if given entity is already attached (or deleted). */
|
||||
if (rc == DDS_RETCODE_OK) {
|
||||
rc = dds_entity_observer_register_nl(e, waitset, dds_waitset_observer);
|
||||
}
|
||||
|
||||
if (rc == DDS_RETCODE_OK) {
|
||||
dds_attachment *a = ddsrt_malloc(sizeof(dds_attachment));
|
||||
a->arg = x;
|
||||
a->entity = e;
|
||||
if (e->m_trigger > 0) {
|
||||
a->next = ws->triggered;
|
||||
ws->triggered = a;
|
||||
} else {
|
||||
a->next = ws->observed;
|
||||
ws->observed = a;
|
||||
}
|
||||
ret = DDS_RETCODE_OK;
|
||||
} else if (rc != DDS_RETCODE_PRECONDITION_NOT_MET) {
|
||||
DDS_ERROR("Entity is not valid\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER);
|
||||
} else {
|
||||
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 {
|
||||
DDS_ERROR("Error occurred on locking waitset\n");
|
||||
ret = DDS_ERRNO(rc);
|
||||
}
|
||||
dds_return_t dds_waitset_attach (dds_entity_t waitset, dds_entity_t entity, dds_attach_t x)
|
||||
{
|
||||
dds_entity *e;
|
||||
dds_waitset *ws;
|
||||
dds_return_t ret;
|
||||
|
||||
if ((ret = dds_waitset_lock (waitset, &ws)) < 0)
|
||||
return ret;
|
||||
|
||||
if (waitset == entity)
|
||||
e = &ws->m_entity;
|
||||
else if ((ret = dds_entity_pin (entity, &e)) < 0)
|
||||
goto err_waitset;
|
||||
|
||||
/* This will fail if given entity is already attached (or deleted). */
|
||||
if ((ret = dds_entity_observer_register (e, &ws->m_entity, dds_waitset_observer, dds_waitset_delete_observer)) != DDS_RETCODE_OK)
|
||||
goto err_entity;
|
||||
|
||||
ws->entities = ddsrt_realloc (ws->entities, (ws->nentities + 1) * sizeof (*ws->entities));
|
||||
ws->entities[ws->nentities].arg = x;
|
||||
ws->entities[ws->nentities].entity = e;
|
||||
ws->entities[ws->nentities].handle = e->m_hdllink.hdl;
|
||||
ws->nentities++;
|
||||
if (is_triggered (e))
|
||||
{
|
||||
const size_t i = ws->nentities - 1;
|
||||
dds_attachment tmp = ws->entities[i];
|
||||
ws->entities[i] = ws->entities[ws->ntriggered];
|
||||
ws->entities[ws->ntriggered++] = tmp;
|
||||
}
|
||||
ddsrt_cond_broadcast (&ws->m_entity.m_cond);
|
||||
|
||||
err_entity:
|
||||
if (e != &ws->m_entity)
|
||||
dds_entity_unpin (e);
|
||||
err_waitset:
|
||||
dds_waitset_unlock (ws);
|
||||
return ret;
|
||||
}
|
||||
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_waitset_detach(
|
||||
dds_entity_t waitset,
|
||||
dds_entity_t entity)
|
||||
dds_return_t dds_waitset_detach (dds_entity_t waitset, dds_entity_t entity)
|
||||
{
|
||||
dds_waitset *ws;
|
||||
dds_retcode_t rc;
|
||||
dds_return_t ret;
|
||||
|
||||
rc = dds_waitset_lock(waitset, &ws);
|
||||
if (rc == DDS_RETCODE_OK) {
|
||||
/* Possibly fails when entity was not attached. */
|
||||
if (waitset == entity) {
|
||||
rc = dds_entity_observer_unregister_nl(&ws->m_entity, waitset);
|
||||
} else {
|
||||
rc = dds_entity_observer_unregister(entity, waitset);
|
||||
}
|
||||
if (rc == DDS_RETCODE_OK) {
|
||||
dds_waitset_remove(ws, entity);
|
||||
ret = DDS_RETCODE_OK;
|
||||
} else if (rc != DDS_RETCODE_PRECONDITION_NOT_MET) {
|
||||
DDS_ERROR("The given entity to detach is invalid\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER);
|
||||
} else {
|
||||
DDS_ERROR("The given entity to detach was not attached previously\n");
|
||||
ret = DDS_ERRNO(rc);
|
||||
}
|
||||
dds_waitset_unlock(ws);
|
||||
} else {
|
||||
DDS_ERROR("Error occurred on locking waitset\n");
|
||||
ret = DDS_ERRNO(rc);
|
||||
}
|
||||
dds_waitset *ws;
|
||||
dds_entity *e;
|
||||
dds_return_t ret;
|
||||
|
||||
if ((ret = dds_waitset_lock (waitset, &ws)) != DDS_RETCODE_OK)
|
||||
return ret;
|
||||
|
||||
/* Possibly fails when entity was not attached. */
|
||||
if (waitset == entity)
|
||||
ret = dds_entity_observer_unregister (&ws->m_entity, &ws->m_entity);
|
||||
else if ((ret = dds_entity_pin (entity, &e)) < 0)
|
||||
; /* entity invalid */
|
||||
else
|
||||
{
|
||||
ret = dds_entity_observer_unregister (e, &ws->m_entity);
|
||||
dds_entity_unpin (e);
|
||||
}
|
||||
|
||||
if (ret == DDS_RETCODE_OK)
|
||||
{
|
||||
dds_waitset_remove (ws, entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ret != DDS_RETCODE_PRECONDITION_NOT_MET)
|
||||
ret = DDS_RETCODE_BAD_PARAMETER;
|
||||
}
|
||||
dds_waitset_unlock (ws);
|
||||
return ret;
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
dds_waitset_wait_until(
|
||||
dds_entity_t waitset,
|
||||
dds_attach_t *xs,
|
||||
size_t nxs,
|
||||
dds_time_t abstimeout)
|
||||
dds_return_t dds_waitset_wait_until (dds_entity_t waitset, dds_attach_t *xs, size_t nxs, dds_time_t abstimeout)
|
||||
{
|
||||
return dds_waitset_wait_impl(waitset, xs, nxs, abstimeout, dds_time());
|
||||
return dds_waitset_wait_impl (waitset, xs, nxs, abstimeout);
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
dds_waitset_wait(
|
||||
dds_entity_t waitset,
|
||||
dds_attach_t *xs,
|
||||
size_t nxs,
|
||||
dds_duration_t reltimeout)
|
||||
dds_return_t dds_waitset_wait (dds_entity_t waitset, dds_attach_t *xs, size_t nxs, dds_duration_t reltimeout)
|
||||
{
|
||||
dds_entity_t ret;
|
||||
|
||||
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{
|
||||
DDS_ERROR("Negative timeout\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
return ret;
|
||||
if (reltimeout < 0)
|
||||
return DDS_RETCODE_BAD_PARAMETER;
|
||||
const dds_time_t tnow = dds_time ();
|
||||
const dds_time_t abstimeout = (DDS_INFINITY - reltimeout <= tnow) ? DDS_NEVER : (tnow + reltimeout);
|
||||
return dds_waitset_wait_impl (waitset, xs, nxs, abstimeout);
|
||||
}
|
||||
|
||||
dds_return_t dds_waitset_set_trigger (dds_entity_t waitset, bool trigger)
|
||||
{
|
||||
dds_waitset *ws;
|
||||
dds_retcode_t rc;
|
||||
dds_entity *ent;
|
||||
dds_return_t rc;
|
||||
|
||||
if ((rc = dds_waitset_lock (waitset, &ws)) != DDS_RETCODE_OK)
|
||||
return DDS_ERRNO (rc);
|
||||
if ((rc = dds_entity_pin (waitset, &ent)) != DDS_RETCODE_OK)
|
||||
return rc;
|
||||
else if (dds_entity_kind (ent) != DDS_KIND_WAITSET)
|
||||
{
|
||||
dds_entity_unpin (ent);
|
||||
return DDS_RETCODE_ILLEGAL_OPERATION;
|
||||
}
|
||||
|
||||
ddsrt_mutex_unlock (&ws->m_entity.m_mutex);
|
||||
ddsrt_mutex_lock (&ent->m_observers_lock);
|
||||
dds_entity_trigger_set (ent, trigger);
|
||||
ddsrt_mutex_unlock (&ent->m_observers_lock);
|
||||
|
||||
ddsrt_mutex_lock (&ws->m_entity.m_observers_lock);
|
||||
if (trigger)
|
||||
dds_entity_status_set (&ws->m_entity, DDS_WAITSET_TRIGGER_STATUS);
|
||||
else
|
||||
dds_entity_status_reset (&ws->m_entity, DDS_WAITSET_TRIGGER_STATUS);
|
||||
ddsrt_mutex_unlock (&ws->m_entity.m_observers_lock);
|
||||
|
||||
ddsrt_mutex_lock (&ws->m_entity.m_mutex);
|
||||
dds_waitset_unlock (ws);
|
||||
dds_entity_unpin (ent);
|
||||
return DDS_RETCODE_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ struct whc_node {
|
|||
struct whc_node *next_seq; /* next in this interval */
|
||||
struct whc_node *prev_seq; /* prev in this interval */
|
||||
struct whc_idxnode *idxnode; /* NULL if not in index */
|
||||
unsigned idxnode_pos; /* index in idxnode.hist */
|
||||
uint32_t idxnode_pos; /* index in idxnode.hist */
|
||||
seqno_t seq;
|
||||
uint64_t total_bytes; /* cumulative number of bytes up to and including this node */
|
||||
size_t size;
|
||||
|
|
@ -43,7 +43,7 @@ struct whc_node {
|
|||
unsigned unacked: 1; /* counted in whc::unacked_bytes iff 1 */
|
||||
unsigned borrowed: 1; /* at most one can borrow it at any time */
|
||||
nn_mtime_t last_rexmit_ts;
|
||||
unsigned rexmit_count;
|
||||
uint32_t rexmit_count;
|
||||
struct ddsi_serdata *serdata;
|
||||
};
|
||||
|
||||
|
|
@ -59,12 +59,8 @@ struct whc_idxnode {
|
|||
uint64_t iid;
|
||||
seqno_t prune_seq;
|
||||
struct ddsi_tkmap_instance *tk;
|
||||
unsigned headidx;
|
||||
#if __STDC_VERSION__ >= 199901L
|
||||
uint32_t headidx;
|
||||
struct whc_node *hist[];
|
||||
#else
|
||||
struct whc_node *hist[1];
|
||||
#endif
|
||||
};
|
||||
|
||||
#if USE_EHH
|
||||
|
|
@ -77,14 +73,18 @@ struct whc_seq_entry {
|
|||
struct whc_impl {
|
||||
struct whc common;
|
||||
ddsrt_mutex_t lock;
|
||||
unsigned seq_size;
|
||||
uint32_t seq_size;
|
||||
size_t unacked_bytes;
|
||||
size_t sample_overhead;
|
||||
uint32_t fragment_size;
|
||||
uint64_t total_bytes; /* total number of bytes pushed in */
|
||||
unsigned is_transient_local: 1;
|
||||
unsigned hdepth; /* 0 = unlimited */
|
||||
unsigned tldepth; /* 0 = disabled/unlimited (no need to maintain an index if KEEP_ALL <=> is_transient_local + tldepth=0) */
|
||||
unsigned idxdepth; /* = max(hdepth, tldepth) */
|
||||
unsigned xchecks: 1;
|
||||
struct q_globals *gv;
|
||||
struct ddsi_tkmap *tkmap;
|
||||
uint32_t hdepth; /* 0 = unlimited */
|
||||
uint32_t tldepth; /* 0 = disabled/unlimited (no need to maintain an index if KEEP_ALL <=> is_transient_local + tldepth=0) */
|
||||
uint32_t idxdepth; /* = max (hdepth, tldepth) */
|
||||
seqno_t max_drop_seq; /* samples in whc with seq <= max_drop_seq => transient-local */
|
||||
struct whc_intvnode *open_intv; /* interval where next sample will go (usually) */
|
||||
struct whc_node *maxseq_node; /* NULL if empty; if not in open_intv, open_intv is empty */
|
||||
|
|
@ -103,14 +103,12 @@ struct whc_sample_iter_impl {
|
|||
};
|
||||
|
||||
/* check that our definition of whc_sample_iter fits in the type that callers allocate */
|
||||
struct whc_sample_iter_sizecheck {
|
||||
char fits_in_generic_type[sizeof(struct whc_sample_iter_impl) <= sizeof(struct whc_sample_iter) ? 1 : -1];
|
||||
};
|
||||
DDSRT_STATIC_ASSERT (sizeof (struct whc_sample_iter_impl) <= sizeof (struct whc_sample_iter));
|
||||
|
||||
/* 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
|
||||
* - length is max(durability_service.history_depth, history.depth), KEEP_ALL => as-if 0
|
||||
* - length is max (durability_service.history_depth, history.depth), KEEP_ALL => as-if 0
|
||||
* - no instance index if above length 0
|
||||
* - each sample (i.e., whc_node): backpointer into index
|
||||
* - maintain index of latest sample, end of history then trivially follows from index arithmetic
|
||||
|
|
@ -124,18 +122,18 @@ static void insert_whcn_in_hash (struct whc_impl *whc, struct whc_node *whcn);
|
|||
static void whc_delete_one (struct whc_impl *whc, struct whc_node *whcn);
|
||||
static int compare_seq (const void *va, const void *vb);
|
||||
static void free_deferred_free_list (struct whc_node *deferred_free_list);
|
||||
static void get_state_locked(const struct whc_impl *whc, struct whc_state *st);
|
||||
static void get_state_locked (const struct whc_impl *whc, struct whc_state *st);
|
||||
|
||||
static unsigned whc_default_remove_acked_messages_full (struct whc_impl *whc, seqno_t max_drop_seq, struct whc_node **deferred_free_list);
|
||||
static unsigned whc_default_remove_acked_messages (struct whc *whc, seqno_t max_drop_seq, struct whc_state *whcst, struct whc_node **deferred_free_list);
|
||||
static uint32_t whc_default_remove_acked_messages_full (struct whc_impl *whc, seqno_t max_drop_seq, struct whc_node **deferred_free_list);
|
||||
static uint32_t whc_default_remove_acked_messages (struct whc *whc, seqno_t max_drop_seq, struct whc_state *whcst, struct whc_node **deferred_free_list);
|
||||
static void whc_default_free_deferred_free_list (struct whc *whc, struct whc_node *deferred_free_list);
|
||||
static void whc_default_get_state(const struct whc *whc, struct whc_state *st);
|
||||
static void whc_default_get_state (const struct whc *whc, struct whc_state *st);
|
||||
static int whc_default_insert (struct whc *whc, seqno_t max_drop_seq, seqno_t seq, struct nn_plist *plist, struct ddsi_serdata *serdata, struct ddsi_tkmap_instance *tk);
|
||||
static seqno_t whc_default_next_seq (const struct whc *whc, seqno_t seq);
|
||||
static bool whc_default_borrow_sample (const struct whc *whc, seqno_t seq, struct whc_borrowed_sample *sample);
|
||||
static bool whc_default_borrow_sample_key (const struct whc *whc, const struct ddsi_serdata *serdata_key, struct whc_borrowed_sample *sample);
|
||||
static void whc_default_return_sample (struct whc *whc, struct whc_borrowed_sample *sample, bool update_retransmit_info);
|
||||
static unsigned whc_default_downgrade_to_volatile (struct whc *whc, struct whc_state *st);
|
||||
static uint32_t whc_default_downgrade_to_volatile (struct whc *whc, struct whc_state *st);
|
||||
static void whc_default_sample_iter_init (const struct whc *whc, struct whc_sample_iter *opaque_it);
|
||||
static bool whc_default_sample_iter_borrow_next (struct whc_sample_iter *opaque_it, struct whc_borrowed_sample *sample);
|
||||
static void whc_default_free (struct whc *whc);
|
||||
|
|
@ -158,13 +156,15 @@ static const struct whc_ops whc_ops = {
|
|||
.free = whc_default_free
|
||||
};
|
||||
|
||||
/* Number of instantiated WHCs and a global freelist for WHC nodes that gets
|
||||
initialized lazily and cleaned up automatically when the last WHC is freed.
|
||||
Protected by dds_global.m_mutex.
|
||||
#define TRACE(...) DDS_CLOG (DDS_LC_WHC, &whc->gv->logconfig, __VA_ARGS__)
|
||||
|
||||
sizeof (whc_node) on 64-bit machines ~ 100 bytes, so this is ~1MB
|
||||
8k entries seems to be roughly the amount needed for minimum samples,
|
||||
maximum message size and a short round-trip time */
|
||||
/* Number of instantiated WHCs and a global freelist for WHC nodes that gets
|
||||
initialized lazily and cleaned up automatically when the last WHC is freed.
|
||||
Protected by dds_global.m_mutex.
|
||||
|
||||
sizeof (whc_node) on 64-bit machines ~ 100 bytes, so this is ~1MB
|
||||
8k entries seems to be roughly the amount needed for minimum samples,
|
||||
maximum message size and a short round-trip time */
|
||||
#define MAX_FREELIST_SIZE 8192
|
||||
static uint32_t whc_count;
|
||||
static struct nn_freelist whc_node_freelist;
|
||||
|
|
@ -175,9 +175,9 @@ static uint32_t whc_seq_entry_hash (const void *vn)
|
|||
const struct whc_seq_entry *n = vn;
|
||||
/* we hash the lower 32 bits, on the assumption that with 4 billion
|
||||
samples in between there won't be significant correlation */
|
||||
const uint64_t c = UINT64_C(16292676669999574021);
|
||||
const uint64_t c = UINT64_C (16292676669999574021);
|
||||
const uint32_t x = (uint32_t) n->seq;
|
||||
return (unsigned) ((x * c) >> 32);
|
||||
return (uint32_t) ((x * c) >> 32);
|
||||
}
|
||||
|
||||
static int whc_seq_entry_eq (const void *va, const void *vb)
|
||||
|
|
@ -192,9 +192,9 @@ static uint32_t whc_node_hash (const void *vn)
|
|||
const struct whc_node *n = vn;
|
||||
/* we hash the lower 32 bits, on the assumption that with 4 billion
|
||||
samples in between there won't be significant correlation */
|
||||
const uint64_t c = UINT64_C(16292676669999574021);
|
||||
const uint64_t c = UINT64_C (16292676669999574021);
|
||||
const uint32_t x = (uint32_t) n->seq;
|
||||
return (unsigned) ((x * c) >> 32);
|
||||
return (uint32_t) ((x * c) >> 32);
|
||||
}
|
||||
|
||||
static int whc_node_eq (const void *va, const void *vb)
|
||||
|
|
@ -245,10 +245,10 @@ static struct whc_node *whc_findmax_procedurally (const struct whc_impl *whc)
|
|||
static void check_whc (const struct whc_impl *whc)
|
||||
{
|
||||
/* there's much more we can check, but it gets expensive quite
|
||||
quickly: all nodes but open_intv non-empty, non-overlapping and
|
||||
non-contiguous; min & maxp1 of intervals correct; each interval
|
||||
contiguous; all samples in seq & in seqhash; tlidx \subseteq seq;
|
||||
seq-number ordered list correct; &c. */
|
||||
quickly: all nodes but open_intv non-empty, non-overlapping and
|
||||
non-contiguous; min & maxp1 of intervals correct; each interval
|
||||
contiguous; all samples in seq & in seqhash; tlidx \subseteq seq;
|
||||
seq-number ordered list correct; &c. */
|
||||
assert (whc->open_intv != NULL);
|
||||
assert (whc->open_intv == ddsrt_avl_find_max (&whc_seq_treedef, &whc->seq));
|
||||
assert (ddsrt_avl_find_succ (&whc_seq_treedef, &whc->seq, whc->open_intv) == NULL);
|
||||
|
|
@ -269,8 +269,8 @@ static void check_whc (const struct whc_impl *whc)
|
|||
}
|
||||
assert (whc->maxseq_node == whc_findmax_procedurally (whc));
|
||||
|
||||
#if !defined(NDEBUG)
|
||||
if (config.enabled_xchecks & DDS_XCHECK_WHC)
|
||||
#if !defined (NDEBUG)
|
||||
if (whc->xchecks)
|
||||
{
|
||||
struct whc_intvnode *firstintv;
|
||||
struct whc_node *cur;
|
||||
|
|
@ -295,10 +295,10 @@ static void insert_whcn_in_hash (struct whc_impl *whc, struct whc_node *whcn)
|
|||
#if USE_EHH
|
||||
struct whc_seq_entry e = { .seq = whcn->seq, .whcn = whcn };
|
||||
if (!ddsrt_ehh_add (whc->seq_hash, &e))
|
||||
assert(0);
|
||||
assert (0);
|
||||
#else
|
||||
if (!ddsrt_hh_add (whc->seq_hash, whcn))
|
||||
assert(0);
|
||||
assert (0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -307,11 +307,11 @@ static void remove_whcn_from_hash (struct whc_impl *whc, struct whc_node *whcn)
|
|||
/* precondition: whcn is in hash */
|
||||
#if USE_EHH
|
||||
struct whc_seq_entry e = { .seq = whcn->seq };
|
||||
if (!ddsrt_ehh_remove(whc->seq_hash, &e))
|
||||
assert(0);
|
||||
if (!ddsrt_ehh_remove (whc->seq_hash, &e))
|
||||
assert (0);
|
||||
#else
|
||||
if (!ddsrt_hh_remove(whc->seq_hash, whcn))
|
||||
assert(0);
|
||||
if (!ddsrt_hh_remove (whc->seq_hash, whcn))
|
||||
assert (0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -319,14 +319,14 @@ static struct whc_node *whc_findseq (const struct whc_impl *whc, seqno_t seq)
|
|||
{
|
||||
#if USE_EHH
|
||||
struct whc_seq_entry e = { .seq = seq }, *r;
|
||||
if ((r = ddsrt_ehh_lookup(whc->seq_hash, &e)) != NULL)
|
||||
if ((r = ddsrt_ehh_lookup (whc->seq_hash, &e)) != NULL)
|
||||
return r->whcn;
|
||||
else
|
||||
return NULL;
|
||||
#else
|
||||
struct whc_node template;
|
||||
template.seq = seq;
|
||||
return ddsrt_hh_lookup(whc->seq_hash, &template);
|
||||
return ddsrt_hh_lookup (whc->seq_hash, &template);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -334,11 +334,11 @@ static struct whc_node *whc_findkey (const struct whc_impl *whc, const struct dd
|
|||
{
|
||||
union {
|
||||
struct whc_idxnode idxn;
|
||||
char pad[sizeof(struct whc_idxnode) + sizeof(struct whc_node *)];
|
||||
char pad[sizeof (struct whc_idxnode) + sizeof (struct whc_node *)];
|
||||
} template;
|
||||
struct whc_idxnode *n;
|
||||
check_whc (whc);
|
||||
template.idxn.iid = ddsi_tkmap_lookup(gv.m_tkmap, serdata_key);
|
||||
template.idxn.iid = ddsi_tkmap_lookup (whc->tkmap, serdata_key);
|
||||
n = ddsrt_hh_lookup (whc->idx_hash, &template.idxn);
|
||||
if (n == NULL)
|
||||
return NULL;
|
||||
|
|
@ -349,18 +349,21 @@ static struct whc_node *whc_findkey (const struct whc_impl *whc, const struct dd
|
|||
}
|
||||
}
|
||||
|
||||
struct whc *whc_new (int is_transient_local, unsigned hdepth, unsigned tldepth)
|
||||
struct whc *whc_new (struct q_globals *gv, int is_transient_local, uint32_t hdepth, uint32_t tldepth)
|
||||
{
|
||||
size_t sample_overhead = 80; /* INFO_TS, DATA (estimate), inline QoS */
|
||||
struct whc_impl *whc;
|
||||
struct whc_intvnode *intv;
|
||||
|
||||
assert((hdepth == 0 || tldepth <= hdepth) || is_transient_local);
|
||||
assert ((hdepth == 0 || tldepth <= hdepth) || is_transient_local);
|
||||
|
||||
whc = ddsrt_malloc (sizeof (*whc));
|
||||
whc->common.ops = &whc_ops;
|
||||
ddsrt_mutex_init (&whc->lock);
|
||||
whc->is_transient_local = is_transient_local ? 1 : 0;
|
||||
whc->xchecks = (gv->config.enabled_xchecks & DDS_XCHECK_WHC) != 0;
|
||||
whc->gv = gv;
|
||||
whc->tkmap = gv->m_tkmap;
|
||||
whc->hdepth = hdepth;
|
||||
whc->tldepth = tldepth;
|
||||
whc->idxdepth = hdepth > tldepth ? hdepth : tldepth;
|
||||
|
|
@ -369,14 +372,15 @@ struct whc *whc_new (int is_transient_local, unsigned hdepth, unsigned tldepth)
|
|||
whc->unacked_bytes = 0;
|
||||
whc->total_bytes = 0;
|
||||
whc->sample_overhead = sample_overhead;
|
||||
whc->fragment_size = gv->config.fragment_size;
|
||||
#if USE_EHH
|
||||
whc->seq_hash = ddsrt_ehh_new (sizeof (struct whc_seq_entry), 32, whc_seq_entry_hash, whc_seq_entry_eq);
|
||||
#else
|
||||
whc->seq_hash = ddsrt_hh_new(32, whc_node_hash, whc_node_eq);
|
||||
whc->seq_hash = ddsrt_hh_new (1, whc_node_hash, whc_node_eq);
|
||||
#endif
|
||||
|
||||
if (whc->idxdepth > 0)
|
||||
whc->idx_hash = ddsrt_hh_new(32, whc_idxnode_hash_key, whc_idxnode_eq_key);
|
||||
whc->idx_hash = ddsrt_hh_new (1, whc_idxnode_hash_key, whc_idxnode_eq_key);
|
||||
else
|
||||
whc->idx_hash = NULL;
|
||||
|
||||
|
|
@ -417,9 +421,9 @@ void whc_default_free (struct whc *whc_generic)
|
|||
{
|
||||
struct ddsrt_hh_iter it;
|
||||
struct whc_idxnode *n;
|
||||
for (n = ddsrt_hh_iter_first(whc->idx_hash, &it); n != NULL; n = ddsrt_hh_iter_next(&it))
|
||||
ddsrt_free(n);
|
||||
ddsrt_hh_free(whc->idx_hash);
|
||||
for (n = ddsrt_hh_iter_first (whc->idx_hash, &it); n != NULL; n = ddsrt_hh_iter_next (&it))
|
||||
ddsrt_free (n);
|
||||
ddsrt_hh_free (whc->idx_hash);
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -427,10 +431,10 @@ void whc_default_free (struct whc *whc_generic)
|
|||
while (whcn)
|
||||
{
|
||||
struct whc_node *tmp = whcn;
|
||||
/* The compiler doesn't realize that whcn->prev_seq is always initialized. */
|
||||
DDSRT_WARNING_MSVC_OFF(6001);
|
||||
/* The compiler doesn't realize that whcn->prev_seq is always initialized. */
|
||||
DDSRT_WARNING_MSVC_OFF (6001);
|
||||
whcn = whcn->prev_seq;
|
||||
DDSRT_WARNING_MSVC_ON(6001);
|
||||
DDSRT_WARNING_MSVC_ON (6001);
|
||||
free_whc_node_contents (tmp);
|
||||
ddsrt_free (tmp);
|
||||
}
|
||||
|
|
@ -452,7 +456,7 @@ DDSRT_WARNING_MSVC_ON(6001);
|
|||
ddsrt_free (whc);
|
||||
}
|
||||
|
||||
static void get_state_locked(const struct whc_impl *whc, struct whc_state *st)
|
||||
static void get_state_locked (const struct whc_impl *whc, struct whc_state *st)
|
||||
{
|
||||
if (whc->seq_size == 0)
|
||||
{
|
||||
|
|
@ -473,12 +477,12 @@ static void get_state_locked(const struct whc_impl *whc, struct whc_state *st)
|
|||
}
|
||||
}
|
||||
|
||||
static void whc_default_get_state(const struct whc *whc_generic, struct whc_state *st)
|
||||
static void whc_default_get_state (const struct whc *whc_generic, struct whc_state *st)
|
||||
{
|
||||
const struct whc_impl * const whc = (const struct whc_impl *)whc_generic;
|
||||
ddsrt_mutex_lock ((ddsrt_mutex_t *)&whc->lock);
|
||||
check_whc (whc);
|
||||
get_state_locked(whc, st);
|
||||
get_state_locked (whc, st);
|
||||
ddsrt_mutex_unlock ((ddsrt_mutex_t *)&whc->lock);
|
||||
}
|
||||
|
||||
|
|
@ -489,8 +493,8 @@ static struct whc_node *find_nextseq_intv (struct whc_intvnode **p_intv, const s
|
|||
if ((n = whc_findseq (whc, seq)) == NULL)
|
||||
{
|
||||
/* don't know seq => lookup interval with min > seq (intervals are
|
||||
contiguous, so if we don't know seq, an interval [X,Y) with X <
|
||||
SEQ < Y can't exist */
|
||||
contiguous, so if we don't know seq, an interval [X,Y) with X <
|
||||
SEQ < Y can't exist */
|
||||
#ifndef NDEBUG
|
||||
{
|
||||
struct whc_intvnode *predintv = ddsrt_avl_lookup_pred_eq (&whc_seq_treedef, &whc->seq, &seq);
|
||||
|
|
@ -551,13 +555,12 @@ static void delete_one_sample_from_idx (struct whc_impl *whc, struct whc_node *w
|
|||
else
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
unsigned i;
|
||||
for (i = 0; i < whc->idxdepth; i++)
|
||||
for (uint32_t i = 0; i < whc->idxdepth; i++)
|
||||
assert (i == idxn->headidx || idxn->hist[i] == NULL);
|
||||
#endif
|
||||
if (!ddsrt_hh_remove (whc->idx_hash, idxn))
|
||||
assert (0);
|
||||
ddsi_tkmap_instance_unref(idxn->tk);
|
||||
ddsi_tkmap_instance_unref (whc->tkmap, idxn->tk);
|
||||
ddsrt_free (idxn);
|
||||
}
|
||||
whcn->idxnode = NULL;
|
||||
|
|
@ -565,8 +568,7 @@ static void delete_one_sample_from_idx (struct whc_impl *whc, struct whc_node *w
|
|||
|
||||
static void free_one_instance_from_idx (struct whc_impl *whc, seqno_t max_drop_seq, struct whc_idxnode *idxn)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < whc->idxdepth; i++)
|
||||
for (uint32_t i = 0; i < whc->idxdepth; i++)
|
||||
{
|
||||
if (idxn->hist[i])
|
||||
{
|
||||
|
|
@ -574,13 +576,13 @@ 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)
|
||||
{
|
||||
DDS_LOG(DDS_LC_WHC, " prune tl whcn %p\n", (void *)oldn);
|
||||
assert(oldn != whc->maxseq_node);
|
||||
TRACE (" prune tl whcn %p\n", (void *)oldn);
|
||||
assert (oldn != whc->maxseq_node);
|
||||
whc_delete_one (whc, oldn);
|
||||
}
|
||||
}
|
||||
}
|
||||
ddsrt_free(idxn);
|
||||
ddsrt_free (idxn);
|
||||
}
|
||||
|
||||
static void delete_one_instance_from_idx (struct whc_impl *whc, seqno_t max_drop_seq, struct whc_idxnode *idxn)
|
||||
|
|
@ -590,34 +592,34 @@ static void delete_one_instance_from_idx (struct whc_impl *whc, seqno_t max_drop
|
|||
free_one_instance_from_idx (whc, max_drop_seq, idxn);
|
||||
}
|
||||
|
||||
static int whcn_in_tlidx (const struct whc_impl *whc, const struct whc_idxnode *idxn, unsigned pos)
|
||||
static int whcn_in_tlidx (const struct whc_impl *whc, const struct whc_idxnode *idxn, uint32_t pos)
|
||||
{
|
||||
if (idxn == NULL)
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
unsigned d = (idxn->headidx + (pos > idxn->headidx ? whc->idxdepth : 0)) - pos;
|
||||
uint32_t d = (idxn->headidx + (pos > idxn->headidx ? whc->idxdepth : 0)) - pos;
|
||||
assert (d < whc->idxdepth);
|
||||
return d < whc->tldepth;
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned whc_default_downgrade_to_volatile (struct whc *whc_generic, struct whc_state *st)
|
||||
static uint32_t whc_default_downgrade_to_volatile (struct whc *whc_generic, struct whc_state *st)
|
||||
{
|
||||
struct whc_impl * const whc = (struct whc_impl *)whc_generic;
|
||||
seqno_t old_max_drop_seq;
|
||||
struct whc_node *deferred_free_list;
|
||||
unsigned cnt;
|
||||
uint32_t cnt;
|
||||
|
||||
/* We only remove them from whc->tlidx: we don't remove them from
|
||||
whc->seq yet. That'll happen eventually. */
|
||||
whc->seq yet. That'll happen eventually. */
|
||||
ddsrt_mutex_lock (&whc->lock);
|
||||
check_whc (whc);
|
||||
|
||||
if (whc->idxdepth == 0)
|
||||
{
|
||||
/* if not maintaining an index at all, this is nonsense */
|
||||
get_state_locked(whc, st);
|
||||
get_state_locked (whc, st);
|
||||
ddsrt_mutex_unlock (&whc->lock);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -625,29 +627,29 @@ static unsigned whc_default_downgrade_to_volatile (struct whc *whc_generic, stru
|
|||
assert (!whc->is_transient_local);
|
||||
if (whc->tldepth > 0)
|
||||
{
|
||||
assert(whc->hdepth == 0 || whc->tldepth <= whc->hdepth);
|
||||
assert (whc->hdepth == 0 || whc->tldepth <= whc->hdepth);
|
||||
whc->tldepth = 0;
|
||||
if (whc->hdepth == 0)
|
||||
{
|
||||
struct ddsrt_hh_iter it;
|
||||
struct whc_idxnode *n;
|
||||
for (n = ddsrt_hh_iter_first(whc->idx_hash, &it); n != NULL; n = ddsrt_hh_iter_next(&it))
|
||||
for (n = ddsrt_hh_iter_first (whc->idx_hash, &it); n != NULL; n = ddsrt_hh_iter_next (&it))
|
||||
free_one_instance_from_idx (whc, 0, n);
|
||||
ddsrt_hh_free(whc->idx_hash);
|
||||
ddsrt_hh_free (whc->idx_hash);
|
||||
whc->idxdepth = 0;
|
||||
whc->idx_hash = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Immediately drop them from the WHC (used to delay it until the
|
||||
next ack); but need to make sure remove_acked_messages processes
|
||||
them all. */
|
||||
next ack); but need to make sure remove_acked_messages processes
|
||||
them all. */
|
||||
old_max_drop_seq = whc->max_drop_seq;
|
||||
whc->max_drop_seq = 0;
|
||||
cnt = whc_default_remove_acked_messages_full (whc, old_max_drop_seq, &deferred_free_list);
|
||||
whc_default_free_deferred_free_list (whc_generic, deferred_free_list);
|
||||
assert (whc->max_drop_seq == old_max_drop_seq);
|
||||
get_state_locked(whc, st);
|
||||
get_state_locked (whc, st);
|
||||
ddsrt_mutex_unlock (&whc->lock);
|
||||
return cnt;
|
||||
}
|
||||
|
|
@ -655,20 +657,20 @@ static unsigned whc_default_downgrade_to_volatile (struct whc *whc_generic, stru
|
|||
static size_t whcn_size (const struct whc_impl *whc, const struct whc_node *whcn)
|
||||
{
|
||||
size_t sz = ddsi_serdata_size (whcn->serdata);
|
||||
return sz + ((sz + config.fragment_size - 1) / config.fragment_size) * whc->sample_overhead;
|
||||
return sz + ((sz + whc->fragment_size - 1) / whc->fragment_size) * whc->sample_overhead;
|
||||
}
|
||||
|
||||
static void whc_delete_one_intv (struct whc_impl *whc, struct whc_intvnode **p_intv, struct whc_node **p_whcn)
|
||||
{
|
||||
/* Removes *p_whcn, possibly deleting or splitting *p_intv, as the
|
||||
case may be. Does *NOT* update whc->seq_size. *p_intv must be
|
||||
the interval containing *p_whcn (&& both must actually exist).
|
||||
case may be. Does *NOT* update whc->seq_size. *p_intv must be
|
||||
the interval containing *p_whcn (&& both must actually exist).
|
||||
|
||||
Returns:
|
||||
- 0 if delete failed (only possible cause is memory exhaustion),
|
||||
in which case *p_intv & *p_whcn are undefined;
|
||||
- 1 if successful, in which case *p_intv & *p_whcn are set
|
||||
correctly for the next sample in sequence number order */
|
||||
Returns:
|
||||
- 0 if delete failed (only possible cause is memory exhaustion),
|
||||
in which case *p_intv & *p_whcn are undefined;
|
||||
- 1 if successful, in which case *p_intv & *p_whcn are set
|
||||
correctly for the next sample in sequence number order */
|
||||
struct whc_intvnode *intv = *p_intv;
|
||||
struct whc_node *whcn = *p_whcn;
|
||||
assert (whcn->seq >= intv->min && whcn->seq < intv->maxp1);
|
||||
|
|
@ -685,13 +687,13 @@ static void whc_delete_one_intv (struct whc_impl *whc, struct whc_intvnode **p_i
|
|||
}
|
||||
|
||||
/* Take it out of seqhash; deleting it from the list ordered on
|
||||
sequence numbers is left to the caller (it has to be done unconditionally,
|
||||
but remove_acked_messages defers it until the end or a skipped node). */
|
||||
sequence numbers is left to the caller (it has to be done unconditionally,
|
||||
but remove_acked_messages defers it until the end or a skipped node). */
|
||||
remove_whcn_from_hash (whc, whcn);
|
||||
|
||||
/* We may have introduced a hole & have to split the interval
|
||||
node, or we may have nibbled of the first one, or even the
|
||||
last one. */
|
||||
node, or we may have nibbled of the first one, or even the
|
||||
last one. */
|
||||
if (whcn == intv->first)
|
||||
{
|
||||
if (whcn == intv->last && intv != whc->open_intv)
|
||||
|
|
@ -714,7 +716,7 @@ static void whc_delete_one_intv (struct whc_impl *whc, struct whc_intvnode **p_i
|
|||
else if (whcn == intv->last)
|
||||
{
|
||||
/* well, at least it isn't the first one & so the interval is
|
||||
still non-empty and we don't have to drop the interval */
|
||||
still non-empty and we don't have to drop the interval */
|
||||
assert (intv->min < whcn->seq);
|
||||
assert (whcn->prev_seq);
|
||||
assert (whcn->prev_seq->seq + 1 == whcn->seq);
|
||||
|
|
@ -725,9 +727,9 @@ static void whc_delete_one_intv (struct whc_impl *whc, struct whc_intvnode **p_i
|
|||
else
|
||||
{
|
||||
/* somewhere in the middle => split the interval (ideally,
|
||||
would split it lazily, but it really is a transient-local
|
||||
issue only, and so we can (for now) get away with splitting
|
||||
it greedily */
|
||||
would split it lazily, but it really is a transient-local
|
||||
issue only, and so we can (for now) get away with splitting
|
||||
it greedily */
|
||||
struct whc_intvnode *new_intv;
|
||||
ddsrt_avl_ipath_t path;
|
||||
|
||||
|
|
@ -746,7 +748,7 @@ static void whc_delete_one_intv (struct whc_impl *whc, struct whc_intvnode **p_i
|
|||
assert (new_intv->min < new_intv->maxp1);
|
||||
|
||||
/* insert new node & continue the loop with intv set to the
|
||||
new interval */
|
||||
new interval */
|
||||
if (ddsrt_avl_lookup_ipath (&whc_seq_treedef, &whc->seq, &new_intv->min, &path) != NULL)
|
||||
assert (0);
|
||||
ddsrt_avl_insert_ipath (&whc_seq_treedef, &whc->seq, new_intv, &path);
|
||||
|
|
@ -801,11 +803,11 @@ static void whc_default_free_deferred_free_list (struct whc *whc_generic, struct
|
|||
free_deferred_free_list (deferred_free_list);
|
||||
}
|
||||
|
||||
static unsigned whc_default_remove_acked_messages_noidx (struct whc_impl *whc, seqno_t max_drop_seq, struct whc_node **deferred_free_list)
|
||||
static uint32_t whc_default_remove_acked_messages_noidx (struct whc_impl *whc, seqno_t max_drop_seq, struct whc_node **deferred_free_list)
|
||||
{
|
||||
struct whc_intvnode *intv;
|
||||
struct whc_node *whcn;
|
||||
unsigned ndropped = 0;
|
||||
uint32_t ndropped = 0;
|
||||
|
||||
/* In the trivial case of an empty WHC, get out quickly */
|
||||
if (max_drop_seq <= whc->max_drop_seq || whc->maxseq_node == NULL)
|
||||
|
|
@ -817,7 +819,7 @@ static unsigned whc_default_remove_acked_messages_noidx (struct whc_impl *whc, s
|
|||
}
|
||||
|
||||
/* If simple, we have always dropped everything up to whc->max_drop_seq,
|
||||
and there can only be a single interval */
|
||||
and there can only be a single interval */
|
||||
#ifndef NDEBUG
|
||||
whcn = find_nextseq_intv (&intv, whc, whc->max_drop_seq);
|
||||
assert (whcn == NULL || whcn->prev_seq == NULL);
|
||||
|
|
@ -826,14 +828,14 @@ static unsigned whc_default_remove_acked_messages_noidx (struct whc_impl *whc, s
|
|||
intv = whc->open_intv;
|
||||
|
||||
/* Drop everything up to and including max_drop_seq, or absent that one,
|
||||
the highest available sequence number (which then must be less) */
|
||||
the highest available sequence number (which then must be less) */
|
||||
if ((whcn = whc_findseq (whc, max_drop_seq)) == NULL)
|
||||
{
|
||||
if (max_drop_seq < intv->min)
|
||||
{
|
||||
/* at startup, whc->max_drop_seq = 0 and reader states have max ack'd seq taken from wr->seq;
|
||||
so if multiple readers are matched and the writer runs ahead of the readers, for the first
|
||||
ack, whc->max_drop_seq < max_drop_seq = MIN(readers max ack) < intv->min */
|
||||
so if multiple readers are matched and the writer runs ahead of the readers, for the first
|
||||
ack, whc->max_drop_seq < max_drop_seq = MIN (readers max ack) < intv->min */
|
||||
if (max_drop_seq > whc->max_drop_seq)
|
||||
whc->max_drop_seq = max_drop_seq;
|
||||
*deferred_free_list = NULL;
|
||||
|
|
@ -847,7 +849,7 @@ static unsigned whc_default_remove_acked_messages_noidx (struct whc_impl *whc, s
|
|||
}
|
||||
|
||||
*deferred_free_list = intv->first;
|
||||
ndropped = (unsigned) (whcn->seq - intv->min + 1);
|
||||
ndropped = (uint32_t) (whcn->seq - intv->min + 1);
|
||||
|
||||
intv->first = whcn->next_seq;
|
||||
intv->min = max_drop_seq + 1;
|
||||
|
|
@ -877,18 +879,18 @@ static unsigned whc_default_remove_acked_messages_noidx (struct whc_impl *whc, s
|
|||
return ndropped;
|
||||
}
|
||||
|
||||
static unsigned whc_default_remove_acked_messages_full (struct whc_impl *whc, seqno_t max_drop_seq, struct whc_node **deferred_free_list)
|
||||
static uint32_t whc_default_remove_acked_messages_full (struct whc_impl *whc, seqno_t max_drop_seq, struct whc_node **deferred_free_list)
|
||||
{
|
||||
struct whc_intvnode *intv;
|
||||
struct whc_node *whcn;
|
||||
struct whc_node *prev_seq;
|
||||
struct whc_node deferred_list_head, *last_to_free = &deferred_list_head;
|
||||
unsigned ndropped = 0;
|
||||
uint32_t ndropped = 0;
|
||||
|
||||
if (whc->is_transient_local && whc->tldepth == 0)
|
||||
{
|
||||
/* KEEP_ALL on transient local, so we can never ever delete anything */
|
||||
DDS_LOG(DDS_LC_WHC, " KEEP_ALL transient-local: do nothing\n");
|
||||
TRACE (" KEEP_ALL transient-local: do nothing\n");
|
||||
*deferred_free_list = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -898,11 +900,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)
|
||||
{
|
||||
DDS_LOG(DDS_LC_WHC, " whcn %p %"PRId64, (void *) whcn, whcn->seq);
|
||||
if (whcn_in_tlidx(whc, whcn->idxnode, whcn->idxnode_pos))
|
||||
TRACE (" whcn %p %"PRId64, (void *) whcn, whcn->seq);
|
||||
if (whcn_in_tlidx (whc, whcn->idxnode, whcn->idxnode_pos))
|
||||
{
|
||||
/* quickly skip over samples in tlidx */
|
||||
DDS_LOG(DDS_LC_WHC, " tl:keep");
|
||||
TRACE (" tl:keep");
|
||||
if (whcn->unacked)
|
||||
{
|
||||
assert (whc->unacked_bytes >= whcn->size);
|
||||
|
|
@ -920,13 +922,13 @@ static unsigned whc_default_remove_acked_messages_full (struct whc_impl *whc, se
|
|||
}
|
||||
else
|
||||
{
|
||||
DDS_LOG(DDS_LC_WHC, " delete");
|
||||
TRACE (" delete");
|
||||
last_to_free->next_seq = whcn;
|
||||
last_to_free = last_to_free->next_seq;
|
||||
whc_delete_one_intv (whc, &intv, &whcn);
|
||||
ndropped++;
|
||||
}
|
||||
DDS_LOG(DDS_LC_WHC, "\n");
|
||||
TRACE ("\n");
|
||||
}
|
||||
if (prev_seq)
|
||||
prev_seq->next_seq = whcn;
|
||||
|
|
@ -936,32 +938,32 @@ static unsigned whc_default_remove_acked_messages_full (struct whc_impl *whc, se
|
|||
*deferred_free_list = deferred_list_head.next_seq;
|
||||
|
||||
/* If the history is deeper than durability_service.history (but not KEEP_ALL), then there
|
||||
may be old samples in this instance, samples that were retained because they were within
|
||||
the T-L history but that are not anymore. Writing new samples will eventually push these
|
||||
out, but if the difference is large and the update rate low, it may take a long time.
|
||||
Thus, we had better prune them. */
|
||||
may be old samples in this instance, samples that were retained because they were within
|
||||
the T-L history but that are not anymore. Writing new samples will eventually push these
|
||||
out, but if the difference is large and the update rate low, it may take a long time.
|
||||
Thus, we had better prune them. */
|
||||
if (whc->tldepth > 0 && whc->idxdepth > whc->tldepth)
|
||||
{
|
||||
assert(whc->hdepth == whc->idxdepth);
|
||||
DDS_LOG(DDS_LC_WHC, " idxdepth %u > tldepth %u > 0 -- must prune\n", whc->idxdepth, whc->tldepth);
|
||||
assert (whc->hdepth == whc->idxdepth);
|
||||
TRACE (" idxdepth %"PRIu32" > tldepth %"PRIu32" > 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
|
||||
(the rest has been dropped already) and we prune old samples in the instance */
|
||||
encounter samples that were retained because of the transient-local durability setting
|
||||
(the rest has been dropped already) and we prune old samples in the instance */
|
||||
whcn = find_nextseq_intv (&intv, whc, whc->max_drop_seq);
|
||||
while (whcn && whcn->seq <= max_drop_seq)
|
||||
{
|
||||
struct whc_idxnode * const idxn = whcn->idxnode;
|
||||
unsigned cnt, idx;
|
||||
uint32_t cnt, idx;
|
||||
|
||||
DDS_LOG(DDS_LC_WHC, " whcn %p %"PRId64" idxn %p prune_seq %"PRId64":", (void *)whcn, whcn->seq, (void *)idxn, idxn->prune_seq);
|
||||
TRACE (" 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 (whcn_in_tlidx (whc, idxn, whcn->idxnode_pos));
|
||||
assert (idxn->prune_seq <= max_drop_seq);
|
||||
|
||||
if (idxn->prune_seq == max_drop_seq)
|
||||
{
|
||||
DDS_LOG(DDS_LC_WHC, " already pruned\n");
|
||||
TRACE (" already pruned\n");
|
||||
whcn = whcn->next_seq;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -977,27 +979,27 @@ static unsigned whc_default_remove_acked_messages_full (struct whc_impl *whc, se
|
|||
if ((oldn = idxn->hist[idx]) != NULL)
|
||||
{
|
||||
/* Delete it - but this may not result in deleting the index node as
|
||||
there must still be a more recent one available */
|
||||
there must still be a more recent one available */
|
||||
#ifndef NDEBUG
|
||||
struct whc_node whcn_template;
|
||||
union {
|
||||
struct whc_idxnode idxn;
|
||||
char pad[sizeof(struct whc_idxnode) + sizeof(struct whc_node *)];
|
||||
char pad[sizeof (struct whc_idxnode) + sizeof (struct whc_node *)];
|
||||
} template;
|
||||
template.idxn.headidx = 0;
|
||||
template.idxn.hist[0] = &whcn_template;
|
||||
whcn_template.serdata = ddsi_serdata_ref(oldn->serdata);
|
||||
assert(oldn->seq < whcn->seq);
|
||||
whcn_template.serdata = ddsi_serdata_ref (oldn->serdata);
|
||||
assert (oldn->seq < whcn->seq);
|
||||
#endif
|
||||
DDS_LOG(DDS_LC_WHC, " del %p %"PRId64, (void *) oldn, oldn->seq);
|
||||
TRACE (" del %p %"PRId64, (void *) oldn, oldn->seq);
|
||||
whc_delete_one (whc, oldn);
|
||||
#ifndef NDEBUG
|
||||
assert(ddsrt_hh_lookup(whc->idx_hash, &template) == idxn);
|
||||
ddsi_serdata_unref(whcn_template.serdata);
|
||||
assert (ddsrt_hh_lookup (whc->idx_hash, &template) == idxn);
|
||||
ddsi_serdata_unref (whcn_template.serdata);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
DDS_LOG(DDS_LC_WHC, "\n");
|
||||
TRACE ("\n");
|
||||
whcn = whcn->next_seq;
|
||||
}
|
||||
}
|
||||
|
|
@ -1011,22 +1013,22 @@ static unsigned whc_default_remove_acked_messages_full (struct whc_impl *whc, se
|
|||
return ndropped;
|
||||
}
|
||||
|
||||
static unsigned whc_default_remove_acked_messages (struct whc *whc_generic, seqno_t max_drop_seq, struct whc_state *whcst, struct whc_node **deferred_free_list)
|
||||
static uint32_t whc_default_remove_acked_messages (struct whc *whc_generic, seqno_t max_drop_seq, struct whc_state *whcst, struct whc_node **deferred_free_list)
|
||||
{
|
||||
struct whc_impl * const whc = (struct whc_impl *)whc_generic;
|
||||
unsigned cnt;
|
||||
uint32_t cnt;
|
||||
|
||||
ddsrt_mutex_lock (&whc->lock);
|
||||
assert (max_drop_seq < MAX_SEQ_NUMBER);
|
||||
assert (max_drop_seq >= whc->max_drop_seq);
|
||||
|
||||
if (dds_get_log_mask() & DDS_LC_WHC)
|
||||
if (whc->gv->logconfig.c.mask & DDS_LC_WHC)
|
||||
{
|
||||
struct whc_state tmp;
|
||||
get_state_locked(whc, &tmp);
|
||||
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);
|
||||
get_state_locked (whc, &tmp);
|
||||
TRACE ("whc_default_remove_acked_messages(%p max_drop_seq %"PRId64")\n", (void *)whc, max_drop_seq);
|
||||
TRACE (" whc: [%"PRId64",%"PRId64"] max_drop_seq %"PRId64" h %"PRIu32" tl %"PRIu32"\n",
|
||||
tmp.min_seq, tmp.max_seq, whc->max_drop_seq, whc->hdepth, whc->tldepth);
|
||||
}
|
||||
|
||||
check_whc (whc);
|
||||
|
|
@ -1035,7 +1037,7 @@ static unsigned whc_default_remove_acked_messages (struct whc *whc_generic, seqn
|
|||
cnt = whc_default_remove_acked_messages_noidx (whc, max_drop_seq, deferred_free_list);
|
||||
else
|
||||
cnt = whc_default_remove_acked_messages_full (whc, max_drop_seq, deferred_free_list);
|
||||
get_state_locked(whc, whcst);
|
||||
get_state_locked (whc, whcst);
|
||||
ddsrt_mutex_unlock (&whc->lock);
|
||||
return cnt;
|
||||
}
|
||||
|
|
@ -1108,38 +1110,39 @@ static int whc_default_insert (struct whc *whc_generic, seqno_t max_drop_seq, se
|
|||
struct whc_idxnode *idxn;
|
||||
union {
|
||||
struct whc_idxnode idxn;
|
||||
char pad[sizeof(struct whc_idxnode) + sizeof(struct whc_node *)];
|
||||
char pad[sizeof (struct whc_idxnode) + sizeof (struct whc_node *)];
|
||||
} template;
|
||||
|
||||
ddsrt_mutex_lock (&whc->lock);
|
||||
check_whc (whc);
|
||||
|
||||
if (dds_get_log_mask() & DDS_LC_WHC)
|
||||
if (whc->gv->logconfig.c.mask & DDS_LC_WHC)
|
||||
{
|
||||
struct whc_state whcst;
|
||||
get_state_locked(whc, &whcst);
|
||||
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);
|
||||
get_state_locked (whc, &whcst);
|
||||
TRACE ("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: [%"PRId64",%"PRId64"] max_drop_seq %"PRId64" h %"PRIu32" tl %"PRIu32"\n",
|
||||
whcst.min_seq, whcst.max_seq, whc->max_drop_seq, whc->hdepth, whc->tldepth);
|
||||
}
|
||||
|
||||
assert (max_drop_seq < MAX_SEQ_NUMBER);
|
||||
assert (max_drop_seq >= whc->max_drop_seq);
|
||||
|
||||
/* Seq must be greater than what is currently stored. Usually it'll
|
||||
be the next sequence number, but if there are no readers
|
||||
temporarily, a gap may be among the possibilities */
|
||||
be the next sequence number, but if there are no readers
|
||||
temporarily, a gap may be among the possibilities */
|
||||
assert (whc->seq_size == 0 || seq > whc->maxseq_node->seq);
|
||||
|
||||
/* Always insert in seq admin */
|
||||
newn = whc_default_insert_seq (whc, max_drop_seq, seq, plist, serdata);
|
||||
|
||||
DDS_LOG(DDS_LC_WHC, " whcn %p:", (void*)newn);
|
||||
TRACE (" 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)
|
||||
{
|
||||
DDS_LOG(DDS_LC_WHC, " empty or no hist\n");
|
||||
TRACE (" empty or no hist\n");
|
||||
ddsrt_mutex_unlock (&whc->lock);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1148,15 +1151,15 @@ static int whc_default_insert (struct whc *whc_generic, seqno_t max_drop_seq, se
|
|||
if ((idxn = ddsrt_hh_lookup (whc->idx_hash, &template)) != NULL)
|
||||
{
|
||||
/* Unregisters cause deleting of index entry, non-unregister of adding/overwriting in history */
|
||||
DDS_LOG(DDS_LC_WHC, " idxn %p", (void *)idxn);
|
||||
TRACE (" idxn %p", (void *)idxn);
|
||||
if (serdata->statusinfo & NN_STATUSINFO_UNREGISTER)
|
||||
{
|
||||
DDS_LOG(DDS_LC_WHC, " unreg:delete\n");
|
||||
TRACE (" 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;
|
||||
DDS_LOG(DDS_LC_WHC, " unreg:seq <= max_drop_seq: delete newn\n");
|
||||
TRACE (" unreg:seq <= max_drop_seq: delete newn\n");
|
||||
whc_delete_one (whc, newn);
|
||||
whc->maxseq_node = prev_seq;
|
||||
}
|
||||
|
|
@ -1168,7 +1171,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)
|
||||
{
|
||||
DDS_LOG(DDS_LC_WHC, " overwrite whcn %p", (void *)oldn);
|
||||
TRACE (" overwrite whcn %p", (void *)oldn);
|
||||
oldn->idxnode = NULL;
|
||||
}
|
||||
idxn->hist[idxn->headidx] = newn;
|
||||
|
|
@ -1177,46 +1180,45 @@ 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))
|
||||
{
|
||||
DDS_LOG(DDS_LC_WHC, " prune whcn %p", (void *)oldn);
|
||||
assert(oldn != whc->maxseq_node);
|
||||
TRACE (" prune whcn %p", (void *)oldn);
|
||||
assert (oldn != whc->maxseq_node);
|
||||
whc_delete_one (whc, oldn);
|
||||
}
|
||||
|
||||
/* Special case for dropping everything beyond T-L history when the new sample is being
|
||||
auto-acknowledged (for lack of reliable readers), and the keep-last T-L history is
|
||||
shallower than the keep-last regular history (normal path handles this via pruning in
|
||||
whc_default_remove_acked_messages, but that never happens when there are no readers). */
|
||||
auto-acknowledged (for lack of reliable readers), and the keep-last T-L history is
|
||||
shallower than the keep-last regular history (normal path handles this via pruning in
|
||||
whc_default_remove_acked_messages, but that never happens when there are no readers). */
|
||||
if (seq <= max_drop_seq && whc->tldepth > 0 && whc->idxdepth > whc->tldepth)
|
||||
{
|
||||
unsigned pos = idxn->headidx + whc->idxdepth - whc->tldepth;
|
||||
uint32_t pos = idxn->headidx + whc->idxdepth - whc->tldepth;
|
||||
if (pos >= whc->idxdepth)
|
||||
pos -= whc->idxdepth;
|
||||
if ((oldn = idxn->hist[pos]) != NULL)
|
||||
{
|
||||
DDS_LOG(DDS_LC_WHC, " prune tl whcn %p", (void *)oldn);
|
||||
assert(oldn != whc->maxseq_node);
|
||||
TRACE (" prune tl whcn %p", (void *)oldn);
|
||||
assert (oldn != whc->maxseq_node);
|
||||
whc_delete_one (whc, oldn);
|
||||
}
|
||||
}
|
||||
DDS_LOG(DDS_LC_WHC, "\n");
|
||||
TRACE ("\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DDS_LOG(DDS_LC_WHC, " newkey");
|
||||
TRACE (" newkey");
|
||||
/* Ignore unregisters, but insert everything else */
|
||||
if (!(serdata->statusinfo & NN_STATUSINFO_UNREGISTER))
|
||||
{
|
||||
unsigned i;
|
||||
idxn = ddsrt_malloc (sizeof (*idxn) + whc->idxdepth * sizeof (idxn->hist[0]));
|
||||
DDS_LOG(DDS_LC_WHC, " idxn %p", (void *)idxn);
|
||||
ddsi_tkmap_instance_ref(tk);
|
||||
TRACE (" idxn %p", (void *)idxn);
|
||||
ddsi_tkmap_instance_ref (tk);
|
||||
idxn->iid = tk->m_iid;
|
||||
idxn->tk = tk;
|
||||
idxn->prune_seq = 0;
|
||||
idxn->headidx = 0;
|
||||
idxn->hist[0] = newn;
|
||||
for (i = 1; i < whc->idxdepth; i++)
|
||||
for (uint32_t i = 1; i < whc->idxdepth; i++)
|
||||
idxn->hist[i] = NULL;
|
||||
newn->idxnode = idxn;
|
||||
newn->idxnode_pos = 0;
|
||||
|
|
@ -1225,24 +1227,24 @@ static int whc_default_insert (struct whc *whc_generic, seqno_t max_drop_seq, se
|
|||
}
|
||||
else
|
||||
{
|
||||
DDS_LOG(DDS_LC_WHC, " unreg:skip");
|
||||
TRACE (" unreg:skip");
|
||||
if (newn->seq <= max_drop_seq)
|
||||
{
|
||||
struct whc_node *prev_seq = newn->prev_seq;
|
||||
DDS_LOG(DDS_LC_WHC, " unreg:seq <= max_drop_seq: delete newn\n");
|
||||
TRACE (" unreg:seq <= max_drop_seq: delete newn\n");
|
||||
whc_delete_one (whc, newn);
|
||||
whc->maxseq_node = prev_seq;
|
||||
}
|
||||
}
|
||||
DDS_LOG(DDS_LC_WHC, "\n");
|
||||
TRACE ("\n");
|
||||
}
|
||||
ddsrt_mutex_unlock (&whc->lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void make_borrowed_sample(struct whc_borrowed_sample *sample, struct whc_node *whcn)
|
||||
static void make_borrowed_sample (struct whc_borrowed_sample *sample, struct whc_node *whcn)
|
||||
{
|
||||
assert(!whcn->borrowed);
|
||||
assert (!whcn->borrowed);
|
||||
whcn->borrowed = 1;
|
||||
sample->seq = whcn->seq;
|
||||
sample->plist = whcn->plist;
|
||||
|
|
@ -1258,11 +1260,11 @@ static bool whc_default_borrow_sample (const struct whc *whc_generic, seqno_t se
|
|||
struct whc_node *whcn;
|
||||
bool found;
|
||||
ddsrt_mutex_lock ((ddsrt_mutex_t *)&whc->lock);
|
||||
if ((whcn = whc_findseq(whc, seq)) == NULL)
|
||||
if ((whcn = whc_findseq (whc, seq)) == NULL)
|
||||
found = false;
|
||||
else
|
||||
{
|
||||
make_borrowed_sample(sample, whcn);
|
||||
make_borrowed_sample (sample, whcn);
|
||||
found = true;
|
||||
}
|
||||
ddsrt_mutex_unlock ((ddsrt_mutex_t *)&whc->lock);
|
||||
|
|
@ -1275,11 +1277,11 @@ static bool whc_default_borrow_sample_key (const struct whc *whc_generic, const
|
|||
struct whc_node *whcn;
|
||||
bool found;
|
||||
ddsrt_mutex_lock ((ddsrt_mutex_t *)&whc->lock);
|
||||
if ((whcn = whc_findkey(whc, serdata_key)) == NULL)
|
||||
if ((whcn = whc_findkey (whc, serdata_key)) == NULL)
|
||||
found = false;
|
||||
else
|
||||
{
|
||||
make_borrowed_sample(sample, whcn);
|
||||
make_borrowed_sample (sample, whcn);
|
||||
found = true;
|
||||
}
|
||||
ddsrt_mutex_unlock ((ddsrt_mutex_t *)&whc->lock);
|
||||
|
|
@ -1293,14 +1295,15 @@ static void return_sample_locked (struct whc_impl *whc, struct whc_borrowed_samp
|
|||
{
|
||||
/* data no longer present in WHC - that means ownership for serdata, plist shifted to the borrowed copy and "returning" it really becomes "destroying" it */
|
||||
ddsi_serdata_unref (sample->serdata);
|
||||
if (sample->plist) {
|
||||
if (sample->plist)
|
||||
{
|
||||
nn_plist_fini (sample->plist);
|
||||
ddsrt_free (sample->plist);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(whcn->borrowed);
|
||||
assert (whcn->borrowed);
|
||||
whcn->borrowed = 0;
|
||||
if (update_retransmit_info)
|
||||
{
|
||||
|
|
@ -1338,7 +1341,7 @@ static bool whc_default_sample_iter_borrow_next (struct whc_sample_iter *opaque_
|
|||
if (!it->first)
|
||||
{
|
||||
seq = sample->seq;
|
||||
return_sample_locked(whc, sample, false);
|
||||
return_sample_locked (whc, sample, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1349,7 +1352,7 @@ static bool whc_default_sample_iter_borrow_next (struct whc_sample_iter *opaque_
|
|||
valid = false;
|
||||
else
|
||||
{
|
||||
make_borrowed_sample(sample, whcn);
|
||||
make_borrowed_sample (sample, whcn);
|
||||
valid = true;
|
||||
}
|
||||
ddsrt_mutex_unlock (&whc->lock);
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/q_ephash.h"
|
||||
#include "dds/ddsi/q_entity.h"
|
||||
#include "dds/ddsi/q_globals.h"
|
||||
#include "dds/ddsi/ddsi_tkmap.h"
|
||||
#include "dds__serdata_builtintopic.h"
|
||||
#include "dds__whc_builtintopic.h"
|
||||
|
|
@ -27,6 +28,7 @@
|
|||
struct bwhc {
|
||||
struct whc common;
|
||||
enum ddsi_sertopic_builtintopic_type type;
|
||||
const struct ephash *guid_hash;
|
||||
};
|
||||
|
||||
enum bwhc_iter_state {
|
||||
|
|
@ -44,9 +46,7 @@ struct bwhc_iter {
|
|||
};
|
||||
|
||||
/* check that our definition of whc_sample_iter fits in the type that callers allocate */
|
||||
struct bwhc_sample_iter_sizecheck {
|
||||
char fits_in_generic_type[sizeof(struct bwhc_iter) <= sizeof(struct whc_sample_iter) ? 1 : -1];
|
||||
};
|
||||
DDSRT_STATIC_ASSERT (sizeof (struct bwhc_iter) <= sizeof (struct whc_sample_iter));
|
||||
|
||||
static void bwhc_free (struct whc *whc_generic)
|
||||
{
|
||||
|
|
@ -64,7 +64,7 @@ static void bwhc_sample_iter_init (const struct whc *whc_generic, struct whc_sam
|
|||
static bool is_visible (const struct entity_common *e)
|
||||
{
|
||||
const nn_vendorid_t vendorid = get_entity_vendorid (e);
|
||||
return ddsi_plugin.builtintopic_is_visible (e->guid.entityid, e->onlylocal, vendorid);
|
||||
return builtintopic_is_visible (e->gv->builtin_topic_interface, &e->guid, vendorid);
|
||||
}
|
||||
|
||||
static bool bwhc_sample_iter_borrow_next (struct whc_sample_iter *opaque_it, struct whc_borrowed_sample *sample)
|
||||
|
|
@ -92,7 +92,7 @@ static bool bwhc_sample_iter_borrow_next (struct whc_sample_iter *opaque_it, str
|
|||
case DSBT_READER: kind = EK_READER; break;
|
||||
}
|
||||
assert (whc->type == DSBT_PARTICIPANT || kind != EK_PARTICIPANT);
|
||||
ephash_enum_init (&it->it, kind);
|
||||
ephash_enum_init (&it->it, whc->guid_hash, kind);
|
||||
it->st = BIS_LOCAL;
|
||||
/* FALLS THROUGH */
|
||||
case BIS_LOCAL:
|
||||
|
|
@ -115,7 +115,7 @@ static bool bwhc_sample_iter_borrow_next (struct whc_sample_iter *opaque_it, str
|
|||
case DSBT_READER: kind = EK_PROXY_READER; break;
|
||||
}
|
||||
assert (kind != EK_PARTICIPANT);
|
||||
ephash_enum_init (&it->it, kind);
|
||||
ephash_enum_init (&it->it, whc->guid_hash, kind);
|
||||
it->st = BIS_PROXY;
|
||||
/* FALLS THROUGH */
|
||||
case BIS_PROXY:
|
||||
|
|
@ -192,10 +192,11 @@ static const struct whc_ops bwhc_ops = {
|
|||
.free = bwhc_free
|
||||
};
|
||||
|
||||
struct whc *builtintopic_whc_new (enum ddsi_sertopic_builtintopic_type type)
|
||||
struct whc *builtintopic_whc_new (enum ddsi_sertopic_builtintopic_type type, const struct ephash *guid_hash)
|
||||
{
|
||||
struct bwhc *whc = ddsrt_malloc (sizeof (*whc));
|
||||
whc->common.ops = &bwhc_ops;
|
||||
whc->type = type;
|
||||
whc->guid_hash = guid_hash;
|
||||
return (struct whc *) whc;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,29 +14,28 @@
|
|||
#include "dds__writer.h"
|
||||
#include "dds__write.h"
|
||||
#include "dds/ddsi/ddsi_tkmap.h"
|
||||
#include "dds/ddsi/q_error.h"
|
||||
#include "dds/ddsi/q_thread.h"
|
||||
#include "dds/ddsi/q_xmsg.h"
|
||||
#include "dds/ddsi/q_rhc.h"
|
||||
#include "dds/ddsi/ddsi_serdata.h"
|
||||
#include "dds__stream.h"
|
||||
#include "dds__err.h"
|
||||
#include "dds/ddsi/q_transmit.h"
|
||||
#include "dds/ddsi/q_ephash.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/q_entity.h"
|
||||
#include "dds/ddsi/q_radmin.h"
|
||||
#include "dds/ddsi/q_globals.h"
|
||||
|
||||
dds_return_t dds_write (dds_entity_t writer, const void *data)
|
||||
{
|
||||
dds_return_t ret;
|
||||
dds_retcode_t rc;
|
||||
dds_writer *wr;
|
||||
|
||||
if (data == NULL)
|
||||
return DDS_ERRNO (DDS_RETCODE_BAD_PARAMETER);
|
||||
return DDS_RETCODE_BAD_PARAMETER;
|
||||
|
||||
if ((rc = dds_writer_lock (writer, &wr)) != DDS_RETCODE_OK)
|
||||
return DDS_ERRNO (rc);
|
||||
if ((ret = dds_writer_lock (writer, &wr)) != DDS_RETCODE_OK)
|
||||
return ret;
|
||||
ret = dds_write_impl (wr, data, dds_time (), 0);
|
||||
dds_writer_unlock (wr);
|
||||
return ret;
|
||||
|
|
@ -45,14 +44,13 @@ dds_return_t dds_write (dds_entity_t writer, const void *data)
|
|||
dds_return_t dds_writecdr (dds_entity_t writer, struct ddsi_serdata *serdata)
|
||||
{
|
||||
dds_return_t ret;
|
||||
dds_retcode_t rc;
|
||||
dds_writer *wr;
|
||||
|
||||
if (serdata == NULL)
|
||||
return DDS_ERRNO (DDS_RETCODE_BAD_PARAMETER);
|
||||
return DDS_RETCODE_BAD_PARAMETER;
|
||||
|
||||
if ((rc = dds_writer_lock (writer, &wr)) != DDS_RETCODE_OK)
|
||||
return DDS_ERRNO (rc);
|
||||
if ((ret = dds_writer_lock (writer, &wr)) != DDS_RETCODE_OK)
|
||||
return ret;
|
||||
ret = dds_writecdr_impl (wr, serdata, dds_time (), 0);
|
||||
dds_writer_unlock (wr);
|
||||
return ret;
|
||||
|
|
@ -61,14 +59,13 @@ dds_return_t dds_writecdr (dds_entity_t writer, struct ddsi_serdata *serdata)
|
|||
dds_return_t dds_write_ts (dds_entity_t writer, const void *data, dds_time_t timestamp)
|
||||
{
|
||||
dds_return_t ret;
|
||||
dds_retcode_t rc;
|
||||
dds_writer *wr;
|
||||
|
||||
if (data == NULL || timestamp < 0)
|
||||
return DDS_ERRNO (DDS_RETCODE_BAD_PARAMETER);
|
||||
return DDS_RETCODE_BAD_PARAMETER;
|
||||
|
||||
if ((rc = dds_writer_lock (writer, &wr)) != DDS_RETCODE_OK)
|
||||
return DDS_ERRNO (rc);
|
||||
if ((ret = dds_writer_lock (writer, &wr)) != DDS_RETCODE_OK)
|
||||
return ret;
|
||||
ret = dds_write_impl (wr, data, timestamp, 0);
|
||||
dds_writer_unlock (wr);
|
||||
return ret;
|
||||
|
|
@ -76,7 +73,7 @@ dds_return_t dds_write_ts (dds_entity_t writer, const void *data, dds_time_t tim
|
|||
|
||||
static dds_return_t try_store (struct rhc *rhc, const struct proxy_writer_info *pwr_info, struct ddsi_serdata *payload, struct ddsi_tkmap_instance *tk, dds_duration_t *max_block_ms)
|
||||
{
|
||||
while (!(ddsi_plugin.rhc_plugin.rhc_store_fn) (rhc, pwr_info, payload, tk))
|
||||
while (! rhc_store (rhc, pwr_info, payload, tk))
|
||||
{
|
||||
if (*max_block_ms > 0)
|
||||
{
|
||||
|
|
@ -85,8 +82,7 @@ static dds_return_t try_store (struct rhc *rhc, const struct proxy_writer_info *
|
|||
}
|
||||
else
|
||||
{
|
||||
DDS_ERROR ("The writer could not deliver data on time, probably due to a local reader resources being full\n");
|
||||
return DDS_ERRNO (DDS_RETCODE_TIMEOUT);
|
||||
return DDS_RETCODE_TIMEOUT;
|
||||
}
|
||||
}
|
||||
return DDS_RETCODE_OK;
|
||||
|
|
@ -101,12 +97,11 @@ static dds_return_t deliver_locally (struct writer *wr, struct ddsi_serdata *pay
|
|||
struct reader ** const rdary = wr->rdary.rdary;
|
||||
if (rdary[0])
|
||||
{
|
||||
dds_duration_t max_block_ms = nn_from_ddsi_duration (wr->xqos->reliability.max_blocking_time);
|
||||
dds_duration_t max_block_ms = wr->xqos->reliability.max_blocking_time;
|
||||
struct proxy_writer_info pwr_info;
|
||||
unsigned i;
|
||||
make_proxy_writer_info (&pwr_info, &wr->e, wr->xqos);
|
||||
for (i = 0; rdary[i]; i++) {
|
||||
DDS_TRACE ("reader "PGUIDFMT"\n", PGUID (rdary[i]->e.guid));
|
||||
for (uint32_t i = 0; rdary[i]; i++) {
|
||||
DDS_CTRACE (&wr->e.gv->logconfig, "reader "PGUIDFMT"\n", PGUID (rdary[i]->e.guid));
|
||||
if ((ret = try_store (rdary[i]->rhc, &pwr_info, payload, tk, &max_block_ms)) != DDS_RETCODE_OK)
|
||||
break;
|
||||
}
|
||||
|
|
@ -116,33 +111,39 @@ static dds_return_t deliver_locally (struct writer *wr, struct ddsi_serdata *pay
|
|||
else
|
||||
{
|
||||
/* When deleting, pwr is no longer accessible via the hash
|
||||
tables, and consequently, a reader may be deleted without
|
||||
it being possible to remove it from rdary. The primary
|
||||
reason rdary exists is to avoid locking the proxy writer
|
||||
but this is less of an issue when we are deleting it, so
|
||||
we fall back to using the GUIDs so that we can deliver all
|
||||
samples we received from it. As writer being deleted any
|
||||
reliable samples that are rejected are simply discarded. */
|
||||
tables, and consequently, a reader may be deleted without
|
||||
it being possible to remove it from rdary. The primary
|
||||
reason rdary exists is to avoid locking the proxy writer
|
||||
but this is less of an issue when we are deleting it, so
|
||||
we fall back to using the GUIDs so that we can deliver all
|
||||
samples we received from it. As writer being deleted any
|
||||
reliable samples that are rejected are simply discarded. */
|
||||
ddsrt_avl_iter_t it;
|
||||
struct pwr_rd_match *m;
|
||||
struct proxy_writer_info pwr_info;
|
||||
dds_duration_t max_block_ms = nn_from_ddsi_duration (wr->xqos->reliability.max_blocking_time);
|
||||
const struct ephash *gh = wr->e.gv->guid_hash;
|
||||
dds_duration_t max_block_ms = wr->xqos->reliability.max_blocking_time;
|
||||
ddsrt_mutex_unlock (&wr->rdary.rdary_lock);
|
||||
make_proxy_writer_info (&pwr_info, &wr->e, wr->xqos);
|
||||
ddsrt_mutex_lock (&wr->e.lock);
|
||||
for (m = ddsrt_avl_iter_first (&wr_local_readers_treedef, &wr->local_readers, &it); m != NULL; m = ddsrt_avl_iter_next (&it))
|
||||
{
|
||||
struct reader *rd;
|
||||
if ((rd = ephash_lookup_reader_guid (&m->rd_guid)) != NULL)
|
||||
if ((rd = ephash_lookup_reader_guid (gh, &m->rd_guid)) != NULL)
|
||||
{
|
||||
DDS_TRACE("reader-via-guid "PGUIDFMT"\n", PGUID (rd->e.guid));
|
||||
/* Copied the return value ignore from DDSI deliver_user_data() function. */
|
||||
DDS_CTRACE (&wr->e.gv->logconfig, "reader-via-guid "PGUIDFMT"\n", PGUID (rd->e.guid));
|
||||
/* Copied the return value ignore from DDSI deliver_user_data () function. */
|
||||
if ((ret = try_store (rd->rhc, &pwr_info, payload, tk, &max_block_ms)) != DDS_RETCODE_OK)
|
||||
break;
|
||||
}
|
||||
}
|
||||
ddsrt_mutex_unlock (&wr->e.lock);
|
||||
}
|
||||
|
||||
if (ret == DDS_RETCODE_TIMEOUT)
|
||||
{
|
||||
DDS_CERROR (&wr->e.gv->logconfig, "The writer could not deliver data on time, probably due to a local reader resources being full\n");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -157,81 +158,72 @@ dds_return_t dds_write_impl (dds_writer *wr, const void * data, dds_time_t tstam
|
|||
int w_rc;
|
||||
|
||||
if (data == NULL)
|
||||
{
|
||||
DDS_ERROR("No data buffer provided\n");
|
||||
return DDS_ERRNO (DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
return DDS_RETCODE_BAD_PARAMETER;
|
||||
|
||||
/* Check for topic filter */
|
||||
if (wr->m_topic->filter_fn && !writekey)
|
||||
if (!(wr->m_topic->filter_fn) (data, wr->m_topic->filter_ctx))
|
||||
if (! wr->m_topic->filter_fn (data, wr->m_topic->filter_ctx))
|
||||
return DDS_RETCODE_OK;
|
||||
|
||||
thread_state_awake (ts1);
|
||||
thread_state_awake (ts1, &wr->m_entity.m_domain->gv);
|
||||
|
||||
/* Serialize and write data or key */
|
||||
d = ddsi_serdata_from_sample (ddsi_wr->topic, writekey ? SDK_KEY : SDK_DATA, data);
|
||||
d->statusinfo = ((action & DDS_WR_DISPOSE_BIT) ? NN_STATUSINFO_DISPOSE : 0) | ((action & DDS_WR_UNREGISTER_BIT) ? NN_STATUSINFO_UNREGISTER : 0);
|
||||
d->statusinfo = (((action & DDS_WR_DISPOSE_BIT) ? NN_STATUSINFO_DISPOSE : 0) |
|
||||
((action & DDS_WR_UNREGISTER_BIT) ? NN_STATUSINFO_UNREGISTER : 0));
|
||||
d->timestamp.v = tstamp;
|
||||
ddsi_serdata_ref (d);
|
||||
tk = ddsi_tkmap_lookup_instance_ref (d);
|
||||
tk = ddsi_tkmap_lookup_instance_ref (wr->m_entity.m_domain->gv.m_tkmap, d);
|
||||
w_rc = write_sample_gc (ts1, wr->m_xp, ddsi_wr, d, tk);
|
||||
|
||||
if (w_rc >= 0)
|
||||
{
|
||||
if (w_rc >= 0) {
|
||||
/* Flush out write unless configured to batch */
|
||||
if (!config.whc_batch)
|
||||
if (!wr->whc_batch)
|
||||
nn_xpack_send (wr->m_xp, false);
|
||||
ret = DDS_RETCODE_OK;
|
||||
} else if (w_rc == Q_ERR_TIMEOUT) {
|
||||
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 == Q_ERR_INVALID_DATA) {
|
||||
DDS_ERROR ("Invalid data provided\n");
|
||||
ret = DDS_ERRNO (DDS_RETCODE_ERROR);
|
||||
} else if (w_rc == DDS_RETCODE_TIMEOUT) {
|
||||
ret = DDS_RETCODE_TIMEOUT;
|
||||
} else if (w_rc == DDS_RETCODE_BAD_PARAMETER) {
|
||||
ret = DDS_RETCODE_ERROR;
|
||||
} else {
|
||||
DDS_ERROR ("Internal error\n");
|
||||
ret = DDS_ERRNO (DDS_RETCODE_ERROR);
|
||||
ret = DDS_RETCODE_ERROR;
|
||||
}
|
||||
if (ret == DDS_RETCODE_OK)
|
||||
ret = deliver_locally (ddsi_wr, d, tk);
|
||||
ddsi_serdata_unref (d);
|
||||
ddsi_tkmap_instance_unref (tk);
|
||||
ddsi_tkmap_instance_unref (wr->m_entity.m_domain->gv.m_tkmap, tk);
|
||||
thread_state_asleep (ts1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
dds_return_t dds_writecdr_impl_lowlevel (struct writer *ddsi_wr, struct nn_xpack *xp, struct ddsi_serdata *d)
|
||||
dds_return_t dds_writecdr_impl_lowlevel (struct writer *ddsi_wr, struct nn_xpack *xp, struct ddsi_serdata *d, bool flush)
|
||||
{
|
||||
struct thread_state1 * const ts1 = lookup_thread_state ();
|
||||
struct ddsi_tkmap_instance * tk;
|
||||
int ret = DDS_RETCODE_OK;
|
||||
int w_rc;
|
||||
|
||||
thread_state_awake (ts1);
|
||||
thread_state_awake (ts1, ddsi_wr->e.gv);
|
||||
ddsi_serdata_ref (d);
|
||||
tk = ddsi_tkmap_lookup_instance_ref (d);
|
||||
tk = ddsi_tkmap_lookup_instance_ref (ddsi_wr->e.gv->m_tkmap, d);
|
||||
w_rc = write_sample_gc (ts1, xp, ddsi_wr, d, tk);
|
||||
if (w_rc >= 0) {
|
||||
/* Flush out write unless configured to batch */
|
||||
if (!config.whc_batch && xp != NULL)
|
||||
if (flush && xp != NULL)
|
||||
nn_xpack_send (xp, false);
|
||||
ret = DDS_RETCODE_OK;
|
||||
} else if (w_rc == Q_ERR_TIMEOUT) {
|
||||
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 == Q_ERR_INVALID_DATA) {
|
||||
DDS_ERROR ("Invalid data provided\n");
|
||||
ret = DDS_ERRNO (DDS_RETCODE_ERROR);
|
||||
} else if (w_rc == DDS_RETCODE_TIMEOUT) {
|
||||
ret = DDS_RETCODE_TIMEOUT;
|
||||
} else if (w_rc == DDS_RETCODE_BAD_PARAMETER) {
|
||||
ret = DDS_RETCODE_ERROR;
|
||||
} else {
|
||||
DDS_ERROR ("Internal error\n");
|
||||
ret = DDS_ERRNO (DDS_RETCODE_ERROR);
|
||||
ret = DDS_RETCODE_ERROR;
|
||||
}
|
||||
|
||||
if (ret == DDS_RETCODE_OK)
|
||||
ret = deliver_locally (ddsi_wr, d, tk);
|
||||
ddsi_serdata_unref (d);
|
||||
ddsi_tkmap_instance_unref (tk);
|
||||
ddsi_tkmap_instance_unref (ddsi_wr->e.gv->m_tkmap, tk);
|
||||
thread_state_asleep (ts1);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -241,28 +233,22 @@ dds_return_t dds_writecdr_impl (dds_writer *wr, struct ddsi_serdata *d, dds_time
|
|||
if (wr->m_topic->filter_fn)
|
||||
abort ();
|
||||
/* Set if disposing or unregistering */
|
||||
d->statusinfo = ((action & DDS_WR_DISPOSE_BIT) ? NN_STATUSINFO_DISPOSE : 0) | ((action & DDS_WR_UNREGISTER_BIT) ? NN_STATUSINFO_UNREGISTER : 0);
|
||||
d->statusinfo = (((action & DDS_WR_DISPOSE_BIT) ? NN_STATUSINFO_DISPOSE : 0) |
|
||||
((action & DDS_WR_UNREGISTER_BIT) ? NN_STATUSINFO_UNREGISTER : 0));
|
||||
d->timestamp.v = tstamp;
|
||||
return dds_writecdr_impl_lowlevel (wr->m_wr, wr->m_xp, d);
|
||||
}
|
||||
|
||||
void dds_write_set_batch (bool enable)
|
||||
{
|
||||
config.whc_batch = enable ? 1 : 0;
|
||||
return dds_writecdr_impl_lowlevel (wr->m_wr, wr->m_xp, d, !wr->whc_batch);
|
||||
}
|
||||
|
||||
void dds_write_flush (dds_entity_t writer)
|
||||
{
|
||||
struct thread_state1 * const ts1 = lookup_thread_state ();
|
||||
dds_writer *wr;
|
||||
dds_retcode_t rc;
|
||||
thread_state_awake (ts1);
|
||||
if ((rc = dds_writer_lock (writer, &wr)) != DDS_RETCODE_OK)
|
||||
DDS_ERROR ("Error occurred on locking writer\n");
|
||||
else
|
||||
dds_return_t rc;
|
||||
if ((rc = dds_writer_lock (writer, &wr)) == DDS_RETCODE_OK)
|
||||
{
|
||||
thread_state_awake (ts1, &wr->m_entity.m_domain->gv);
|
||||
nn_xpack_send (wr->m_xp, true);
|
||||
thread_state_asleep (ts1);
|
||||
dds_writer_unlock (wr);
|
||||
}
|
||||
thread_state_asleep (ts1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include "dds/dds.h"
|
||||
#include "dds/version.h"
|
||||
#include "dds/ddsrt/static_assert.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/q_globals.h"
|
||||
#include "dds/ddsi/q_entity.h"
|
||||
|
|
@ -20,45 +21,25 @@
|
|||
#include "dds/ddsi/q_xmsg.h"
|
||||
#include "dds__writer.h"
|
||||
#include "dds__listener.h"
|
||||
#include "dds__qos.h"
|
||||
#include "dds__err.h"
|
||||
#include "dds__init.h"
|
||||
#include "dds__publisher.h"
|
||||
#include "dds__topic.h"
|
||||
#include "dds__get_status.h"
|
||||
#include "dds__qos.h"
|
||||
#include "dds/ddsi/ddsi_tkmap.h"
|
||||
#include "dds__whc.h"
|
||||
|
||||
DECL_ENTITY_LOCK_UNLOCK(extern inline, dds_writer)
|
||||
DECL_ENTITY_LOCK_UNLOCK (extern inline, dds_writer)
|
||||
|
||||
#define DDS_WRITER_STATUS_MASK \
|
||||
DDS_LIVELINESS_LOST_STATUS |\
|
||||
DDS_OFFERED_DEADLINE_MISSED_STATUS |\
|
||||
DDS_OFFERED_INCOMPATIBLE_QOS_STATUS |\
|
||||
DDS_PUBLICATION_MATCHED_STATUS
|
||||
(DDS_LIVELINESS_LOST_STATUS |\
|
||||
DDS_OFFERED_DEADLINE_MISSED_STATUS |\
|
||||
DDS_OFFERED_INCOMPATIBLE_QOS_STATUS |\
|
||||
DDS_PUBLICATION_MATCHED_STATUS)
|
||||
|
||||
static dds_return_t
|
||||
dds_writer_instance_hdl(
|
||||
dds_entity *e,
|
||||
dds_instance_handle_t *i)
|
||||
static dds_return_t dds_writer_status_validate (uint32_t mask)
|
||||
{
|
||||
assert(e);
|
||||
assert(i);
|
||||
*i = (dds_instance_handle_t)writer_instance_id(&e->m_guid);
|
||||
return DDS_RETCODE_OK;
|
||||
}
|
||||
|
||||
static dds_return_t
|
||||
dds_writer_status_validate(
|
||||
uint32_t mask)
|
||||
{
|
||||
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;
|
||||
return (mask & ~DDS_WRITER_STATUS_MASK) ? DDS_RETCODE_BAD_PARAMETER : DDS_RETCODE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -77,7 +58,7 @@ static void dds_writer_status_cb (void *ventity, const status_cb_data_t *data)
|
|||
{
|
||||
/* Release the initial claim that was done during the create. This
|
||||
* will indicate that further API deletion is now possible. */
|
||||
dds_handle_release (&entity->m_hdllink);
|
||||
dds_handle_unpin (&entity->m_hdllink);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +75,7 @@ static void dds_writer_status_cb (void *ventity, const status_cb_data_t *data)
|
|||
|
||||
/* Reset the status for possible Listener call.
|
||||
* When a listener is not called, the status will be set (again). */
|
||||
dds_entity_status_reset (entity, 1u << status_id);
|
||||
dds_entity_status_reset (entity, (status_mask_t) (1u << status_id));
|
||||
|
||||
/* Update status metrics. */
|
||||
dds_writer * const wr = (dds_writer *) entity;
|
||||
|
|
@ -166,7 +147,7 @@ static void dds_writer_status_cb (void *ventity, const status_cb_data_t *data)
|
|||
}
|
||||
else
|
||||
{
|
||||
dds_entity_status_set (entity, 1u << status_id);
|
||||
dds_entity_status_set (entity, (status_mask_t) (1u << status_id));
|
||||
}
|
||||
|
||||
entity->m_cb_count--;
|
||||
|
|
@ -174,422 +155,208 @@ static void dds_writer_status_cb (void *ventity, const status_cb_data_t *data)
|
|||
ddsrt_mutex_unlock (&entity->m_observers_lock);
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
get_bandwidth_limit(
|
||||
nn_transport_priority_qospolicy_t transport_priority)
|
||||
static uint32_t get_bandwidth_limit (dds_transport_priority_qospolicy_t transport_priority)
|
||||
{
|
||||
#ifdef DDSI_INCLUDE_NETWORK_CHANNELS
|
||||
struct config_channel_listelem *channel = find_channel (transport_priority);
|
||||
struct config_channel_listelem *channel = find_channel (&config, transport_priority);
|
||||
return channel->data_bandwidth_limit;
|
||||
#else
|
||||
(void)transport_priority;
|
||||
(void) transport_priority;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static dds_return_t
|
||||
dds_writer_close(
|
||||
dds_entity *e)
|
||||
static dds_return_t dds_writer_close (dds_entity *e) ddsrt_nonnull_all;
|
||||
|
||||
static dds_return_t dds_writer_close (dds_entity *e)
|
||||
{
|
||||
dds_return_t ret = DDS_RETCODE_OK;
|
||||
dds_writer *wr = (dds_writer*)e;
|
||||
dds_writer * const wr = (dds_writer *) e;
|
||||
dds_return_t ret;
|
||||
thread_state_awake (lookup_thread_state (), &e->m_domain->gv);
|
||||
nn_xpack_send (wr->m_xp, false);
|
||||
if ((ret = delete_writer (&e->m_domain->gv, &e->m_guid)) < 0)
|
||||
ret = DDS_RETCODE_ERROR;
|
||||
thread_state_asleep (lookup_thread_state ());
|
||||
return ret;
|
||||
}
|
||||
|
||||
assert(e);
|
||||
static dds_return_t dds_writer_delete (dds_entity *e) ddsrt_nonnull_all;
|
||||
|
||||
thread_state_awake (lookup_thread_state ());
|
||||
nn_xpack_send (wr->m_xp, false);
|
||||
if (delete_writer (&e->m_guid) != 0) {
|
||||
DDS_ERROR("Internal error");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_ERROR);
|
||||
}
|
||||
static dds_return_t dds_writer_delete (dds_entity *e)
|
||||
{
|
||||
dds_writer * const wr = (dds_writer *) e;
|
||||
dds_return_t ret;
|
||||
/* FIXME: not freeing WHC here because it is owned by the DDSI entity */
|
||||
thread_state_awake (lookup_thread_state (), &e->m_domain->gv);
|
||||
nn_xpack_free (wr->m_xp);
|
||||
thread_state_asleep (lookup_thread_state ());
|
||||
if ((ret = dds_delete (wr->m_topic->m_entity.m_hdllink.hdl)) == DDS_RETCODE_OK)
|
||||
{
|
||||
ret = dds_delete_impl (e->m_parent->m_hdllink.hdl, true);
|
||||
if (ret == DDS_RETCODE_BAD_PARAMETER)
|
||||
ret = DDS_RETCODE_OK;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static dds_return_t dds_writer_qos_set (dds_entity *e, const dds_qos_t *qos, bool enabled)
|
||||
{
|
||||
/* note: e->m_qos is still the old one to allow for failure here */
|
||||
if (enabled)
|
||||
{
|
||||
struct writer *wr;
|
||||
thread_state_awake (lookup_thread_state (), &e->m_domain->gv);
|
||||
if ((wr = ephash_lookup_writer_guid (e->m_domain->gv.guid_hash, &e->m_guid)) != NULL)
|
||||
update_writer_qos (wr, qos);
|
||||
thread_state_asleep (lookup_thread_state ());
|
||||
return ret;
|
||||
}
|
||||
return DDS_RETCODE_OK;
|
||||
}
|
||||
|
||||
static dds_return_t
|
||||
dds_writer_delete(
|
||||
dds_entity *e)
|
||||
{
|
||||
dds_writer *wr = (dds_writer*)e;
|
||||
dds_return_t ret;
|
||||
/* FIXME: not freeing WHC here because it is owned by the DDSI entity */
|
||||
thread_state_awake (lookup_thread_state ());
|
||||
nn_xpack_free(wr->m_xp);
|
||||
thread_state_asleep (lookup_thread_state ());
|
||||
ret = dds_delete(wr->m_topic->m_entity.m_hdllink.hdl);
|
||||
if(ret == DDS_RETCODE_OK){
|
||||
ret = dds_delete_impl(e->m_parent->m_hdllink.hdl, true);
|
||||
if(dds_err_nr(ret) == DDS_RETCODE_BAD_PARAMETER){
|
||||
ret = DDS_RETCODE_OK;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static dds_return_t
|
||||
dds_writer_qos_validate(
|
||||
const dds_qos_t *qos,
|
||||
bool enabled)
|
||||
{
|
||||
dds_return_t ret = DDS_RETCODE_OK;
|
||||
|
||||
assert(qos);
|
||||
|
||||
/* Check consistency. */
|
||||
if(dds_qos_validate_common(qos) != true){
|
||||
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){
|
||||
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){
|
||||
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){
|
||||
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)){
|
||||
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);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static dds_return_t
|
||||
dds_writer_qos_set(
|
||||
dds_entity *e,
|
||||
const dds_qos_t *qos,
|
||||
bool enabled)
|
||||
{
|
||||
dds_return_t ret = dds_writer_qos_validate(qos, enabled);
|
||||
if (ret == DDS_RETCODE_OK) {
|
||||
/*
|
||||
* TODO: CHAM-95: DDSI does not support changing QoS policies.
|
||||
*
|
||||
* Only Ownership is required for the minimum viable product. This seems
|
||||
* to be the only QoS policy that DDSI supports changes on.
|
||||
*/
|
||||
if (qos->present & QP_OWNERSHIP_STRENGTH) {
|
||||
dds_ownership_kind_t kind;
|
||||
/* check for ownership before updating, ownership strength is applicable only if
|
||||
* writer is exclusive */
|
||||
dds_qget_ownership (e->m_qos, &kind);
|
||||
|
||||
if (kind == DDS_OWNERSHIP_EXCLUSIVE) {
|
||||
struct writer * ddsi_wr = ((dds_writer*)e)->m_wr;
|
||||
|
||||
dds_qset_ownership_strength (e->m_qos, qos->ownership_strength.value);
|
||||
|
||||
thread_state_awake (lookup_thread_state ());
|
||||
|
||||
/* FIXME: with QoS changes being unsupported by the underlying stack I wonder what will happen; locking the underlying DDSI writer is of doubtful value as well */
|
||||
ddsrt_mutex_lock (&ddsi_wr->e.lock);
|
||||
if (qos->ownership_strength.value != ddsi_wr->xqos->ownership_strength.value) {
|
||||
ddsi_wr->xqos->ownership_strength.value = qos->ownership_strength.value;
|
||||
}
|
||||
ddsrt_mutex_unlock (&ddsi_wr->e.lock);
|
||||
thread_state_asleep (lookup_thread_state ());
|
||||
} else {
|
||||
DDS_ERROR("Setting ownership strength doesn't make sense when the ownership is shared\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_ERROR);
|
||||
}
|
||||
} else {
|
||||
if (enabled) {
|
||||
DDS_ERROR(DDS_PROJECT_NAME" does not support changing QoS policies yet\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct whc *make_whc(const dds_qos_t *qos)
|
||||
static struct whc *make_whc (struct dds_domain *dom, const dds_qos_t *qos)
|
||||
{
|
||||
bool handle_as_transient_local;
|
||||
unsigned hdepth, tldepth;
|
||||
uint32_t hdepth, tldepth;
|
||||
/* Construct WHC -- if aggressive_keep_last1 is set, the WHC will
|
||||
drop all samples for which a later update is available. This
|
||||
forces it to maintain a tlidx. */
|
||||
handle_as_transient_local = (qos->durability.kind == NN_TRANSIENT_LOCAL_DURABILITY_QOS);
|
||||
if (qos->history.kind == NN_KEEP_ALL_HISTORY_QOS)
|
||||
drop all samples for which a later update is available. This
|
||||
forces it to maintain a tlidx. */
|
||||
handle_as_transient_local = (qos->durability.kind == DDS_DURABILITY_TRANSIENT_LOCAL);
|
||||
if (qos->history.kind == DDS_HISTORY_KEEP_ALL)
|
||||
hdepth = 0;
|
||||
else
|
||||
hdepth = (unsigned)qos->history.depth;
|
||||
if (handle_as_transient_local) {
|
||||
if (qos->durability_service.history.kind == NN_KEEP_ALL_HISTORY_QOS)
|
||||
hdepth = (unsigned) qos->history.depth;
|
||||
if (!handle_as_transient_local)
|
||||
tldepth = 0;
|
||||
else
|
||||
{
|
||||
if (qos->durability_service.history.kind == DDS_HISTORY_KEEP_ALL)
|
||||
tldepth = 0;
|
||||
else
|
||||
tldepth = (unsigned)qos->durability_service.history.depth;
|
||||
} else {
|
||||
tldepth = 0;
|
||||
tldepth = (unsigned) qos->durability_service.history.depth;
|
||||
}
|
||||
return whc_new (handle_as_transient_local, hdepth, tldepth);
|
||||
return whc_new (&dom->gv, handle_as_transient_local, hdepth, tldepth);
|
||||
}
|
||||
|
||||
const struct dds_entity_deriver dds_entity_deriver_writer = {
|
||||
.close = dds_writer_close,
|
||||
.delete = dds_writer_delete,
|
||||
.set_qos = dds_writer_qos_set,
|
||||
.validate_status = dds_writer_status_validate
|
||||
};
|
||||
|
||||
dds_entity_t
|
||||
dds_create_writer(
|
||||
dds_entity_t participant_or_publisher,
|
||||
dds_entity_t topic,
|
||||
const dds_qos_t *qos,
|
||||
const dds_listener_t *listener)
|
||||
dds_entity_t dds_create_writer (dds_entity_t participant_or_publisher, dds_entity_t topic, const dds_qos_t *qos, const dds_listener_t *listener)
|
||||
{
|
||||
dds_retcode_t rc;
|
||||
dds_qos_t * wqos;
|
||||
dds_writer * wr;
|
||||
dds_entity_t writer;
|
||||
dds_publisher * pub = NULL;
|
||||
dds_topic * tp;
|
||||
dds_entity_t publisher;
|
||||
ddsi_tran_conn_t conn = gv.data_conn_uc;
|
||||
dds_return_t ret;
|
||||
dds_return_t rc;
|
||||
dds_qos_t *wqos;
|
||||
dds_writer *wr;
|
||||
dds_entity_t writer;
|
||||
dds_publisher *pub = NULL;
|
||||
dds_topic *tp;
|
||||
dds_entity_t publisher;
|
||||
|
||||
{
|
||||
dds_entity *p_or_p;
|
||||
if ((rc = dds_entity_claim (participant_or_publisher, &p_or_p)) != DDS_RETCODE_OK) {
|
||||
return DDS_ERRNO (rc);
|
||||
}
|
||||
if (dds_entity_kind (p_or_p) == DDS_KIND_PARTICIPANT) {
|
||||
publisher = dds_create_publisher(participant_or_publisher, qos, NULL);
|
||||
} else {
|
||||
publisher = participant_or_publisher;
|
||||
}
|
||||
dds_entity_release (p_or_p);
|
||||
}
|
||||
{
|
||||
dds_entity *p_or_p;
|
||||
if ((rc = dds_entity_pin (participant_or_publisher, &p_or_p)) != DDS_RETCODE_OK)
|
||||
return rc;
|
||||
if (dds_entity_kind (p_or_p) == DDS_KIND_PARTICIPANT)
|
||||
publisher = dds_create_publisher(participant_or_publisher, qos, NULL);
|
||||
else
|
||||
publisher = participant_or_publisher;
|
||||
dds_entity_unpin (p_or_p);
|
||||
}
|
||||
|
||||
if ((rc = dds_publisher_lock(publisher, &pub)) != DDS_RETCODE_OK) {
|
||||
writer = DDS_ERRNO(rc);
|
||||
goto err_pub_lock;
|
||||
}
|
||||
if ((rc = dds_publisher_lock (publisher, &pub)) != DDS_RETCODE_OK)
|
||||
return rc;
|
||||
|
||||
if (publisher != participant_or_publisher) {
|
||||
pub->m_entity.m_flags |= DDS_ENTITY_IMPLICIT;
|
||||
}
|
||||
ddsi_tran_conn_t conn = pub->m_entity.m_domain->gv.data_conn_uc;
|
||||
if (publisher != participant_or_publisher)
|
||||
pub->m_entity.m_flags |= DDS_ENTITY_IMPLICIT;
|
||||
|
||||
rc = dds_topic_lock(topic, &tp);
|
||||
if (rc != DDS_RETCODE_OK) {
|
||||
DDS_ERROR("Error occurred on locking topic\n");
|
||||
writer = DDS_ERRNO(rc);
|
||||
goto err_tp_lock;
|
||||
}
|
||||
assert(tp->m_stopic);
|
||||
assert(pub->m_entity.m_domain == tp->m_entity.m_domain);
|
||||
if ((rc = dds_topic_lock (topic, &tp)) != DDS_RETCODE_OK)
|
||||
goto err_tp_lock;
|
||||
|
||||
/* Merge Topic & Publisher qos */
|
||||
wqos = dds_create_qos();
|
||||
if (qos) {
|
||||
/* Only returns failure when one of the qos args is NULL, which
|
||||
* is not the case here. */
|
||||
(void)dds_copy_qos(wqos, qos);
|
||||
}
|
||||
assert (tp->m_stopic);
|
||||
assert (pub->m_entity.m_domain == tp->m_entity.m_domain);
|
||||
|
||||
if (pub->m_entity.m_qos) {
|
||||
dds_merge_qos(wqos, pub->m_entity.m_qos);
|
||||
}
|
||||
/* Merge Topic & Publisher qos */
|
||||
wqos = dds_create_qos ();
|
||||
if (qos)
|
||||
nn_xqos_mergein_missing (wqos, qos, DDS_WRITER_QOS_MASK);
|
||||
if (pub->m_entity.m_qos)
|
||||
nn_xqos_mergein_missing (wqos, pub->m_entity.m_qos, ~(uint64_t)0);
|
||||
if (tp->m_entity.m_qos)
|
||||
nn_xqos_mergein_missing (wqos, tp->m_entity.m_qos, ~(uint64_t)0);
|
||||
nn_xqos_mergein_missing (wqos, &pub->m_entity.m_domain->gv.default_xqos_wr, ~(uint64_t)0);
|
||||
|
||||
if (tp->m_entity.m_qos) {
|
||||
/* merge topic qos data to writer qos */
|
||||
dds_merge_qos(wqos, tp->m_entity.m_qos);
|
||||
}
|
||||
nn_xqos_mergein_missing(wqos, &gv.default_xqos_wr);
|
||||
if ((rc = nn_xqos_valid (&pub->m_entity.m_domain->gv.logconfig, wqos)) < 0)
|
||||
{
|
||||
dds_delete_qos(wqos);
|
||||
goto err_bad_qos;
|
||||
}
|
||||
|
||||
ret = dds_writer_qos_validate(wqos, false);
|
||||
if (ret != 0) {
|
||||
dds_delete_qos(wqos);
|
||||
writer = ret;
|
||||
goto err_bad_qos;
|
||||
}
|
||||
/* Create writer */
|
||||
wr = dds_alloc (sizeof (*wr));
|
||||
writer = dds_entity_init (&wr->m_entity, &pub->m_entity, DDS_KIND_WRITER, wqos, listener, DDS_WRITER_STATUS_MASK);
|
||||
|
||||
/* Create writer */
|
||||
wr = dds_alloc(sizeof (*wr));
|
||||
writer = dds_entity_init(&wr->m_entity, &pub->m_entity, DDS_KIND_WRITER, wqos, listener, DDS_WRITER_STATUS_MASK);
|
||||
wr->m_topic = tp;
|
||||
dds_entity_add_ref_locked (&tp->m_entity);
|
||||
wr->m_xp = nn_xpack_new (conn, get_bandwidth_limit (wqos->transport_priority), pub->m_entity.m_domain->gv.config.xpack_send_async);
|
||||
wr->m_whc = make_whc (pub->m_entity.m_domain, wqos);
|
||||
wr->whc_batch = pub->m_entity.m_domain->gv.config.whc_batch;
|
||||
|
||||
wr->m_topic = tp;
|
||||
dds_entity_add_ref_nolock(&tp->m_entity);
|
||||
wr->m_xp = nn_xpack_new(conn, get_bandwidth_limit(wqos->transport_priority), config.xpack_send_async);
|
||||
wr->m_entity.m_deriver.close = dds_writer_close;
|
||||
wr->m_entity.m_deriver.delete = dds_writer_delete;
|
||||
wr->m_entity.m_deriver.set_qos = dds_writer_qos_set;
|
||||
wr->m_entity.m_deriver.validate_status = dds_writer_status_validate;
|
||||
wr->m_entity.m_deriver.get_instance_hdl = dds_writer_instance_hdl;
|
||||
wr->m_whc = make_whc (wqos);
|
||||
/* Extra claim of this writer to make sure that the delete waits until DDSI
|
||||
* has deleted its writer as well. This can be known through the callback. */
|
||||
dds_handle_repin (&wr->m_entity.m_hdllink);
|
||||
|
||||
/* Extra claim of this writer to make sure that the delete waits until DDSI
|
||||
* has deleted its writer as well. This can be known through the callback. */
|
||||
dds_handle_claim_inc (&wr->m_entity.m_hdllink);
|
||||
ddsrt_mutex_unlock (&tp->m_entity.m_mutex);
|
||||
ddsrt_mutex_unlock (&pub->m_entity.m_mutex);
|
||||
|
||||
ddsrt_mutex_unlock (&tp->m_entity.m_mutex);
|
||||
ddsrt_mutex_unlock (&pub->m_entity.m_mutex);
|
||||
thread_state_awake (lookup_thread_state (), &pub->m_entity.m_domain->gv);
|
||||
rc = new_writer (&wr->m_wr, &wr->m_entity.m_domain->gv, &wr->m_entity.m_guid, NULL, &pub->m_entity.m_participant->m_guid, tp->m_stopic, wqos, wr->m_whc, dds_writer_status_cb, wr);
|
||||
ddsrt_mutex_lock (&pub->m_entity.m_mutex);
|
||||
ddsrt_mutex_lock (&tp->m_entity.m_mutex);
|
||||
assert(rc == DDS_RETCODE_OK);
|
||||
thread_state_asleep (lookup_thread_state ());
|
||||
|
||||
thread_state_awake (lookup_thread_state ());
|
||||
ret = new_writer(&wr->m_wr, &wr->m_entity.m_guid, NULL, &pub->m_entity.m_participant->m_guid, tp->m_stopic, wqos, wr->m_whc, dds_writer_status_cb, wr);
|
||||
ddsrt_mutex_lock (&pub->m_entity.m_mutex);
|
||||
ddsrt_mutex_lock (&tp->m_entity.m_mutex);
|
||||
assert(ret == DDS_RETCODE_OK);
|
||||
thread_state_asleep (lookup_thread_state ());
|
||||
dds_topic_unlock(tp);
|
||||
dds_publisher_unlock(pub);
|
||||
return writer;
|
||||
wr->m_entity.m_iid = get_entity_instance_id (&wr->m_entity.m_domain->gv, &wr->m_entity.m_guid);
|
||||
dds_entity_register_child (&pub->m_entity, &wr->m_entity);
|
||||
|
||||
dds_topic_unlock (tp);
|
||||
dds_publisher_unlock (pub);
|
||||
return writer;
|
||||
|
||||
err_bad_qos:
|
||||
dds_topic_unlock(tp);
|
||||
dds_topic_unlock (tp);
|
||||
err_tp_lock:
|
||||
dds_publisher_unlock(pub);
|
||||
if((pub->m_entity.m_flags & DDS_ENTITY_IMPLICIT) != 0){
|
||||
(void)dds_delete(publisher);
|
||||
}
|
||||
err_pub_lock:
|
||||
return writer;
|
||||
dds_publisher_unlock (pub);
|
||||
if ((pub->m_entity.m_flags & DDS_ENTITY_IMPLICIT) != 0){
|
||||
(void )dds_delete (publisher);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
dds_entity_t
|
||||
dds_get_publisher(
|
||||
dds_entity_t writer)
|
||||
dds_entity_t dds_get_publisher (dds_entity_t writer)
|
||||
{
|
||||
dds_entity *e;
|
||||
dds_retcode_t rc;
|
||||
if ((rc = dds_entity_claim (writer, &e)) != DDS_RETCODE_OK)
|
||||
return DDS_ERRNO (rc);
|
||||
dds_return_t rc;
|
||||
if ((rc = dds_entity_pin (writer, &e)) != DDS_RETCODE_OK)
|
||||
return rc;
|
||||
else
|
||||
{
|
||||
dds_entity_t pubh;
|
||||
if (dds_entity_kind (e) != DDS_KIND_WRITER)
|
||||
pubh = DDS_ERRNO (DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
pubh = DDS_RETCODE_ILLEGAL_OPERATION;
|
||||
else
|
||||
{
|
||||
assert (dds_entity_kind (e->m_parent) == DDS_KIND_PUBLISHER);
|
||||
pubh = e->m_parent->m_hdllink.hdl;
|
||||
}
|
||||
dds_entity_release (e);
|
||||
dds_entity_unpin (e);
|
||||
return pubh;
|
||||
}
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
dds_get_publication_matched_status (
|
||||
dds_entity_t writer,
|
||||
dds_publication_matched_status_t * status)
|
||||
{
|
||||
dds_retcode_t rc;
|
||||
dds_writer *wr;
|
||||
dds_return_t ret = DDS_RETCODE_OK;
|
||||
|
||||
rc = dds_writer_lock(writer, &wr);
|
||||
if (rc != DDS_RETCODE_OK) {
|
||||
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 */
|
||||
if (status) {
|
||||
*status = wr->m_publication_matched_status;
|
||||
}
|
||||
ddsrt_mutex_lock (&wr->m_entity.m_observers_lock);
|
||||
if (wr->m_entity.m_status_enable & DDS_PUBLICATION_MATCHED_STATUS) {
|
||||
wr->m_publication_matched_status.total_count_change = 0;
|
||||
wr->m_publication_matched_status.current_count_change = 0;
|
||||
dds_entity_status_reset(&wr->m_entity, DDS_PUBLICATION_MATCHED_STATUS);
|
||||
}
|
||||
ddsrt_mutex_unlock (&wr->m_entity.m_observers_lock);
|
||||
dds_writer_unlock(wr);
|
||||
fail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
dds_get_liveliness_lost_status (
|
||||
dds_entity_t writer,
|
||||
dds_liveliness_lost_status_t * status)
|
||||
{
|
||||
dds_retcode_t rc;
|
||||
dds_writer *wr;
|
||||
dds_return_t ret = DDS_RETCODE_OK;
|
||||
|
||||
rc = dds_writer_lock(writer, &wr);
|
||||
if (rc != DDS_RETCODE_OK) {
|
||||
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 */
|
||||
if (status) {
|
||||
*status = wr->m_liveliness_lost_status;
|
||||
}
|
||||
ddsrt_mutex_lock (&wr->m_entity.m_observers_lock);
|
||||
if (wr->m_entity.m_status_enable & DDS_LIVELINESS_LOST_STATUS) {
|
||||
wr->m_liveliness_lost_status.total_count_change = 0;
|
||||
dds_entity_status_reset(&wr->m_entity, DDS_LIVELINESS_LOST_STATUS);
|
||||
}
|
||||
ddsrt_mutex_unlock (&wr->m_entity.m_observers_lock);
|
||||
dds_writer_unlock(wr);
|
||||
fail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
dds_get_offered_deadline_missed_status(
|
||||
dds_entity_t writer,
|
||||
dds_offered_deadline_missed_status_t *status)
|
||||
{
|
||||
dds_retcode_t rc;
|
||||
dds_writer *wr;
|
||||
dds_return_t ret = DDS_RETCODE_OK;
|
||||
|
||||
rc = dds_writer_lock(writer, &wr);
|
||||
if (rc != DDS_RETCODE_OK) {
|
||||
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 */
|
||||
if (status) {
|
||||
*status = wr->m_offered_deadline_missed_status;
|
||||
}
|
||||
ddsrt_mutex_lock (&wr->m_entity.m_observers_lock);
|
||||
if (wr->m_entity.m_status_enable & DDS_OFFERED_DEADLINE_MISSED_STATUS) {
|
||||
wr->m_offered_deadline_missed_status.total_count_change = 0;
|
||||
dds_entity_status_reset(&wr->m_entity, DDS_OFFERED_DEADLINE_MISSED_STATUS);
|
||||
}
|
||||
ddsrt_mutex_unlock (&wr->m_entity.m_observers_lock);
|
||||
dds_writer_unlock(wr);
|
||||
fail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
dds_get_offered_incompatible_qos_status (
|
||||
dds_entity_t writer,
|
||||
dds_offered_incompatible_qos_status_t * status)
|
||||
{
|
||||
dds_retcode_t rc;
|
||||
dds_writer *wr;
|
||||
dds_return_t ret = DDS_RETCODE_OK;
|
||||
|
||||
rc = dds_writer_lock(writer, &wr);
|
||||
if (rc != DDS_RETCODE_OK) {
|
||||
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 */
|
||||
if (status) {
|
||||
*status = wr->m_offered_incompatible_qos_status;
|
||||
}
|
||||
ddsrt_mutex_lock (&wr->m_entity.m_observers_lock);
|
||||
if (wr->m_entity.m_status_enable & DDS_OFFERED_INCOMPATIBLE_QOS_STATUS) {
|
||||
wr->m_offered_incompatible_qos_status.total_count_change = 0;
|
||||
dds_entity_status_reset(&wr->m_entity, DDS_OFFERED_INCOMPATIBLE_QOS_STATUS);
|
||||
}
|
||||
ddsrt_mutex_unlock (&wr->m_entity.m_observers_lock);
|
||||
dds_writer_unlock(wr);
|
||||
fail:
|
||||
return ret;
|
||||
}
|
||||
DDS_GET_STATUS(writer, publication_matched, PUBLICATION_MATCHED, total_count_change, current_count_change)
|
||||
DDS_GET_STATUS(writer, liveliness_lost, LIVELINESS_LOST, total_count_change)
|
||||
DDS_GET_STATUS(writer, offered_deadline_missed, OFFERED_DEADLINE_MISSED, total_count_change)
|
||||
DDS_GET_STATUS(writer, offered_incompatible_qos, OFFERED_INCOMPATIBLE_QOS, total_count_change)
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ static void config__check_env(
|
|||
}
|
||||
|
||||
if ( !env_ok ) {
|
||||
dds_retcode_t r;
|
||||
dds_return_t r;
|
||||
|
||||
r = ddsrt_setenv(env_variable, expected_value);
|
||||
CU_ASSERT_EQUAL_FATAL(r, DDS_RETCODE_OK);
|
||||
|
|
|
|||
|
|
@ -13,24 +13,23 @@
|
|||
<CycloneDDS>
|
||||
<!-- Simple config-file for testing whether a config-file can be picked up
|
||||
correctly. -->
|
||||
<Domain>
|
||||
<Id>3</Id>
|
||||
<Domain id="3">
|
||||
<General>
|
||||
<NetworkInterfaceAddress>127.0.0.1</NetworkInterfaceAddress>
|
||||
<AllowMulticast>true</AllowMulticast>
|
||||
<EnableMulticastLoopback>true</EnableMulticastLoopback>
|
||||
</General>
|
||||
<Compatibility>
|
||||
<StandardsConformance>lax</StandardsConformance>
|
||||
</Compatibility>
|
||||
<Tracing>
|
||||
<Verbosity>warning</Verbosity>
|
||||
<OutputFile>vortexdds-<![CDATA[trace]]>.${NON_EXISTENT_ENV_VARIABLE:-l}${CYCLONEDDS_URI:+o}g </OutputFile>
|
||||
</Tracing>
|
||||
<Internal>
|
||||
<MaxParticipants>${MAX_PARTICIPANTS}</MaxParticipants>
|
||||
<HeartbeatInterval max="10 s"> 100 ms </HeartbeatInterval>
|
||||
<RediscoveryBlacklistDuration></RediscoveryBlacklistDuration>
|
||||
</Internal>
|
||||
</Domain>
|
||||
<General>
|
||||
<NetworkInterfaceAddress>127.0.0.1</NetworkInterfaceAddress>
|
||||
<AllowMulticast>true</AllowMulticast>
|
||||
<EnableMulticastLoopback>true</EnableMulticastLoopback>
|
||||
</General>
|
||||
<Compatibility>
|
||||
<StandardsConformance>lax</StandardsConformance>
|
||||
</Compatibility>
|
||||
<Tracing>
|
||||
<Verbosity>warning</Verbosity>
|
||||
<OutputFile>vortexdds-<![CDATA[trace]]>.${NON_EXISTENT_ENV_VARIABLE:-l}${CYCLONEDDS_URI:+o}g </OutputFile>
|
||||
</Tracing>
|
||||
<Internal>
|
||||
<MaxParticipants>${MAX_PARTICIPANTS}</MaxParticipants>
|
||||
<HeartbeatInterval max="10 s"> 100 ms </HeartbeatInterval>
|
||||
<RediscoveryBlacklistDuration></RediscoveryBlacklistDuration>
|
||||
</Internal>
|
||||
</CycloneDDS>
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ CU_Test(ddsc_writedispose, deleted, .init=disposing_init, .fini=disposing_fini)
|
|||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_writedispose(g_writer, NULL);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -164,7 +164,7 @@ CU_Test(ddsc_writedispose, null, .init=disposing_init, .fini=disposing_fini)
|
|||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_writedispose(g_writer, NULL);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -174,13 +174,12 @@ CU_TheoryDataPoints(ddsc_writedispose, invalid_writers) = {
|
|||
};
|
||||
CU_Theory((dds_entity_t writer), ddsc_writedispose, invalid_writers, .init=disposing_init, .fini=disposing_fini)
|
||||
{
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
dds_return_t ret;
|
||||
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_writedispose(writer, NULL);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -194,7 +193,7 @@ CU_Theory((dds_entity_t *writer), ddsc_writedispose, non_writers, .init=disposin
|
|||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_writedispose(*writer, NULL);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -290,7 +289,7 @@ CU_Test(ddsc_writedispose, timeout, .init=disposing_init, .fini=disposing_fini)
|
|||
ret = dds_writedispose(g_writer, &newInstance1);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
ret = dds_writedispose(g_writer, &newInstance2);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_TIMEOUT);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_TIMEOUT);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -310,7 +309,7 @@ CU_Test(ddsc_writedispose_ts, deleted, .init=disposing_init, .fini=disposing_fin
|
|||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_writedispose_ts(g_writer, NULL, g_present);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -321,7 +320,7 @@ CU_Test(ddsc_writedispose_ts, null, .init=disposing_init, .fini=disposing_fini)
|
|||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_writedispose_ts(g_writer, NULL, g_present);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -335,7 +334,7 @@ CU_Test(ddsc_writedispose_ts, timeout, .init=disposing_init, .fini=disposing_fin
|
|||
ret = dds_writedispose_ts(g_writer, &newInstance1, g_present);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
ret = dds_writedispose_ts(g_writer, &newInstance2, g_present);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_TIMEOUT);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_TIMEOUT);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -345,13 +344,12 @@ CU_TheoryDataPoints(ddsc_writedispose_ts, invalid_writers) = {
|
|||
};
|
||||
CU_Theory((dds_entity_t writer), ddsc_writedispose_ts, invalid_writers, .init=disposing_init, .fini=disposing_fini)
|
||||
{
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
dds_return_t ret;
|
||||
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_writedispose_ts(writer, NULL, g_present);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -365,7 +363,7 @@ CU_Theory((dds_entity_t *writer), ddsc_writedispose_ts, non_writers, .init=dispo
|
|||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_writedispose_ts(*writer, NULL, g_present);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -510,7 +508,7 @@ CU_Test(ddsc_dispose, deleted, .init=disposing_init, .fini=disposing_fini)
|
|||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_dispose(g_writer, NULL);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -521,7 +519,7 @@ CU_Test(ddsc_dispose, null, .init=disposing_init, .fini=disposing_fini)
|
|||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_dispose(g_writer, NULL);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -535,7 +533,7 @@ CU_Test(ddsc_dispose, timeout, .init=disposing_init, .fini=disposing_fini)
|
|||
ret = dds_dispose(g_writer, &newInstance1);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
ret = dds_dispose(g_writer, &newInstance2);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_TIMEOUT);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_TIMEOUT);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -545,13 +543,12 @@ CU_TheoryDataPoints(ddsc_dispose, invalid_writers) = {
|
|||
};
|
||||
CU_Theory((dds_entity_t writer), ddsc_dispose, invalid_writers, .init=disposing_init, .fini=disposing_fini)
|
||||
{
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
dds_return_t ret;
|
||||
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_dispose(writer, NULL);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -563,9 +560,10 @@ CU_Theory((dds_entity_t *writer), ddsc_dispose, non_writers, .init=disposing_ini
|
|||
{
|
||||
dds_return_t ret;
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_dispose(*writer, NULL);
|
||||
/* pass a non-null pointer that'll trigger a crash if it is read */
|
||||
ret = dds_dispose(*writer, (void *) 1);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -665,7 +663,7 @@ CU_Test(ddsc_dispose_ts, deleted, .init=disposing_init, .fini=disposing_fini)
|
|||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_dispose_ts(g_writer, NULL, g_present);
|
||||
DDSRT_WARNING_MSVC_ON(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -676,7 +674,7 @@ CU_Test(ddsc_dispose_ts, null, .init=disposing_init, .fini=disposing_fini)
|
|||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_dispose_ts(g_writer, NULL, g_present);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -690,7 +688,7 @@ CU_Test(ddsc_dispose_ts, timeout, .init=disposing_init, .fini=disposing_fini)
|
|||
ret = dds_dispose_ts(g_writer, &newInstance1, g_present);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
ret = dds_dispose_ts(g_writer, &newInstance2, g_present);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_TIMEOUT);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_TIMEOUT);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -700,13 +698,12 @@ CU_TheoryDataPoints(ddsc_dispose_ts, invalid_writers) = {
|
|||
};
|
||||
CU_Theory((dds_entity_t writer), ddsc_dispose_ts, invalid_writers, .init=disposing_init, .fini=disposing_fini)
|
||||
{
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
dds_return_t ret;
|
||||
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_dispose_ts(writer, NULL, g_present);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -718,9 +715,10 @@ CU_Theory((dds_entity_t *writer), ddsc_dispose_ts, non_writers, .init=disposing_
|
|||
{
|
||||
dds_return_t ret;
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_dispose_ts(*writer, NULL, g_present);
|
||||
/* pass a non-null pointer that'll trigger a crash if it is read */
|
||||
ret = dds_dispose_ts(*writer, (void *) 1, g_present);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -861,7 +859,7 @@ CU_Test(ddsc_dispose_ih, deleted, .init=disposing_init, .fini=disposing_fini)
|
|||
dds_return_t ret;
|
||||
dds_delete(g_writer);
|
||||
ret = dds_dispose_ih(g_writer, DDS_HANDLE_NIL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -873,7 +871,7 @@ CU_Theory((dds_instance_handle_t handle), ddsc_dispose_ih, invalid_handles, .ini
|
|||
{
|
||||
dds_return_t ret;
|
||||
ret = dds_dispose_ih(g_writer, handle);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -883,11 +881,10 @@ CU_TheoryDataPoints(ddsc_dispose_ih, invalid_writers) = {
|
|||
};
|
||||
CU_Theory((dds_entity_t writer), ddsc_dispose_ih, invalid_writers, .init=disposing_init, .fini=disposing_fini)
|
||||
{
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
dds_return_t ret;
|
||||
|
||||
ret = dds_dispose_ih(writer, DDS_HANDLE_NIL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -899,7 +896,7 @@ CU_Theory((dds_entity_t *writer), ddsc_dispose_ih, non_writers, .init=disposing_
|
|||
{
|
||||
dds_return_t ret;
|
||||
ret = dds_dispose_ih(*writer, DDS_HANDLE_NIL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -959,7 +956,7 @@ CU_Test(ddsc_dispose_ih_ts, deleted, .init=disposing_init, .fini=disposing_fini)
|
|||
dds_return_t ret;
|
||||
dds_delete(g_writer);
|
||||
ret = dds_dispose_ih_ts(g_writer, DDS_HANDLE_NIL, g_present);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -971,7 +968,7 @@ CU_Theory((dds_instance_handle_t handle), ddsc_dispose_ih_ts, invalid_handles, .
|
|||
{
|
||||
dds_return_t ret;
|
||||
ret = dds_dispose_ih_ts(g_writer, handle, g_present);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -981,11 +978,10 @@ CU_TheoryDataPoints(ddsc_dispose_ih_ts, invalid_writers) = {
|
|||
};
|
||||
CU_Theory((dds_entity_t writer), ddsc_dispose_ih_ts, invalid_writers, .init=disposing_init, .fini=disposing_fini)
|
||||
{
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
dds_return_t ret;
|
||||
|
||||
ret = dds_dispose_ih_ts(writer, DDS_HANDLE_NIL, g_present);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -997,7 +993,7 @@ CU_Theory((dds_entity_t *writer), ddsc_dispose_ih_ts, non_writers, .init=disposi
|
|||
{
|
||||
dds_return_t ret;
|
||||
ret = dds_dispose_ih_ts(*writer, DDS_HANDLE_NIL, g_present);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
|
|||
|
|
@ -23,10 +23,8 @@
|
|||
|
||||
static dds_entity_t entity = -1;
|
||||
|
||||
#define cu_assert_status_eq(s1, s2) CU_ASSERT_FATAL(dds_err_nr(s1)== s2)
|
||||
|
||||
/* Fixture to create prerequisite entity */
|
||||
void create_entity(void)
|
||||
static void create_entity(void)
|
||||
{
|
||||
CU_ASSERT_EQUAL_FATAL(entity, -1);
|
||||
entity = dds_create_participant(DDS_DOMAIN_DEFAULT, NULL, NULL);
|
||||
|
|
@ -34,11 +32,11 @@ void create_entity(void)
|
|||
}
|
||||
|
||||
/* Fixture to delete prerequisite entity */
|
||||
void delete_entity(void)
|
||||
static void delete_entity(void)
|
||||
{
|
||||
CU_ASSERT_FATAL(entity > 0);
|
||||
dds_return_t ret = dds_delete(entity);
|
||||
cu_assert_status_eq(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
entity = -1;
|
||||
}
|
||||
|
||||
|
|
@ -55,20 +53,20 @@ CU_Test(ddsc_entity, enable, .init = create_entity, .fini = delete_entity)
|
|||
|
||||
/* Check enabling with bad parameters. */
|
||||
status = dds_enable(0);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
|
||||
/* Check actual enabling. */
|
||||
/* TODO: CHAM-96: Check enabling.
|
||||
status = dds_enable(&entity);
|
||||
cu_assert_status_eq(status, dds_err_nr(DDS_RETCODE_OK), "dds_enable (delayed enable)");
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_OK, "dds_enable (delayed enable)");
|
||||
*/
|
||||
|
||||
/* Check re-enabling (should be a noop). */
|
||||
status = dds_enable(entity);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_OK);
|
||||
}
|
||||
|
||||
void entity_qos_get_set(dds_entity_t e, const char* info)
|
||||
static void entity_qos_get_set(dds_entity_t e, const char* info)
|
||||
{
|
||||
dds_return_t status;
|
||||
dds_qos_t *qos = dds_create_qos();
|
||||
|
|
@ -77,10 +75,10 @@ void entity_qos_get_set(dds_entity_t e, const char* info)
|
|||
|
||||
/* Get QoS. */
|
||||
status = dds_get_qos (e, qos);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_OK);
|
||||
|
||||
status = dds_set_qos (e, qos); /* Doesn't change anything, so no need to forbid. But we return NOT_SUPPORTED anyway for now*/
|
||||
cu_assert_status_eq(status, DDS_RETCODE_UNSUPPORTED);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_OK);
|
||||
|
||||
dds_delete_qos(qos);
|
||||
}
|
||||
|
|
@ -95,19 +93,19 @@ CU_Test(ddsc_entity, qos, .init = create_entity, .fini = delete_entity)
|
|||
|
||||
/* Check getting QoS with bad parameters. */
|
||||
status = dds_get_qos (0, NULL);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
status = dds_get_qos (entity, NULL);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
status = dds_get_qos (0, qos);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
|
||||
/* Check setting QoS with bad parameters. */
|
||||
status = dds_set_qos (0, NULL);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
status = dds_set_qos (entity, NULL);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
status = dds_set_qos (0, qos);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
|
||||
/* Check set/get with entity without initial qos. */
|
||||
entity_qos_get_set(entity, "{without initial qos}");
|
||||
|
|
@ -145,15 +143,15 @@ CU_Test(ddsc_entity, listener, .init = create_entity, .fini = delete_entity)
|
|||
|
||||
/* Check getting Listener with bad parameters. */
|
||||
status = dds_get_listener (0, NULL);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
status = dds_get_listener (entity, NULL);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
status = dds_get_listener (0, l1);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
|
||||
/* Get Listener, which should be unset. */
|
||||
status = dds_get_listener (entity, l1);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_OK);
|
||||
dds_lget_liveliness_changed (l1, (dds_on_liveliness_changed_fn*)&cb1);
|
||||
CU_ASSERT_EQUAL_FATAL(cb1, DDS_LUNSET);
|
||||
dds_lget_requested_deadline_missed (l1, (dds_on_requested_deadline_missed_fn*)&cb1);
|
||||
|
|
@ -165,15 +163,15 @@ CU_Test(ddsc_entity, listener, .init = create_entity, .fini = delete_entity)
|
|||
|
||||
/* Check setting Listener with bad parameters. */
|
||||
status = dds_set_listener (0, NULL);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
status = dds_set_listener (0, l2);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
|
||||
/* Getting after setting should return set listener. */
|
||||
status = dds_set_listener (entity, l2);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_OK);
|
||||
status = dds_get_listener (entity, l1);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_OK);
|
||||
dds_lget_liveliness_changed (l1, (dds_on_liveliness_changed_fn*)&cb1);
|
||||
dds_lget_liveliness_changed (l2, (dds_on_liveliness_changed_fn*)&cb2);
|
||||
CU_ASSERT_EQUAL_FATAL(cb1, cb2);
|
||||
|
|
@ -189,9 +187,9 @@ CU_Test(ddsc_entity, listener, .init = create_entity, .fini = delete_entity)
|
|||
|
||||
/* Reset listener. */
|
||||
status = dds_set_listener (entity, NULL);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_OK);
|
||||
status = dds_get_listener (entity, l2);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_OK);
|
||||
dds_lget_liveliness_changed (l2, (dds_on_liveliness_changed_fn*)&cb2);
|
||||
CU_ASSERT_EQUAL_FATAL(cb2, DDS_LUNSET);
|
||||
dds_lget_requested_deadline_missed (l2, (dds_on_requested_deadline_missed_fn*)&cb2);
|
||||
|
|
@ -215,46 +213,46 @@ CU_Test(ddsc_entity, status, .init = create_entity, .fini = delete_entity)
|
|||
|
||||
/* Check getting Status with bad parameters. */
|
||||
status1 = dds_get_status_mask (0, NULL);
|
||||
cu_assert_status_eq(status1, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status1, DDS_RETCODE_BAD_PARAMETER);
|
||||
status1 = dds_get_status_mask (entity, NULL);
|
||||
cu_assert_status_eq(status1, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status1, DDS_RETCODE_BAD_PARAMETER);
|
||||
status1 = dds_get_status_mask (0, &s1);
|
||||
cu_assert_status_eq(status1, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status1, DDS_RETCODE_BAD_PARAMETER);
|
||||
|
||||
/* Get Status, which should be 0 for a participant. */
|
||||
status1 = dds_get_status_mask (entity, &s1);
|
||||
cu_assert_status_eq(status1, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status1, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(s1, 0);
|
||||
|
||||
/* Check setting Status with bad parameters. */
|
||||
status1 = dds_set_status_mask (0, 0);
|
||||
cu_assert_status_eq(status1, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status1, DDS_RETCODE_BAD_PARAMETER);
|
||||
|
||||
/* I shouldn't be able to set statuses on a participant. */
|
||||
status1 = dds_set_status_mask (entity, 0);
|
||||
cu_assert_status_eq(status1, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status1, DDS_RETCODE_OK);
|
||||
status1 = dds_set_status_mask (entity, DDS_DATA_AVAILABLE_STATUS);
|
||||
cu_assert_status_eq(status1, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status1, DDS_RETCODE_BAD_PARAMETER);
|
||||
|
||||
/* Check getting Status changes with bad parameters. */
|
||||
status1 = dds_get_status_changes (0, NULL);
|
||||
cu_assert_status_eq(status1, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status1, DDS_RETCODE_BAD_PARAMETER);
|
||||
status1 = dds_get_status_changes (entity, NULL);
|
||||
cu_assert_status_eq(status1, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status1, DDS_RETCODE_BAD_PARAMETER);
|
||||
status1 = dds_get_status_changes (0, &s1);
|
||||
cu_assert_status_eq(status1, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status1, DDS_RETCODE_BAD_PARAMETER);
|
||||
status1 = dds_get_status_changes (entity, &s1);
|
||||
cu_assert_status_eq(status1, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status1, DDS_RETCODE_OK);
|
||||
|
||||
/* Status read and take shouldn't work either. */
|
||||
status1 = dds_read_status (0, &s1, 0);
|
||||
cu_assert_status_eq(status1, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status1, DDS_RETCODE_BAD_PARAMETER);
|
||||
status1 = dds_read_status (entity, &s1, 0);
|
||||
cu_assert_status_eq(status1, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status1, DDS_RETCODE_OK);
|
||||
status1 = dds_take_status (0, &s1, 0);
|
||||
cu_assert_status_eq(status1, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status1, DDS_RETCODE_BAD_PARAMETER);
|
||||
status1 = dds_take_status (entity, &s1, 0);
|
||||
cu_assert_status_eq(status1, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status1, DDS_RETCODE_OK);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -268,15 +266,15 @@ CU_Test(ddsc_entity, instance_handle, .init = create_entity, .fini = delete_enti
|
|||
|
||||
/* Check getting Handle with bad parameters. */
|
||||
status = dds_get_instance_handle (0, NULL);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
status = dds_get_instance_handle (entity, NULL);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
status = dds_get_instance_handle (0, &hdl);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
|
||||
/* Get Instance Handle, which should not be 0 for a participant. */
|
||||
status = dds_get_instance_handle (entity, &hdl);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_NOT_EQUAL_FATAL(hdl, 0);
|
||||
}
|
||||
|
||||
|
|
@ -290,17 +288,17 @@ CU_Test(ddsc_entity, get_entities, .init = create_entity, .fini = delete_entity)
|
|||
|
||||
/* Check getting Parent with bad parameters. */
|
||||
par = dds_get_parent (0);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(par), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(par, DDS_RETCODE_BAD_PARAMETER);
|
||||
|
||||
/* Get Parent, a participant doesn't have a parent. */
|
||||
par = dds_get_parent (entity);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(par), DDS_ENTITY_NIL);
|
||||
CU_ASSERT_EQUAL_FATAL(par, DDS_ENTITY_NIL);
|
||||
|
||||
/* ---------- Get Participant ------------ */
|
||||
|
||||
/* Check getting Participant with bad parameters. */
|
||||
par = dds_get_participant (0);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(par), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(par, DDS_RETCODE_BAD_PARAMETER);
|
||||
|
||||
/* Get Participant, a participants' participant is itself. */
|
||||
par = dds_get_participant (entity);
|
||||
|
|
@ -310,15 +308,15 @@ CU_Test(ddsc_entity, get_entities, .init = create_entity, .fini = delete_entity)
|
|||
|
||||
/* Check getting Children with bad parameters. */
|
||||
status = dds_get_children (0, &child, 1);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
status = dds_get_children (entity, NULL, 1);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
status = dds_get_children (entity, &child, 0);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
status = dds_get_children (0, NULL, 1);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
status = dds_get_children (0, &child, 0);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
|
||||
/* Get Children, of which there are currently none. */
|
||||
status = dds_get_children (entity, NULL, 0);
|
||||
|
|
@ -338,30 +336,30 @@ CU_Test(ddsc_entity, get_entities, .init = create_entity, .fini = delete_entity)
|
|||
CU_Test(ddsc_entity, get_domainid, .init = create_entity, .fini = delete_entity)
|
||||
{
|
||||
dds_return_t status;
|
||||
dds_domainid_t id = -1;
|
||||
dds_domainid_t id = DDS_DOMAIN_DEFAULT;
|
||||
|
||||
/* Check getting ID with bad parameters. */
|
||||
status = dds_get_domainid (0, NULL);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
status = dds_get_domainid (entity, NULL);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
status = dds_get_domainid (0, &id);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
|
||||
/* Get and check the domain id. */
|
||||
status = dds_get_domainid (entity, &id);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_FATAL(id != -1);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_FATAL(id != DDS_DOMAIN_DEFAULT);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_entity, delete, .init = create_entity)
|
||||
{
|
||||
dds_return_t status;
|
||||
status = dds_delete(0);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
|
||||
status = dds_delete(entity);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_OK);
|
||||
entity = 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -125,43 +125,43 @@ CU_Test(ddsc_entity_delete, recursive, .init=hierarchy_init, .fini=hierarchy_fin
|
|||
|
||||
/* First be sure that 'dds_get_domainid' returns ok. */
|
||||
ret = dds_get_domainid(g_participant, &id);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
ret = dds_get_domainid(g_topic, &id);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
ret = dds_get_domainid(g_publisher, &id);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
ret = dds_get_domainid(g_subscriber, &id);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
ret = dds_get_domainid(g_writer, &id);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
ret = dds_get_domainid(g_reader, &id);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
ret = dds_get_domainid(g_readcond, &id);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
ret = dds_get_domainid(g_querycond, &id);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
|
||||
/* Deleting the top dog (participant) should delete all children. */
|
||||
ret = dds_delete(g_participant);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
|
||||
/* Check if all the entities are deleted now. */
|
||||
ret = dds_get_domainid(g_participant, &id);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
ret = dds_get_domainid(g_topic, &id);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
ret = dds_get_domainid(g_publisher, &id);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
ret = dds_get_domainid(g_subscriber, &id);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
ret = dds_get_domainid(g_writer, &id);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
ret = dds_get_domainid(g_reader, &id);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
ret = dds_get_domainid(g_readcond, &id);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
ret = dds_get_domainid(g_querycond, &id);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -190,22 +190,22 @@ CU_Test(ddsc_entity_delete, recursive_with_deleted_topic)
|
|||
* reference to the topic and thus will delete it when it itself is
|
||||
* deleted. */
|
||||
ret = dds_delete(g_topic);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
|
||||
/* Third, deleting the participant should delete all children of which
|
||||
* the writer with the last topic reference is one. */
|
||||
ret = dds_delete(g_participant);
|
||||
/* Before the CHAM-424 fix, we would not get here because of a crash,
|
||||
* or it (incidentally) continued but returned an error. */
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
|
||||
/* Check if the entities are actually deleted. */
|
||||
ret = dds_get_domainid(g_participant, &id);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER );
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER );
|
||||
ret = dds_get_domainid(g_topic, &id);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
ret = dds_get_domainid(g_writer, &id);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
|
||||
dds_delete(g_keep);
|
||||
}
|
||||
|
|
@ -240,7 +240,7 @@ CU_Theory((dds_entity_t *entity), ddsc_entity_get_participant, deleted_entities,
|
|||
dds_entity_t participant;
|
||||
dds_delete(*entity);
|
||||
participant = dds_get_participant(*entity);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(participant), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(participant, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -250,11 +250,10 @@ CU_TheoryDataPoints(ddsc_entity_get_participant, invalid_entities) = {
|
|||
};
|
||||
CU_Theory((dds_entity_t entity), ddsc_entity_get_participant, invalid_entities, .init=hierarchy_init, .fini=hierarchy_fini)
|
||||
{
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
dds_entity_t participant;
|
||||
|
||||
participant = dds_get_participant(entity);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(participant), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(participant, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -314,7 +313,7 @@ CU_Test(ddsc_entity_get_parent, participant, .init=hierarchy_init, .fini=hierarc
|
|||
{
|
||||
dds_entity_t parent;
|
||||
parent = dds_get_parent(g_participant);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(parent), DDS_ENTITY_NIL);
|
||||
CU_ASSERT_EQUAL_FATAL(parent, DDS_ENTITY_NIL);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -327,7 +326,7 @@ CU_Theory((dds_entity_t *entity), ddsc_entity_get_parent, deleted_entities, .ini
|
|||
dds_entity_t parent;
|
||||
dds_delete(*entity);
|
||||
parent = dds_get_parent(*entity);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(parent), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(parent, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -337,11 +336,10 @@ CU_TheoryDataPoints(ddsc_entity_get_parent, invalid_entities) = {
|
|||
};
|
||||
CU_Theory((dds_entity_t entity), ddsc_entity_get_parent, invalid_entities, .init=hierarchy_init, .fini=hierarchy_fini)
|
||||
{
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
dds_entity_t parent;
|
||||
|
||||
parent = dds_get_parent(entity);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(parent), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(parent, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -369,7 +367,7 @@ CU_Test(ddsc_entity_get_children, invalid_size, .init=hierarchy_init, .fini=hier
|
|||
dds_return_t ret;
|
||||
dds_entity_t child;
|
||||
ret = dds_get_children(g_participant, &child, INT32_MAX);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -478,7 +476,7 @@ CU_Theory((dds_entity_t *entity), ddsc_entity_get_children, deleted_entities, .i
|
|||
dds_entity_t children[4];
|
||||
dds_delete(*entity);
|
||||
ret = dds_get_children(*entity, children, 4);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -488,12 +486,11 @@ CU_TheoryDataPoints(ddsc_entity_get_children, invalid_entities) = {
|
|||
};
|
||||
CU_Theory((dds_entity_t entity), ddsc_entity_get_children, invalid_entities, .init=hierarchy_init, .fini=hierarchy_fini)
|
||||
{
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
dds_entity_t children[4];
|
||||
dds_return_t ret;
|
||||
|
||||
ret = dds_get_children(entity, children, 4);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -527,7 +524,7 @@ CU_Theory((dds_entity_t *entity), ddsc_entity_get_topic, deleted_entities, .init
|
|||
dds_entity_t topic;
|
||||
dds_delete(*entity);
|
||||
topic = dds_get_topic(*entity);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(topic), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(topic, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -537,11 +534,10 @@ CU_TheoryDataPoints(ddsc_entity_get_topic, invalid_entities) = {
|
|||
};
|
||||
CU_Theory((dds_entity_t entity), ddsc_entity_get_topic, invalid_entities, .init=hierarchy_init, .fini=hierarchy_fini)
|
||||
{
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
dds_entity_t topic;
|
||||
|
||||
topic = dds_get_topic(entity);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(topic), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(topic, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -553,7 +549,7 @@ CU_Theory((dds_entity_t *entity), ddsc_entity_get_topic, non_data_entities, .ini
|
|||
{
|
||||
dds_entity_t topic;
|
||||
topic = dds_get_topic(*entity);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(topic), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(topic, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -581,7 +577,7 @@ CU_Test(ddsc_entity_get_publisher, deleted_writer, .init=hierarchy_init, .fini=h
|
|||
dds_entity_t publisher;
|
||||
dds_delete(g_writer);
|
||||
publisher = dds_get_publisher(g_writer);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(publisher), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(publisher, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -591,11 +587,10 @@ CU_TheoryDataPoints(ddsc_entity_get_publisher, invalid_writers) = {
|
|||
};
|
||||
CU_Theory((dds_entity_t entity), ddsc_entity_get_publisher, invalid_writers, .init=hierarchy_init, .fini=hierarchy_fini)
|
||||
{
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
dds_entity_t publisher;
|
||||
|
||||
publisher = dds_get_publisher(entity);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(publisher), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(publisher, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -607,7 +602,7 @@ CU_Theory((dds_entity_t *cond), ddsc_entity_get_publisher, non_writers, .init=hi
|
|||
{
|
||||
dds_entity_t publisher;
|
||||
publisher = dds_get_publisher(*cond);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(publisher), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(publisher, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -640,7 +635,7 @@ CU_Theory((dds_entity_t *entity), ddsc_entity_get_subscriber, deleted_readers, .
|
|||
dds_entity_t subscriber;
|
||||
dds_delete(*entity);
|
||||
subscriber = dds_get_subscriber(*entity);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(subscriber), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(subscriber, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -650,11 +645,10 @@ CU_TheoryDataPoints(ddsc_entity_get_subscriber, invalid_readers) = {
|
|||
};
|
||||
CU_Theory((dds_entity_t entity), ddsc_entity_get_subscriber, invalid_readers, .init=hierarchy_init, .fini=hierarchy_fini)
|
||||
{
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
dds_entity_t subscriber;
|
||||
|
||||
subscriber = dds_get_subscriber(entity);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(subscriber), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(subscriber, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -666,7 +660,7 @@ CU_Theory((dds_entity_t *cond), ddsc_entity_get_subscriber, non_readers, .init=h
|
|||
{
|
||||
dds_entity_t subscriber;
|
||||
subscriber = dds_get_subscriber(*cond);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(subscriber), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(subscriber, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -701,7 +695,7 @@ CU_Theory((dds_entity_t *cond), ddsc_entity_get_datareader, deleted_conds, .init
|
|||
dds_entity_t reader;
|
||||
dds_delete(*cond);
|
||||
reader = dds_get_datareader(*cond);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(reader), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(reader, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -711,11 +705,10 @@ CU_TheoryDataPoints(ddsc_entity_get_datareader, invalid_conds) = {
|
|||
};
|
||||
CU_Theory((dds_entity_t cond), ddsc_entity_get_datareader, invalid_conds, .init=hierarchy_init, .fini=hierarchy_fini)
|
||||
{
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
dds_entity_t reader;
|
||||
|
||||
reader = dds_get_datareader(cond);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(reader), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(reader, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -727,7 +720,7 @@ CU_Theory((dds_entity_t *cond), ddsc_entity_get_datareader, non_conds, .init=hie
|
|||
{
|
||||
dds_entity_t reader;
|
||||
reader = dds_get_datareader(*cond);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(reader), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(reader, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
|
||||
/*************************************************************************************************/
|
||||
|
|
@ -954,7 +947,7 @@ CU_Test(ddsc_entity_get_parent, implicit_publisher)
|
|||
dds_delete(writer);
|
||||
|
||||
ret = dds_delete(parent);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
dds_delete(participant);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
|
@ -985,7 +978,7 @@ CU_Test(ddsc_entity_get_parent, implicit_subscriber)
|
|||
dds_delete(reader);
|
||||
|
||||
ret = dds_delete(parent);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
dds_delete(participant);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,14 @@ static dds_time_t waitTimeout = DDS_SECS (2);
|
|||
static dds_time_t shortTimeout = DDS_MSECS (10);
|
||||
static dds_publication_matched_status_t publication_matched;
|
||||
static dds_subscription_matched_status_t subscription_matched;
|
||||
static dds_resource_limits_qospolicy_t resource_limits = {1,1,1};
|
||||
|
||||
struct reslimits {
|
||||
int32_t max_samples;
|
||||
int32_t max_instances;
|
||||
int32_t max_samples_per_instance;
|
||||
};
|
||||
|
||||
static struct reslimits resource_limits = {1,1,1};
|
||||
|
||||
static dds_instance_handle_t reader_i_hdl = 0;
|
||||
static dds_instance_handle_t writer_i_hdl = 0;
|
||||
|
|
@ -138,10 +145,19 @@ CU_Test(ddsc_entity_status, publication_matched, .init=init_entity_status, .fini
|
|||
CU_ASSERT_EQUAL_FATAL(publication_matched.total_count_change, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(publication_matched.last_subscription_handle, reader_i_hdl);
|
||||
|
||||
/* Second call should reset the changed count. */
|
||||
ret = dds_get_publication_matched_status(wri, &publication_matched);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(publication_matched.current_count, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(publication_matched.current_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(publication_matched.total_count, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(publication_matched.total_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(publication_matched.last_subscription_handle, reader_i_hdl);
|
||||
|
||||
/* Getting the status should have reset the trigger,
|
||||
* meaning that the wait should timeout. */
|
||||
ret = dds_waitset_wait(waitSetwr, wsresults, wsresultsize, shortTimeout);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), 0);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, 0);
|
||||
|
||||
/* Un-match the publication by deleting the reader. */
|
||||
dds_delete(rea);
|
||||
|
|
@ -156,6 +172,15 @@ CU_Test(ddsc_entity_status, publication_matched, .init=init_entity_status, .fini
|
|||
CU_ASSERT_EQUAL_FATAL(publication_matched.total_count, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(publication_matched.total_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(publication_matched.last_subscription_handle, reader_i_hdl);
|
||||
|
||||
/* Second call should reset the changed count. */
|
||||
ret = dds_get_publication_matched_status(wri, &publication_matched);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(publication_matched.current_count, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(publication_matched.current_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(publication_matched.total_count, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(publication_matched.total_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(publication_matched.last_subscription_handle, reader_i_hdl);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_entity_status, subscription_matched, .init=init_entity_status, .fini=fini_entity_status)
|
||||
|
|
@ -175,10 +200,19 @@ CU_Test(ddsc_entity_status, subscription_matched, .init=init_entity_status, .fin
|
|||
CU_ASSERT_EQUAL_FATAL(subscription_matched.total_count_change, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(subscription_matched.last_publication_handle, writer_i_hdl);
|
||||
|
||||
/* Second call should reset the changed count. */
|
||||
ret = dds_get_subscription_matched_status(rea, &subscription_matched);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(subscription_matched.current_count, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(subscription_matched.current_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(subscription_matched.total_count, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(subscription_matched.total_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(subscription_matched.last_publication_handle, writer_i_hdl);
|
||||
|
||||
/* Getting the status should have reset the trigger,
|
||||
* meaning that the wait should timeout. */
|
||||
ret = dds_waitset_wait(waitSetrd, wsresults, wsresultsize, shortTimeout);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), 0);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, 0);
|
||||
|
||||
/* Un-match the subscription by deleting the writer. */
|
||||
dds_delete(wri);
|
||||
|
|
@ -193,6 +227,15 @@ CU_Test(ddsc_entity_status, subscription_matched, .init=init_entity_status, .fin
|
|||
CU_ASSERT_EQUAL_FATAL(subscription_matched.total_count, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(subscription_matched.total_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(subscription_matched.last_publication_handle, writer_i_hdl);
|
||||
|
||||
/* Second call should reset the changed count. */
|
||||
ret = dds_get_subscription_matched_status(rea, &subscription_matched);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(subscription_matched.current_count, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(subscription_matched.current_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(subscription_matched.total_count, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(subscription_matched.total_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(subscription_matched.last_publication_handle, writer_i_hdl);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_entity, incompatible_qos, .init=init_entity_status, .fini=fini_entity_status)
|
||||
|
|
@ -231,9 +274,16 @@ CU_Test(ddsc_entity, incompatible_qos, .init=init_entity_status, .fini=fini_enti
|
|||
CU_ASSERT_EQUAL_FATAL(req_incompatible_qos.total_count_change, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(req_incompatible_qos.last_policy_id, DDS_DURABILITY_QOS_POLICY_ID);
|
||||
|
||||
/* Second call should reset the changed count. */
|
||||
ret = dds_get_requested_incompatible_qos_status (reader2, &req_incompatible_qos);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(req_incompatible_qos.total_count, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(req_incompatible_qos.total_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(req_incompatible_qos.last_policy_id, DDS_DURABILITY_QOS_POLICY_ID);
|
||||
|
||||
/*Getting the status should have reset the trigger, waitset should timeout */
|
||||
ret = dds_waitset_wait(waitSetrd, wsresults, wsresultsize, shortTimeout);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), 0);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, 0);
|
||||
|
||||
/* Wait for offered incompatible QoS status */
|
||||
ret = dds_waitset_wait(waitSetwr, wsresults, wsresultsize, waitTimeout);
|
||||
|
|
@ -244,9 +294,16 @@ CU_Test(ddsc_entity, incompatible_qos, .init=init_entity_status, .fini=fini_enti
|
|||
CU_ASSERT_EQUAL_FATAL(off_incompatible_qos.total_count_change, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(off_incompatible_qos.last_policy_id, DDS_DURABILITY_QOS_POLICY_ID);
|
||||
|
||||
/* Second call should reset the changed count. */
|
||||
ret = dds_get_offered_incompatible_qos_status (wri, &off_incompatible_qos);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(off_incompatible_qos.total_count, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(off_incompatible_qos.total_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(off_incompatible_qos.last_policy_id, DDS_DURABILITY_QOS_POLICY_ID);
|
||||
|
||||
/*Getting the status should have reset the trigger, waitset should timeout */
|
||||
ret = dds_waitset_wait(waitSetrd, wsresults, wsresultsize, shortTimeout);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), 0);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, 0);
|
||||
|
||||
ret = dds_waitset_detach(waitSetrd, reader2);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
|
|
@ -278,9 +335,18 @@ CU_Test(ddsc_entity, liveliness_changed, .init=init_entity_status, .fini=fini_en
|
|||
CU_ASSERT_EQUAL_FATAL(liveliness_changed.not_alive_count_change,0);
|
||||
CU_ASSERT_EQUAL_FATAL(liveliness_changed.last_publication_handle, writer_i_hdl);
|
||||
|
||||
/* Second call should reset the changed count. */
|
||||
ret = dds_get_liveliness_changed_status (rea, &liveliness_changed);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(liveliness_changed.alive_count, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(liveliness_changed.alive_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(liveliness_changed.not_alive_count, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(liveliness_changed.not_alive_count_change,0);
|
||||
CU_ASSERT_EQUAL_FATAL(liveliness_changed.last_publication_handle, writer_i_hdl);
|
||||
|
||||
/*Getting the status should have reset the trigger, waitset should timeout */
|
||||
ret = dds_waitset_wait(waitSetrd, wsresults, wsresultsize, shortTimeout);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), 0);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, 0);
|
||||
|
||||
/* Reset writer */
|
||||
ret = dds_waitset_detach(waitSetwr, wri);
|
||||
|
|
@ -298,6 +364,15 @@ CU_Test(ddsc_entity, liveliness_changed, .init=init_entity_status, .fini=fini_en
|
|||
CU_ASSERT_EQUAL_FATAL(liveliness_changed.not_alive_count, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(liveliness_changed.not_alive_count_change,1);
|
||||
CU_ASSERT_EQUAL_FATAL(liveliness_changed.last_publication_handle, writer_i_hdl);
|
||||
|
||||
/* Second call should reset the changed count. */
|
||||
ret = dds_get_liveliness_changed_status (rea, &liveliness_changed);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(liveliness_changed.alive_count, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(liveliness_changed.alive_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(liveliness_changed.not_alive_count, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(liveliness_changed.not_alive_count_change,0);
|
||||
CU_ASSERT_EQUAL_FATAL(liveliness_changed.last_publication_handle, writer_i_hdl);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_entity, sample_rejected, .init=init_entity_status, .fini=fini_entity_status)
|
||||
|
|
@ -339,9 +414,16 @@ CU_Test(ddsc_entity, sample_rejected, .init=init_entity_status, .fini=fini_entit
|
|||
CU_ASSERT_EQUAL_FATAL(sample_rejected.total_count_change, 4);
|
||||
CU_ASSERT_EQUAL_FATAL(sample_rejected.last_reason, DDS_REJECTED_BY_SAMPLES_LIMIT);
|
||||
|
||||
/* Second call should reset the changed count. */
|
||||
ret = dds_get_sample_rejected_status (rea, &sample_rejected);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(sample_rejected.total_count, 4);
|
||||
CU_ASSERT_EQUAL_FATAL(sample_rejected.total_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(sample_rejected.last_reason, DDS_REJECTED_BY_SAMPLES_LIMIT);
|
||||
|
||||
/*Getting the status should have reset the trigger, waitset should timeout */
|
||||
ret = dds_waitset_wait(waitSetrd, wsresults, wsresultsize, shortTimeout);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), 0);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, 0);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
|
@ -370,7 +452,7 @@ Test(ddsc_entity, inconsistent_topic)
|
|||
|
||||
/*Getting the status should have reset the trigger, waitset should timeout */
|
||||
status = dds_waitset_wait(waitSetrd, wsresults, wsresultsize, shortTimeout);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(status), 0, "returned %d", dds_err_nr(status));
|
||||
CU_ASSERT_EQUAL_FATAL(status, 0, "returned %d", status);
|
||||
|
||||
/* Wait for sub inconsistent topic status callback */
|
||||
ret = dds_waitset_wait(waitSetrd, wsresults, wsresultsize, waitTimeout);
|
||||
|
|
@ -381,7 +463,7 @@ Test(ddsc_entity, inconsistent_topic)
|
|||
|
||||
/*Getting the status should have reset the trigger, waitset should timeout */
|
||||
status = dds_waitset_wait(waitSetrd, wsresults, wsresultsize, shortTimeout);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(status), 0);
|
||||
CU_ASSERT_EQUAL_FATAL(status, 0);
|
||||
|
||||
dds_delete(top);
|
||||
}
|
||||
|
|
@ -426,12 +508,18 @@ CU_Test(ddsc_entity, sample_lost, .init=init_entity_status, .fini=fini_entity_st
|
|||
CU_ASSERT_EQUAL_FATAL(ret, (dds_return_t)wsresultsize);
|
||||
ret = dds_get_sample_lost_status (rea, &sample_lost);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(sample_lost.total_count, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(sample_lost.total_count, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(sample_lost.total_count_change, 1);
|
||||
|
||||
/* Second call should reset the changed count. */
|
||||
ret = dds_get_sample_lost_status (rea, &sample_lost);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(sample_lost.total_count, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(sample_lost.total_count_change, 0);
|
||||
|
||||
/*Getting the status should have reset the trigger, waitset should timeout */
|
||||
ret = dds_waitset_wait(waitSetrd, wsresults, wsresultsize, shortTimeout);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), 0);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, 0);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -594,10 +682,9 @@ CU_TheoryDataPoints(ddsc_get_enabled_status, bad_param) = {
|
|||
CU_Theory((dds_entity_t e), ddsc_get_enabled_status, bad_param, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
uint32_t mask;
|
||||
dds_return_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
|
||||
ret = dds_get_status_mask(e, &mask);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_get_enabled_status, deleted_reader, .init=init_entity_status, .fini=fini_entity_status)
|
||||
|
|
@ -605,14 +692,14 @@ CU_Test(ddsc_get_enabled_status, deleted_reader, .init=init_entity_status, .fini
|
|||
uint32_t mask;
|
||||
dds_delete(rea);
|
||||
ret = dds_get_status_mask(rea, &mask);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_get_enabled_status, illegal, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
uint32_t mask;
|
||||
ret = dds_get_status_mask(waitSetrd, &mask);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
|
||||
CU_TheoryDataPoints(ddsc_get_enabled_status, status_ok) = {
|
||||
|
|
@ -632,23 +719,21 @@ CU_TheoryDataPoints(ddsc_set_enabled_status, bad_param) = {
|
|||
};
|
||||
CU_Theory((dds_entity_t e), ddsc_set_enabled_status, bad_param, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
|
||||
ret = dds_set_status_mask(e, 0 /*mask*/);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_set_enabled_status, deleted_reader, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
dds_delete(rea);
|
||||
ret = dds_set_status_mask(rea, 0 /*mask*/);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_set_enabled_status, illegal, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
ret = dds_set_status_mask(waitSetrd, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
|
||||
CU_TheoryDataPoints(ddsc_set_enabled_status, status_ok) = {
|
||||
|
|
@ -668,10 +753,9 @@ CU_TheoryDataPoints(ddsc_read_status, bad_param) = {
|
|||
CU_Theory((dds_entity_t e), ddsc_read_status, bad_param, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
uint32_t status;
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
|
||||
ret = dds_read_status(e, &status, 0 /*mask*/);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_read_status, deleted_reader, .init=init_entity_status, .fini=fini_entity_status)
|
||||
|
|
@ -679,14 +763,14 @@ CU_Test(ddsc_read_status, deleted_reader, .init=init_entity_status, .fini=fini_e
|
|||
uint32_t status;
|
||||
dds_delete(rea);
|
||||
ret = dds_read_status(rea, &status, 0 /*mask*/);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_read_status, illegal, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
uint32_t status;
|
||||
ret = dds_read_status(waitSetrd, &status, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
CU_TheoryDataPoints(ddsc_read_status, status_ok) = {
|
||||
CU_DataPoints(dds_entity_t *,&rea, &wri, &participant, &top, &publisher, &subscriber),
|
||||
|
|
@ -702,14 +786,14 @@ CU_Test(ddsc_read_status, invalid_status_on_reader, .init=init_entity_status, .f
|
|||
{
|
||||
uint32_t status;
|
||||
ret = dds_read_status(rea, &status, DDS_PUBLICATION_MATCHED_STATUS);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_read_status, invalid_status_on_writer, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
uint32_t status;
|
||||
ret = dds_read_status(wri, &status, DDS_SUBSCRIPTION_MATCHED_STATUS);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -720,10 +804,9 @@ CU_TheoryDataPoints(ddsc_take_status, bad_param) = {
|
|||
CU_Theory((dds_entity_t e), ddsc_take_status, bad_param, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
uint32_t status;
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
|
||||
ret = dds_take_status(e, &status, 0 /*mask*/);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_take_status, deleted_reader, .init=init_entity_status, .fini=fini_entity_status)
|
||||
|
|
@ -731,13 +814,13 @@ CU_Test(ddsc_take_status, deleted_reader, .init=init_entity_status, .fini=fini_e
|
|||
uint32_t status;
|
||||
dds_delete(rea);
|
||||
ret = dds_take_status(rea, &status, 0 /*mask*/);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
CU_Test(ddsc_take_status, illegal, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
uint32_t status;
|
||||
ret = dds_take_status(waitSetrd, &status, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
|
||||
CU_TheoryDataPoints(ddsc_take_status, status_ok) = {
|
||||
|
|
@ -759,10 +842,9 @@ CU_TheoryDataPoints(ddsc_get_status_changes, bad_param) = {
|
|||
CU_Theory((dds_entity_t e), ddsc_get_status_changes, bad_param, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
uint32_t status;
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
|
||||
ret = dds_get_status_changes(e, &status);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_get_status_changes, deleted_reader, .init=init_entity_status, .fini=fini_entity_status)
|
||||
|
|
@ -770,14 +852,14 @@ CU_Test(ddsc_get_status_changes, deleted_reader, .init=init_entity_status, .fini
|
|||
uint32_t status;
|
||||
dds_delete(rea);
|
||||
ret = dds_get_status_changes(rea, &status);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_get_status_changes, illegal, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
uint32_t status;
|
||||
ret = dds_get_status_changes(waitSetrd, &status);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
|
||||
CU_TheoryDataPoints(ddsc_get_status_changes, status_ok) = {
|
||||
|
|
@ -797,17 +879,15 @@ CU_TheoryDataPoints(ddsc_triggered, bad_param) = {
|
|||
};
|
||||
CU_Theory((dds_entity_t e), ddsc_triggered, bad_param, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
|
||||
ret = dds_triggered(e);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_triggered, deleted_reader, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
dds_delete(rea);
|
||||
ret = dds_triggered(rea);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
CU_TheoryDataPoints(ddsc_triggered, status_ok) = {
|
||||
|
|
@ -825,7 +905,7 @@ CU_Test(ddsc_get_inconsistent_topic_status, inconsistent_topic_status, .init=ini
|
|||
{
|
||||
dds_inconsistent_topic_status_t inconsistent_topic_status;
|
||||
ret = dds_get_inconsistent_topic_status(top, &inconsistent_topic_status);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(inconsistent_topic_status.total_count, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(inconsistent_topic_status.total_count_change, 0);
|
||||
}
|
||||
|
|
@ -838,10 +918,9 @@ CU_TheoryDataPoints(ddsc_get_inconsistent_topic_status, bad_params) = {
|
|||
CU_Theory((dds_entity_t topic), ddsc_get_inconsistent_topic_status, bad_params, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
dds_inconsistent_topic_status_t topic_status;
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
|
||||
ret = dds_get_inconsistent_topic_status(topic, &topic_status);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -850,7 +929,7 @@ CU_Test(ddsc_get_inconsistent_topic_status, null, .init=init_entity_status, .fin
|
|||
{
|
||||
dds_set_status_mask(top, 0);
|
||||
ret = dds_get_inconsistent_topic_status(top, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -861,7 +940,7 @@ CU_TheoryDataPoints(ddsc_get_inconsistent_topic_status, non_topics) = {
|
|||
CU_Theory((dds_entity_t *topic), ddsc_get_inconsistent_topic_status, non_topics, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
ret = dds_get_inconsistent_topic_status(*topic, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -870,7 +949,7 @@ CU_Test(ddsc_get_inconsistent_topic_status, deleted_topic, .init=init_entity_sta
|
|||
{
|
||||
dds_delete(top);
|
||||
ret = dds_get_inconsistent_topic_status(top, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -881,10 +960,9 @@ CU_TheoryDataPoints(ddsc_get_publication_matched_status, bad_params) = {
|
|||
CU_Theory((dds_entity_t writer), ddsc_get_publication_matched_status, bad_params, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
dds_publication_matched_status_t status;
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
|
||||
ret = dds_get_publication_matched_status(writer, &status);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -893,7 +971,7 @@ CU_Test(ddsc_get_publication_matched_status, null, .init=init_entity_status, .fi
|
|||
{
|
||||
dds_set_status_mask(wri, 0);
|
||||
ret = dds_get_publication_matched_status(wri, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -904,7 +982,7 @@ CU_TheoryDataPoints(ddsc_get_publication_matched_status, non_writers) = {
|
|||
CU_Theory((dds_entity_t *writer), ddsc_get_publication_matched_status, non_writers, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
ret = dds_get_publication_matched_status(*writer, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -913,7 +991,7 @@ CU_Test(ddsc_get_publication_matched_status, deleted_writer, .init=init_entity_s
|
|||
{
|
||||
dds_delete(wri);
|
||||
ret = dds_get_publication_matched_status(wri, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -922,7 +1000,7 @@ CU_Test(ddsc_get_liveliness_lost_status, liveliness_lost_status, .init=init_enti
|
|||
{
|
||||
dds_liveliness_lost_status_t liveliness_lost_status;
|
||||
ret = dds_get_liveliness_lost_status(wri, &liveliness_lost_status);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(liveliness_lost_status.total_count, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(liveliness_lost_status.total_count_change, 0);
|
||||
}
|
||||
|
|
@ -935,10 +1013,9 @@ CU_TheoryDataPoints(ddsc_get_liveliness_lost_status, bad_params) = {
|
|||
CU_Theory((dds_entity_t writer), ddsc_get_liveliness_lost_status, bad_params, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
dds_liveliness_lost_status_t status;
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
|
||||
ret = dds_get_liveliness_lost_status(writer, &status);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -947,7 +1024,7 @@ CU_Test(ddsc_get_liveliness_lost_status, null, .init=init_entity_status, .fini=f
|
|||
{
|
||||
dds_set_status_mask(wri, 0);
|
||||
ret = dds_get_liveliness_lost_status(wri, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -958,7 +1035,7 @@ CU_TheoryDataPoints(ddsc_get_liveliness_lost_status, non_writers) = {
|
|||
CU_Theory((dds_entity_t *writer), ddsc_get_liveliness_lost_status, non_writers, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
ret = dds_get_liveliness_lost_status(*writer, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -967,7 +1044,7 @@ CU_Test(ddsc_get_liveliness_lost_status, deleted_writer, .init=init_entity_statu
|
|||
{
|
||||
dds_delete(wri);
|
||||
ret = dds_get_liveliness_lost_status(wri, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -976,7 +1053,7 @@ CU_Test(ddsc_get_offered_deadline_missed_status, offered_deadline_missed_status,
|
|||
{
|
||||
dds_offered_deadline_missed_status_t offered_deadline_missed_status;
|
||||
ret = dds_get_offered_deadline_missed_status(wri, &offered_deadline_missed_status);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(offered_deadline_missed_status.total_count, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(offered_deadline_missed_status.total_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(offered_deadline_missed_status.last_instance_handle, 0);
|
||||
|
|
@ -990,10 +1067,9 @@ CU_TheoryDataPoints(ddsc_get_offered_deadline_missed_status, bad_params) = {
|
|||
CU_Theory((dds_entity_t writer), ddsc_get_offered_deadline_missed_status, bad_params, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
dds_offered_deadline_missed_status_t status;
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
|
||||
ret = dds_get_offered_deadline_missed_status(writer, &status);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1002,7 +1078,7 @@ CU_Test(ddsc_get_offered_deadline_missed_status, null, .init=init_entity_status,
|
|||
{
|
||||
dds_set_status_mask(wri, 0);
|
||||
ret = dds_get_offered_deadline_missed_status(wri, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1013,7 +1089,7 @@ CU_TheoryDataPoints(ddsc_get_offered_deadline_missed_status, non_writers) = {
|
|||
CU_Theory((dds_entity_t *writer), ddsc_get_offered_deadline_missed_status, non_writers, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
ret = dds_get_offered_deadline_missed_status(*writer, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1022,7 +1098,7 @@ CU_Test(ddsc_get_offered_deadline_missed_status, deleted_writer, .init=init_enti
|
|||
{
|
||||
dds_delete(wri);
|
||||
ret = dds_get_offered_deadline_missed_status(wri, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1033,10 +1109,9 @@ CU_TheoryDataPoints(ddsc_get_offered_incompatible_qos_status, bad_params) = {
|
|||
CU_Theory((dds_entity_t writer), ddsc_get_offered_incompatible_qos_status, bad_params, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
dds_offered_incompatible_qos_status_t status;
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
|
||||
ret = dds_get_offered_incompatible_qos_status(writer, &status);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1045,7 +1120,7 @@ CU_Test(ddsc_get_offered_incompatible_qos_status, null, .init=init_entity_status
|
|||
{
|
||||
dds_set_status_mask(wri, 0);
|
||||
ret = dds_get_offered_incompatible_qos_status(wri, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1056,7 +1131,7 @@ CU_TheoryDataPoints(ddsc_get_offered_incompatible_qos_status, non_writers) = {
|
|||
CU_Theory((dds_entity_t *writer), ddsc_get_offered_incompatible_qos_status, non_writers, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
ret = dds_get_offered_incompatible_qos_status(*writer, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1065,7 +1140,7 @@ CU_Test(ddsc_get_offered_incompatible_qos_status, deleted_writer, .init=init_ent
|
|||
{
|
||||
dds_delete(wri);
|
||||
ret = dds_get_offered_incompatible_qos_status(wri, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1076,10 +1151,9 @@ CU_TheoryDataPoints(ddsc_get_subscription_matched_status, bad_params) = {
|
|||
CU_Theory((dds_entity_t reader), ddsc_get_subscription_matched_status, bad_params, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
dds_subscription_matched_status_t status;
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
|
||||
ret = dds_get_subscription_matched_status(reader, &status);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1088,7 +1162,7 @@ CU_Test(ddsc_get_subscription_matched_status, null, .init=init_entity_status, .f
|
|||
{
|
||||
dds_set_status_mask(rea, 0);
|
||||
ret = dds_get_subscription_matched_status(rea, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1099,7 +1173,7 @@ CU_TheoryDataPoints(ddsc_get_subscription_matched_status, non_readers) = {
|
|||
CU_Theory((dds_entity_t *reader), ddsc_get_subscription_matched_status, non_readers, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
ret = dds_get_subscription_matched_status(*reader, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1108,7 +1182,7 @@ CU_Test(ddsc_get_subscription_matched_status, deleted_reader, .init=init_entity_
|
|||
{
|
||||
dds_delete(rea);
|
||||
ret = dds_get_subscription_matched_status(rea, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1119,10 +1193,9 @@ CU_TheoryDataPoints(ddsc_get_liveliness_changed_status, bad_params) = {
|
|||
CU_Theory((dds_entity_t reader), ddsc_get_liveliness_changed_status, bad_params, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
dds_liveliness_changed_status_t status;
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
|
||||
ret = dds_get_liveliness_changed_status(reader, &status);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1131,7 +1204,7 @@ CU_Test(ddsc_get_liveliness_changed_status, null, .init=init_entity_status, .fin
|
|||
{
|
||||
dds_set_status_mask(rea, 0);
|
||||
ret = dds_get_liveliness_changed_status(rea, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1142,7 +1215,7 @@ CU_TheoryDataPoints(ddsc_get_liveliness_changed_status, non_readers) = {
|
|||
CU_Theory((dds_entity_t *reader), ddsc_get_liveliness_changed_status, non_readers, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
ret = dds_get_liveliness_changed_status(*reader, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1151,7 +1224,7 @@ CU_Test(ddsc_get_liveliness_changed_status, deleted_reader, .init=init_entity_st
|
|||
{
|
||||
dds_delete(rea);
|
||||
ret = dds_get_liveliness_changed_status(rea, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1162,10 +1235,9 @@ CU_TheoryDataPoints(ddsc_get_sample_rejected_status, bad_params) = {
|
|||
CU_Theory((dds_entity_t reader), ddsc_get_sample_rejected_status, bad_params, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
dds_sample_rejected_status_t status;
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
|
||||
ret = dds_get_sample_rejected_status(reader, &status);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1174,7 +1246,7 @@ CU_Test(ddsc_get_sample_rejected_status, null, .init=init_entity_status, .fini=f
|
|||
{
|
||||
dds_set_status_mask(rea, 0);
|
||||
ret = dds_get_sample_rejected_status(rea, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1185,7 +1257,7 @@ CU_TheoryDataPoints(ddsc_get_sample_rejected_status, non_readers) = {
|
|||
CU_Theory((dds_entity_t *reader), ddsc_get_sample_rejected_status, non_readers, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
ret = dds_get_sample_rejected_status(*reader, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1194,7 +1266,7 @@ CU_Test(ddsc_get_sample_rejected_status, deleted_reader, .init=init_entity_statu
|
|||
{
|
||||
dds_delete(rea);
|
||||
ret = dds_get_sample_rejected_status(rea, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1205,10 +1277,9 @@ CU_TheoryDataPoints(ddsc_get_sample_lost_status, bad_params) = {
|
|||
CU_Theory((dds_entity_t reader), ddsc_get_sample_lost_status, bad_params, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
dds_sample_lost_status_t status;
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
|
||||
ret = dds_get_sample_lost_status(reader, &status);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1217,7 +1288,7 @@ CU_Test(ddsc_get_sample_lost_status, null, .init=init_entity_status, .fini=fini_
|
|||
{
|
||||
dds_set_status_mask(rea, 0);
|
||||
ret = dds_get_sample_lost_status(rea, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1228,7 +1299,7 @@ CU_TheoryDataPoints(ddsc_get_sample_lost_status, non_readers) = {
|
|||
CU_Theory((dds_entity_t *reader), ddsc_get_sample_lost_status, non_readers, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
ret = dds_get_sample_lost_status(*reader, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1237,7 +1308,7 @@ CU_Test(ddsc_get_sample_lost_status, deleted_reader, .init=init_entity_status, .
|
|||
{
|
||||
dds_delete(rea);
|
||||
ret = dds_get_sample_lost_status(rea, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1246,7 +1317,7 @@ CU_Test(ddsc_get_requested_deadline_missed_status, requested_deadline_missed_sta
|
|||
{
|
||||
dds_requested_deadline_missed_status_t requested_deadline_missed_status;
|
||||
ret = dds_get_requested_deadline_missed_status(rea, &requested_deadline_missed_status);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(requested_deadline_missed_status.total_count, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(requested_deadline_missed_status.total_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(requested_deadline_missed_status.last_instance_handle, DDS_HANDLE_NIL);
|
||||
|
|
@ -1260,10 +1331,9 @@ CU_TheoryDataPoints(ddsc_get_requested_deadline_missed_status, bad_params) = {
|
|||
CU_Theory((dds_entity_t reader), ddsc_get_requested_deadline_missed_status, bad_params, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
dds_requested_deadline_missed_status_t status;
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
|
||||
ret = dds_get_requested_deadline_missed_status(reader, &status);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1272,7 +1342,7 @@ CU_Test(ddsc_get_requested_deadline_missed_status, null, .init=init_entity_statu
|
|||
{
|
||||
dds_set_status_mask(rea, 0);
|
||||
ret = dds_get_requested_deadline_missed_status(rea, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1283,7 +1353,7 @@ CU_TheoryDataPoints(ddsc_get_requested_deadline_missed_status, non_readers) = {
|
|||
CU_Theory((dds_entity_t *reader), ddsc_get_requested_deadline_missed_status, non_readers, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
ret = dds_get_requested_deadline_missed_status(*reader, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1292,7 +1362,7 @@ CU_Test(ddsc_get_requested_deadline_missed_status, deleted_reader, .init=init_en
|
|||
{
|
||||
dds_delete(rea);
|
||||
ret = dds_get_requested_deadline_missed_status(rea, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1303,10 +1373,9 @@ CU_TheoryDataPoints(ddsc_get_requested_incompatible_qos_status, bad_params) = {
|
|||
CU_Theory((dds_entity_t reader), ddsc_get_requested_incompatible_qos_status, bad_params, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
dds_requested_incompatible_qos_status_t status;
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
|
||||
ret = dds_get_requested_incompatible_qos_status(reader, &status);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1315,7 +1384,7 @@ CU_Test(ddsc_get_requested_incompatible_qos_status, null, .init=init_entity_stat
|
|||
{
|
||||
dds_set_status_mask(rea, 0);
|
||||
ret = dds_get_requested_incompatible_qos_status(rea, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1326,7 +1395,7 @@ CU_TheoryDataPoints(ddsc_get_requested_incompatible_qos_status, non_readers) = {
|
|||
CU_Theory((dds_entity_t *reader), ddsc_get_requested_incompatible_qos_status, non_readers, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
ret = dds_get_requested_incompatible_qos_status(*reader, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1335,7 +1404,7 @@ CU_Test(ddsc_get_requested_incompatible_qos_status, deleted_reader, .init=init_e
|
|||
{
|
||||
dds_delete(rea);
|
||||
ret = dds_get_requested_incompatible_qos_status(rea, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
|
|||
|
|
@ -18,20 +18,40 @@
|
|||
#include "dds/ddsrt/string.h"
|
||||
#include "RoundTrip.h"
|
||||
|
||||
#define MAX_SAMPLES 10
|
||||
|
||||
static dds_entity_t participant = DDS_ENTITY_NIL;
|
||||
static dds_entity_t waitset = DDS_ENTITY_NIL;
|
||||
static dds_entity_t topic = DDS_ENTITY_NIL;
|
||||
static dds_entity_t publisher = DDS_ENTITY_NIL;
|
||||
static dds_entity_t subscriber = DDS_ENTITY_NIL;
|
||||
static dds_entity_t writer = DDS_ENTITY_NIL;
|
||||
|
||||
static dds_entity_t reader = DDS_ENTITY_NIL;
|
||||
static dds_entity_t readcondition = DDS_ENTITY_NIL;
|
||||
static dds_entity_t querycondition = DDS_ENTITY_NIL;
|
||||
static dds_instance_handle_t handle = DDS_HANDLE_NIL;
|
||||
|
||||
static bool
|
||||
filter(const void * sample)
|
||||
{
|
||||
const RoundTripModule_Address *s = sample;
|
||||
return (s->port == 1);
|
||||
}
|
||||
|
||||
static RoundTripModule_Address data;
|
||||
|
||||
/* Fixture to create prerequisite entity */
|
||||
static void setup(void)
|
||||
{
|
||||
uint32_t mask = DDS_ANY_SAMPLE_STATE | DDS_ANY_VIEW_STATE | DDS_ANY_INSTANCE_STATE;
|
||||
dds_return_t ret;
|
||||
|
||||
participant = dds_create_participant(DDS_DOMAIN_DEFAULT, NULL, NULL);
|
||||
CU_ASSERT_FATAL(participant > 0);
|
||||
|
||||
waitset = dds_create_waitset(participant);
|
||||
CU_ASSERT_FATAL(waitset > 0);
|
||||
|
||||
topic = dds_create_topic(participant, &RoundTripModule_Address_desc, "ddsc_instance_get_key", NULL, NULL);
|
||||
CU_ASSERT_FATAL(topic > 0);
|
||||
|
||||
|
|
@ -41,6 +61,24 @@ static void setup(void)
|
|||
writer = dds_create_writer(publisher, topic, NULL, NULL);
|
||||
CU_ASSERT_FATAL(writer > 0);
|
||||
|
||||
subscriber = dds_create_subscriber(participant, NULL, NULL);
|
||||
CU_ASSERT_FATAL(subscriber > 0);
|
||||
|
||||
reader = dds_create_reader(subscriber, topic, NULL, NULL);
|
||||
CU_ASSERT_FATAL(reader > 0);
|
||||
|
||||
readcondition = dds_create_readcondition(reader, mask);
|
||||
CU_ASSERT_FATAL(readcondition > 0);
|
||||
|
||||
ret = dds_waitset_attach(waitset, readcondition, readcondition);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
|
||||
querycondition = dds_create_querycondition(reader, mask, filter);
|
||||
CU_ASSERT_FATAL(querycondition > 0);
|
||||
|
||||
ret = dds_waitset_attach(waitset, querycondition, querycondition);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
|
||||
memset(&data, 0, sizeof(data));
|
||||
data.ip = ddsrt_strdup("some data");
|
||||
CU_ASSERT_PTR_NOT_NULL_FATAL(data.ip);
|
||||
|
|
@ -52,9 +90,6 @@ static void teardown(void)
|
|||
{
|
||||
RoundTripModule_Address_free(&data, DDS_FREE_CONTENTS);
|
||||
|
||||
dds_delete(writer);
|
||||
dds_delete(publisher);
|
||||
dds_delete(topic);
|
||||
dds_delete(participant);
|
||||
}
|
||||
|
||||
|
|
@ -63,7 +98,7 @@ CU_Test(ddsc_instance_get_key, bad_entity, .init=setup, .fini=teardown)
|
|||
dds_return_t ret;
|
||||
|
||||
ret = dds_instance_get_key(participant, handle, &data);
|
||||
CU_ASSERT_EQUAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL(ret, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_instance_get_key, null_data, .init=setup, .fini=teardown)
|
||||
|
|
@ -71,7 +106,7 @@ CU_Test(ddsc_instance_get_key, null_data, .init=setup, .fini=teardown)
|
|||
dds_return_t ret;
|
||||
|
||||
ret = dds_register_instance(writer, &handle, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_instance_get_key, null_handle, .init=setup, .fini=teardown)
|
||||
|
|
@ -81,7 +116,7 @@ CU_Test(ddsc_instance_get_key, null_handle, .init=setup, .fini=teardown)
|
|||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
|
||||
ret = dds_instance_get_key(writer, DDS_HANDLE_NIL, &data);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_instance_get_key, registered_instance, .init=setup, .fini=teardown)
|
||||
|
|
@ -99,8 +134,67 @@ CU_Test(ddsc_instance_get_key, registered_instance, .init=setup, .fini=teardown)
|
|||
CU_ASSERT_PTR_NOT_NULL_FATAL(key_data.ip);
|
||||
CU_ASSERT_STRING_EQUAL_FATAL(key_data.ip, data.ip);
|
||||
CU_ASSERT_EQUAL_FATAL(key_data.port, data.port);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
|
||||
RoundTripModule_Address_free(&key_data, DDS_FREE_CONTENTS);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_instance_get_key, readcondition, .init=setup, .fini=teardown)
|
||||
{
|
||||
dds_return_t ret;
|
||||
RoundTripModule_Address key_data;
|
||||
|
||||
/* The instance handle of a successful write is by
|
||||
* design the same as the instance handle for the
|
||||
* readers,readconditions and queryconditions.
|
||||
* For that reason there is no need to actually read
|
||||
* the data. It is sufficient to do a successful write
|
||||
* and use the instance handle to obtain the key_data
|
||||
* for the readcondition. */
|
||||
ret = dds_write(writer, &data);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
|
||||
handle = dds_lookup_instance (writer, &data);
|
||||
CU_ASSERT_PTR_NOT_NULL_FATAL(handle);
|
||||
|
||||
memset(&key_data, 0, sizeof(key_data));
|
||||
|
||||
ret = dds_instance_get_key(readcondition, handle, &key_data);
|
||||
|
||||
CU_ASSERT_PTR_NOT_NULL_FATAL(key_data.ip);
|
||||
CU_ASSERT_STRING_EQUAL_FATAL(key_data.ip, data.ip);
|
||||
CU_ASSERT_EQUAL_FATAL(key_data.port, data.port);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
|
||||
RoundTripModule_Address_free(&key_data, DDS_FREE_CONTENTS);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_instance_get_key, querycondition, .init=setup, .fini=teardown)
|
||||
{
|
||||
dds_return_t ret;
|
||||
RoundTripModule_Address key_data;
|
||||
|
||||
/* The instance handle of a successful write is by
|
||||
* design the same as the instance handle for the
|
||||
* readers,readconditions and queryconditions.
|
||||
* For that reason there is no need to actually read
|
||||
* the data. It is sufficient to do a successful write
|
||||
* and use the instance handle to obtain the key_data
|
||||
* for the querycondition. */
|
||||
ret = dds_write(writer, &data);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
|
||||
handle = dds_lookup_instance (writer, &data);
|
||||
CU_ASSERT_PTR_NOT_NULL_FATAL(handle);
|
||||
|
||||
memset(&key_data, 0, sizeof(key_data));
|
||||
|
||||
ret = dds_instance_get_key(querycondition, handle, &key_data);
|
||||
|
||||
CU_ASSERT_PTR_NOT_NULL_FATAL(key_data.ip);
|
||||
CU_ASSERT_STRING_EQUAL_FATAL(key_data.ip, data.ip);
|
||||
CU_ASSERT_EQUAL_FATAL(key_data.port, data.port);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
|
||||
RoundTripModule_Address_free(&key_data, DDS_FREE_CONTENTS);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -692,6 +692,7 @@ CU_Test(ddsc_listener, matched, .init=init_triggering_base, .fini=fini_triggerin
|
|||
|
||||
CU_Test(ddsc_listener, publication_matched, .init=init_triggering_test, .fini=fini_triggering_test)
|
||||
{
|
||||
dds_publication_matched_status_t publication_matched;
|
||||
dds_instance_handle_t reader_hdl;
|
||||
dds_return_t ret;
|
||||
uint32_t triggered;
|
||||
|
|
@ -716,6 +717,15 @@ CU_Test(ddsc_listener, publication_matched, .init=init_triggering_test, .fini=fi
|
|||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status, 0);
|
||||
|
||||
/* The listener should have reset the count_change. */
|
||||
ret = dds_get_publication_matched_status(g_writer, &publication_matched);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(publication_matched.current_count, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(publication_matched.current_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(publication_matched.total_count, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(publication_matched.total_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(publication_matched.last_subscription_handle, reader_hdl);
|
||||
|
||||
/* Reset the trigger flags. */
|
||||
cb_called = 0;
|
||||
|
||||
|
|
@ -731,10 +741,20 @@ CU_Test(ddsc_listener, publication_matched, .init=init_triggering_test, .fini=fi
|
|||
CU_ASSERT_EQUAL_FATAL(cb_publication_matched_status.total_count, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(cb_publication_matched_status.total_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(cb_publication_matched_status.last_subscription_handle, reader_hdl);
|
||||
|
||||
/* The listener should have reset the count_change. */
|
||||
ret = dds_get_publication_matched_status(g_writer, &publication_matched);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(publication_matched.current_count, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(publication_matched.current_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(publication_matched.total_count, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(publication_matched.total_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(publication_matched.last_subscription_handle, reader_hdl);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_listener, subscription_matched, .init=init_triggering_test, .fini=fini_triggering_test)
|
||||
{
|
||||
dds_subscription_matched_status_t subscription_matched;
|
||||
dds_instance_handle_t writer_hdl;
|
||||
dds_return_t ret;
|
||||
uint32_t triggered;
|
||||
|
|
@ -759,6 +779,15 @@ CU_Test(ddsc_listener, subscription_matched, .init=init_triggering_test, .fini=f
|
|||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status, 0);
|
||||
|
||||
/* The listener should have reset the count_change. */
|
||||
ret = dds_get_subscription_matched_status(g_reader, &subscription_matched);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(subscription_matched.current_count, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(subscription_matched.current_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(subscription_matched.total_count, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(subscription_matched.total_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(subscription_matched.last_publication_handle, writer_hdl);
|
||||
|
||||
/* Reset the trigger flags. */
|
||||
cb_called = 0;
|
||||
|
||||
|
|
@ -774,10 +803,21 @@ CU_Test(ddsc_listener, subscription_matched, .init=init_triggering_test, .fini=f
|
|||
CU_ASSERT_EQUAL_FATAL(cb_subscription_matched_status.total_count, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(cb_subscription_matched_status.total_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(cb_subscription_matched_status.last_publication_handle, writer_hdl);
|
||||
|
||||
/* The listener should have reset the count_change. */
|
||||
ret = dds_get_subscription_matched_status(g_reader, &subscription_matched);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(subscription_matched.current_count, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(subscription_matched.current_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(subscription_matched.total_count, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(subscription_matched.total_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(subscription_matched.last_publication_handle, writer_hdl);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_listener, incompatible_qos, .init=init_triggering_base, .fini=fini_triggering_base)
|
||||
{
|
||||
dds_offered_incompatible_qos_status_t offered_incompatible_qos;
|
||||
dds_requested_incompatible_qos_status_t requested_incompatible_qos;
|
||||
dds_return_t ret;
|
||||
uint32_t triggered;
|
||||
uint32_t status;
|
||||
|
|
@ -815,6 +855,18 @@ CU_Test(ddsc_listener, incompatible_qos, .init=init_triggering_base, .fini=fini_
|
|||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status, 0);
|
||||
|
||||
/* The listener should have reset the count_change. */
|
||||
ret = dds_get_offered_incompatible_qos_status(g_writer, &offered_incompatible_qos);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
ret = dds_get_requested_incompatible_qos_status(g_reader, &requested_incompatible_qos);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(offered_incompatible_qos.total_count, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(offered_incompatible_qos.total_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(offered_incompatible_qos.last_policy_id, DDS_DURABILITY_QOS_POLICY_ID);
|
||||
CU_ASSERT_EQUAL_FATAL(requested_incompatible_qos.total_count, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(requested_incompatible_qos.total_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(requested_incompatible_qos.last_policy_id, DDS_DURABILITY_QOS_POLICY_ID);
|
||||
|
||||
dds_delete(g_writer);
|
||||
dds_delete(g_reader);
|
||||
}
|
||||
|
|
@ -997,6 +1049,7 @@ CU_Test(ddsc_listener, data_on_readers, .init=init_triggering_test, .fini=fini_t
|
|||
|
||||
CU_Test(ddsc_listener, sample_lost, .init=init_triggering_test, .fini=fini_triggering_test)
|
||||
{
|
||||
dds_sample_lost_status_t sample_lost;
|
||||
dds_return_t ret;
|
||||
uint32_t triggered;
|
||||
dds_time_t the_past;
|
||||
|
|
@ -1031,10 +1084,17 @@ CU_Test(ddsc_listener, sample_lost, .init=init_triggering_test, .fini=fini_trigg
|
|||
ret = dds_read_status(g_reader, &status, DDS_SAMPLE_LOST_STATUS);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status, 0);
|
||||
|
||||
/* The listener should have reset the count_change. */
|
||||
ret = dds_get_sample_lost_status(g_reader, &sample_lost);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(sample_lost.total_count, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(sample_lost.total_count_change, 0);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_listener, sample_rejected, .init=init_triggering_test, .fini=fini_triggering_test)
|
||||
{
|
||||
dds_sample_rejected_status_t sample_rejected;
|
||||
dds_return_t ret;
|
||||
uint32_t triggered;
|
||||
uint32_t status;
|
||||
|
|
@ -1060,15 +1120,24 @@ CU_Test(ddsc_listener, sample_rejected, .init=init_triggering_test, .fini=fini_t
|
|||
CU_ASSERT_EQUAL_FATAL(cb_reader, g_reader);
|
||||
CU_ASSERT_EQUAL_FATAL(cb_sample_rejected_status.total_count, 2);
|
||||
CU_ASSERT_EQUAL_FATAL(cb_sample_rejected_status.total_count_change, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(cb_sample_rejected_status.last_reason, DDS_REJECTED_BY_SAMPLES_LIMIT);
|
||||
|
||||
/* The listener should have swallowed the status. */
|
||||
ret = dds_read_status(g_reader, &status, DDS_SAMPLE_REJECTED_STATUS);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status, 0);
|
||||
|
||||
/* The listener should have reset the count_change. */
|
||||
ret = dds_get_sample_rejected_status(g_reader, &sample_rejected);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(sample_rejected.total_count, 2);
|
||||
CU_ASSERT_EQUAL_FATAL(sample_rejected.total_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(cb_sample_rejected_status.last_reason, DDS_REJECTED_BY_SAMPLES_LIMIT);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_listener, liveliness_changed, .init=init_triggering_test, .fini=fini_triggering_base)
|
||||
{
|
||||
dds_liveliness_changed_status_t liveliness_changed;
|
||||
dds_instance_handle_t writer_hdl;
|
||||
dds_return_t ret;
|
||||
uint32_t triggered;
|
||||
|
|
@ -1095,6 +1164,15 @@ CU_Test(ddsc_listener, liveliness_changed, .init=init_triggering_test, .fini=fin
|
|||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status, 0);
|
||||
|
||||
/* The listener should have reset the count_change. */
|
||||
ret = dds_get_liveliness_changed_status(g_reader, &liveliness_changed);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(liveliness_changed.alive_count, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(liveliness_changed.alive_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(liveliness_changed.not_alive_count, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(liveliness_changed.not_alive_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(liveliness_changed.last_publication_handle, writer_hdl);
|
||||
|
||||
/* Reset the trigger flags. */
|
||||
cb_called = 0;
|
||||
|
||||
|
|
@ -1110,6 +1188,15 @@ CU_Test(ddsc_listener, liveliness_changed, .init=init_triggering_test, .fini=fin
|
|||
CU_ASSERT_EQUAL_FATAL(cb_liveliness_changed_status.not_alive_count, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(cb_liveliness_changed_status.not_alive_count_change, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(cb_liveliness_changed_status.last_publication_handle, writer_hdl);
|
||||
|
||||
/* The listener should have reset the count_change. */
|
||||
ret = dds_get_liveliness_changed_status(g_reader, &liveliness_changed);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(liveliness_changed.alive_count, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(liveliness_changed.alive_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(liveliness_changed.not_alive_count, 1);
|
||||
CU_ASSERT_EQUAL_FATAL(liveliness_changed.not_alive_count_change, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(liveliness_changed.last_publication_handle, writer_hdl);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@
|
|||
#include "dds/version.h"
|
||||
#include "dds/ddsrt/environ.h"
|
||||
|
||||
#define cu_assert_status_eq(s1, s2) CU_ASSERT_EQUAL_FATAL(dds_err_nr(s1), s2)
|
||||
|
||||
|
||||
CU_Test(ddsc_participant, create_and_delete) {
|
||||
|
||||
|
|
@ -44,29 +42,25 @@ CU_Test(ddsc_participant, create_and_delete) {
|
|||
/* Test for creating participant with no configuration file */
|
||||
CU_Test(ddsc_participant, create_with_no_conf_no_env)
|
||||
{
|
||||
dds_entity_t participant, participant2, participant3;
|
||||
dds_entity_t participant2, participant3;
|
||||
dds_return_t status;
|
||||
dds_domainid_t domain_id;
|
||||
dds_domainid_t valid_domain=3;
|
||||
|
||||
ddsrt_unsetenv(DDS_PROJECT_NAME_NOSPACE_CAPS"_URI");
|
||||
|
||||
//invalid domain
|
||||
participant = dds_create_participant (-2, NULL, NULL);
|
||||
CU_ASSERT_FATAL(participant < 0);
|
||||
|
||||
//valid specific domain value
|
||||
participant2 = dds_create_participant (valid_domain, NULL, NULL);
|
||||
CU_ASSERT_FATAL(participant2 > 0);
|
||||
status = dds_get_domainid(participant2, &domain_id);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(domain_id, valid_domain);
|
||||
|
||||
//DDS_DOMAIN_DEFAULT from user
|
||||
participant3 = dds_create_participant (DDS_DOMAIN_DEFAULT, NULL, NULL);
|
||||
CU_ASSERT_FATAL(participant3 > 0);
|
||||
status = dds_get_domainid(participant3, &domain_id);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(domain_id, valid_domain);
|
||||
|
||||
dds_delete(participant2);
|
||||
|
|
@ -74,11 +68,41 @@ CU_Test(ddsc_participant, create_with_no_conf_no_env)
|
|||
}
|
||||
|
||||
|
||||
/* Test for creating participants in multiple domains with no configuration file */
|
||||
CU_Test(ddsc_participant, create_multiple_domains)
|
||||
{
|
||||
dds_entity_t participant1, participant2;
|
||||
dds_return_t status;
|
||||
dds_domainid_t domain_id;
|
||||
|
||||
ddsrt_setenv("CYCLONEDDS_URI", "<Tracing><Verbosity>finest</><OutputFile>multi-domain-1.log</></>");
|
||||
|
||||
//valid specific domain value
|
||||
participant1 = dds_create_participant (1, NULL, NULL);
|
||||
CU_ASSERT_FATAL(participant1 > 0);
|
||||
status = dds_get_domainid(participant1, &domain_id);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(domain_id, 1);
|
||||
|
||||
ddsrt_setenv("CYCLONEDDS_URI", "<Tracing><Verbosity>finest</><OutputFile>multi-domain-2.log</></>");
|
||||
|
||||
//DDS_DOMAIN_DEFAULT from user
|
||||
participant2 = dds_create_participant (2, NULL, NULL);
|
||||
CU_ASSERT_FATAL(participant2 > 0);
|
||||
status = dds_get_domainid(participant2, &domain_id);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(domain_id, 2);
|
||||
|
||||
dds_delete(participant1);
|
||||
dds_delete(participant2);
|
||||
}
|
||||
|
||||
|
||||
////WITH CONF
|
||||
|
||||
/* Test for creating participant with valid configuration file */
|
||||
CU_Test(ddsc_participant, create_with_conf_no_env) {
|
||||
dds_entity_t participant, participant2, participant3;
|
||||
dds_entity_t participant2, participant3;
|
||||
dds_return_t status;
|
||||
dds_domainid_t domain_id;
|
||||
dds_domainid_t valid_domain=3;
|
||||
|
|
@ -90,16 +114,11 @@ CU_Test(ddsc_participant, create_with_conf_no_env) {
|
|||
ddsrt_getenv(DDS_PROJECT_NAME_NOSPACE_CAPS"_URI", &env_uri);
|
||||
CU_ASSERT_PTR_NOT_EQUAL_FATAL(env_uri, NULL);
|
||||
|
||||
//invalid domain
|
||||
participant = dds_create_participant (1, NULL, NULL);
|
||||
printf("\n participant is %d\n", participant);
|
||||
CU_ASSERT_FATAL(participant < 0);
|
||||
|
||||
//valid specific domain value
|
||||
participant2 = dds_create_participant (valid_domain, NULL, NULL);
|
||||
CU_ASSERT_FATAL(participant2 > 0);
|
||||
status = dds_get_domainid(participant2, &domain_id);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(domain_id, valid_domain);
|
||||
|
||||
|
||||
|
|
@ -107,7 +126,7 @@ CU_Test(ddsc_participant, create_with_conf_no_env) {
|
|||
participant3 = dds_create_participant (DDS_DOMAIN_DEFAULT, NULL, NULL);
|
||||
CU_ASSERT_FATAL(participant3 > 0);
|
||||
status = dds_get_domainid(participant3, &domain_id);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(domain_id, valid_domain);
|
||||
|
||||
dds_delete(participant2);
|
||||
|
|
@ -128,7 +147,7 @@ CU_Test(ddsc_participant_lookup, one) {
|
|||
|
||||
/* Get domain id */
|
||||
status = dds_get_domainid(participant, &domain_id);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_OK);
|
||||
|
||||
num_of_found_pp = dds_lookup_participant( domain_id, participants, size);
|
||||
CU_ASSERT_EQUAL_FATAL(num_of_found_pp, 1);
|
||||
|
|
@ -154,7 +173,7 @@ CU_Test(ddsc_participant_lookup, multiple) {
|
|||
|
||||
/* Get domain id */
|
||||
status = dds_get_domainid(participant, &domain_id);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_OK);
|
||||
|
||||
num_of_found_pp = dds_lookup_participant( domain_id, participants, size);
|
||||
CU_ASSERT_EQUAL_FATAL(num_of_found_pp, 2);
|
||||
|
|
@ -186,7 +205,7 @@ CU_Test(ddsc_participant_lookup, array_too_small) {
|
|||
|
||||
/* Get domain id */
|
||||
status = dds_get_domainid(participant, &domain_id);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_OK);
|
||||
|
||||
num_of_found_pp = dds_lookup_participant( domain_id, participants, size);
|
||||
CU_ASSERT_EQUAL_FATAL(num_of_found_pp, 3);
|
||||
|
|
@ -212,7 +231,7 @@ CU_Test(ddsc_participant_lookup, null_zero){
|
|||
|
||||
/* Get domain id */
|
||||
status = dds_get_domainid(participant, &domain_id);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_OK);
|
||||
|
||||
num_of_found_pp = dds_lookup_participant( domain_id, NULL, size);
|
||||
CU_ASSERT_EQUAL_FATAL(num_of_found_pp, 1);
|
||||
|
|
@ -233,10 +252,10 @@ CU_Test(ddsc_participant_lookup, null_nonzero){
|
|||
|
||||
/* Get domain id */
|
||||
status = dds_get_domainid(participant, &domain_id);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_OK);
|
||||
|
||||
num_of_found_pp = dds_lookup_participant( domain_id, NULL, size);
|
||||
cu_assert_status_eq(num_of_found_pp, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(num_of_found_pp, DDS_RETCODE_BAD_PARAMETER);
|
||||
|
||||
dds_delete (participant);
|
||||
}
|
||||
|
|
@ -255,7 +274,7 @@ CU_Test(ddsc_participant_lookup, unknown_id) {
|
|||
|
||||
/* Get domain id */
|
||||
status = dds_get_domainid(participant, &domain_id);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_OK);
|
||||
domain_id ++;
|
||||
|
||||
num_of_found_pp = dds_lookup_participant( domain_id, participants, size);
|
||||
|
|
@ -288,7 +307,7 @@ CU_Test(ddsc_participant_lookup, no_more) {
|
|||
|
||||
/* Get domain id */
|
||||
status = dds_get_domainid(participant, &domain_id);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_OK);
|
||||
|
||||
dds_delete (participant);
|
||||
|
||||
|
|
@ -313,7 +332,7 @@ CU_Test(ddsc_participant_lookup, deleted) {
|
|||
|
||||
/* Get domain id */
|
||||
status = dds_get_domainid(participant, &domain_id);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_OK);
|
||||
|
||||
dds_delete (participant2);
|
||||
|
||||
|
|
|
|||
|
|
@ -19,8 +19,6 @@
|
|||
#pragma warning(disable: 28020)
|
||||
#endif
|
||||
|
||||
#define cu_assert_status_eq(s1, s2) CU_ASSERT_EQUAL_FATAL(dds_err_nr(s1), s2)
|
||||
|
||||
/* Dummy callback */
|
||||
static void data_available_cb(dds_entity_t reader, void* arg)
|
||||
{
|
||||
|
|
@ -42,7 +40,7 @@ CU_Test(ddsc_publisher, create)
|
|||
|
||||
/* Use NULL participant */
|
||||
publisher = dds_create_publisher(0, NULL, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(publisher), DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
CU_ASSERT_EQUAL_FATAL(publisher, DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
|
||||
participant = dds_create_participant (DDS_DOMAIN_DEFAULT, NULL, NULL);
|
||||
CU_ASSERT_FATAL(participant > 0);
|
||||
|
|
@ -53,7 +51,7 @@ CU_Test(ddsc_publisher, create)
|
|||
|
||||
/* Use entity that is not a participant */
|
||||
publisher1 = dds_create_publisher(publisher, NULL, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(publisher1), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(publisher1, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
dds_delete(publisher);
|
||||
|
||||
/* Create a non-null qos */
|
||||
|
|
@ -143,35 +141,35 @@ CU_Test(ddsc_publisher, suspend_resume)
|
|||
|
||||
/* Suspend a 0 publisher */
|
||||
status = dds_suspend(0);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
|
||||
/* Resume a 0 publisher */
|
||||
status = dds_resume(0);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
|
||||
/* Uae dds_suspend on something else than a publisher */
|
||||
participant = dds_create_participant (DDS_DOMAIN_DEFAULT, NULL, NULL);
|
||||
CU_ASSERT_FATAL(participant > 0);
|
||||
status = dds_suspend(participant);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
|
||||
/* Use dds_resume on something else than a publisher */
|
||||
status = dds_resume(participant);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
|
||||
/* Use dds_resume without calling dds_suspend */
|
||||
publisher = dds_create_publisher(participant, NULL, NULL);
|
||||
CU_ASSERT_FATAL(publisher > 0);
|
||||
status = dds_resume(publisher); /* Should be precondition not met? */
|
||||
cu_assert_status_eq(status, DDS_RETCODE_UNSUPPORTED);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_UNSUPPORTED);
|
||||
|
||||
/* Use dds_suspend on non-null publisher */
|
||||
status = dds_suspend(publisher);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_UNSUPPORTED);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_UNSUPPORTED);
|
||||
|
||||
/* Use dds_resume on non-null publisher */
|
||||
status = dds_resume(publisher);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_UNSUPPORTED);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_UNSUPPORTED);
|
||||
|
||||
dds_delete(publisher);
|
||||
dds_delete(participant);
|
||||
|
|
@ -189,38 +187,38 @@ CU_Test(ddsc_publisher, wait_for_acks)
|
|||
|
||||
/* Wait_for_acks on 0 publisher or writer and minusOneSec timeout */
|
||||
status = dds_wait_for_acks(0, minusOneSec);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
|
||||
/* Wait_for_acks on NULL publisher or writer and zeroSec timeout */
|
||||
status = dds_wait_for_acks(0, zeroSec);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
|
||||
/* wait_for_acks on NULL publisher or writer and oneSec timeout */
|
||||
status = dds_wait_for_acks(0, oneSec);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
|
||||
/* wait_for_acks on NULL publisher or writer and DDS_INFINITE timeout */
|
||||
status = dds_wait_for_acks(0, DDS_INFINITY);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
|
||||
participant = dds_create_participant (DDS_DOMAIN_DEFAULT, NULL, NULL);
|
||||
CU_ASSERT_FATAL(participant > 0);
|
||||
|
||||
/* Wait_for_acks on participant and minusOneSec timeout */
|
||||
status = dds_wait_for_acks(participant, minusOneSec);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
|
||||
/* Wait_for_acks on participant and zeroSec timeout */
|
||||
status = dds_wait_for_acks(participant, zeroSec);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
|
||||
/* Wait_for_acks on participant and oneSec timeout */
|
||||
status = dds_wait_for_acks(participant, oneSec);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
|
||||
/* Wait_for_acks on participant and DDS_INFINITE timeout */
|
||||
status = dds_wait_for_acks(participant, DDS_INFINITY);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
|
||||
publisher = dds_create_publisher(participant, NULL, NULL);
|
||||
CU_ASSERT_FATAL(publisher > 0);
|
||||
|
|
@ -228,40 +226,40 @@ CU_Test(ddsc_publisher, wait_for_acks)
|
|||
/* Wait_for_acks on publisher and minusOneSec timeout --
|
||||
either BAD_PARAMETER or UNSUPPORTED would be both be ok, really */
|
||||
status = dds_wait_for_acks(publisher, minusOneSec);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
|
||||
/* Wait_for_acks on publisher and zeroSec timeout */
|
||||
status = dds_wait_for_acks(publisher, zeroSec);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_UNSUPPORTED);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_UNSUPPORTED);
|
||||
|
||||
/* Wait_for_acks on publisher and oneSec timeout */
|
||||
status = dds_wait_for_acks(publisher, oneSec);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_UNSUPPORTED);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_UNSUPPORTED);
|
||||
|
||||
/* Wait_for_acks on publisher and DDS_INFINITE timeout */
|
||||
status = dds_wait_for_acks(publisher, DDS_INFINITY);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_UNSUPPORTED);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_UNSUPPORTED);
|
||||
|
||||
/* TODO: create tests by calling dds_qwait_for_acks on writers */
|
||||
|
||||
status = dds_suspend(publisher);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_UNSUPPORTED);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_UNSUPPORTED);
|
||||
|
||||
/* Wait_for_acks on suspended publisher and minusOneSec timeout */
|
||||
status = dds_wait_for_acks(publisher, minusOneSec);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
|
||||
/* Wait_for_acks on suspended publisher and zeroSec timeout */
|
||||
status = dds_wait_for_acks(publisher, zeroSec);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_UNSUPPORTED);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_UNSUPPORTED);
|
||||
|
||||
/* Wait_for_acks on suspended publisher and oneSec timeout */
|
||||
status = dds_wait_for_acks(publisher, oneSec);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_UNSUPPORTED);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_UNSUPPORTED);
|
||||
|
||||
/* Wait_for_acks on suspended publisher and DDS_INFINITE timeout */
|
||||
status = dds_wait_for_acks(publisher, DDS_INFINITY);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_UNSUPPORTED);
|
||||
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_UNSUPPORTED);
|
||||
|
||||
dds_delete(publisher);
|
||||
dds_delete(participant);
|
||||
|
|
|
|||
|
|
@ -234,7 +234,7 @@ CU_Test(ddsc_qos, copy_bad_source, .init=qos_init, .fini=qos_fini)
|
|||
dds_return_t result;
|
||||
|
||||
result = dds_copy_qos(g_qos, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(result), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(result, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_qos, copy_bad_destination, .init=qos_init, .fini=qos_fini)
|
||||
|
|
@ -242,7 +242,7 @@ CU_Test(ddsc_qos, copy_bad_destination, .init=qos_init, .fini=qos_fini)
|
|||
dds_return_t result;
|
||||
|
||||
result = dds_copy_qos(NULL, g_qos);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(result), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(result, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_qos, copy_with_partition, .init=qos_init, .fini=qos_fini)
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ CU_Test(ddsc_querycondition_create, deleted_reader, .init=querycondition_init, .
|
|||
dds_entity_t cond;
|
||||
dds_delete(g_reader);
|
||||
cond = dds_create_querycondition(g_reader, mask, filter_mod2);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(cond), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(cond, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -256,11 +256,10 @@ CU_TheoryDataPoints(ddsc_querycondition_create, invalid_readers) = {
|
|||
CU_Theory((dds_entity_t rdr), ddsc_querycondition_create, invalid_readers, .init=querycondition_init, .fini=querycondition_fini)
|
||||
{
|
||||
uint32_t mask = DDS_ANY_SAMPLE_STATE | DDS_ANY_VIEW_STATE | DDS_ANY_INSTANCE_STATE;
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
dds_entity_t cond;
|
||||
|
||||
cond = dds_create_querycondition(rdr, mask, filter_mod2);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(cond), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(cond, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -273,7 +272,7 @@ CU_Theory((dds_entity_t *rdr), ddsc_querycondition_create, non_readers, .init=qu
|
|||
uint32_t mask = DDS_ANY_SAMPLE_STATE | DDS_ANY_VIEW_STATE | DDS_ANY_INSTANCE_STATE;
|
||||
dds_entity_t cond;
|
||||
cond = dds_create_querycondition(*rdr, mask, filter_mod2);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(cond), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(cond, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -297,7 +296,7 @@ CU_Test(ddsc_querycondition_get_mask, deleted, .init=querycondition_init, .fini=
|
|||
dds_delete(condition);
|
||||
mask = 0;
|
||||
ret = dds_get_mask(condition, &mask);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -312,7 +311,7 @@ CU_Test(ddsc_querycondition_get_mask, null, .init=querycondition_init, .fini=que
|
|||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_get_mask(condition, NULL);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
dds_delete(condition);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
|
@ -323,12 +322,11 @@ CU_TheoryDataPoints(ddsc_querycondition_get_mask, invalid_conditions) = {
|
|||
};
|
||||
CU_Theory((dds_entity_t cond), ddsc_querycondition_get_mask, invalid_conditions, .init=querycondition_init, .fini=querycondition_fini)
|
||||
{
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
dds_return_t ret;
|
||||
uint32_t mask;
|
||||
|
||||
ret = dds_get_mask(cond, &mask);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -341,7 +339,7 @@ CU_Theory((dds_entity_t *cond), ddsc_querycondition_get_mask, non_conditions, .i
|
|||
dds_return_t ret;
|
||||
uint32_t mask;
|
||||
ret = dds_get_mask(*cond, &mask);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -362,7 +360,7 @@ CU_Theory((uint32_t ss, uint32_t vs, uint32_t is), ddsc_querycondition_get_mask,
|
|||
CU_ASSERT_FATAL(condition > 0);
|
||||
|
||||
ret = dds_get_mask(condition, &maskOut);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(maskIn, maskOut);
|
||||
|
||||
dds_delete(condition);
|
||||
|
|
@ -924,7 +922,7 @@ CU_Test(ddsc_querycondition_read, already_deleted, .init=querycondition_init, .f
|
|||
|
||||
/* Try to read with a deleted condition. */
|
||||
ret = dds_read(condition, g_samples, g_info, MAX_SAMPLES, MAX_SAMPLES);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -1487,7 +1485,7 @@ CU_Test(ddsc_querycondition_take, already_deleted, .init=querycondition_init, .f
|
|||
|
||||
/* Try to take with a deleted condition. */
|
||||
ret = dds_take(condition, g_samples, g_info, MAX_SAMPLES, MAX_SAMPLES);
|
||||
CU_ASSERT_EQUAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
|
|||
|
|
@ -299,7 +299,7 @@ CU_Theory((dds_entity_t *ent, void **buf, dds_sample_info_t *si, size_t bufsz, u
|
|||
* However, that's not the case yet. So don't test it. */
|
||||
if (buf != g_loans) {
|
||||
ret = dds_read_instance(*ent, buf, si, bufsz, maxs, g_hdl_valid);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
} else {
|
||||
CU_PASS("Skipped");
|
||||
}
|
||||
|
|
@ -320,7 +320,7 @@ CU_Theory((dds_entity_t *ent, void **buf, dds_sample_info_t *si, uint32_t maxs),
|
|||
* invalid and neither is the handle. So, don't test that. */
|
||||
if ((buf != g_loans) || (si != g_info) || (maxs == 0)) {
|
||||
ret = dds_read_instance_wl(*ent, buf, si, maxs, g_hdl_valid);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
} else {
|
||||
CU_PASS("Skipped");
|
||||
}
|
||||
|
|
@ -350,7 +350,7 @@ CU_Theory((dds_entity_t *ent, void **buf, dds_sample_info_t *si, size_t bufsz, u
|
|||
* However, that's not the case yet. So don't test it. */
|
||||
if (buf != g_loans) {
|
||||
ret = dds_read_instance_mask(*ent, buf, si, bufsz, maxs, g_hdl_valid, mask);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
} else {
|
||||
CU_PASS("Skipped");
|
||||
}
|
||||
|
|
@ -372,7 +372,7 @@ CU_Theory((dds_entity_t *ent, void **buf, dds_sample_info_t *si, uint32_t maxs),
|
|||
* invalid and neither is the handle. So, don't test that. */
|
||||
CU_ASSERT_FATAL((buf != g_loans) || (si != g_info) || (maxs == 0));
|
||||
ret = dds_read_instance_mask_wl(*ent, buf, si, maxs, g_hdl_valid, mask);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -394,7 +394,7 @@ CU_Theory((dds_entity_t *rdr, dds_instance_handle_t hdl), ddsc_read_instance, in
|
|||
{
|
||||
dds_return_t ret;
|
||||
ret = dds_read_instance(*rdr, g_samples, g_info, MAX_SAMPLES, MAX_SAMPLES, hdl);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -407,7 +407,7 @@ CU_Theory((dds_entity_t *rdr, dds_instance_handle_t hdl), ddsc_read_instance_wl,
|
|||
{
|
||||
dds_return_t ret;
|
||||
ret = dds_read_instance_wl(*rdr, g_loans, g_info, MAX_SAMPLES, hdl);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -421,7 +421,7 @@ CU_Theory((dds_entity_t *rdr, dds_instance_handle_t hdl), ddsc_read_instance_mas
|
|||
uint32_t mask = DDS_ANY_SAMPLE_STATE | DDS_ANY_VIEW_STATE | DDS_ANY_INSTANCE_STATE;
|
||||
dds_return_t ret;
|
||||
ret = dds_read_instance_mask(*rdr, g_samples, g_info, MAX_SAMPLES, MAX_SAMPLES, hdl, mask);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -435,7 +435,7 @@ CU_Theory((dds_entity_t *rdr, dds_instance_handle_t hdl), ddsc_read_instance_mas
|
|||
uint32_t mask = DDS_ANY_SAMPLE_STATE | DDS_ANY_VIEW_STATE | DDS_ANY_INSTANCE_STATE;
|
||||
dds_return_t ret;
|
||||
ret = dds_read_instance_mask_wl(*rdr, g_loans, g_info, MAX_SAMPLES, hdl, mask);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -454,11 +454,10 @@ CU_TheoryDataPoints(ddsc_read_instance, invalid_readers) = {
|
|||
};
|
||||
CU_Theory((dds_entity_t rdr), ddsc_read_instance, invalid_readers, .init=read_instance_init, .fini=read_instance_fini)
|
||||
{
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
dds_return_t ret;
|
||||
|
||||
ret = dds_read_instance(rdr, g_samples, g_info, MAX_SAMPLES, MAX_SAMPLES, g_hdl_valid);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -468,11 +467,10 @@ CU_TheoryDataPoints(ddsc_read_instance_wl, invalid_readers) = {
|
|||
};
|
||||
CU_Theory((dds_entity_t rdr), ddsc_read_instance_wl, invalid_readers, .init=read_instance_init, .fini=read_instance_fini)
|
||||
{
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
dds_return_t ret;
|
||||
|
||||
ret = dds_read_instance_wl(rdr, g_loans, g_info, MAX_SAMPLES, g_hdl_valid);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -483,11 +481,10 @@ CU_TheoryDataPoints(ddsc_read_instance_mask, invalid_readers) = {
|
|||
CU_Theory((dds_entity_t rdr), ddsc_read_instance_mask, invalid_readers, .init=read_instance_init, .fini=read_instance_fini)
|
||||
{
|
||||
uint32_t mask = DDS_ANY_SAMPLE_STATE | DDS_ANY_VIEW_STATE | DDS_ANY_INSTANCE_STATE;
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
dds_return_t ret;
|
||||
|
||||
ret = dds_read_instance_mask(rdr, g_samples, g_info, MAX_SAMPLES, MAX_SAMPLES, g_hdl_valid, mask);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -498,11 +495,10 @@ CU_TheoryDataPoints(ddsc_read_instance_mask_wl, invalid_readers) = {
|
|||
CU_Theory((dds_entity_t rdr), ddsc_read_instance_mask_wl, invalid_readers, .init=read_instance_init, .fini=read_instance_fini)
|
||||
{
|
||||
uint32_t mask = DDS_ANY_SAMPLE_STATE | DDS_ANY_VIEW_STATE | DDS_ANY_INSTANCE_STATE;
|
||||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
dds_return_t ret;
|
||||
|
||||
ret = dds_read_instance_mask_wl(rdr, g_loans, g_info, MAX_SAMPLES, g_hdl_valid, mask);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -524,7 +520,7 @@ CU_Theory((dds_entity_t *rdr), ddsc_read_instance, non_readers, .init=read_insta
|
|||
{
|
||||
dds_return_t ret;
|
||||
ret = dds_read_instance(*rdr, g_samples, g_info, MAX_SAMPLES, MAX_SAMPLES, g_hdl_valid);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -536,7 +532,7 @@ CU_Theory((dds_entity_t *rdr), ddsc_read_instance_wl, non_readers, .init=read_in
|
|||
{
|
||||
dds_return_t ret;
|
||||
ret = dds_read_instance_wl(*rdr, g_loans, g_info, MAX_SAMPLES, g_hdl_valid);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -549,7 +545,7 @@ CU_Theory((dds_entity_t *rdr), ddsc_read_instance_mask, non_readers, .init=read_
|
|||
uint32_t mask = DDS_ANY_SAMPLE_STATE | DDS_ANY_VIEW_STATE | DDS_ANY_INSTANCE_STATE;
|
||||
dds_return_t ret;
|
||||
ret = dds_read_instance_mask(*rdr, g_samples, g_info, MAX_SAMPLES, MAX_SAMPLES, g_hdl_valid, mask);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -562,7 +558,7 @@ CU_Theory((dds_entity_t *rdr), ddsc_read_instance_mask_wl, non_readers, .init=re
|
|||
uint32_t mask = DDS_ANY_SAMPLE_STATE | DDS_ANY_VIEW_STATE | DDS_ANY_INSTANCE_STATE;
|
||||
dds_return_t ret;
|
||||
ret = dds_read_instance_mask_wl(*rdr, g_loans, g_info, MAX_SAMPLES, g_hdl_valid, mask);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -586,7 +582,7 @@ CU_Theory((dds_entity_t *rdr), ddsc_read_instance, already_deleted, .init=read_i
|
|||
ret = dds_delete(*rdr);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
ret = dds_read_instance(*rdr, g_samples, g_info, MAX_SAMPLES, MAX_SAMPLES, g_hdl_valid);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -600,7 +596,7 @@ CU_Theory((dds_entity_t *rdr), ddsc_read_instance_wl, already_deleted, .init=rea
|
|||
ret = dds_delete(*rdr);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
ret = dds_read_instance_wl(*rdr, g_loans, g_info, MAX_SAMPLES, g_hdl_valid);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -615,7 +611,7 @@ CU_Theory((dds_entity_t *rdr), ddsc_read_instance_mask, already_deleted, .init=r
|
|||
ret = dds_delete(*rdr);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
ret = dds_read_instance_mask(*rdr, g_samples, g_info, MAX_SAMPLES, MAX_SAMPLES, g_hdl_valid, mask);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
@ -630,7 +626,7 @@ CU_Theory((dds_entity_t *rdr), ddsc_read_instance_mask_wl, already_deleted, .ini
|
|||
ret = dds_delete(*rdr);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
ret = dds_read_instance_mask_wl(*rdr, g_loans, g_info, MAX_SAMPLES, g_hdl_valid, mask);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue