lift limits on handle allocation and reuse (#95)
The old entity handle mechanism suffered from a number of problems, the most terrible one being that it would only ever allocate 1000 handles (not even have at most 1000 in use at the same time). Secondarily, it was protected by a single mutex that actually does show up as a limiting factor in, say, a polling-based throughput test with small messages. Thirdly, it tried to provide for various use cases that don't exist in practice but add complexity and overhead. This commit totally rewrites the mechanism, by replacing the old array with a hash table and allowing a near-arbitrary number of handles as well as reuse of handles. It also removes the entity "kind" bits in the most significant bits of the handles, because they only resulted in incorrect checking of argument validity. All that is taken out, but there is still more cleaning up to be done. It furthermore removes an indirection in the handle-to-entity lookup by embedding the "dds_handle_link" structure in the entity. Handle allocation is randomized to avoid the have a high probability of quickly finding an available handle (the total number of handles is limited to a number much smaller than the domain from which they are allocated). The likelihood of handle reuse is still dependent on the number of allocated handles -- the fewer handles there are, the longer the expected time to reuse. Non-randomized handles would give a few guarantees more, though. It moreover moves the code from the "util" to the "core/ddsc" component, because it really is only used for entities, and besides the new implementation relies on the deferred freeing (a.k.a. garbage collection mechanism) implemented in the core. The actual handle management has two variants, selectable with a macro: the preferred embodiment uses a concurrent hash table, the actually used one performs all operations inside a single mutex and uses a non-concurrent version of the hash table. The reason the less-predeferred embodiment is used is that the concurrent version requires the freeing of entity objects to be deferred (much like the GUID-to-entity hash tables in DDSI function, or indeed the key value to instance handle mapping). That is a fair bit of work, and the non-concurrent version is a reasonable intermediate step. Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
parent
58c0cb2317
commit
9b3a71e1ab
55 changed files with 871 additions and 1681 deletions
|
@ -152,7 +152,6 @@ if(NOT (${USE_SANITIZER} STREQUAL "none"))
|
|||
link_libraries(-fno-omit-frame-pointer -fsanitize=${USE_SANITIZER})
|
||||
endif()
|
||||
|
||||
include(FileIDs)
|
||||
include(GNUInstallDirs)
|
||||
include(AnalyzeBuild)
|
||||
# Include Coverage before CTest so that COVERAGE_COMMAND can be modified
|
||||
|
|
|
@ -1,146 +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
|
||||
#
|
||||
|
||||
# To uniquely identify the origin of every error all source files must be
|
||||
# assigned a pseudo unique identifier (or module). Because only 32 bits are
|
||||
# available in the return code (for now) to store the sign bit (1), return
|
||||
# code (4), line number (8) and file identifier, using a deterministic hash
|
||||
# will likely lead to collisions. To work around this issue a static map is
|
||||
# applied, which also ensures that file identifiers are persisted accross
|
||||
# versions/branches. Of course one could choose to specify the module manually
|
||||
# with every return, but that is tedious and error prone.
|
||||
|
||||
if(FILE_IDS_INCLUDED)
|
||||
return()
|
||||
endif()
|
||||
set(FILE_IDS_INCLUDED true)
|
||||
|
||||
|
||||
# Verify syntax for all .fileids files and ensure no source file id is used
|
||||
# more than once.
|
||||
file(GLOB_RECURSE fils__ LIST_DIRECTORIES false "${CMAKE_SOURCE_DIR}/.fileids")
|
||||
|
||||
set(ids__)
|
||||
foreach(fil__ ${fils__})
|
||||
file(READ "${fil__}" lines__)
|
||||
string(REGEX REPLACE "\n" ";" lines__ ${lines__})
|
||||
foreach(line__ ${lines__})
|
||||
if("${line__}" MATCHES "^[ \t]*([0-9]+)[ \t]+.*$")
|
||||
set(id__ "${CMAKE_MATCH_1}")
|
||||
if(${id__} IN_LIST ids__)
|
||||
set(dup__ true)
|
||||
message(STATUS "Id ${id__} used more than once")
|
||||
else()
|
||||
list(APPEND ids__ ${id__})
|
||||
endif()
|
||||
elseif(NOT "${line__}" MATCHES "^[ \t]*#")
|
||||
message(FATAL_ERROR "Syntax error in ${fil__}")
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
if(dup__)
|
||||
message(FATAL_ERROR "Duplicate ids")
|
||||
endif()
|
||||
|
||||
function(JOIN lst glue var)
|
||||
string(REPLACE ";" "${glue}" tmp "${${lst}}")
|
||||
set(${var} "${tmp}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(FILE_ID src var) # private
|
||||
# .fileids files may reside in subdirectories to keep them together with the
|
||||
# files they assign an identifier to, much like .gitignore files
|
||||
set(dir "${CMAKE_SOURCE_DIR}")
|
||||
set(parts "${src}")
|
||||
string(REGEX REPLACE "[/\\]+" ";" parts "${parts}")
|
||||
while(parts)
|
||||
set(map "${dir}/.fileids")
|
||||
join(parts "/" fil)
|
||||
list(APPEND maps "${map}^${fil}")
|
||||
list(GET parts 0 part)
|
||||
list(REMOVE_AT parts 0)
|
||||
set(dir "${dir}/${part}")
|
||||
endwhile()
|
||||
|
||||
set(id)
|
||||
foreach(entry ${maps})
|
||||
string(REPLACE "^" ";" entry "${entry}")
|
||||
list(GET entry 0 map)
|
||||
list(GET entry 1 fil)
|
||||
if(EXISTS "${map}")
|
||||
file(READ "${map}" contents)
|
||||
string(REGEX REPLACE "\n" ";" lines "${contents}")
|
||||
|
||||
foreach(line ${lines})
|
||||
if("${line}" MATCHES "^[ \t]*([0-9]+)[ \t]+(.*)$")
|
||||
set(id "${CMAKE_MATCH_1}")
|
||||
string(STRIP "${CMAKE_MATCH_2}" expr)
|
||||
if("${fil}" STREQUAL "${expr}")
|
||||
set(${var} ${id} PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
elseif(NOT "${line}" MATCHES "^[ \t]*#")
|
||||
message(FATAL_ERROR "Syntax error in ${map}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
# Source file properties are visible only to targets added in the same
|
||||
# directory (CMakeLists.txt).
|
||||
# https://cmake.org/cmake/help/latest/command/set_source_files_properties.html
|
||||
function(SET_TARGET_FILE_IDS tgt)
|
||||
get_target_property(external ${tgt} IMPORTED)
|
||||
get_target_property(alias ${tgt} ALIASED_TARGET)
|
||||
string(LENGTH "${CMAKE_SOURCE_DIR}" len)
|
||||
math(EXPR len "${len} + 1") # strip slash following source dir too
|
||||
|
||||
if((NOT external) AND (NOT alias))
|
||||
get_target_property(srcs ${tgt} SOURCES)
|
||||
get_target_property(src_dir ${tgt} SOURCE_DIR)
|
||||
foreach(src ${srcs})
|
||||
set(id)
|
||||
if(IS_ABSOLUTE "${src}")
|
||||
set(fil "${src}")
|
||||
else()
|
||||
set(fil "${src_dir}/${src}")
|
||||
endif()
|
||||
|
||||
get_filename_component(fil "${fil}" ABSOLUTE)
|
||||
|
||||
string(FIND "${fil}" "${CMAKE_SOURCE_DIR}" pos)
|
||||
if(${pos} EQUAL 0)
|
||||
string(SUBSTRING "${fil}" ${len} -1 rel)
|
||||
file_id("${rel}" id)
|
||||
endif()
|
||||
|
||||
if(id)
|
||||
if(("${source_file_id_${id}}" STREQUAL "") OR
|
||||
("${source_file_id_${id}}" STREQUAL "${rel}"))
|
||||
set("source_file_id_${id}" "${rel}" CACHE INTERNAL "")
|
||||
set_source_files_properties(
|
||||
"${src}" PROPERTIES COMPILE_DEFINITIONS __FILE_ID__=${id})
|
||||
else()
|
||||
message(FATAL_ERROR "Same file id for ${rel} and ${source_file_id_${id}}")
|
||||
endif()
|
||||
else()
|
||||
get_filename_component(ext "${rel}" EXT)
|
||||
if (NOT "${ext}" MATCHES "\.h*")
|
||||
message(FATAL_ERROR "No source file id for ${rel}")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endfunction()
|
||||
|
|
@ -64,8 +64,6 @@ target_include_directories(
|
|||
# SOVERSION should increase on incompatible ABI change
|
||||
set_target_properties(ddsc PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})
|
||||
|
||||
set_target_file_ids(ddsc)
|
||||
|
||||
# Create a pseudo-target that other targets (i.e. examples, tests) can depend
|
||||
# on and can also be provided as import-target by a package-file when building
|
||||
# those targets outside the regular Cyclone build-tree (i.e. the installed tree)
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
# ddsc sources
|
||||
40 src/dds_alloc.c
|
||||
41 src/dds_coherent.c
|
||||
42 src/dds_iid.c
|
||||
43 src/dds_participant.c
|
||||
44 src/dds_reader.c
|
||||
45 src/dds_thread.c
|
||||
46 src/dds_writer.c
|
||||
47 src/dds_init.c
|
||||
48 src/dds_publisher.c
|
||||
49 src/dds_rhc.c
|
||||
50 src/dds_time.c
|
||||
51 src/q_osplser.c
|
||||
52 src/dds_domain.c
|
||||
53 src/dds_instance.c
|
||||
54 src/dds_qos.c
|
||||
55 src/dds_tkmap.c
|
||||
56 src/dds_entity.c
|
||||
57 src/dds_key.c
|
||||
58 src/dds_querycond.c
|
||||
59 src/dds_topic.c
|
||||
60 src/dds_err.c
|
||||
61 src/dds_listener.c
|
||||
62 src/dds_read.c
|
||||
63 src/dds_stream.c
|
||||
64 src/dds_waitset.c
|
||||
65 src/dds_log.c
|
||||
66 src/dds_readcond.c
|
||||
67 src/dds_subscriber.c
|
||||
68 src/dds_write.c
|
||||
70 src/dds_builtin.c
|
||||
72 src/dds_guardcond.c
|
||||
73 src/dds_whc.c
|
|
@ -22,6 +22,7 @@ PREPEND(srcs_ddsc "${CMAKE_CURRENT_LIST_DIR}/src"
|
|||
dds_domain.c
|
||||
dds_instance.c
|
||||
dds_qos.c
|
||||
dds_handles.c
|
||||
dds_entity.c
|
||||
dds_key.c
|
||||
dds_querycond.c
|
||||
|
@ -54,6 +55,7 @@ PREPEND(hdrs_private_ddsc "${CMAKE_CURRENT_LIST_DIR}/src"
|
|||
dds__alloc.h
|
||||
dds__builtin.h
|
||||
dds__domain.h
|
||||
dds__handles.h
|
||||
dds__entity.h
|
||||
dds__init.h
|
||||
dds__key.h
|
||||
|
|
|
@ -69,6 +69,9 @@ struct ddsi_serdata;
|
|||
*/
|
||||
DDS_EXPORT dds_domainid_t dds_domain_default (void);
|
||||
|
||||
|
||||
#define DDS_MIN_PSEUDO_HANDLE ((dds_entity_t) 0x7fff0000)
|
||||
|
||||
/* @defgroup builtintopic_constants Convenience constants for referring to builtin topics
|
||||
*
|
||||
* These constants can be used in place of an actual dds_topic_t, when creating
|
||||
|
@ -76,10 +79,10 @@ DDS_EXPORT dds_domainid_t dds_domain_default (void);
|
|||
*
|
||||
* @{
|
||||
*/
|
||||
extern DDS_EXPORT const dds_entity_t DDS_BUILTIN_TOPIC_DCPSPARTICIPANT;
|
||||
extern DDS_EXPORT const dds_entity_t DDS_BUILTIN_TOPIC_DCPSTOPIC;
|
||||
extern DDS_EXPORT const dds_entity_t DDS_BUILTIN_TOPIC_DCPSPUBLICATION;
|
||||
extern DDS_EXPORT const dds_entity_t DDS_BUILTIN_TOPIC_DCPSSUBSCRIPTION;
|
||||
#define DDS_BUILTIN_TOPIC_DCPSPARTICIPANT ((dds_entity_t) (DDS_MIN_PSEUDO_HANDLE + 1))
|
||||
#define DDS_BUILTIN_TOPIC_DCPSTOPIC ((dds_entity_t) (DDS_MIN_PSEUDO_HANDLE + 2))
|
||||
#define DDS_BUILTIN_TOPIC_DCPSPUBLICATION ((dds_entity_t) (DDS_MIN_PSEUDO_HANDLE + 3))
|
||||
#define DDS_BUILTIN_TOPIC_DCPSSUBSCRIPTION ((dds_entity_t) (DDS_MIN_PSEUDO_HANDLE + 4))
|
||||
/** @}*/
|
||||
|
||||
/** @name Communication Status definitions
|
||||
|
|
|
@ -96,7 +96,6 @@ dds_topic_descriptor_t;
|
|||
#define DDS_HANDLE_NIL 0
|
||||
#define DDS_ENTITY_NIL 0
|
||||
|
||||
#define DDS_ENTITY_KIND_MASK (0x7F000000) /* Should be same as UT_HANDLE_KIND_MASK. */
|
||||
typedef enum dds_entity_kind
|
||||
{
|
||||
DDS_KIND_DONTCARE = 0x00000000,
|
||||
|
@ -109,8 +108,7 @@ typedef enum dds_entity_kind
|
|||
DDS_KIND_COND_READ = 0x07000000,
|
||||
DDS_KIND_COND_QUERY = 0x08000000,
|
||||
DDS_KIND_COND_GUARD = 0x09000000,
|
||||
DDS_KIND_WAITSET = 0x0A000000,
|
||||
DDS_KIND_INTERNAL = 0x0B000000,
|
||||
DDS_KIND_WAITSET = 0x0A000000
|
||||
}
|
||||
dds_entity_kind_t;
|
||||
|
||||
|
|
|
@ -53,6 +53,10 @@ dds_entity_add_ref_nolock(dds_entity *e);
|
|||
qualifier_ dds_retcode_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) {
|
||||
return (dds_entity *) ((char *) hdllink - offsetof (struct dds_entity, m_hdllink));
|
||||
}
|
||||
|
||||
DDS_EXPORT inline bool dds_entity_is_enabled (const dds_entity *e) {
|
||||
return (e->m_flags & DDS_ENTITY_ENABLED) != 0;
|
||||
}
|
||||
|
@ -68,11 +72,7 @@ DDS_EXPORT inline bool dds_entity_status_match (const dds_entity *e, uint32_t t)
|
|||
}
|
||||
|
||||
DDS_EXPORT inline dds_entity_kind_t dds_entity_kind (const dds_entity *e) {
|
||||
return (dds_entity_kind_t) (e->m_hdl & DDS_ENTITY_KIND_MASK);
|
||||
}
|
||||
|
||||
DDS_EXPORT inline dds_entity_kind_t dds_entity_kind_from_handle (dds_entity_t hdl) {
|
||||
return (hdl > 0) ? (dds_entity_kind_t) (hdl & DDS_ENTITY_KIND_MASK) : DDS_KIND_DONTCARE;
|
||||
return e->m_kind;
|
||||
}
|
||||
|
||||
DDS_EXPORT void dds_entity_status_signal (dds_entity *e);
|
||||
|
@ -80,7 +80,9 @@ DDS_EXPORT void dds_entity_status_signal (dds_entity *e);
|
|||
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_valid_hdl(dds_entity_t hdl, dds_entity_kind_t kind);
|
||||
dds_entity_claim (
|
||||
dds_entity_t hdl,
|
||||
dds_entity **eptr);
|
||||
|
||||
DDS_EXPORT dds_retcode_t
|
||||
dds_entity_lock(
|
||||
|
@ -118,14 +120,22 @@ dds_delete_impl(
|
|||
dds_entity_t entity,
|
||||
bool keep_if_explicit);
|
||||
|
||||
DDS_EXPORT const char *
|
||||
dds__entity_kind_str(
|
||||
dds_entity_t e);
|
||||
|
||||
DDS_EXPORT dds_domain *
|
||||
dds__entity_domain(
|
||||
dds_entity* e);
|
||||
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_generic_unimplemented_operation_manykinds(
|
||||
dds_entity_t handle,
|
||||
size_t nkinds,
|
||||
const dds_entity_kind_t *kinds);
|
||||
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_generic_unimplemented_operation(
|
||||
dds_entity_t handle,
|
||||
dds_entity_kind_t kind);
|
||||
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -20,20 +20,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* To construct return status
|
||||
* Use '+' instead of '|'. Otherwise, the SAL checking doesn't
|
||||
* understand when a return value is negative or positive and
|
||||
* complains a lot about "A successful path through the function
|
||||
* does not set the named _Out_ parameter." */
|
||||
#if !defined(__FILE_ID__)
|
||||
#error "__FILE_ID__ not defined"
|
||||
#endif
|
||||
|
||||
#define DDS__FILE_ID__ (((__FILE_ID__ & 0x1ff)) << 22)
|
||||
#define DDS__LINE__ ((__LINE__ & 0x3fff) << 8)
|
||||
|
||||
#define DDS_ERRNO(err) \
|
||||
(assert(err > DDS_RETCODE_OK), -(DDS__FILE_ID__ + DDS__LINE__ + (err)))
|
||||
#define DDS_ERRNO(err) (assert(err > DDS_RETCODE_OK), -(err))
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
|
|
|
@ -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,19 +9,20 @@
|
|||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#ifndef UT_HANDLESERVER_H
|
||||
#define UT_HANDLESERVER_H
|
||||
#ifndef DDS__HANDLES_H
|
||||
#define DDS__HANDLES_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "dds/export.h"
|
||||
#include "dds/ddsrt/time.h"
|
||||
#include "dds/ddsrt/retcode.h"
|
||||
#include "dds/ddsrt/atomics.h"
|
||||
#include "dds/dds.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct dds_entity;
|
||||
|
||||
/********************************************************************************************
|
||||
*
|
||||
* TODO CHAM-138: Header file improvements
|
||||
|
@ -51,46 +52,8 @@ extern "C" {
|
|||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Some error return values.
|
||||
*/
|
||||
typedef enum ut_handle_retcode_t {
|
||||
UT_HANDLE_OK = 0,
|
||||
UT_HANDLE_ERROR = -1, /* General error. */
|
||||
UT_HANDLE_CLOSED = -2, /* Handle has been previously close. */
|
||||
UT_HANDLE_DELETED = -3, /* Handle has been previously deleted. */
|
||||
UT_HANDLE_INVALID = -4, /* Handle is not a valid handle. */
|
||||
UT_HANDLE_UNEQUAL_KIND = -5, /* Handle does not contain expected kind. */
|
||||
UT_HANDLE_TIMEOUT = -6, /* Operation timed out. */
|
||||
UT_HANDLE_OUT_OF_RESOURCES = -7, /* Action isn't possible because of limited resources. */
|
||||
UT_HANDLE_NOT_INITALIZED = -8 /* Not initialized. */
|
||||
} ut_handle_retcode_t;
|
||||
|
||||
|
||||
/*
|
||||
* The 32 bit handle
|
||||
* | bits | # values | description |
|
||||
* --------------------------------------------------------------------------------------
|
||||
* | 31 | 2 | positive/negative (negative can be used to indicate errors) |
|
||||
* | 24-30 | 127 | handle kind (value determined by client) |
|
||||
* | 0-23 | 16.777.215 | index or hash (maintained by the handleserver) |
|
||||
*
|
||||
* When the handle is negative, it'll contain a ut_handle_retcode_t error value.
|
||||
*
|
||||
* FYI: the entity id within DDSI is also 24 bits...
|
||||
*/
|
||||
typedef int32_t ut_handle_t;
|
||||
|
||||
/*
|
||||
* Handle bits
|
||||
* +kkk kkkk iiii iiii iiii iiii iiii iiii
|
||||
* 31| | 24| 0|
|
||||
*/
|
||||
#define UT_HANDLE_SIGN_MASK (0x80000000)
|
||||
#define UT_HANDLE_KIND_MASK (0x7F000000)
|
||||
#define UT_HANDLE_IDX_MASK (0x00FFFFFF)
|
||||
|
||||
#define UT_HANDLE_DONTCARE_KIND (0)
|
||||
typedef int32_t dds_handle_t;
|
||||
|
||||
/*
|
||||
* The handle link type.
|
||||
|
@ -106,14 +69,16 @@ typedef int32_t ut_handle_t;
|
|||
* This handlelink is invalid after the related handle is deleted and should
|
||||
* never be used afterwards.
|
||||
*/
|
||||
struct ut_handlelink;
|
||||
|
||||
struct dds_handle_link {
|
||||
dds_handle_t hdl;
|
||||
ddsrt_atomic_uint32_t cnt_flags;
|
||||
};
|
||||
|
||||
/*
|
||||
* Initialize handleserver singleton.
|
||||
*/
|
||||
DDS_EXPORT ut_handle_retcode_t
|
||||
ut_handleserver_init(void);
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_handle_server_init(void (*free_via_gc) (void *x));
|
||||
|
||||
|
||||
/*
|
||||
|
@ -121,7 +86,7 @@ ut_handleserver_init(void);
|
|||
* The handleserver is destroyed when fini() is called as often as init().
|
||||
*/
|
||||
DDS_EXPORT void
|
||||
ut_handleserver_fini(void);
|
||||
dds_handle_server_fini(void);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -142,8 +107,9 @@ ut_handleserver_fini(void);
|
|||
* Valid handle when returned value is positive.
|
||||
* Otherwise negative handle is returned.
|
||||
*/
|
||||
DDS_EXPORT ut_handle_t
|
||||
ut_handle_create(int32_t kind, void *arg);
|
||||
DDS_EXPORT dds_handle_t
|
||||
dds_handle_create(
|
||||
struct dds_handle_link *link);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -153,7 +119,8 @@ ut_handle_create(int32_t kind, void *arg);
|
|||
* This is a noop on an already closed handle.
|
||||
*/
|
||||
DDS_EXPORT void
|
||||
ut_handle_close(ut_handle_t hdl, struct ut_handlelink *link);
|
||||
dds_handle_close(
|
||||
struct dds_handle_link *link);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -165,46 +132,35 @@ ut_handle_close(ut_handle_t hdl, struct ut_handlelink *link);
|
|||
* It will delete the information when there are no more active claims. It'll
|
||||
* block when necessary to wait for all possible claims to be released.
|
||||
*/
|
||||
DDS_EXPORT ut_handle_retcode_t
|
||||
ut_handle_delete(
|
||||
ut_handle_t hdl,
|
||||
struct ut_handlelink *link,
|
||||
DDS_EXPORT int32_t
|
||||
dds_handle_delete(
|
||||
struct dds_handle_link *link,
|
||||
dds_time_t timeout);
|
||||
|
||||
|
||||
/*
|
||||
* Returns the status the given handle; valid/deleted/closed/etc.
|
||||
*
|
||||
* Returns OK when valid.
|
||||
*/
|
||||
ut_handle_retcode_t
|
||||
ut_handle_status(
|
||||
ut_handle_t hdl,
|
||||
struct ut_handlelink *link,
|
||||
int32_t kind);
|
||||
|
||||
|
||||
/*
|
||||
* If the a valid handle is given, which matches the kind and it is not closed,
|
||||
* then the related arg will be provided and the claims count is increased.
|
||||
*
|
||||
* Returns OK when succeeded.
|
||||
*/
|
||||
DDS_EXPORT ut_handle_retcode_t
|
||||
ut_handle_claim(
|
||||
ut_handle_t hdl,
|
||||
struct ut_handlelink *link,
|
||||
int32_t kind,
|
||||
void **arg);
|
||||
DDS_EXPORT int32_t
|
||||
dds_handle_claim(
|
||||
dds_handle_t hdl,
|
||||
struct dds_handle_link **entity);
|
||||
|
||||
|
||||
DDS_EXPORT void
|
||||
dds_handle_claim_inc(
|
||||
struct dds_handle_link *link);
|
||||
|
||||
|
||||
/*
|
||||
* The active claims count is decreased.
|
||||
*/
|
||||
DDS_EXPORT void
|
||||
ut_handle_release(
|
||||
ut_handle_t hdl,
|
||||
struct ut_handlelink *link);
|
||||
dds_handle_release(
|
||||
struct dds_handle_link *link);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -217,21 +173,12 @@ ut_handle_release(
|
|||
* possible.
|
||||
*/
|
||||
DDS_EXPORT bool
|
||||
ut_handle_is_closed(
|
||||
ut_handle_t hdl,
|
||||
struct ut_handlelink *link);
|
||||
dds_handle_is_closed(
|
||||
struct dds_handle_link *link);
|
||||
|
||||
|
||||
/*
|
||||
* This will get the link of the handle, which can be used for performance
|
||||
* increase.
|
||||
*/
|
||||
DDS_EXPORT struct ut_handlelink*
|
||||
ut_handle_get_link(
|
||||
ut_handle_t hdl);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* UT_HANDLESERVER_H */
|
||||
#endif /* DDS__HANDLES_H */
|
|
@ -13,11 +13,14 @@
|
|||
#define _DDS_PUBLISHER_H_
|
||||
|
||||
#include "dds/dds.h"
|
||||
#include "dds__entity.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
DEFINE_ENTITY_LOCK_UNLOCK(inline, dds_publisher, DDS_KIND_PUBLISHER)
|
||||
|
||||
dds_return_t dds_publisher_begin_coherent (dds_entity_t e);
|
||||
dds_return_t dds_publisher_end_coherent (dds_entity_t e);
|
||||
|
||||
|
|
|
@ -13,12 +13,13 @@
|
|||
#define _DDS_SUBSCRIBER_H_
|
||||
|
||||
#include "dds/dds.h"
|
||||
#include "dds__entity.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct dds_entity;
|
||||
DEFINE_ENTITY_LOCK_UNLOCK(inline, dds_subscriber, DDS_KIND_SUBSCRIBER)
|
||||
|
||||
dds_entity_t
|
||||
dds__create_subscriber_l(
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "dds/ddsrt/sync.h"
|
||||
#include "dds/ddsi/q_rtps.h"
|
||||
#include "dds/util/ut_avl.h"
|
||||
#include "dds/util/ut_handleserver.h"
|
||||
#include "dds__handles.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
|
@ -125,7 +125,8 @@ dds_entity_observer;
|
|||
|
||||
typedef struct dds_entity
|
||||
{
|
||||
ut_handle_t m_hdl;
|
||||
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;
|
||||
|
@ -147,8 +148,6 @@ typedef struct dds_entity
|
|||
uint32_t m_status_enable;
|
||||
uint32_t m_cb_count;
|
||||
dds_entity_observer *m_observers;
|
||||
|
||||
struct ut_handlelink *m_hdllink;
|
||||
}
|
||||
dds_entity;
|
||||
|
||||
|
|
|
@ -21,52 +21,14 @@ dds_return_t
|
|||
dds_begin_coherent(
|
||||
dds_entity_t entity)
|
||||
{
|
||||
dds_return_t ret;
|
||||
|
||||
switch(dds_entity_kind_from_handle(entity)) {
|
||||
case DDS_KIND_READER:
|
||||
case DDS_KIND_WRITER:
|
||||
/* Invoking on a writer/reader behaves as if invoked on
|
||||
* its parent publisher/subscriber. */
|
||||
ret = dds_begin_coherent(dds_get_parent(entity));
|
||||
break;
|
||||
case DDS_KIND_PUBLISHER:
|
||||
ret = dds_publisher_begin_coherent(entity);
|
||||
break;
|
||||
case DDS_KIND_SUBSCRIBER:
|
||||
ret = dds_subscriber_begin_coherent(entity);
|
||||
break;
|
||||
default:
|
||||
DDS_ERROR("Given entity can not control coherency\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER);
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
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 ret;
|
||||
|
||||
switch(dds_entity_kind_from_handle(entity)) {
|
||||
case DDS_KIND_READER:
|
||||
case DDS_KIND_WRITER:
|
||||
/* Invoking on a writer/reader behaves as if invoked on
|
||||
* its parent publisher/subscriber. */
|
||||
ret = dds_end_coherent(dds_get_parent(entity));
|
||||
break;
|
||||
case DDS_KIND_PUBLISHER:
|
||||
ret = dds_publisher_end_coherent(entity);
|
||||
break;
|
||||
case DDS_KIND_SUBSCRIBER:
|
||||
ret = dds_subscriber_end_coherent(entity);
|
||||
break;
|
||||
default:
|
||||
DDS_ERROR("Given entity can not control coherency\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER);
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -22,16 +22,11 @@
|
|||
#include "dds__err.h"
|
||||
#include "dds/version.h"
|
||||
|
||||
/* Sanity check. */
|
||||
#if DDS_ENTITY_KIND_MASK != UT_HANDLE_KIND_MASK
|
||||
#error "DDS_ENTITY_KIND_MASK != UT_HANDLE_KIND_MASK"
|
||||
#endif
|
||||
|
||||
extern inline dds_entity *dds_entity_from_handle_link (struct dds_handle_link *hdllink);
|
||||
extern inline bool dds_entity_is_enabled (const dds_entity *e);
|
||||
extern inline void dds_entity_status_reset (dds_entity *e, uint32_t t);
|
||||
extern inline bool dds_entity_status_match (const dds_entity *e, uint32_t t);
|
||||
extern inline dds_entity_kind_t dds_entity_kind (const dds_entity *e);
|
||||
extern inline dds_entity_kind_t dds_entity_kind_from_handle (dds_entity_t hdl);
|
||||
|
||||
static void dds_entity_observers_signal (dds_entity *observed, uint32_t status);
|
||||
static void dds_entity_observers_delete (dds_entity *observed);
|
||||
|
@ -71,10 +66,13 @@ static dds_entity *dds__nonself_parent (dds_entity *e)
|
|||
|
||||
dds_entity_t dds_entity_init (dds_entity *e, dds_entity *parent, dds_entity_kind_t kind, dds_qos_t *qos, const dds_listener_t *listener, uint32_t mask)
|
||||
{
|
||||
dds_handle_t handle;
|
||||
|
||||
assert ((kind == DDS_KIND_PARTICIPANT) == (parent == NULL));
|
||||
assert (e);
|
||||
|
||||
e->m_refc = 1;
|
||||
e->m_kind = kind;
|
||||
e->m_qos = qos;
|
||||
e->m_cb_count = 0;
|
||||
e->m_observers = NULL;
|
||||
|
@ -116,29 +114,11 @@ dds_entity_t dds_entity_init (dds_entity *e, dds_entity *parent, dds_entity_kind
|
|||
ddsrt_mutex_unlock (&e->m_observers_lock);
|
||||
}
|
||||
|
||||
e->m_hdllink = NULL;
|
||||
e->m_hdl = ut_handle_create ((int32_t) kind, e);
|
||||
if (e->m_hdl > 0)
|
||||
{
|
||||
e->m_hdllink = ut_handle_get_link (e->m_hdl);
|
||||
assert(e->m_hdllink);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (e->m_hdl == UT_HANDLE_OUT_OF_RESOURCES) {
|
||||
DDS_ERROR ("Can not create new entity; too many where created previously\n");
|
||||
e->m_hdl = DDS_ERRNO (DDS_RETCODE_OUT_OF_RESOURCES);
|
||||
} else if (e->m_hdl == UT_HANDLE_NOT_INITALIZED) {
|
||||
DDS_ERROR (DDS_PROJECT_NAME" is not yet initialized. Please create a participant before executing an other method\n");
|
||||
e->m_hdl = DDS_ERRNO (DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
} else {
|
||||
DDS_ERROR ("An internal error has occurred\n");
|
||||
e->m_hdl = DDS_ERRNO (DDS_RETCODE_ERROR);
|
||||
}
|
||||
}
|
||||
if ((handle = dds_handle_create (&e->m_hdllink)) <= 0)
|
||||
return (dds_entity_t) handle;
|
||||
|
||||
/* An ut_handle_t is directly used as dds_entity_t. */
|
||||
return (dds_entity_t) e->m_hdl;
|
||||
/* An dds_handle_t is directly used as dds_entity_t. */
|
||||
return (dds_entity_t) handle;
|
||||
}
|
||||
|
||||
dds_return_t dds_delete (dds_entity_t entity)
|
||||
|
@ -164,7 +144,7 @@ dds_return_t dds_delete_impl (dds_entity_t entity, bool keep_if_explicit)
|
|||
dds_return_t ret;
|
||||
dds_retcode_t rc;
|
||||
|
||||
rc = dds_entity_lock (entity, UT_HANDLE_DONTCARE_KIND, &e);
|
||||
rc = dds_entity_lock (entity, DDS_KIND_DONTCARE, &e);
|
||||
if (rc != DDS_RETCODE_OK)
|
||||
{
|
||||
DDS_TRACE ("dds_delete_impl: error on locking entity %"PRIu32" keep_if_explicit %d\n", entity, (int) keep_if_explicit);
|
||||
|
@ -183,7 +163,7 @@ dds_return_t dds_delete_impl (dds_entity_t entity, bool keep_if_explicit)
|
|||
return DDS_RETCODE_OK;
|
||||
}
|
||||
|
||||
ut_handle_close (e->m_hdl, e->m_hdllink);
|
||||
dds_handle_close (&e->m_hdllink);
|
||||
ddsrt_mutex_lock (&e->m_observers_lock);
|
||||
while (e->m_cb_count > 0)
|
||||
ddsrt_cond_wait (&e->m_observers_cond, &e->m_observers_lock);
|
||||
|
@ -219,7 +199,7 @@ dds_return_t dds_delete_impl (dds_entity_t entity, bool keep_if_explicit)
|
|||
{
|
||||
next = next_non_topic_child (child->m_next);
|
||||
/* This will probably delete the child entry from the current children's list */
|
||||
ret = dds_delete (child->m_hdl);
|
||||
ret = dds_delete (child->m_hdllink.hdl);
|
||||
child = next;
|
||||
}
|
||||
child = e->m_children;
|
||||
|
@ -227,7 +207,7 @@ dds_return_t dds_delete_impl (dds_entity_t entity, bool keep_if_explicit)
|
|||
{
|
||||
next = child->m_next;
|
||||
assert (dds_entity_kind (child) == DDS_KIND_TOPIC);
|
||||
ret = dds_delete (child->m_hdl);
|
||||
ret = dds_delete (child->m_hdllink.hdl);
|
||||
child = next;
|
||||
}
|
||||
if (ret == DDS_RETCODE_OK && e->m_deriver.close)
|
||||
|
@ -239,11 +219,11 @@ dds_return_t dds_delete_impl (dds_entity_t entity, bool keep_if_explicit)
|
|||
|
||||
if (ret == DDS_RETCODE_OK)
|
||||
{
|
||||
/* The ut_handle_delete will wait until the last active claim on that handle
|
||||
/* The dds_handle_delete will wait until the last active claim on that handle
|
||||
* is released. It is possible that this last release will be done by a thread
|
||||
* that was kicked during the close(). */
|
||||
if (ut_handle_delete (e->m_hdl, e->m_hdllink, timeout) != UT_HANDLE_OK)
|
||||
return DDS_ERRNO (DDS_RETCODE_TIMEOUT);
|
||||
if ((ret = dds_handle_delete (&e->m_hdllink, timeout)) != DDS_RETCODE_OK)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (ret == DDS_RETCODE_OK)
|
||||
|
@ -301,7 +281,7 @@ dds_entity_t dds_get_parent (dds_entity_t entity)
|
|||
hdl = DDS_ENTITY_NIL;
|
||||
else
|
||||
{
|
||||
hdl = parent->m_hdl;
|
||||
hdl = parent->m_hdllink.hdl;
|
||||
dds_set_explicit (hdl);
|
||||
}
|
||||
dds_entity_unlock (e);
|
||||
|
@ -317,7 +297,7 @@ dds_entity_t dds_get_participant (dds_entity_t entity)
|
|||
return DDS_ERRNO (rc);
|
||||
else
|
||||
{
|
||||
dds_entity_t hdl = e->m_participant->m_hdl;
|
||||
dds_entity_t hdl = e->m_participant->m_hdllink.hdl;
|
||||
dds_entity_unlock (e);
|
||||
return hdl;
|
||||
}
|
||||
|
@ -343,8 +323,8 @@ dds_return_t dds_get_children (dds_entity_t entity, dds_entity_t *children, size
|
|||
{
|
||||
if ((size_t) n < size)
|
||||
{
|
||||
children[n] = iter->m_hdl;
|
||||
dds_set_explicit (iter->m_hdl);
|
||||
children[n] = iter->m_hdllink.hdl;
|
||||
dds_set_explicit (iter->m_hdllink.hdl);
|
||||
}
|
||||
n++;
|
||||
iter = iter->m_next;
|
||||
|
@ -437,65 +417,65 @@ void dds_entity_invoke_listener (const dds_entity *entity, enum dds_status_id wh
|
|||
{
|
||||
case DDS_INCONSISTENT_TOPIC_STATUS_ID: {
|
||||
struct dds_inconsistent_topic_status const * const st = vst;
|
||||
lst->on_inconsistent_topic (entity->m_hdl, *st, lst->on_inconsistent_topic_arg);
|
||||
lst->on_inconsistent_topic (entity->m_hdllink.hdl, *st, lst->on_inconsistent_topic_arg);
|
||||
break;
|
||||
}
|
||||
case DDS_REQUESTED_DEADLINE_MISSED_STATUS_ID: {
|
||||
struct dds_requested_deadline_missed_status const * const st = vst;
|
||||
lst->on_requested_deadline_missed (entity->m_hdl, *st, lst->on_requested_deadline_missed_arg);
|
||||
lst->on_requested_deadline_missed (entity->m_hdllink.hdl, *st, lst->on_requested_deadline_missed_arg);
|
||||
break;
|
||||
}
|
||||
case DDS_REQUESTED_INCOMPATIBLE_QOS_STATUS_ID: {
|
||||
struct dds_requested_incompatible_qos_status const * const st = vst;
|
||||
lst->on_requested_incompatible_qos (entity->m_hdl, *st, lst->on_requested_incompatible_qos_arg);
|
||||
lst->on_requested_incompatible_qos (entity->m_hdllink.hdl, *st, lst->on_requested_incompatible_qos_arg);
|
||||
break;
|
||||
}
|
||||
case DDS_SAMPLE_LOST_STATUS_ID: {
|
||||
struct dds_sample_lost_status const * const st = vst;
|
||||
lst->on_sample_lost (entity->m_hdl, *st, lst->on_sample_lost_arg);
|
||||
lst->on_sample_lost (entity->m_hdllink.hdl, *st, lst->on_sample_lost_arg);
|
||||
break;
|
||||
}
|
||||
case DDS_SAMPLE_REJECTED_STATUS_ID: {
|
||||
struct dds_sample_rejected_status const * const st = vst;
|
||||
lst->on_sample_rejected (entity->m_hdl, *st, lst->on_sample_rejected_arg);
|
||||
lst->on_sample_rejected (entity->m_hdllink.hdl, *st, lst->on_sample_rejected_arg);
|
||||
break;
|
||||
}
|
||||
case DDS_LIVELINESS_CHANGED_STATUS_ID: {
|
||||
struct dds_liveliness_changed_status const * const st = vst;
|
||||
lst->on_liveliness_changed (entity->m_hdl, *st, lst->on_liveliness_changed_arg);
|
||||
lst->on_liveliness_changed (entity->m_hdllink.hdl, *st, lst->on_liveliness_changed_arg);
|
||||
break;
|
||||
}
|
||||
case DDS_SUBSCRIPTION_MATCHED_STATUS_ID: {
|
||||
struct dds_subscription_matched_status const * const st = vst;
|
||||
lst->on_subscription_matched (entity->m_hdl, *st, lst->on_subscription_matched_arg);
|
||||
lst->on_subscription_matched (entity->m_hdllink.hdl, *st, lst->on_subscription_matched_arg);
|
||||
break;
|
||||
}
|
||||
case DDS_OFFERED_DEADLINE_MISSED_STATUS_ID: {
|
||||
struct dds_offered_deadline_missed_status const * const st = vst;
|
||||
lst->on_offered_deadline_missed (entity->m_hdl, *st, lst->on_offered_deadline_missed_arg);
|
||||
lst->on_offered_deadline_missed (entity->m_hdllink.hdl, *st, lst->on_offered_deadline_missed_arg);
|
||||
break;
|
||||
}
|
||||
case DDS_LIVELINESS_LOST_STATUS_ID: {
|
||||
struct dds_liveliness_lost_status const * const st = vst;
|
||||
lst->on_liveliness_lost (entity->m_hdl, *st, lst->on_liveliness_lost_arg);
|
||||
lst->on_liveliness_lost (entity->m_hdllink.hdl, *st, lst->on_liveliness_lost_arg);
|
||||
break;
|
||||
}
|
||||
case DDS_OFFERED_INCOMPATIBLE_QOS_STATUS_ID: {
|
||||
struct dds_offered_incompatible_qos_status const * const st = vst;
|
||||
lst->on_offered_incompatible_qos (entity->m_hdl, *st, lst->on_offered_incompatible_qos_arg);
|
||||
lst->on_offered_incompatible_qos (entity->m_hdllink.hdl, *st, lst->on_offered_incompatible_qos_arg);
|
||||
break;
|
||||
}
|
||||
case DDS_PUBLICATION_MATCHED_STATUS_ID: {
|
||||
struct dds_publication_matched_status const * const st = vst;
|
||||
lst->on_publication_matched (entity->m_hdl, *st, lst->on_publication_matched_arg);
|
||||
lst->on_publication_matched (entity->m_hdllink.hdl, *st, lst->on_publication_matched_arg);
|
||||
break;
|
||||
}
|
||||
case DDS_DATA_AVAILABLE_STATUS_ID: {
|
||||
lst->on_data_available (entity->m_hdl, lst->on_data_available_arg);
|
||||
lst->on_data_available (entity->m_hdllink.hdl, lst->on_data_available_arg);
|
||||
break;
|
||||
}
|
||||
case DDS_DATA_ON_READERS_STATUS_ID: {
|
||||
lst->on_data_on_readers (entity->m_hdl, lst->on_data_on_readers_arg);
|
||||
lst->on_data_on_readers (entity->m_hdllink.hdl, lst->on_data_on_readers_arg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -768,45 +748,36 @@ dds_return_t dds_get_instance_handle (dds_entity_t entity, dds_instance_handle_t
|
|||
return ret;
|
||||
}
|
||||
|
||||
|
||||
dds_retcode_t dds_valid_hdl (dds_entity_t hdl, dds_entity_kind_t kind)
|
||||
dds_retcode_t dds_entity_claim (dds_entity_t hdl, dds_entity **eptr)
|
||||
{
|
||||
ut_handle_t utr;
|
||||
if ((utr = ut_handle_status (hdl, NULL, (int32_t) kind)) == UT_HANDLE_OK)
|
||||
return DDS_RETCODE_OK;
|
||||
else if (hdl < 0)
|
||||
return DDS_RETCODE_BAD_PARAMETER;
|
||||
dds_retcode_t hres;
|
||||
struct dds_handle_link *hdllink;
|
||||
if ((hres = dds_handle_claim (hdl, &hdllink)) != DDS_RETCODE_OK)
|
||||
return hres;
|
||||
else
|
||||
{
|
||||
switch (utr)
|
||||
{
|
||||
case UT_HANDLE_OK:
|
||||
assert (0);
|
||||
/* FALLS THROUGH */
|
||||
case UT_HANDLE_UNEQUAL_KIND:
|
||||
return DDS_RETCODE_ILLEGAL_OPERATION;
|
||||
case UT_HANDLE_INVALID:
|
||||
return DDS_RETCODE_BAD_PARAMETER;
|
||||
case UT_HANDLE_DELETED:
|
||||
case UT_HANDLE_CLOSED:
|
||||
return DDS_RETCODE_ALREADY_DELETED;
|
||||
default:
|
||||
return DDS_RETCODE_ERROR;
|
||||
}
|
||||
*eptr = dds_entity_from_handle_link (hdllink);
|
||||
return DDS_RETCODE_OK;
|
||||
}
|
||||
}
|
||||
|
||||
dds_retcode_t dds_entity_lock (dds_entity_t hdl, dds_entity_kind_t kind, dds_entity **eptr)
|
||||
{
|
||||
ut_handle_t utr;
|
||||
void *raw;
|
||||
dds_retcode_t hres;
|
||||
dds_entity *e;
|
||||
|
||||
/* When the given handle already contains an error, then return that
|
||||
* same error to retain the original information. */
|
||||
if ((utr = ut_handle_claim (hdl, NULL, (int32_t) kind, &raw)) == UT_HANDLE_OK)
|
||||
if ((hres = dds_entity_claim (hdl, &e)) != DDS_RETCODE_OK)
|
||||
return hres;
|
||||
else
|
||||
{
|
||||
dds_entity *e;
|
||||
*eptr = e = raw;
|
||||
if (dds_entity_kind (e) != kind && kind != DDS_KIND_DONTCARE)
|
||||
{
|
||||
dds_handle_release (&e->m_hdllink);
|
||||
return DDS_RETCODE_ILLEGAL_OPERATION;
|
||||
}
|
||||
|
||||
ddsrt_mutex_lock (&e->m_mutex);
|
||||
/* FIXME: The handle could have been closed while we were waiting for the mutex -- that should be handled differently!
|
||||
|
||||
|
@ -815,41 +786,20 @@ dds_retcode_t dds_entity_lock (dds_entity_t hdl, dds_entity_kind_t kind, dds_ent
|
|||
(2) preventing dds_delete_impl from doing anything once the entity is being deleted.
|
||||
|
||||
Without (1), it would be possible to add children while trying to delete them, without (2) you're looking at crashes. */
|
||||
if (ut_handle_is_closed (hdl, e->m_hdllink))
|
||||
if (dds_handle_is_closed (&e->m_hdllink))
|
||||
{
|
||||
dds_entity_unlock (e);
|
||||
return DDS_RETCODE_ALREADY_DELETED;
|
||||
return DDS_RETCODE_BAD_PARAMETER;
|
||||
}
|
||||
*eptr = e;
|
||||
return DDS_RETCODE_OK;
|
||||
}
|
||||
else if (hdl < 0)
|
||||
{
|
||||
return DDS_RETCODE_BAD_PARAMETER;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (utr)
|
||||
{
|
||||
case UT_HANDLE_OK:
|
||||
assert (0);
|
||||
/* FALLS THROUGH */
|
||||
case UT_HANDLE_UNEQUAL_KIND:
|
||||
return DDS_RETCODE_ILLEGAL_OPERATION;
|
||||
case UT_HANDLE_INVALID:
|
||||
return DDS_RETCODE_BAD_PARAMETER;
|
||||
case UT_HANDLE_DELETED:
|
||||
case UT_HANDLE_CLOSED:
|
||||
return DDS_RETCODE_ALREADY_DELETED;
|
||||
default:
|
||||
return DDS_RETCODE_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void dds_entity_unlock (dds_entity *e)
|
||||
{
|
||||
ddsrt_mutex_unlock (&e->m_mutex);
|
||||
ut_handle_release (e->m_hdl, e->m_hdllink);
|
||||
dds_handle_release (&e->m_hdllink);
|
||||
}
|
||||
|
||||
dds_return_t dds_triggered (dds_entity_t entity)
|
||||
|
@ -965,7 +915,7 @@ static void dds_entity_observers_delete (dds_entity *observed)
|
|||
static void dds_entity_observers_signal (dds_entity *observed, uint32_t status)
|
||||
{
|
||||
for (dds_entity_observer *idx = observed->m_observers; idx; idx = idx->m_next)
|
||||
idx->m_cb (idx->m_observer, observed->m_hdl, status);
|
||||
idx->m_cb (idx->m_observer, observed->m_hdllink.hdl, status);
|
||||
}
|
||||
|
||||
void dds_entity_status_signal (dds_entity *e)
|
||||
|
@ -996,19 +946,19 @@ dds_entity_t dds_get_topic (dds_entity_t entity)
|
|||
{
|
||||
case DDS_KIND_READER: {
|
||||
dds_reader *rd = (dds_reader *) e;
|
||||
hdl = rd->m_topic->m_entity.m_hdl;
|
||||
hdl = rd->m_topic->m_entity.m_hdllink.hdl;
|
||||
break;
|
||||
}
|
||||
case DDS_KIND_WRITER: {
|
||||
dds_writer *wr = (dds_writer *) e;
|
||||
hdl = wr->m_topic->m_entity.m_hdl;
|
||||
hdl = wr->m_topic->m_entity.m_hdllink.hdl;
|
||||
break;
|
||||
}
|
||||
case DDS_KIND_COND_READ:
|
||||
case DDS_KIND_COND_QUERY: {
|
||||
assert (dds_entity_kind (e->m_parent) == DDS_KIND_READER);
|
||||
dds_reader *rd = (dds_reader *) e->m_parent;
|
||||
hdl = rd->m_topic->m_entity.m_hdl;
|
||||
hdl = rd->m_topic->m_entity.m_hdllink.hdl;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
@ -1020,21 +970,32 @@ dds_entity_t dds_get_topic (dds_entity_t entity)
|
|||
return hdl;
|
||||
}
|
||||
|
||||
const char *dds__entity_kind_str (dds_entity_t e)
|
||||
dds_return_t dds_generic_unimplemented_operation_manykinds (dds_entity_t handle, size_t nkinds, const dds_entity_kind_t *kinds)
|
||||
{
|
||||
if (e <= 0)
|
||||
return "(ERROR)";
|
||||
switch (e & DDS_ENTITY_KIND_MASK)
|
||||
dds_entity *e;
|
||||
dds_retcode_t ret;
|
||||
if ((ret = dds_entity_claim (handle, &e)) != DDS_RETCODE_OK)
|
||||
return DDS_ERRNO (ret);
|
||||
else
|
||||
{
|
||||
case DDS_KIND_TOPIC: return "Topic";
|
||||
case DDS_KIND_PARTICIPANT: return "Participant";
|
||||
case DDS_KIND_READER: return "Reader";
|
||||
case DDS_KIND_WRITER: return "Writer";
|
||||
case DDS_KIND_SUBSCRIBER: return "Subscriber";
|
||||
case DDS_KIND_PUBLISHER: return "Publisher";
|
||||
case DDS_KIND_COND_READ: return "ReadCondition";
|
||||
case DDS_KIND_COND_QUERY: return "QueryCondition";
|
||||
case DDS_KIND_WAITSET: return "WaitSet";
|
||||
default: return "(INVALID_ENTITY)";
|
||||
const dds_entity_kind_t actual = dds_entity_kind (e);
|
||||
ret = DDS_RETCODE_ILLEGAL_OPERATION;
|
||||
for (size_t i = 0; i < nkinds; i++)
|
||||
{
|
||||
if (kinds[i] == actual)
|
||||
{
|
||||
/* If the handle happens to be for an entity of the right kind, return unsupported */
|
||||
ret = DDS_RETCODE_UNSUPPORTED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
dds_handle_release (&e->m_hdllink);
|
||||
return DDS_ERRNO (ret);
|
||||
}
|
||||
}
|
||||
|
||||
dds_return_t dds_generic_unimplemented_operation (dds_entity_t handle, dds_entity_kind_t kind)
|
||||
{
|
||||
return dds_generic_unimplemented_operation_manykinds (handle, 1, &kind);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ dds_return_t dds_set_guardcondition (dds_entity_t condition, bool triggered)
|
|||
dds_retcode_t rc;
|
||||
|
||||
if ((rc = dds_guardcond_lock (condition, &gcond)) != DDS_RETCODE_OK)
|
||||
return DDS_ERRNO (dds_valid_hdl (condition, DDS_KIND_COND_GUARD));
|
||||
return DDS_ERRNO (DDS_RETCODE_BAD_PARAMETER);
|
||||
else
|
||||
{
|
||||
ddsrt_mutex_lock (&gcond->m_entity.m_observers_lock);
|
||||
|
@ -67,7 +67,7 @@ dds_return_t dds_read_guardcondition (dds_entity_t condition, bool *triggered)
|
|||
|
||||
*triggered = false;
|
||||
if ((rc = dds_guardcond_lock (condition, &gcond)) != DDS_RETCODE_OK)
|
||||
return DDS_ERRNO (dds_valid_hdl (condition, DDS_KIND_COND_GUARD));
|
||||
return DDS_ERRNO (DDS_RETCODE_BAD_PARAMETER);
|
||||
else
|
||||
{
|
||||
ddsrt_mutex_lock (&gcond->m_entity.m_observers_lock);
|
||||
|
@ -88,7 +88,7 @@ dds_return_t dds_take_guardcondition (dds_entity_t condition, bool *triggered)
|
|||
|
||||
*triggered = false;
|
||||
if ((rc = dds_guardcond_lock (condition, &gcond)) != DDS_RETCODE_OK)
|
||||
return DDS_ERRNO (dds_valid_hdl (condition, DDS_KIND_COND_GUARD));
|
||||
return DDS_ERRNO (DDS_RETCODE_BAD_PARAMETER);
|
||||
else
|
||||
{
|
||||
ddsrt_mutex_lock (&gcond->m_entity.m_observers_lock);
|
||||
|
|
267
src/core/ddsc/src/dds_handles.c
Normal file
267
src/core/ddsc/src/dds_handles.c
Normal file
|
@ -0,0 +1,267 @@
|
|||
/*
|
||||
* 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 <string.h>
|
||||
#include <assert.h>
|
||||
#include "dds/ddsrt/time.h"
|
||||
#include "dds/ddsrt/sync.h"
|
||||
#include "dds/ddsrt/heap.h"
|
||||
#include "dds/ddsrt/random.h"
|
||||
#include "dds/util/ut_hopscotch.h"
|
||||
#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
|
||||
- there is no provision in the code for a handle being deleted concurrent to a lookup,
|
||||
that is, deleting handle links should also go through the GC
|
||||
entity framework needs a fair bit of rewriting anyway ... */
|
||||
#define USE_CHH 0
|
||||
|
||||
#define HDL_FLAG_CLOSED (0x80000000u)
|
||||
#define HDL_COUNT_MASK (0x00ffffffu)
|
||||
|
||||
/* 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
|
||||
increases with an increasing number of handles. 16M handles seems likely to be
|
||||
enough and makes the likely cost of allocating a new handle somewhat more
|
||||
reasonable */
|
||||
#define MAX_HANDLES (INT32_MAX / 128)
|
||||
|
||||
struct dds_handle_server {
|
||||
#if USE_CHH
|
||||
struct ut_chh *ht;
|
||||
#else
|
||||
struct ut_hh *ht;
|
||||
#endif
|
||||
size_t count;
|
||||
ddsrt_mutex_t lock;
|
||||
ddsrt_cond_t cond;
|
||||
};
|
||||
|
||||
static struct dds_handle_server handles;
|
||||
|
||||
static uint32_t handle_hash (const void *va)
|
||||
{
|
||||
/* handles are already pseudo-random numbers, so not much point in hashing it again */
|
||||
const struct dds_handle_link *a = va;
|
||||
return (uint32_t) a->hdl;
|
||||
}
|
||||
|
||||
static int handle_equal (const void *va, const void *vb)
|
||||
{
|
||||
const struct dds_handle_link *a = va;
|
||||
const struct dds_handle_link *b = vb;
|
||||
return a->hdl == b->hdl;
|
||||
}
|
||||
|
||||
dds_return_t dds_handle_server_init (void (*free_via_gc) (void *x))
|
||||
{
|
||||
#if USE_CHH
|
||||
handles.ht = ut_chhNew (128, handle_hash, handle_equal, free_via_gc);
|
||||
#else
|
||||
handles.ht = ut_hhNew (128, handle_hash, handle_equal);
|
||||
(void) free_via_gc;
|
||||
#endif
|
||||
handles.count = 0;
|
||||
ddsrt_mutex_init (&handles.lock);
|
||||
ddsrt_cond_init (&handles.cond);
|
||||
return DDS_RETCODE_OK;
|
||||
}
|
||||
|
||||
void dds_handle_server_fini (void)
|
||||
{
|
||||
#if USE_CHH
|
||||
#ifndef NDEBUG
|
||||
struct ut_chhIter it;
|
||||
assert (ut_chhIterFirst (handles.ht, &it) == NULL);
|
||||
#endif
|
||||
ut_chhFree (handles.ht);
|
||||
#else /* USE_CHH */
|
||||
#ifndef NDEBUG
|
||||
struct ut_hhIter it;
|
||||
assert (ut_hhIterFirst (handles.ht, &it) == NULL);
|
||||
#endif
|
||||
ut_hhFree (handles.ht);
|
||||
#endif /* USE_CHH */
|
||||
ddsrt_cond_destroy (&handles.cond);
|
||||
ddsrt_mutex_destroy (&handles.lock);
|
||||
handles.ht = NULL;
|
||||
}
|
||||
|
||||
#if USE_CHH
|
||||
static bool hhadd (struct ut_chh *ht, void *elem) { return ut_chhAdd (ht, elem); }
|
||||
#else
|
||||
static bool hhadd (struct ut_hh *ht, void *elem) { return ut_hhAdd (ht, elem); }
|
||||
#endif
|
||||
static dds_handle_t dds_handle_create_int (struct dds_handle_link *link)
|
||||
{
|
||||
ddsrt_atomic_st32 (&link->cnt_flags, 0);
|
||||
do {
|
||||
do {
|
||||
link->hdl = (int32_t) (ddsrt_random () & INT32_MAX);
|
||||
} while (link->hdl == 0 || link->hdl >= DDS_MIN_PSEUDO_HANDLE);
|
||||
} while (!hhadd (handles.ht, link));
|
||||
return link->hdl;
|
||||
}
|
||||
|
||||
dds_handle_t dds_handle_create (struct dds_handle_link *link)
|
||||
{
|
||||
dds_handle_t ret;
|
||||
#if USE_CHH
|
||||
struct thread_state1 * const self = lookup_thread_state ();
|
||||
const bool asleep = vtime_asleep_p (self->vtime);
|
||||
if (asleep)
|
||||
thread_state_awake (self);
|
||||
#endif
|
||||
ddsrt_mutex_lock (&handles.lock);
|
||||
if (handles.count == MAX_HANDLES)
|
||||
{
|
||||
ddsrt_mutex_unlock (&handles.lock);
|
||||
ret = DDS_ERRNO (DDS_RETCODE_OUT_OF_RESOURCES);
|
||||
}
|
||||
else
|
||||
{
|
||||
handles.count++;
|
||||
#if USE_CHH
|
||||
ddsrt_mutex_unlock (&handles.lock);
|
||||
ret = dds_handle_create_int (link);
|
||||
#else
|
||||
ret = dds_handle_create_int (link);
|
||||
ddsrt_mutex_unlock (&handles.lock);
|
||||
#endif
|
||||
assert (ret > 0);
|
||||
}
|
||||
#if USE_CHH
|
||||
if (asleep)
|
||||
thread_state_asleep (self);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
void dds_handle_close (struct dds_handle_link *link)
|
||||
{
|
||||
ddsrt_atomic_or32 (&link->cnt_flags, HDL_FLAG_CLOSED);
|
||||
}
|
||||
|
||||
int32_t dds_handle_delete (struct dds_handle_link *link, dds_duration_t timeout)
|
||||
{
|
||||
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)
|
||||
{
|
||||
/* FIXME: */
|
||||
const dds_time_t abstimeout = dds_time () + timeout;
|
||||
while ((ddsrt_atomic_ld32 (&link->cnt_flags) & HDL_COUNT_MASK) != 0)
|
||||
{
|
||||
if (!ddsrt_cond_waituntil (&handles.cond, &handles.lock, abstimeout))
|
||||
{
|
||||
ddsrt_mutex_unlock (&handles.lock);
|
||||
fprintf (stderr, "** timeout in handle_delete **\n");
|
||||
return DDS_RETCODE_TIMEOUT;
|
||||
}
|
||||
}
|
||||
}
|
||||
#if USE_CHH
|
||||
struct thread_state1 * const self = lookup_thread_state ();
|
||||
const bool asleep = vtime_asleep_p (self->vtime);
|
||||
if (asleep)
|
||||
thread_state_awake (self);
|
||||
int x = ut_chhRemove (handles.ht, link);
|
||||
if (asleep)
|
||||
thread_state_asleep (self);
|
||||
#else
|
||||
int x = ut_hhRemove (handles.ht, link);
|
||||
#endif
|
||||
assert(x);
|
||||
(void)x;
|
||||
assert (handles.count > 0);
|
||||
handles.count--;
|
||||
ddsrt_mutex_unlock (&handles.lock);
|
||||
return DDS_RETCODE_OK;
|
||||
}
|
||||
|
||||
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
|
||||
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).
|
||||
|
||||
One could check that the handle is > 0, but that would catch fewer errors
|
||||
without any advantages. */
|
||||
if (handles.ht == NULL)
|
||||
return DDS_RETCODE_PRECONDITION_NOT_MET;
|
||||
|
||||
#if USE_CHH
|
||||
struct thread_state1 * const self = lookup_thread_state ();
|
||||
const bool asleep = vtime_asleep_p (self->vtime);
|
||||
if (asleep)
|
||||
thread_state_awake (self);
|
||||
*link = ut_chhLookup (handles.ht, &dummy);
|
||||
#else
|
||||
ddsrt_mutex_lock (&handles.lock);
|
||||
*link = ut_hhLookup (handles.ht, &dummy);
|
||||
#endif
|
||||
if (*link == NULL)
|
||||
rc = DDS_RETCODE_BAD_PARAMETER;
|
||||
else
|
||||
{
|
||||
uint32_t cnt_flags;
|
||||
/* Assume success; bail out if the object turns out to be in the process of
|
||||
being deleted */
|
||||
rc = DDS_RETCODE_OK;
|
||||
do {
|
||||
cnt_flags = ddsrt_atomic_ld32 (&(*link)->cnt_flags);
|
||||
if (cnt_flags & HDL_FLAG_CLOSED)
|
||||
{
|
||||
rc = DDS_RETCODE_BAD_PARAMETER;
|
||||
break;
|
||||
}
|
||||
} while (!ddsrt_atomic_cas32 (&(*link)->cnt_flags, cnt_flags, cnt_flags + 1));
|
||||
}
|
||||
|
||||
#if USE_CHH
|
||||
if (asleep)
|
||||
thread_state_asleep (self);
|
||||
#else
|
||||
ddsrt_mutex_unlock (&handles.lock);
|
||||
#endif
|
||||
return rc;
|
||||
}
|
||||
|
||||
void dds_handle_claim_inc (struct dds_handle_link *link)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (ddsrt_atomic_dec32_ov (&link->cnt_flags) == (HDL_FLAG_CLOSED | 1))
|
||||
{
|
||||
ddsrt_mutex_lock (&handles.lock);
|
||||
ddsrt_cond_broadcast (&handles.cond);
|
||||
ddsrt_mutex_unlock (&handles.lock);
|
||||
}
|
||||
}
|
||||
|
||||
bool dds_handle_is_closed (struct dds_handle_link *link)
|
||||
{
|
||||
return (ddsrt_atomic_ld32 (&link->cnt_flags) & HDL_FLAG_CLOSED) != 0;
|
||||
}
|
|
@ -16,6 +16,7 @@
|
|||
#include "dds/ddsrt/cdtors.h"
|
||||
#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"
|
||||
|
@ -28,6 +29,7 @@
|
|||
#include "dds/ddsi/q_servicelease.h"
|
||||
#include "dds/ddsi/q_entity.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/q_gc.h"
|
||||
#include "dds/version.h"
|
||||
|
||||
#define DOMAIN_ID_MIN 0
|
||||
|
@ -38,6 +40,20 @@ struct q_globals gv;
|
|||
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)
|
||||
{
|
||||
void *bs = gcreq->arg;
|
||||
gcreq_free (gcreq);
|
||||
ddsrt_free (bs);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -60,13 +76,6 @@ dds_init(dds_domainid_t domain)
|
|||
goto skip;
|
||||
}
|
||||
|
||||
if (ut_handleserver_init() != UT_HANDLE_OK)
|
||||
{
|
||||
DDS_ERROR("Failed to initialize internal handle server\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_ERROR);
|
||||
goto fail_handleserver;
|
||||
}
|
||||
|
||||
gv.tstart = now ();
|
||||
gv.exception = false;
|
||||
ddsrt_mutex_init (&dds_global.m_mutex);
|
||||
|
@ -137,6 +146,13 @@ dds_init(dds_domainid_t domain)
|
|||
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);
|
||||
goto fail_handleserver;
|
||||
}
|
||||
|
||||
dds__builtin_init ();
|
||||
|
||||
if (rtps_start () < 0)
|
||||
|
@ -178,6 +194,8 @@ skip:
|
|||
fail_servicelease_start:
|
||||
if (gv.servicelease)
|
||||
nn_servicelease_stop_renewing (gv.servicelease);
|
||||
dds_handle_server_fini();
|
||||
fail_handleserver:
|
||||
rtps_stop ();
|
||||
fail_rtps_start:
|
||||
dds__builtin_fini ();
|
||||
|
@ -198,8 +216,6 @@ fail_config_domainid:
|
|||
dds_cfgst = NULL;
|
||||
fail_config:
|
||||
ddsrt_mutex_destroy (&dds_global.m_mutex);
|
||||
ut_handleserver_fini();
|
||||
fail_handleserver:
|
||||
dds_global.m_init_count--;
|
||||
ddsrt_mutex_unlock(init_mutex);
|
||||
ddsrt_fini();
|
||||
|
@ -217,6 +233,7 @@ extern void dds_fini (void)
|
|||
{
|
||||
if (gv.servicelease)
|
||||
nn_servicelease_stop_renewing (gv.servicelease);
|
||||
dds_handle_server_fini();
|
||||
rtps_stop ();
|
||||
dds__builtin_fini ();
|
||||
rtps_fini ();
|
||||
|
@ -229,7 +246,6 @@ extern void dds_fini (void)
|
|||
config_fini (dds_cfgst);
|
||||
dds_cfgst = NULL;
|
||||
ddsrt_mutex_destroy (&dds_global.m_mutex);
|
||||
ut_handleserver_fini();
|
||||
dds_global.m_default_domain = DDS_DOMAIN_DEFAULT;
|
||||
}
|
||||
ddsrt_mutex_unlock(init_mutex);
|
||||
|
|
|
@ -55,7 +55,7 @@ dds_participant_delete(
|
|||
|
||||
assert(e);
|
||||
assert(thr);
|
||||
assert(dds_entity_kind_from_handle(e->m_hdl) == DDS_KIND_PARTICIPANT);
|
||||
assert(dds_entity_kind(e) == DDS_KIND_PARTICIPANT);
|
||||
|
||||
if (asleep) {
|
||||
thread_state_awake(thr);
|
||||
|
@ -280,7 +280,7 @@ dds_lookup_participant(
|
|||
while (iter) {
|
||||
if (iter->m_domainid == domain_id) {
|
||||
if ((size_t)ret < size) {
|
||||
participants[ret] = iter->m_hdl;
|
||||
participants[ret] = iter->m_hdllink.hdl;
|
||||
}
|
||||
ret++;
|
||||
}
|
||||
|
|
|
@ -13,11 +13,14 @@
|
|||
#include <string.h>
|
||||
#include "dds/ddsrt/misc.h"
|
||||
#include "dds__listener.h"
|
||||
#include "dds__publisher.h"
|
||||
#include "dds__qos.h"
|
||||
#include "dds__err.h"
|
||||
#include "dds/ddsi/q_entity.h"
|
||||
#include "dds/version.h"
|
||||
|
||||
DECL_ENTITY_LOCK_UNLOCK(extern inline, dds_publisher)
|
||||
|
||||
#define DDS_PUBLISHER_STATUS_MASK 0u
|
||||
|
||||
static dds_return_t
|
||||
|
@ -145,36 +148,14 @@ DDS_EXPORT dds_return_t
|
|||
dds_suspend(
|
||||
dds_entity_t publisher)
|
||||
{
|
||||
dds_return_t ret;
|
||||
|
||||
if(dds_entity_kind_from_handle(publisher) != DDS_KIND_PUBLISHER) {
|
||||
DDS_ERROR("Provided entity is not a publisher kind\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER);
|
||||
goto err;
|
||||
}
|
||||
/* TODO: CHAM-123 Currently unsupported. */
|
||||
DDS_ERROR("Suspend publication operation does not being supported yet\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED);
|
||||
err:
|
||||
return ret;
|
||||
return dds_generic_unimplemented_operation (publisher, DDS_KIND_PUBLISHER);
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
dds_resume(
|
||||
dds_entity_t publisher)
|
||||
{
|
||||
dds_return_t ret = DDS_RETCODE_OK;
|
||||
|
||||
if(dds_entity_kind_from_handle(publisher) != DDS_KIND_PUBLISHER) {
|
||||
DDS_ERROR("Provided entity is not a publisher kind\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER);
|
||||
goto err;
|
||||
}
|
||||
/* TODO: CHAM-123 Currently unsupported. */
|
||||
DDS_ERROR("Suspend publication operation does not being supported yet\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED);
|
||||
err:
|
||||
return ret;
|
||||
return dds_generic_unimplemented_operation (publisher, DDS_KIND_PUBLISHER);
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
|
@ -182,27 +163,10 @@ dds_wait_for_acks(
|
|||
dds_entity_t publisher_or_writer,
|
||||
dds_duration_t timeout)
|
||||
{
|
||||
dds_return_t ret;
|
||||
|
||||
/* TODO: CHAM-125 Currently unsupported. */
|
||||
DDSRT_UNUSED_ARG(timeout);
|
||||
|
||||
switch(dds_entity_kind_from_handle(publisher_or_writer)) {
|
||||
case DDS_KIND_WRITER:
|
||||
DDS_ERROR("Wait for acknowledgments on a writer is not being supported yet\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED);
|
||||
break;
|
||||
case DDS_KIND_PUBLISHER:
|
||||
DDS_ERROR("Wait for acknowledgments on a publisher is not being supported yet\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED);
|
||||
break;
|
||||
default:
|
||||
DDS_ERROR("Provided entity is not a publisher nor a writer\n");
|
||||
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER);
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
if (timeout < 0)
|
||||
return DDS_ERRNO (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
|
||||
|
|
|
@ -39,9 +39,9 @@ dds_create_querycondition(
|
|||
const bool success = (cond->m_entity.m_deriver.delete != 0);
|
||||
dds_reader_unlock(r);
|
||||
if (success) {
|
||||
hdl = cond->m_entity.m_hdl;
|
||||
hdl = cond->m_entity.m_hdllink.hdl;
|
||||
} else {
|
||||
dds_delete (cond->m_entity.m_hdl);
|
||||
dds_delete (cond->m_entity.m_hdllink.hdl);
|
||||
hdl = DDS_ERRNO(DDS_RETCODE_OUT_OF_RESOURCES);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -47,7 +47,7 @@ static dds_retcode_t dds_read_lock (dds_entity_t hdl, dds_reader **reader, dds_r
|
|||
DDS_ERROR ("Given entity is a reader nor a condition\n");
|
||||
return DDS_RETCODE_ILLEGAL_OPERATION;
|
||||
}
|
||||
else if ((rc = dds_entity_lock (entity->m_parent->m_hdl, DDS_KIND_READER, &parent_entity)) != DDS_RETCODE_OK)
|
||||
else if ((rc = dds_entity_lock (entity->m_parent->m_hdllink.hdl, DDS_KIND_READER, &parent_entity)) != DDS_RETCODE_OK)
|
||||
{
|
||||
dds_entity_unlock (entity);
|
||||
DDS_ERROR ("Failed to lock condition's reader\n");
|
||||
|
@ -168,7 +168,7 @@ dds_read_impl(
|
|||
/* read/take resets data available status */
|
||||
dds_entity_status_reset(&rd->m_entity, DDS_DATA_AVAILABLE_STATUS);
|
||||
/* reset DATA_ON_READERS status on subscriber after successful read/take */
|
||||
if (dds_entity_kind_from_handle(rd->m_entity.m_parent->m_hdl) == DDS_KIND_SUBSCRIBER) {
|
||||
if (dds_entity_kind(rd->m_entity.m_parent) == DDS_KIND_SUBSCRIBER) {
|
||||
dds_entity_status_reset(rd->m_entity.m_parent, DDS_DATA_ON_READERS_STATUS);
|
||||
}
|
||||
dds_read_unlock(rd, cond);
|
||||
|
@ -225,7 +225,7 @@ dds_readcdr_impl(
|
|||
|
||||
/* reset DATA_ON_READERS status on subscriber after successful read/take */
|
||||
|
||||
if (dds_entity_kind_from_handle(rd->m_entity.m_parent->m_hdl) == DDS_KIND_SUBSCRIBER)
|
||||
if (dds_entity_kind(rd->m_entity.m_parent) == DDS_KIND_SUBSCRIBER)
|
||||
{
|
||||
dds_entity_status_reset(rd->m_entity.m_parent, DDS_DATA_ON_READERS_STATUS);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ dds_create_readcond(
|
|||
{
|
||||
dds_readcond * cond = dds_alloc(sizeof(*cond));
|
||||
assert((kind == DDS_KIND_COND_READ && filter == 0) || (kind == DDS_KIND_COND_QUERY && filter != 0));
|
||||
cond->m_entity.m_hdl = dds_entity_init(&cond->m_entity, (dds_entity*)rd, kind, NULL, NULL, 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;
|
||||
|
@ -70,7 +70,7 @@ dds_create_readcondition(
|
|||
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_hdl;
|
||||
hdl = cond->m_entity.m_hdllink.hdl;
|
||||
dds_reader_unlock(rd);
|
||||
} else {
|
||||
DDS_ERROR("Error occurred on locking reader\n");
|
||||
|
@ -82,19 +82,30 @@ dds_create_readcondition(
|
|||
|
||||
dds_entity_t dds_get_datareader (dds_entity_t condition)
|
||||
{
|
||||
dds_entity_t hdl;
|
||||
|
||||
if (dds_entity_kind_from_handle(condition) == DDS_KIND_COND_READ) {
|
||||
hdl = dds_get_parent(condition);
|
||||
} else if (dds_entity_kind_from_handle(condition) == DDS_KIND_COND_QUERY) {
|
||||
hdl = dds_get_parent(condition);
|
||||
} else {
|
||||
DDS_ERROR("Argument condition is not valid\n");
|
||||
hdl = DDS_ERRNO(dds_valid_hdl(condition, DDS_KIND_COND_READ));
|
||||
struct dds_entity *e;
|
||||
dds_retcode_t rc;
|
||||
if ((rc = dds_entity_claim (condition, &e)) != DDS_RETCODE_OK)
|
||||
return DDS_ERRNO (rc);
|
||||
else
|
||||
{
|
||||
dds_entity_t rdh;
|
||||
switch (dds_entity_kind (e))
|
||||
{
|
||||
case DDS_KIND_COND_READ:
|
||||
case DDS_KIND_COND_QUERY:
|
||||
assert (dds_entity_kind (e->m_parent) == DDS_KIND_READER);
|
||||
rdh = e->m_parent->m_hdllink.hdl;
|
||||
break;
|
||||
default:
|
||||
rdh = DDS_ERRNO (DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
break;
|
||||
}
|
||||
dds_handle_release (&e->m_hdllink);
|
||||
return rdh;
|
||||
}
|
||||
}
|
||||
|
||||
return hdl;
|
||||
}
|
||||
|
||||
|
||||
dds_return_t dds_get_mask (dds_entity_t condition, uint32_t *mask)
|
||||
{
|
||||
|
@ -109,7 +120,7 @@ dds_return_t dds_get_mask (dds_entity_t condition, uint32_t *mask)
|
|||
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_valid_hdl (condition, DDS_KIND_COND_READ));
|
||||
return DDS_ERRNO (DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -81,10 +81,10 @@ dds_reader_delete(
|
|||
dds_reader *rd = (dds_reader*)e;
|
||||
dds_return_t ret;
|
||||
assert(e);
|
||||
ret = dds_delete(rd->m_topic->m_entity.m_hdl);
|
||||
ret = dds_delete(rd->m_topic->m_entity.m_hdllink.hdl);
|
||||
if(ret == DDS_RETCODE_OK){
|
||||
ret = dds_delete_impl(e->m_parent->m_hdl, true);
|
||||
if(dds_err_nr(ret) == DDS_RETCODE_ALREADY_DELETED){
|
||||
ret = dds_delete_impl(e->m_parent->m_hdllink.hdl, true);
|
||||
if(dds_err_nr(ret) == DDS_RETCODE_BAD_PARAMETER){
|
||||
ret = DDS_RETCODE_OK;
|
||||
}
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ void dds_reader_data_available_cb (struct dds_reader *rd)
|
|||
sub->m_cb_count++;
|
||||
ddsrt_mutex_unlock (&sub->m_observers_lock);
|
||||
|
||||
lst->on_data_on_readers (sub->m_hdl, lst->on_data_on_readers_arg);
|
||||
lst->on_data_on_readers (sub->m_hdllink.hdl, lst->on_data_on_readers_arg);
|
||||
|
||||
ddsrt_mutex_lock (&rd->m_entity.m_observers_lock);
|
||||
ddsrt_mutex_lock (&sub->m_observers_lock);
|
||||
|
@ -196,7 +196,7 @@ void dds_reader_data_available_cb (struct dds_reader *rd)
|
|||
else if (rd->m_entity.m_listener.on_data_available)
|
||||
{
|
||||
ddsrt_mutex_unlock (&rd->m_entity.m_observers_lock);
|
||||
lst->on_data_available (rd->m_entity.m_hdl, lst->on_data_available_arg);
|
||||
lst->on_data_available (rd->m_entity.m_hdllink.hdl, lst->on_data_available_arg);
|
||||
ddsrt_mutex_lock (&rd->m_entity.m_observers_lock);
|
||||
}
|
||||
else
|
||||
|
@ -222,7 +222,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. */
|
||||
ut_handle_release (entity->m_hdl, entity->m_hdllink);
|
||||
dds_handle_release (&entity->m_hdllink);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -361,7 +361,7 @@ dds_create_reader(
|
|||
{
|
||||
dds_qos_t * rqos;
|
||||
dds_retcode_t rc;
|
||||
dds_entity * sub = NULL;
|
||||
dds_subscriber * sub = NULL;
|
||||
dds_entity_t subscriber;
|
||||
dds_reader * rd;
|
||||
struct rhc * rhc;
|
||||
|
@ -371,31 +371,43 @@ dds_create_reader(
|
|||
struct thread_state1 * const thr = lookup_thread_state ();
|
||||
const bool asleep = !vtime_awake_p (thr->vtime);
|
||||
dds_return_t ret = DDS_RETCODE_OK;
|
||||
bool internal_topic;
|
||||
|
||||
if (dds_entity_kind_from_handle(topic) != DDS_KIND_INTERNAL) {
|
||||
/* Try claiming a participant. If that's not working, then it could be a subscriber. */
|
||||
if (dds_entity_kind_from_handle(participant_or_subscriber) == DDS_KIND_PARTICIPANT) {
|
||||
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_handle_release (&p_or_s->m_hdllink);
|
||||
internal_topic = false;
|
||||
t = topic;
|
||||
} else {
|
||||
subscriber = dds__get_builtin_subscriber(participant_or_subscriber);
|
||||
t = dds__get_builtin_topic(subscriber, topic);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
rc = dds_entity_lock(subscriber, DDS_KIND_SUBSCRIBER, &sub);
|
||||
if (rc != DDS_RETCODE_OK) {
|
||||
DDS_ERROR("Error occurred on locking subscriber\n");
|
||||
if ((rc = dds_subscriber_lock (subscriber, &sub)) != DDS_RETCODE_OK) {
|
||||
reader = DDS_ERRNO (rc);
|
||||
goto err_sub_lock;
|
||||
}
|
||||
|
||||
if ((subscriber != participant_or_subscriber) &&
|
||||
(dds_entity_kind_from_handle(topic) != DDS_KIND_INTERNAL)) {
|
||||
if ((subscriber != participant_or_subscriber) && !internal_topic) {
|
||||
/* Delete implicit subscriber if reader creation fails */
|
||||
sub->m_flags |= DDS_ENTITY_IMPLICIT;
|
||||
sub->m_entity.m_flags |= DDS_ENTITY_IMPLICIT;
|
||||
}
|
||||
|
||||
rc = dds_topic_lock(t, &tp);
|
||||
|
@ -405,7 +417,7 @@ dds_create_reader(
|
|||
goto err_tp_lock;
|
||||
}
|
||||
assert (tp->m_stopic);
|
||||
assert (sub->m_domain == tp->m_entity.m_domain);
|
||||
assert (sub->m_entity.m_domain == tp->m_entity.m_domain);
|
||||
|
||||
/* Merge qos from topic and subscriber */
|
||||
rqos = dds_create_qos ();
|
||||
|
@ -415,8 +427,8 @@ dds_create_reader(
|
|||
(void)dds_copy_qos(rqos, qos);
|
||||
}
|
||||
|
||||
if(sub->m_qos){
|
||||
dds_merge_qos (rqos, sub->m_qos);
|
||||
if(sub->m_entity.m_qos){
|
||||
dds_merge_qos (rqos, sub->m_entity.m_qos);
|
||||
}
|
||||
|
||||
if (tp->m_entity.m_qos) {
|
||||
|
@ -435,7 +447,7 @@ dds_create_reader(
|
|||
}
|
||||
|
||||
/* Additional checks required for built-in topics */
|
||||
if (dds_entity_kind_from_handle(topic) == DDS_KIND_INTERNAL && !dds__validate_builtin_reader_qos(topic, qos)) {
|
||||
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);
|
||||
|
@ -444,7 +456,7 @@ dds_create_reader(
|
|||
|
||||
/* Create reader and associated read cache */
|
||||
rd = dds_alloc (sizeof (*rd));
|
||||
reader = dds_entity_init (&rd->m_entity, sub, DDS_KIND_READER, rqos, listener, DDS_READER_STATUS_MASK);
|
||||
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);
|
||||
|
@ -457,19 +469,17 @@ dds_create_reader(
|
|||
|
||||
/* 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. */
|
||||
if (ut_handle_claim(rd->m_entity.m_hdl, rd->m_entity.m_hdllink, DDS_KIND_READER, NULL) != UT_HANDLE_OK) {
|
||||
assert(0);
|
||||
}
|
||||
dds_handle_claim_inc (&rd->m_entity.m_hdllink);
|
||||
|
||||
ddsrt_mutex_unlock(&tp->m_entity.m_mutex);
|
||||
ddsrt_mutex_unlock(&sub->m_mutex);
|
||||
ddsrt_mutex_unlock(&sub->m_entity.m_mutex);
|
||||
|
||||
if (asleep) {
|
||||
thread_state_awake (thr);
|
||||
}
|
||||
rd->m_rd = new_reader(&rd->m_entity.m_guid, NULL, &sub->m_participant->m_guid, tp->m_stopic,
|
||||
rd->m_rd = new_reader(&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_mutex);
|
||||
ddsrt_mutex_lock(&sub->m_entity.m_mutex);
|
||||
ddsrt_mutex_lock(&tp->m_entity.m_mutex);
|
||||
assert (rd->m_rd);
|
||||
if (asleep) {
|
||||
|
@ -481,9 +491,9 @@ dds_create_reader(
|
|||
(dds_global.m_dur_reader) (rd, rhc);
|
||||
}
|
||||
dds_topic_unlock(tp);
|
||||
dds_entity_unlock(sub);
|
||||
dds_subscriber_unlock(sub);
|
||||
|
||||
if (dds_entity_kind_from_handle(topic) == DDS_KIND_INTERNAL) {
|
||||
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);
|
||||
|
@ -494,12 +504,12 @@ dds_create_reader(
|
|||
err_bad_qos:
|
||||
dds_topic_unlock(tp);
|
||||
err_tp_lock:
|
||||
dds_entity_unlock(sub);
|
||||
if((sub->m_flags & DDS_ENTITY_IMPLICIT) != 0){
|
||||
dds_subscriber_unlock(sub);
|
||||
if((sub->m_entity.m_flags & DDS_ENTITY_IMPLICIT) != 0){
|
||||
(void)dds_delete(subscriber);
|
||||
}
|
||||
err_sub_lock:
|
||||
if (dds_entity_kind_from_handle(topic) == DDS_KIND_INTERNAL) {
|
||||
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);
|
||||
|
@ -509,10 +519,17 @@ err_sub_lock:
|
|||
|
||||
void dds_reader_ddsi2direct (dds_entity_t entity, ddsi2direct_directread_cb_t cb, void *cbarg)
|
||||
{
|
||||
dds_reader *dds_rd;
|
||||
dds_entity *dds_entity;
|
||||
if (dds_entity_claim(entity, &dds_entity) != DDS_RETCODE_OK)
|
||||
return;
|
||||
|
||||
if (ut_handle_claim(entity, NULL, DDS_KIND_READER, (void**)&dds_rd) == UT_HANDLE_OK)
|
||||
if (dds_entity_kind (dds_entity) != DDS_KIND_READER)
|
||||
{
|
||||
dds_handle_release (&dds_entity->m_hdllink);
|
||||
return;
|
||||
}
|
||||
|
||||
dds_reader *dds_rd = (dds_reader *) dds_entity;
|
||||
struct reader *rd = dds_rd->m_rd;
|
||||
nn_guid_t pwrguid;
|
||||
struct proxy_writer *pwr;
|
||||
|
@ -548,8 +565,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);
|
||||
ut_handle_release(entity, dds_rd->m_entity.m_hdllink);
|
||||
}
|
||||
dds_handle_release (&dds_rd->m_entity.m_hdllink);
|
||||
}
|
||||
|
||||
uint32_t dds_reader_lock_samples (dds_entity_t reader)
|
||||
|
@ -587,23 +603,32 @@ 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_t hdl;
|
||||
if (dds_entity_kind_from_handle (entity) == DDS_KIND_READER)
|
||||
hdl = dds_get_parent (entity);
|
||||
else if (dds_entity_kind_from_handle (entity) == DDS_KIND_COND_READ || dds_entity_kind_from_handle (entity) == DDS_KIND_COND_QUERY)
|
||||
{
|
||||
hdl = dds_get_parent (entity);
|
||||
if (hdl > 0)
|
||||
hdl = dds_get_subscriber (hdl);
|
||||
DDS_ERROR ("Reader of this condition is already deleted\n");
|
||||
}
|
||||
dds_entity *e;
|
||||
dds_retcode_t ret;
|
||||
if ((ret = dds_entity_claim (entity, &e)) != DDS_RETCODE_OK)
|
||||
return (dds_entity_t) DDS_ERRNO (ret);
|
||||
else
|
||||
{
|
||||
DDS_ERROR ("Provided entity is not a reader nor a condition\n");
|
||||
hdl = DDS_ERRNO (dds_valid_hdl (entity, DDS_KIND_READER));
|
||||
dds_entity_t subh;
|
||||
switch (dds_entity_kind (e))
|
||||
{
|
||||
case DDS_KIND_READER:
|
||||
assert (dds_entity_kind (e->m_parent) == DDS_KIND_SUBSCRIBER);
|
||||
subh = e->m_parent->m_hdllink.hdl;
|
||||
break;
|
||||
case DDS_KIND_COND_READ:
|
||||
case DDS_KIND_COND_QUERY:
|
||||
assert (dds_entity_kind (e->m_parent) == DDS_KIND_READER);
|
||||
assert (dds_entity_kind (e->m_parent->m_parent) == DDS_KIND_SUBSCRIBER);
|
||||
subh = e->m_parent->m_parent->m_hdllink.hdl;
|
||||
break;
|
||||
default:
|
||||
subh = DDS_ERRNO (DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
break;
|
||||
}
|
||||
dds_handle_release (&e->m_hdllink);
|
||||
return subh;
|
||||
}
|
||||
|
||||
return hdl;
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
|
|
|
@ -13,9 +13,12 @@
|
|||
#include "dds__listener.h"
|
||||
#include "dds__qos.h"
|
||||
#include "dds__err.h"
|
||||
#include "dds__subscriber.h"
|
||||
#include "dds/ddsi/q_entity.h"
|
||||
#include "dds/version.h"
|
||||
|
||||
DECL_ENTITY_LOCK_UNLOCK(extern inline, dds_subscriber)
|
||||
|
||||
#define DDS_SUBSCRIBER_STATUS_MASK \
|
||||
DDS_DATA_ON_READERS_STATUS
|
||||
|
||||
|
|
|
@ -40,12 +40,6 @@ const ut_avlTreedef_t dds_topictree_def = UT_AVL_TREEDEF_INITIALIZER_INDKEY
|
|||
0
|
||||
);
|
||||
|
||||
/* builtin-topic handles */
|
||||
const dds_entity_t DDS_BUILTIN_TOPIC_DCPSPARTICIPANT = (DDS_KIND_INTERNAL + 1);
|
||||
const dds_entity_t DDS_BUILTIN_TOPIC_DCPSTOPIC = (DDS_KIND_INTERNAL + 2);
|
||||
const dds_entity_t DDS_BUILTIN_TOPIC_DCPSPUBLICATION = (DDS_KIND_INTERNAL + 3);
|
||||
const dds_entity_t DDS_BUILTIN_TOPIC_DCPSSUBSCRIPTION = (DDS_KIND_INTERNAL + 4);
|
||||
|
||||
static bool
|
||||
is_valid_name(
|
||||
const char *name)
|
||||
|
@ -198,7 +192,7 @@ dds_find_topic(
|
|||
st = dds_topic_lookup_locked (p->m_domain, name);
|
||||
if (st) {
|
||||
dds_entity_add_ref (&st->status_cb_entity->m_entity);
|
||||
tp = st->status_cb_entity->m_entity.m_hdl;
|
||||
tp = st->status_cb_entity->m_entity.m_hdllink.hdl;
|
||||
} else {
|
||||
DDS_ERROR("Topic is not being created yet\n");
|
||||
tp = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
|
@ -370,7 +364,7 @@ dds_create_topic_arbitrary (
|
|||
hdl = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY);
|
||||
} else {
|
||||
dds_entity_add_ref (&stgeneric->status_cb_entity->m_entity);
|
||||
hdl = stgeneric->status_cb_entity->m_entity.m_hdl;
|
||||
hdl = stgeneric->status_cb_entity->m_entity.m_hdllink.hdl;
|
||||
}
|
||||
ddsrt_mutex_unlock (&dds_global.m_mutex);
|
||||
} else {
|
||||
|
|
|
@ -152,7 +152,7 @@ dds_waitset_close_list(
|
|||
dds_attachment *next;
|
||||
while (idx != NULL) {
|
||||
next = idx->next;
|
||||
(void)dds_entity_observer_unregister(idx->entity->m_hdl, waitset);
|
||||
(void)dds_entity_observer_unregister(idx->entity->m_hdllink.hdl, waitset);
|
||||
ddsrt_free(idx);
|
||||
idx = next;
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ dds_waitset_remove_from_list(
|
|||
dds_attachment *prev = NULL;
|
||||
|
||||
while (idx != NULL) {
|
||||
if (idx->entity->m_hdl == observed) {
|
||||
if (idx->entity->m_hdllink.hdl == observed) {
|
||||
if (prev == NULL) {
|
||||
*list = idx->next;
|
||||
} else {
|
||||
|
@ -191,8 +191,8 @@ dds_waitset_close(
|
|||
{
|
||||
dds_waitset *ws = (dds_waitset*)e;
|
||||
|
||||
dds_waitset_close_list(&ws->observed, e->m_hdl);
|
||||
dds_waitset_close_list(&ws->triggered, e->m_hdl);
|
||||
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);
|
||||
|
@ -242,7 +242,7 @@ dds_waitset_get_entities(
|
|||
iter = ws->observed;
|
||||
while (iter) {
|
||||
if (((size_t)ret < size) && (entities != NULL)) {
|
||||
entities[ret] = iter->entity->m_hdl;
|
||||
entities[ret] = iter->entity->m_hdllink.hdl;
|
||||
}
|
||||
ret++;
|
||||
iter = iter->next;
|
||||
|
@ -251,7 +251,7 @@ dds_waitset_get_entities(
|
|||
iter = ws->triggered;
|
||||
while (iter) {
|
||||
if (((size_t)ret < size) && (entities != NULL)) {
|
||||
entities[ret] = iter->entity->m_hdl;
|
||||
entities[ret] = iter->entity->m_hdllink.hdl;
|
||||
}
|
||||
ret++;
|
||||
iter = iter->next;
|
||||
|
@ -275,7 +275,7 @@ dds_waitset_move(
|
|||
dds_attachment *idx = *src;
|
||||
dds_attachment *prev = NULL;
|
||||
while (idx != NULL) {
|
||||
if (idx->entity->m_hdl == entity) {
|
||||
if (idx->entity->m_hdllink.hdl == entity) {
|
||||
/* Swap idx from src to dst. */
|
||||
dds_waitset_swap(dst, src, prev, idx);
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "dds__qos.h"
|
||||
#include "dds__err.h"
|
||||
#include "dds__init.h"
|
||||
#include "dds__publisher.h"
|
||||
#include "dds__topic.h"
|
||||
#include "dds/ddsi/ddsi_tkmap.h"
|
||||
#include "dds__whc.h"
|
||||
|
@ -75,7 +76,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. */
|
||||
ut_handle_release (entity->m_hdl, entity->m_hdllink);
|
||||
dds_handle_release (&entity->m_hdllink);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -235,10 +236,10 @@ dds_writer_delete(
|
|||
if (asleep) {
|
||||
thread_state_asleep(thr);
|
||||
}
|
||||
ret = dds_delete(wr->m_topic->m_entity.m_hdl);
|
||||
ret = dds_delete(wr->m_topic->m_entity.m_hdllink.hdl);
|
||||
if(ret == DDS_RETCODE_OK){
|
||||
ret = dds_delete_impl(e->m_parent->m_hdl, true);
|
||||
if(dds_err_nr(ret) == DDS_RETCODE_ALREADY_DELETED){
|
||||
ret = dds_delete_impl(e->m_parent->m_hdllink.hdl, true);
|
||||
if(dds_err_nr(ret) == DDS_RETCODE_BAD_PARAMETER){
|
||||
ret = DDS_RETCODE_OK;
|
||||
}
|
||||
}
|
||||
|
@ -399,7 +400,7 @@ dds_create_writer(
|
|||
dds_qos_t * wqos;
|
||||
dds_writer * wr;
|
||||
dds_entity_t writer;
|
||||
dds_entity * pub = NULL;
|
||||
dds_publisher * pub = NULL;
|
||||
dds_topic * tp;
|
||||
dds_entity_t publisher;
|
||||
struct thread_state1 * const thr = lookup_thread_state();
|
||||
|
@ -407,22 +408,26 @@ dds_create_writer(
|
|||
ddsi_tran_conn_t conn = gv.data_conn_uc;
|
||||
dds_return_t ret;
|
||||
|
||||
/* Try claiming a participant. If that's not working, then it could be a subscriber. */
|
||||
if(dds_entity_kind_from_handle(participant_or_publisher) == DDS_KIND_PARTICIPANT){
|
||||
{
|
||||
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;
|
||||
}
|
||||
rc = dds_entity_lock(publisher, DDS_KIND_PUBLISHER, &pub);
|
||||
dds_handle_release (&p_or_p->m_hdllink);
|
||||
}
|
||||
|
||||
if (rc != DDS_RETCODE_OK) {
|
||||
DDS_ERROR("Error occurred on locking publisher\n");
|
||||
if ((rc = dds_publisher_lock(publisher, &pub)) != DDS_RETCODE_OK) {
|
||||
writer = DDS_ERRNO(rc);
|
||||
goto err_pub_lock;
|
||||
}
|
||||
|
||||
if (publisher != participant_or_publisher) {
|
||||
pub->m_flags |= DDS_ENTITY_IMPLICIT;
|
||||
pub->m_entity.m_flags |= DDS_ENTITY_IMPLICIT;
|
||||
}
|
||||
|
||||
rc = dds_topic_lock(topic, &tp);
|
||||
|
@ -432,7 +437,7 @@ dds_create_writer(
|
|||
goto err_tp_lock;
|
||||
}
|
||||
assert(tp->m_stopic);
|
||||
assert(pub->m_domain == tp->m_entity.m_domain);
|
||||
assert(pub->m_entity.m_domain == tp->m_entity.m_domain);
|
||||
|
||||
/* Merge Topic & Publisher qos */
|
||||
wqos = dds_create_qos();
|
||||
|
@ -442,8 +447,8 @@ dds_create_writer(
|
|||
(void)dds_copy_qos(wqos, qos);
|
||||
}
|
||||
|
||||
if (pub->m_qos) {
|
||||
dds_merge_qos(wqos, pub->m_qos);
|
||||
if (pub->m_entity.m_qos) {
|
||||
dds_merge_qos(wqos, pub->m_entity.m_qos);
|
||||
}
|
||||
|
||||
if (tp->m_entity.m_qos) {
|
||||
|
@ -461,7 +466,7 @@ dds_create_writer(
|
|||
|
||||
/* Create writer */
|
||||
wr = dds_alloc(sizeof (*wr));
|
||||
writer = dds_entity_init(&wr->m_entity, pub, DDS_KIND_WRITER, wqos, listener, DDS_WRITER_STATUS_MASK);
|
||||
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_nolock(&tp->m_entity);
|
||||
|
@ -475,32 +480,30 @@ dds_create_writer(
|
|||
|
||||
/* 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. */
|
||||
if (ut_handle_claim(wr->m_entity.m_hdl, wr->m_entity.m_hdllink, DDS_KIND_WRITER, NULL) != UT_HANDLE_OK) {
|
||||
assert(0);
|
||||
}
|
||||
dds_handle_claim_inc (&wr->m_entity.m_hdllink);
|
||||
|
||||
ddsrt_mutex_unlock (&tp->m_entity.m_mutex);
|
||||
ddsrt_mutex_unlock(&pub->m_mutex);
|
||||
ddsrt_mutex_unlock (&pub->m_entity.m_mutex);
|
||||
|
||||
if (asleep) {
|
||||
thread_state_awake(thr);
|
||||
}
|
||||
wr->m_wr = new_writer(&wr->m_entity.m_guid, NULL, &pub->m_participant->m_guid, tp->m_stopic, wqos, wr->m_whc, dds_writer_status_cb, wr);
|
||||
ddsrt_mutex_lock(&pub->m_mutex);
|
||||
wr->m_wr = new_writer(&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(wr->m_wr);
|
||||
if (asleep) {
|
||||
thread_state_asleep(thr);
|
||||
}
|
||||
dds_topic_unlock(tp);
|
||||
dds_entity_unlock(pub);
|
||||
dds_publisher_unlock(pub);
|
||||
return writer;
|
||||
|
||||
err_bad_qos:
|
||||
dds_topic_unlock(tp);
|
||||
err_tp_lock:
|
||||
dds_entity_unlock(pub);
|
||||
if((pub->m_flags & DDS_ENTITY_IMPLICIT) != 0){
|
||||
dds_publisher_unlock(pub);
|
||||
if((pub->m_entity.m_flags & DDS_ENTITY_IMPLICIT) != 0){
|
||||
(void)dds_delete(publisher);
|
||||
}
|
||||
err_pub_lock:
|
||||
|
@ -511,17 +514,23 @@ dds_entity_t
|
|||
dds_get_publisher(
|
||||
dds_entity_t writer)
|
||||
{
|
||||
dds_entity_t hdl = DDS_RETCODE_OK;
|
||||
|
||||
hdl = dds_valid_hdl(writer, DDS_KIND_WRITER);
|
||||
if(hdl != DDS_RETCODE_OK){
|
||||
DDS_ERROR("Provided handle is not writer kind, so it is not valid\n");
|
||||
hdl = DDS_ERRNO(hdl);
|
||||
} else{
|
||||
hdl = dds_get_parent(writer);
|
||||
dds_entity *e;
|
||||
dds_retcode_t rc;
|
||||
if ((rc = dds_entity_claim (writer, &e)) != DDS_RETCODE_OK)
|
||||
return DDS_ERRNO (rc);
|
||||
else
|
||||
{
|
||||
dds_entity_t pubh;
|
||||
if (dds_entity_kind (e) != DDS_KIND_WRITER)
|
||||
pubh = DDS_ERRNO (DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
else
|
||||
{
|
||||
assert (dds_entity_kind (e->m_parent) == DDS_KIND_PUBLISHER);
|
||||
pubh = e->m_parent->m_hdllink.hdl;
|
||||
}
|
||||
dds_handle_release (&e->m_hdllink);
|
||||
return pubh;
|
||||
}
|
||||
|
||||
return hdl;
|
||||
}
|
||||
|
||||
dds_return_t
|
||||
|
|
|
@ -23,7 +23,7 @@ set(ddsc_test_sources
|
|||
"entity_api.c"
|
||||
"entity_hierarchy.c"
|
||||
"entity_status.c"
|
||||
"file_id.c"
|
||||
"err.c"
|
||||
"instance_get_key.c"
|
||||
"listener.c"
|
||||
"participant.c"
|
||||
|
|
|
@ -63,7 +63,7 @@ teardown(void)
|
|||
}
|
||||
|
||||
static void
|
||||
check_default_qos_of_builtin_entity(dds_entity_t entity)
|
||||
check_default_qos_of_builtin_entity(dds_entity_t entity, bool isread)
|
||||
{
|
||||
dds_return_t ret;
|
||||
int64_t deadline;
|
||||
|
@ -110,8 +110,7 @@ check_default_qos_of_builtin_entity(dds_entity_t entity)
|
|||
dds_qget_partition(qos, &plen, &partitions);
|
||||
// no getter for ENTITY_FACTORY
|
||||
|
||||
CU_ASSERT_FATAL((entity & DDS_ENTITY_KIND_MASK) == DDS_KIND_SUBSCRIBER || (entity & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER);
|
||||
if ((entity & DDS_ENTITY_KIND_MASK) == DDS_KIND_SUBSCRIBER) {
|
||||
if (!isread) {
|
||||
CU_ASSERT_FATAL(plen == 1);
|
||||
CU_ASSERT_STRING_EQUAL_FATAL(partitions[0], "__BUILT-IN PARTITION__");
|
||||
} else {
|
||||
|
@ -303,9 +302,9 @@ CU_Test(ddsc_builtin_topics, builtin_qos, .init = setup, .fini = teardown)
|
|||
|
||||
dds_sub_rdr = dds_create_reader(g_participant, DDS_BUILTIN_TOPIC_DCPSSUBSCRIPTION, NULL, NULL);
|
||||
CU_ASSERT_FATAL(dds_sub_rdr > 0);
|
||||
check_default_qos_of_builtin_entity(dds_sub_rdr);
|
||||
check_default_qos_of_builtin_entity(dds_sub_rdr, 1);
|
||||
|
||||
dds_sub_subscriber = dds_get_parent(dds_sub_rdr);
|
||||
CU_ASSERT_FATAL(dds_sub_subscriber > 0);
|
||||
check_default_qos_of_builtin_entity(dds_sub_subscriber);
|
||||
check_default_qos_of_builtin_entity(dds_sub_subscriber, 0);
|
||||
}
|
||||
|
|
|
@ -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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -170,7 +170,7 @@ CU_Test(ddsc_writedispose, null, .init=disposing_init, .fini=disposing_fini)
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_writedispose, invalid_writers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t writer), ddsc_writedispose, invalid_writers, .init=disposing_init, .fini=disposing_fini)
|
||||
{
|
||||
|
@ -310,7 +310,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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -341,7 +341,7 @@ CU_Test(ddsc_writedispose_ts, timeout, .init=disposing_init, .fini=disposing_fin
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_writedispose_ts, invalid_writers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t writer), ddsc_writedispose_ts, invalid_writers, .init=disposing_init, .fini=disposing_fini)
|
||||
{
|
||||
|
@ -510,7 +510,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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -541,7 +541,7 @@ CU_Test(ddsc_dispose, timeout, .init=disposing_init, .fini=disposing_fini)
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_dispose, invalid_writers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t writer), ddsc_dispose, invalid_writers, .init=disposing_init, .fini=disposing_fini)
|
||||
{
|
||||
|
@ -665,7 +665,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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -696,7 +696,7 @@ CU_Test(ddsc_dispose_ts, timeout, .init=disposing_init, .fini=disposing_fini)
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_dispose_ts, invalid_writers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t writer), ddsc_dispose_ts, invalid_writers, .init=disposing_init, .fini=disposing_fini)
|
||||
{
|
||||
|
@ -861,7 +861,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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -879,7 +879,7 @@ CU_Theory((dds_instance_handle_t handle), ddsc_dispose_ih, invalid_handles, .ini
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_dispose_ih, invalid_writers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t writer), ddsc_dispose_ih, invalid_writers, .init=disposing_init, .fini=disposing_fini)
|
||||
{
|
||||
|
@ -959,7 +959,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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -977,7 +977,7 @@ CU_Theory((dds_instance_handle_t handle), ddsc_dispose_ih_ts, invalid_handles, .
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_dispose_ih_ts, invalid_writers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t writer), ddsc_dispose_ih_ts, invalid_writers, .init=disposing_init, .fini=disposing_fini)
|
||||
{
|
||||
|
|
|
@ -147,21 +147,21 @@ CU_Test(ddsc_entity_delete, recursive, .init=hierarchy_init, .fini=hierarchy_fin
|
|||
|
||||
/* 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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
ret = dds_get_domainid(g_topic, &id);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
ret = dds_get_domainid(g_publisher, &id);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
ret = dds_get_domainid(g_subscriber, &id);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
ret = dds_get_domainid(g_writer, &id);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
ret = dds_get_domainid(g_reader, &id);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
ret = dds_get_domainid(g_readcond, &id);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
ret = dds_get_domainid(g_querycond, &id);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -201,11 +201,11 @@ CU_Test(ddsc_entity_delete, recursive_with_deleted_topic)
|
|||
|
||||
/* Check if the entities are actually deleted. */
|
||||
ret = dds_get_domainid(g_participant, &id);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED );
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER );
|
||||
ret = dds_get_domainid(g_topic, &id);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
ret = dds_get_domainid(g_writer, &id);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
|
||||
dds_delete(g_keep);
|
||||
}
|
||||
|
@ -240,13 +240,13 @@ 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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(participant), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_entity_get_participant, invalid_entities) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t entity), ddsc_entity_get_participant, invalid_entities, .init=hierarchy_init, .fini=hierarchy_fini)
|
||||
{
|
||||
|
@ -327,13 +327,13 @@ 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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(parent), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_entity_get_parent, invalid_entities) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t entity), ddsc_entity_get_parent, invalid_entities, .init=hierarchy_init, .fini=hierarchy_fini)
|
||||
{
|
||||
|
@ -478,13 +478,13 @@ 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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_entity_get_children, invalid_entities) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t entity), ddsc_entity_get_children, invalid_entities, .init=hierarchy_init, .fini=hierarchy_fini)
|
||||
{
|
||||
|
@ -527,13 +527,13 @@ 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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(topic), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_entity_get_topic, invalid_entities) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t entity), ddsc_entity_get_topic, invalid_entities, .init=hierarchy_init, .fini=hierarchy_fini)
|
||||
{
|
||||
|
@ -581,13 +581,13 @@ 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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(publisher), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_entity_get_publisher, invalid_writers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t entity), ddsc_entity_get_publisher, invalid_writers, .init=hierarchy_init, .fini=hierarchy_fini)
|
||||
{
|
||||
|
@ -640,13 +640,13 @@ 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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(subscriber), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_entity_get_subscriber, invalid_readers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t entity), ddsc_entity_get_subscriber, invalid_readers, .init=hierarchy_init, .fini=hierarchy_fini)
|
||||
{
|
||||
|
@ -701,13 +701,13 @@ 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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(reader), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_entity_get_datareader, invalid_conds) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t cond), ddsc_entity_get_datareader, invalid_conds, .init=hierarchy_init, .fini=hierarchy_fini)
|
||||
{
|
||||
|
|
|
@ -589,9 +589,9 @@ CU_Test(ddsc_entity, all_data_available, .init=init_entity_status, .fini=fini_en
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_get_enabled_status, bad_param) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t e), 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;
|
||||
|
@ -605,7 +605,7 @@ 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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_get_enabled_status, illegal, .init=init_entity_status, .fini=fini_entity_status)
|
||||
|
@ -628,9 +628,9 @@ CU_Theory((dds_entity_t *e), ddsc_get_enabled_status, status_ok, .init=init_enti
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_set_enabled_status, bad_param) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t e), 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;
|
||||
|
||||
|
@ -642,7 +642,7 @@ CU_Test(ddsc_set_enabled_status, deleted_reader, .init=init_entity_status, .fini
|
|||
{
|
||||
dds_delete(rea);
|
||||
ret = dds_set_status_mask(rea, 0 /*mask*/);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_set_enabled_status, illegal, .init=init_entity_status, .fini=fini_entity_status)
|
||||
|
@ -663,9 +663,9 @@ CU_Theory((dds_entity_t *entity), ddsc_set_enabled_status, status_ok, .init=init
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_read_status, bad_param) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t e), 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;
|
||||
|
@ -679,7 +679,7 @@ 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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_read_status, illegal, .init=init_entity_status, .fini=fini_entity_status)
|
||||
|
@ -715,9 +715,9 @@ CU_Test(ddsc_read_status, invalid_status_on_writer, .init=init_entity_status, .f
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_take_status, bad_param) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t e), 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;
|
||||
|
@ -731,7 +731,7 @@ 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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
CU_Test(ddsc_take_status, illegal, .init=init_entity_status, .fini=fini_entity_status)
|
||||
{
|
||||
|
@ -754,9 +754,9 @@ CU_Theory((dds_entity_t *e), ddsc_take_status, status_ok, .init=init_entity_stat
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_get_status_changes, bad_param) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t e), 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;
|
||||
|
@ -770,7 +770,7 @@ 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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_get_status_changes, illegal, .init=init_entity_status, .fini=fini_entity_status)
|
||||
|
@ -793,9 +793,9 @@ CU_Theory((dds_entity_t *e), ddsc_get_status_changes, status_ok, .init=init_enti
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_triggered, bad_param) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t e), 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;
|
||||
|
||||
|
@ -807,7 +807,7 @@ CU_Test(ddsc_triggered, deleted_reader, .init=init_entity_status, .fini=fini_ent
|
|||
{
|
||||
dds_delete(rea);
|
||||
ret = dds_triggered(rea);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
CU_TheoryDataPoints(ddsc_triggered, status_ok) = {
|
||||
|
@ -833,9 +833,9 @@ CU_Test(ddsc_get_inconsistent_topic_status, inconsistent_topic_status, .init=ini
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_get_inconsistent_topic_status, bad_params) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t topic), 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;
|
||||
|
@ -876,9 +876,9 @@ CU_Test(ddsc_get_inconsistent_topic_status, deleted_topic, .init=init_entity_sta
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_get_publication_matched_status, bad_params) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t writer), 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;
|
||||
|
@ -913,7 +913,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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -930,9 +930,9 @@ CU_Test(ddsc_get_liveliness_lost_status, liveliness_lost_status, .init=init_enti
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_get_liveliness_lost_status, bad_params) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t writer), 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;
|
||||
|
@ -967,7 +967,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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -985,9 +985,9 @@ CU_Test(ddsc_get_offered_deadline_missed_status, offered_deadline_missed_status,
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_get_offered_deadline_missed_status, bad_params) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t writer), 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;
|
||||
|
@ -1022,15 +1022,15 @@ 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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_get_offered_incompatible_qos_status, bad_params) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t writer), 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;
|
||||
|
@ -1065,15 +1065,15 @@ 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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_get_subscription_matched_status, bad_params) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t reader), 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;
|
||||
|
@ -1108,15 +1108,15 @@ 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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_get_liveliness_changed_status, bad_params) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t reader), 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;
|
||||
|
@ -1151,15 +1151,15 @@ 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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_get_sample_rejected_status, bad_params) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t reader), 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;
|
||||
|
@ -1194,15 +1194,15 @@ 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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_get_sample_lost_status, bad_params) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t reader), 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;
|
||||
|
@ -1237,7 +1237,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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -1255,9 +1255,9 @@ CU_Test(ddsc_get_requested_deadline_missed_status, requested_deadline_missed_sta
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_get_requested_deadline_missed_status, bad_params) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t reader), 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;
|
||||
|
@ -1292,15 +1292,15 @@ 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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_get_requested_incompatible_qos_status, bad_params) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t reader), 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;
|
||||
|
@ -1335,7 +1335,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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
|
@ -1,37 +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 "dds/dds.h"
|
||||
#include "CUnit/Test.h"
|
||||
|
||||
#include "dds/ddsrt/misc.h"
|
||||
|
||||
CU_Test(ddsc_err, unique_file_id)
|
||||
{
|
||||
dds_entity_t participant, reader, writer;
|
||||
|
||||
participant = dds_create_participant(DDS_DOMAIN_DEFAULT, NULL, NULL);
|
||||
CU_ASSERT_FATAL(participant > 0);
|
||||
|
||||
/* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(28020);
|
||||
reader = dds_create_reader(0, 0, NULL, NULL);
|
||||
CU_ASSERT_FATAL(reader < 0);
|
||||
|
||||
writer = dds_create_writer(0, 0, NULL, NULL);
|
||||
CU_ASSERT_FATAL(writer < 0);
|
||||
|
||||
DDSRT_WARNING_MSVC_ON(28020);
|
||||
|
||||
CU_ASSERT_NOT_EQUAL_FATAL(dds_err_file_id(reader), dds_err_file_id(writer));
|
||||
|
||||
dds_delete(participant);
|
||||
}
|
|
@ -42,7 +42,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_BAD_PARAMETER);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(publisher), DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
|
||||
participant = dds_create_participant (DDS_DOMAIN_DEFAULT, NULL, NULL);
|
||||
CU_ASSERT_FATAL(participant > 0);
|
||||
|
@ -143,21 +143,21 @@ CU_Test(ddsc_publisher, suspend_resume)
|
|||
|
||||
/* Suspend a 0 publisher */
|
||||
status = dds_suspend(0);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
|
||||
/* Resume a 0 publisher */
|
||||
status = dds_resume(0);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
cu_assert_status_eq(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_BAD_PARAMETER);
|
||||
cu_assert_status_eq(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_BAD_PARAMETER);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
|
||||
/* Use dds_resume without calling dds_suspend */
|
||||
publisher = dds_create_publisher(participant, NULL, NULL);
|
||||
|
@ -193,15 +193,15 @@ CU_Test(ddsc_publisher, wait_for_acks)
|
|||
|
||||
/* 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_BAD_PARAMETER);
|
||||
cu_assert_status_eq(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_BAD_PARAMETER);
|
||||
cu_assert_status_eq(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_BAD_PARAMETER);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_PRECONDITION_NOT_MET);
|
||||
|
||||
participant = dds_create_participant (DDS_DOMAIN_DEFAULT, NULL, NULL);
|
||||
CU_ASSERT_FATAL(participant > 0);
|
||||
|
@ -212,22 +212,23 @@ CU_Test(ddsc_publisher, wait_for_acks)
|
|||
|
||||
/* Wait_for_acks on participant and zeroSec timeout */
|
||||
status = dds_wait_for_acks(participant, zeroSec);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
cu_assert_status_eq(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_BAD_PARAMETER);
|
||||
cu_assert_status_eq(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_BAD_PARAMETER);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
|
||||
publisher = dds_create_publisher(participant, NULL, NULL);
|
||||
CU_ASSERT_FATAL(publisher > 0);
|
||||
|
||||
/* Wait_for_acks on publisher and minusOneSec timeout */
|
||||
/* 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_UNSUPPORTED);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
|
||||
/* Wait_for_acks on publisher and zeroSec timeout */
|
||||
status = dds_wait_for_acks(publisher, zeroSec);
|
||||
|
@ -248,7 +249,7 @@ CU_Test(ddsc_publisher, wait_for_acks)
|
|||
|
||||
/* Wait_for_acks on suspended publisher and minusOneSec timeout */
|
||||
status = dds_wait_for_acks(publisher, minusOneSec);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_UNSUPPORTED);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_BAD_PARAMETER);
|
||||
|
||||
/* Wait_for_acks on suspended publisher and zeroSec timeout */
|
||||
status = dds_wait_for_acks(publisher, zeroSec);
|
||||
|
|
|
@ -245,13 +245,13 @@ 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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(cond), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_querycondition_create, invalid_readers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t rdr), ddsc_querycondition_create, invalid_readers, .init=querycondition_init, .fini=querycondition_fini)
|
||||
{
|
||||
|
@ -297,7 +297,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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -319,7 +319,7 @@ CU_Test(ddsc_querycondition_get_mask, null, .init=querycondition_init, .fini=que
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_querycondition_get_mask, invalid_conditions) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t cond), ddsc_querycondition_get_mask, invalid_conditions, .init=querycondition_init, .fini=querycondition_fini)
|
||||
{
|
||||
|
@ -924,7 +924,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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -1487,7 +1487,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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
|
@ -450,7 +450,7 @@ CU_Theory((dds_entity_t *rdr, dds_instance_handle_t hdl), ddsc_read_instance_mas
|
|||
*************************************************************************************************/
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_read_instance, invalid_readers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t rdr), ddsc_read_instance, invalid_readers, .init=read_instance_init, .fini=read_instance_fini)
|
||||
{
|
||||
|
@ -464,7 +464,7 @@ CU_Theory((dds_entity_t rdr), ddsc_read_instance, invalid_readers, .init=read_in
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_read_instance_wl, invalid_readers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t rdr), ddsc_read_instance_wl, invalid_readers, .init=read_instance_init, .fini=read_instance_fini)
|
||||
{
|
||||
|
@ -478,7 +478,7 @@ CU_Theory((dds_entity_t rdr), ddsc_read_instance_wl, invalid_readers, .init=read
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_read_instance_mask, invalid_readers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t rdr), ddsc_read_instance_mask, invalid_readers, .init=read_instance_init, .fini=read_instance_fini)
|
||||
{
|
||||
|
@ -493,7 +493,7 @@ CU_Theory((dds_entity_t rdr), ddsc_read_instance_mask, invalid_readers, .init=re
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_read_instance_mask_wl, invalid_readers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t rdr), ddsc_read_instance_mask_wl, invalid_readers, .init=read_instance_init, .fini=read_instance_fini)
|
||||
{
|
||||
|
@ -586,7 +586,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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -600,7 +600,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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -615,7 +615,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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -630,7 +630,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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
|
@ -227,13 +227,13 @@ CU_Test(ddsc_readcondition_create, deleted_reader, .init=readcondition_init, .fi
|
|||
dds_entity_t cond;
|
||||
dds_delete(g_reader);
|
||||
cond = dds_create_readcondition(g_reader, mask);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(cond), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(cond), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_readcondition_create, invalid_readers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t rdr), ddsc_readcondition_create, invalid_readers, .init=readcondition_init, .fini=readcondition_fini)
|
||||
{
|
||||
|
@ -279,7 +279,7 @@ CU_Test(ddsc_readcondition_get_mask, deleted, .init=readcondition_init, .fini=re
|
|||
dds_delete(condition);
|
||||
mask = 0;
|
||||
ret = dds_get_mask(condition, &mask);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -301,7 +301,7 @@ CU_Test(ddsc_readcondition_get_mask, null, .init=readcondition_init, .fini=readc
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_readcondition_get_mask, invalid_conditions) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t cond), ddsc_readcondition_get_mask, invalid_conditions, .init=readcondition_init, .fini=readcondition_fini)
|
||||
{
|
||||
|
@ -906,7 +906,7 @@ CU_Test(ddsc_readcondition_read, already_deleted, .init=readcondition_init, .fin
|
|||
|
||||
/* 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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -1462,7 +1462,7 @@ CU_Test(ddsc_readcondition_take, already_deleted, .init=readcondition_init, .fin
|
|||
|
||||
/* Try to take with a deleted condition. */
|
||||
ret = dds_take(condition, g_samples, g_info, MAX_SAMPLES, MAX_SAMPLES);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
|
@ -316,7 +316,7 @@ CU_Theory((void **buf, dds_sample_info_t *si, size_t bufsz, uint32_t maxs), ddsc
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_read, invalid_readers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t rdr), ddsc_read, invalid_readers, .init=reader_init, .fini=reader_fini)
|
||||
{
|
||||
|
@ -347,7 +347,7 @@ CU_Test(ddsc_read, already_deleted, .init=reader_init, .fini=reader_fini)
|
|||
/* Try to read with a deleted reader. */
|
||||
dds_delete(g_reader);
|
||||
ret = dds_read(g_reader, g_samples, g_info, MAX_SAMPLES, MAX_SAMPLES);
|
||||
CU_ASSERT_EQUAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -426,7 +426,7 @@ CU_Theory((void **buf, dds_sample_info_t *si, uint32_t maxs), ddsc_read_wl, inva
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_read_wl, invalid_readers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t rdr), ddsc_read_wl, invalid_readers, .init=reader_init, .fini=reader_fini)
|
||||
{
|
||||
|
@ -457,7 +457,7 @@ CU_Test(ddsc_read_wl, already_deleted, .init=reader_init, .fini=reader_fini)
|
|||
/* Try to read with a deleted reader. */
|
||||
dds_delete(g_reader);
|
||||
ret = dds_read_wl(g_reader, g_loans, g_info, MAX_SAMPLES);
|
||||
CU_ASSERT_EQUAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -550,7 +550,7 @@ CU_Theory((void **buf, dds_sample_info_t *si, size_t bufsz, uint32_t maxs), ddsc
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_read_mask, invalid_readers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t rdr), ddsc_read_mask, invalid_readers, .init=reader_init, .fini=reader_fini)
|
||||
{
|
||||
|
@ -584,7 +584,7 @@ CU_Test(ddsc_read_mask, already_deleted, .init=reader_init, .fini=reader_fini)
|
|||
/* Try to read with a deleted reader. */
|
||||
dds_delete(g_reader);
|
||||
ret = dds_read_mask(g_reader, g_samples, g_info, MAX_SAMPLES, MAX_SAMPLES, mask);
|
||||
CU_ASSERT_EQUAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -1098,7 +1098,7 @@ CU_Theory((void **buf, dds_sample_info_t *si, uint32_t maxs), ddsc_read_mask_wl,
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_read_mask_wl, invalid_readers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t rdr), ddsc_read_mask_wl, invalid_readers, .init=reader_init, .fini=reader_fini)
|
||||
{
|
||||
|
@ -1132,7 +1132,7 @@ CU_Test(ddsc_read_mask_wl, already_deleted, .init=reader_init, .fini=reader_fini
|
|||
/* Try to read with a deleted reader. */
|
||||
dds_delete(g_reader);
|
||||
ret = dds_read_mask_wl(g_reader, g_loans, g_info, MAX_SAMPLES, mask);
|
||||
CU_ASSERT_EQUAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -1686,7 +1686,7 @@ CU_Theory((void **buf, dds_sample_info_t *si, size_t bufsz, uint32_t maxs), ddsc
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_take, invalid_readers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t rdr), ddsc_take, invalid_readers, .init=reader_init, .fini=reader_fini)
|
||||
{
|
||||
|
@ -1717,7 +1717,7 @@ CU_Test(ddsc_take, already_deleted, .init=reader_init, .fini=reader_fini)
|
|||
/* Try to take with a deleted reader. */
|
||||
dds_delete(g_reader);
|
||||
ret = dds_take(g_reader, g_samples, g_info, MAX_SAMPLES, MAX_SAMPLES);
|
||||
CU_ASSERT_EQUAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -1796,7 +1796,7 @@ CU_Theory((void **buf, dds_sample_info_t *si, uint32_t maxs), ddsc_take_wl, inva
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_take_wl, invalid_readers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t rdr), ddsc_take_wl, invalid_readers, .init=reader_init, .fini=reader_fini)
|
||||
{
|
||||
|
@ -1827,7 +1827,7 @@ CU_Test(ddsc_take_wl, already_deleted, .init=reader_init, .fini=reader_fini)
|
|||
/* Try to read with a deleted reader. */
|
||||
dds_delete(g_reader);
|
||||
ret = dds_take_wl(g_reader, g_loans, g_info, MAX_SAMPLES);
|
||||
CU_ASSERT_EQUAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -1921,7 +1921,7 @@ CU_Theory((void **buf, dds_sample_info_t *si, size_t bufsz, uint32_t maxs), ddsc
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_take_mask, invalid_readers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t rdr), ddsc_take_mask, invalid_readers, .init=reader_init, .fini=reader_fini)
|
||||
{
|
||||
|
@ -1955,7 +1955,7 @@ CU_Test(ddsc_take_mask, already_deleted, .init=reader_init, .fini=reader_fini)
|
|||
/* Try to read with a deleted reader. */
|
||||
dds_delete(g_reader);
|
||||
ret = dds_take_mask(g_reader, g_samples, g_info, MAX_SAMPLES, MAX_SAMPLES, mask);
|
||||
CU_ASSERT_EQUAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -2602,7 +2602,7 @@ CU_Theory((void **buf, dds_sample_info_t *si, uint32_t maxs), ddsc_take_mask_wl,
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_take_mask_wl, invalid_readers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t rdr), ddsc_take_mask_wl, invalid_readers, .init=reader_init, .fini=reader_fini)
|
||||
{
|
||||
|
@ -2636,7 +2636,7 @@ CU_Test(ddsc_take_mask_wl, already_deleted, .init=reader_init, .fini=reader_fini
|
|||
/* Try to read with a deleted reader. */
|
||||
dds_delete(g_reader);
|
||||
ret = dds_take_mask_wl(g_reader, g_loans, g_info, MAX_SAMPLES, mask);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
|
@ -356,7 +356,7 @@ CU_Test(ddsc_read_next, reader, .init=reader_iterator_init, .fini=reader_iterato
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_read_next, invalid_readers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t rdr), ddsc_read_next, invalid_readers, .init=reader_iterator_init, .fini=reader_iterator_fini)
|
||||
{
|
||||
|
@ -390,7 +390,7 @@ CU_Theory((dds_entity_t *rdr), ddsc_read_next, already_deleted, .init=reader_ite
|
|||
ret = dds_delete(*rdr);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
ret = dds_read_next(*rdr, g_samples, g_info);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
/*************************************************************************************************/
|
||||
|
@ -472,7 +472,7 @@ CU_Test(ddsc_read_next_wl, reader, .init=reader_iterator_init, .fini=reader_iter
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_read_next_wl, invalid_readers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t rdr), ddsc_read_next_wl, invalid_readers, .init=reader_iterator_init, .fini=reader_iterator_fini)
|
||||
{
|
||||
|
@ -506,7 +506,7 @@ CU_Theory((dds_entity_t *rdr), ddsc_read_next_wl, already_deleted, .init=reader_
|
|||
ret = dds_delete(*rdr);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
ret = dds_read_next_wl(*rdr, g_loans, g_info);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
/*************************************************************************************************/
|
||||
|
@ -582,7 +582,7 @@ CU_Test(ddsc_take_next, reader, .init=reader_iterator_init, .fini=reader_iterato
|
|||
}
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_take_next, invalid_readers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t rdr), ddsc_take_next, invalid_readers, .init=reader_iterator_init, .fini=reader_iterator_fini)
|
||||
{
|
||||
|
@ -616,7 +616,7 @@ CU_Theory((dds_entity_t *rdr), ddsc_take_next, already_deleted, .init=reader_ite
|
|||
ret = dds_delete(*rdr);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
ret = dds_take_next(*rdr, g_samples, g_info);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
/*************************************************************************************************/
|
||||
|
@ -695,7 +695,7 @@ CU_Test(ddsc_take_next_wl, reader, .init=reader_iterator_init, .fini=reader_iter
|
|||
}
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_take_next_wl, invalid_readers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t rdr), ddsc_take_next_wl, invalid_readers, .init=reader_iterator_init, .fini=reader_iterator_fini)
|
||||
{
|
||||
|
@ -729,7 +729,7 @@ CU_Theory((dds_entity_t *rdr), ddsc_take_next_wl, already_deleted, .init=reader_
|
|||
ret = dds_delete(*rdr);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
ret = dds_take_next_wl(*rdr, g_loans, g_info);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ CU_Test(ddsc_register_instance, deleted_entity, .init=registering_init, .fini=re
|
|||
dds_instance_handle_t handle;
|
||||
dds_delete(g_writer);
|
||||
ret = dds_register_instance(g_writer, &handle, g_data);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
static dds_instance_handle_t hndle = 0;
|
||||
|
@ -173,7 +173,7 @@ CU_Theory((dds_instance_handle_t *hndl2, void *datap), ddsc_register_instance, i
|
|||
}
|
||||
|
||||
CU_TheoryDataPoints(ddsc_register_instance, invalid_writers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t writer), ddsc_register_instance, invalid_writers, .init=registering_init, .fini=registering_fini)
|
||||
{
|
||||
|
|
|
@ -447,7 +447,7 @@ CU_Theory((dds_entity_t *rdr, dds_instance_handle_t hdl), ddsc_take_instance_mas
|
|||
*************************************************************************************************/
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_take_instance, invalid_readers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t rdr), ddsc_take_instance, invalid_readers, .init=take_instance_init, .fini=take_instance_fini)
|
||||
{
|
||||
|
@ -461,7 +461,7 @@ CU_Theory((dds_entity_t rdr), ddsc_take_instance, invalid_readers, .init=take_in
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_take_instance_wl, invalid_readers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t rdr), ddsc_take_instance_wl, invalid_readers, .init=take_instance_init, .fini=take_instance_fini)
|
||||
{
|
||||
|
@ -475,7 +475,7 @@ CU_Theory((dds_entity_t rdr), ddsc_take_instance_wl, invalid_readers, .init=take
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_take_instance_mask, invalid_readers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t rdr), ddsc_take_instance_mask, invalid_readers, .init=take_instance_init, .fini=take_instance_fini)
|
||||
{
|
||||
|
@ -490,7 +490,7 @@ CU_Theory((dds_entity_t rdr), ddsc_take_instance_mask, invalid_readers, .init=ta
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_take_instance_mask_wl, invalid_readers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t rdr), ddsc_take_instance_mask_wl, invalid_readers, .init=take_instance_init, .fini=take_instance_fini)
|
||||
{
|
||||
|
@ -583,7 +583,7 @@ CU_Theory((dds_entity_t *rdr), ddsc_take_instance, already_deleted, .init=take_i
|
|||
ret = dds_delete(*rdr);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
ret = dds_take_instance(*rdr, g_samples, g_info, MAX_SAMPLES, MAX_SAMPLES, g_hdl_valid);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -597,7 +597,7 @@ CU_Theory((dds_entity_t *rdr), ddsc_take_instance_wl, already_deleted, .init=tak
|
|||
ret = dds_delete(*rdr);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
ret = dds_take_instance_wl(*rdr, g_loans, g_info, MAX_SAMPLES, g_hdl_valid);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -612,7 +612,7 @@ CU_Theory((dds_entity_t *rdr), ddsc_take_instance_mask, already_deleted, .init=t
|
|||
ret = dds_delete(*rdr);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
ret = dds_take_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_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -627,7 +627,7 @@ CU_Theory((dds_entity_t *rdr), ddsc_take_instance_mask_wl, already_deleted, .ini
|
|||
ret = dds_delete(*rdr);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||
ret = dds_take_instance_mask_wl(*rdr, g_loans, g_info, MAX_SAMPLES, g_hdl_valid, mask);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
|
@ -314,7 +314,7 @@ CU_Test(ddsc_topic_get_name, deleted, .init=ddsc_topic_init, .fini=ddsc_topic_fi
|
|||
dds_return_t ret;
|
||||
dds_delete(g_topicRtmDataType);
|
||||
ret = dds_get_name(g_topicRtmDataType, name, MAX_NAME_SIZE);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -387,7 +387,7 @@ CU_Test(ddsc_topic_get_type_name, deleted, .init=ddsc_topic_init, .fini=ddsc_top
|
|||
dds_return_t ret;
|
||||
dds_delete(g_topicRtmDataType);
|
||||
ret = dds_get_type_name(g_topicRtmDataType, name, MAX_NAME_SIZE);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
|
@ -152,7 +152,7 @@ CU_Test(ddsc_unregister_instance, deleted, .init=unregistering_init, .fini=unreg
|
|||
dds_delete(g_writer);
|
||||
|
||||
ret = dds_unregister_instance(g_writer, g_data);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -167,7 +167,7 @@ CU_Test(ddsc_unregister_instance, null, .init=unregistering_init, .fini=unregist
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_unregister_instance, invalid_writers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t writer), ddsc_unregister_instance, invalid_writers, .init=unregistering_init, .fini=unregistering_fini)
|
||||
{
|
||||
|
@ -246,7 +246,7 @@ CU_Test(ddsc_unregister_instance_ts, deleted, .init=unregistering_init, .fini=un
|
|||
dds_return_t ret;
|
||||
dds_delete(g_writer);
|
||||
ret = dds_unregister_instance_ts(g_writer, g_data, g_present);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -261,7 +261,7 @@ CU_Test(ddsc_unregister_instance_ts, null, .init=unregistering_init, .fini=unreg
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_unregister_instance_ts, invalid_writers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t writer), ddsc_unregister_instance_ts, invalid_writers, .init=unregistering_init, .fini=unregistering_fini)
|
||||
{
|
||||
|
@ -383,7 +383,7 @@ CU_Test(ddsc_unregister_instance_ih, deleted, .init=unregistering_init, .fini=un
|
|||
dds_return_t ret;
|
||||
dds_delete(g_writer);
|
||||
ret = dds_unregister_instance_ih(g_writer, DDS_HANDLE_NIL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -401,7 +401,7 @@ CU_Theory((dds_instance_handle_t handle), ddsc_unregister_instance_ih, invalid_h
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_unregister_instance_ih, invalid_writers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t writer), ddsc_unregister_instance_ih, invalid_writers, .init=unregistering_init, .fini=unregistering_fini)
|
||||
{
|
||||
|
@ -481,7 +481,7 @@ CU_Test(ddsc_unregister_instance_ih_ts, deleted, .init=unregistering_init, .fini
|
|||
dds_return_t ret;
|
||||
dds_delete(g_writer);
|
||||
ret = dds_unregister_instance_ih_ts(g_writer, DDS_HANDLE_NIL, g_present);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -499,7 +499,7 @@ CU_Theory((dds_instance_handle_t handle), ddsc_unregister_instance_ih_ts, invali
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_unregister_instance_ih_ts, invalid_writers) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t writer), ddsc_unregister_instance_ih_ts, invalid_writers, .init=unregistering_init, .fini=unregistering_fini)
|
||||
{
|
||||
|
|
|
@ -50,7 +50,7 @@ setup(void)
|
|||
CU_ASSERT_FATAL(e[REA] > 0);
|
||||
e[RCD] = dds_create_readcondition(e[REA], DDS_ANY_STATE);
|
||||
CU_ASSERT_FATAL(e[RCD] > 0);
|
||||
e[BAD] = 1;
|
||||
e[BAD] = 314159265;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -104,7 +104,7 @@ CU_Test(ddsc_unsupported, dds_suspend_resume, .init = setup, .fini = teardown)
|
|||
dds_return_t result;
|
||||
static struct index_result pars[] = {
|
||||
{PUB, DDS_RETCODE_UNSUPPORTED},
|
||||
{WRI, DDS_RETCODE_BAD_PARAMETER},
|
||||
{WRI, DDS_RETCODE_ILLEGAL_OPERATION},
|
||||
{BAD, DDS_RETCODE_BAD_PARAMETER}
|
||||
};
|
||||
|
||||
|
|
|
@ -226,13 +226,13 @@ CU_Test(ddsc_waitset_create, deleted_participant, .init=ddsc_waitset_basic_init,
|
|||
deleted = dds_create_participant(DDS_DOMAIN_DEFAULT, NULL, NULL);
|
||||
dds_delete(deleted);
|
||||
ws = dds_create_waitset(deleted);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ws), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ws), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_waitset_create, invalid_params) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t par), ddsc_waitset_create, invalid_params, .init=ddsc_waitset_basic_init, .fini=ddsc_waitset_basic_fini)
|
||||
{
|
||||
|
@ -269,7 +269,7 @@ CU_Theory((dds_entity_t *par), ddsc_waitset_create, non_participants, .init=ddsc
|
|||
*************************************************************************************************/
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_waitset_attach, invalid_params) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_attach_t, (dds_attach_t)NULL, (dds_attach_t)&reader, (dds_attach_t)3, (dds_attach_t)0, (dds_attach_t)0, (dds_attach_t)0, (dds_attach_t)0),
|
||||
};
|
||||
CU_Theory((dds_entity_t e, dds_attach_t a), ddsc_waitset_attach, invalid_params, .init=ddsc_waitset_basic_init, .fini=ddsc_waitset_basic_fini)
|
||||
|
@ -282,7 +282,7 @@ CU_Theory((dds_entity_t e, dds_attach_t a), ddsc_waitset_attach, invalid_params,
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_waitset_attach, invalid_waitsets) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_attach_t, (dds_attach_t)NULL, (dds_attach_t)&reader, (dds_attach_t)3, (dds_attach_t)0, (dds_attach_t)0, (dds_attach_t)0, (dds_attach_t)0),
|
||||
};
|
||||
CU_Theory((dds_entity_t ws, dds_attach_t a), ddsc_waitset_attach, invalid_waitsets, .init=ddsc_waitset_basic_init, .fini=ddsc_waitset_basic_fini)
|
||||
|
@ -315,7 +315,7 @@ CU_Test(ddsc_waitset_attach, deleted_waitset, .init=ddsc_waitset_basic_init, .fi
|
|||
dds_return_t ret;
|
||||
dds_delete(waitset);
|
||||
ret = dds_waitset_attach(waitset, participant, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
@ -393,7 +393,7 @@ CU_Test(ddsc_waitset_attach_detach, second, .init=ddsc_waitset_basic_init, .fini
|
|||
*************************************************************************************************/
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_waitset_detach, invalid_params) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t e), ddsc_waitset_detach, invalid_params, .init=ddsc_waitset_basic_init, .fini=ddsc_waitset_basic_fini)
|
||||
{
|
||||
|
@ -405,7 +405,7 @@ CU_Theory((dds_entity_t e), ddsc_waitset_detach, invalid_params, .init=ddsc_wait
|
|||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_waitset_detach, invalid_waitsets) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t ws), ddsc_waitset_detach, invalid_waitsets, .init=ddsc_waitset_basic_init, .fini=ddsc_waitset_basic_fini)
|
||||
{
|
||||
|
@ -580,13 +580,13 @@ CU_Test(ddsc_waitset_set_trigger, deleted_waitset, .init=ddsc_waitset_basic_init
|
|||
dds_return_t ret;
|
||||
dds_delete(waitset);
|
||||
ret = dds_waitset_set_trigger(waitset, true);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_waitset_set_trigger, invalid_params) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t ws), ddsc_waitset_set_trigger, invalid_params, .init=ddsc_waitset_basic_init, .fini=ddsc_waitset_basic_fini)
|
||||
{
|
||||
|
@ -625,13 +625,13 @@ CU_Test(ddsc_waitset_wait, deleted_waitset, .init=ddsc_waitset_attached_init, .f
|
|||
dds_return_t ret;
|
||||
dds_delete(waitset);
|
||||
ret = dds_waitset_wait(waitset, &triggered, 1, DDS_SECS(1));
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_waitset_wait, invalid_waitsets) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t ws), ddsc_waitset_wait, invalid_waitsets, .init=ddsc_waitset_basic_init, .fini=ddsc_waitset_basic_fini)
|
||||
{
|
||||
|
@ -683,13 +683,13 @@ CU_Test(ddsc_waitset_wait_until, deleted_waitset, .init=ddsc_waitset_attached_in
|
|||
dds_return_t ret;
|
||||
dds_delete(waitset);
|
||||
ret = dds_waitset_wait_until(waitset, &triggered, 1, dds_time());
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_waitset_wait_until, invalid_waitsets) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t ws), ddsc_waitset_wait_until, invalid_waitsets, .init=ddsc_waitset_basic_init, .fini=ddsc_waitset_basic_fini)
|
||||
{
|
||||
|
@ -843,13 +843,13 @@ CU_Test(ddsc_waitset_get_entities, deleted_waitset, .init=ddsc_waitset_attached_
|
|||
dds_entity_t entities[MAX_ENTITIES_CNT];
|
||||
dds_delete(waitset);
|
||||
ret = dds_waitset_get_entities(waitset, entities, MAX_ENTITIES_CNT);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
CU_TheoryDataPoints(ddsc_waitset_get_entities, invalid_params) = {
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, 1, 100, INT_MAX, INT_MIN),
|
||||
CU_DataPoints(dds_entity_t, -2, -1, 0, INT_MAX, INT_MIN),
|
||||
};
|
||||
CU_Theory((dds_entity_t ws), ddsc_waitset_get_entities, invalid_params, .init=ddsc_waitset_attached_init, .fini=ddsc_waitset_attached_fini)
|
||||
{
|
||||
|
|
|
@ -95,7 +95,7 @@ CU_Test(ddsc_write, closed_writer, .init = setup, .fini = teardown)
|
|||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(status), DDS_RETCODE_OK);
|
||||
status = dds_write(writer, &data);
|
||||
writer = 0;
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(status), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(status), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_write, null_sample, .init = setup, .fini = teardown)
|
||||
|
|
|
@ -83,7 +83,7 @@ CU_Test(ddsc_create_writer, deleted_publisher, .init = setup, .fini = teardown)
|
|||
dds_delete(publisher);
|
||||
|
||||
writer = dds_create_writer(publisher, topic, NULL, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(writer), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(writer), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_create_writer, null_topic, .init = setup, .fini = teardown)
|
||||
|
@ -105,5 +105,5 @@ CU_Test(ddsc_create_writer, deleted_topic, .init = setup, .fini = teardown)
|
|||
dds_delete(topic);
|
||||
|
||||
writer = dds_create_writer(publisher, topic, NULL, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(writer), DDS_RETCODE_ALREADY_DELETED);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(writer), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
# ddsi sources
|
||||
1 src/ddsi_ser.c
|
||||
2 src/ddsi_ssl.c
|
||||
3 src/ddsi_tcp.c
|
||||
4 src/ddsi_tran.c
|
||||
5 src/ddsi_udp.c
|
||||
6 src/q_addrset.c
|
||||
7 src/q_bitset_inlines.c
|
||||
8 src/q_bswap.c
|
||||
9 src/q_bswap_inlines.c
|
||||
10 src/q_config.c
|
||||
11 src/q_ddsi_discovery.c
|
||||
12 src/q_debmon.c
|
||||
13 src/q_entity.c
|
||||
14 src/q_ephash.c
|
||||
15 src/q_gc.c
|
||||
16 src/q_init.c
|
||||
17 src/q_lat_estim.c
|
||||
18 src/q_lease.c
|
||||
20 src/q_md5.c
|
||||
21 src/q_misc.c
|
||||
22 src/q_nwif.c
|
||||
23 src/q_pcap.c
|
||||
24 src/q_plist.c
|
||||
25 src/q_qosmatch.c
|
||||
26 src/q_radmin.c
|
||||
27 src/q_receive.c
|
||||
28 src/q_security.c
|
||||
29 src/q_servicelease.c
|
||||
30 src/q_sockwaitset.c
|
||||
31 src/q_thread.c
|
||||
32 src/q_thread_inlines.c
|
||||
33 src/q_time.c
|
||||
34 src/q_transmit.c
|
||||
36 src/q_xevent.c
|
||||
37 src/q_xmsg.c
|
||||
38 src/q_freelist.c
|
||||
39 src/sysdeps.c
|
||||
71 src/q_builtin_topic.c
|
||||
|
|
@ -19,4 +19,3 @@ extern inline void thread_state_asleep (struct thread_state1 *ts1);
|
|||
extern inline void thread_state_awake (struct thread_state1 *ts1);
|
||||
extern inline void thread_state_blocked (struct thread_state1 *ts1);
|
||||
extern inline void thread_state_unblocked (struct thread_state1 *ts1);
|
||||
|
||||
|
|
|
@ -390,7 +390,6 @@ static void inapplicable_qos(dds_entity_kind_t qt, const char *n) {
|
|||
case DDS_KIND_COND_READ: en = "cond read"; break;
|
||||
case DDS_KIND_COND_QUERY: en = "cond query"; break;
|
||||
case DDS_KIND_WAITSET: en = "waitset"; break;
|
||||
case DDS_KIND_INTERNAL: en = "internal"; break;
|
||||
default: en = "?"; break;
|
||||
}
|
||||
fprintf(stderr, "warning: %s entity ignoring inapplicable QoS \"%s\"\n", en, n);
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
include (GenerateExportHeader)
|
||||
|
||||
PREPEND(srcs_util "${CMAKE_CURRENT_SOURCE_DIR}/src" ut_avl.c ut_crc.c ut_expand_envvars.c ut_fibheap.c ut_handleserver.c ut_hopscotch.c ut_thread_pool.c ut_xmlparser.c)
|
||||
PREPEND(srcs_util "${CMAKE_CURRENT_SOURCE_DIR}/src" ut_avl.c ut_crc.c ut_expand_envvars.c ut_fibheap.c ut_hopscotch.c ut_thread_pool.c ut_xmlparser.c)
|
||||
|
||||
add_library(util ${srcs_util})
|
||||
set_property(TARGET util PROPERTY POSITION_INDEPENDENT_CODE TRUE)
|
||||
|
|
|
@ -1,393 +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 <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "dds/ddsrt/cdtors.h"
|
||||
#include "dds/ddsrt/heap.h"
|
||||
#include "dds/ddsrt/sync.h"
|
||||
#include "dds/util/ut_handleserver.h"
|
||||
|
||||
/* Arbitrarily number of max handles. Should be enough for the mock. */
|
||||
#define MAX_NR_OF_HANDLES (1000)
|
||||
|
||||
#define HDL_FLAG_NONE (0x00)
|
||||
#define HDL_FLAG_CLOSED (0x01)
|
||||
|
||||
typedef struct ut_handlelink {
|
||||
ut_handle_t hdl;
|
||||
void *arg;
|
||||
uint32_t cnt;
|
||||
uint8_t flags;
|
||||
} ut_handlelink;
|
||||
|
||||
typedef struct ut_handleserver {
|
||||
ut_handlelink *hdls[MAX_NR_OF_HANDLES];
|
||||
int32_t last;
|
||||
ddsrt_mutex_t mutex;
|
||||
} ut_handleserver;
|
||||
|
||||
|
||||
/* Singleton handle server. */
|
||||
static ut_handleserver *hs = NULL;
|
||||
|
||||
|
||||
static ut_handle_retcode_t
|
||||
lookup_handle(ut_handle_t hdl, int32_t kind, ut_handlelink **link);
|
||||
|
||||
static ut_handle_t
|
||||
check_handle(ut_handle_t hdl, int32_t kind);
|
||||
|
||||
static void
|
||||
delete_handle(int32_t idx);
|
||||
|
||||
|
||||
ut_handle_retcode_t
|
||||
ut_handleserver_init(void)
|
||||
{
|
||||
ddsrt_init();
|
||||
/* TODO Allow re-entry (something like ddsrt_init()). */
|
||||
assert(hs == NULL);
|
||||
hs = ddsrt_malloc(sizeof(ut_handleserver));
|
||||
hs->last = 0;
|
||||
ddsrt_mutex_init(&hs->mutex);
|
||||
return UT_HANDLE_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ut_handleserver_fini(void)
|
||||
{
|
||||
int32_t i;
|
||||
|
||||
/* TODO Only destroy when this is the last fini (something like ddsrt_fini()). */
|
||||
assert(hs);
|
||||
|
||||
/* Every handle should have been deleted, but make sure. */
|
||||
for (i = 0; i < hs->last; i++) {
|
||||
if (hs->hdls[i] != NULL) {
|
||||
/* TODO CHAM-138: Print warning. */
|
||||
ddsrt_free(hs->hdls[i]);
|
||||
}
|
||||
}
|
||||
ddsrt_mutex_destroy(&hs->mutex);
|
||||
ddsrt_free(hs);
|
||||
hs = NULL;
|
||||
ddsrt_fini();
|
||||
}
|
||||
|
||||
|
||||
ut_handle_t
|
||||
ut_handle_create(
|
||||
int32_t kind,
|
||||
void *arg)
|
||||
{
|
||||
ut_handle_t hdl = (ut_handle_t)UT_HANDLE_OUT_OF_RESOURCES;
|
||||
|
||||
/* A kind is obligatory. */
|
||||
assert(kind & UT_HANDLE_KIND_MASK);
|
||||
/* The kind should extent outside its boundaries. */
|
||||
assert(!(kind & ~UT_HANDLE_KIND_MASK));
|
||||
|
||||
if (hs == NULL) {
|
||||
return (ut_handle_t)UT_HANDLE_NOT_INITALIZED;
|
||||
}
|
||||
|
||||
ddsrt_mutex_lock(&hs->mutex);
|
||||
|
||||
/* TODO CHAM-138: Improve the creation and management of handles. */
|
||||
if (hs->last < MAX_NR_OF_HANDLES) {
|
||||
hdl = hs->last;
|
||||
hdl |= kind;
|
||||
hs->hdls[hs->last] = ddsrt_malloc(sizeof(ut_handlelink));
|
||||
hs->hdls[hs->last]->cnt = 0;
|
||||
hs->hdls[hs->last]->arg = arg;
|
||||
hs->hdls[hs->last]->hdl = hdl;
|
||||
hs->hdls[hs->last]->flags = HDL_FLAG_NONE;
|
||||
hs->last++;
|
||||
}
|
||||
|
||||
ddsrt_mutex_unlock(&hs->mutex);
|
||||
|
||||
return hdl;
|
||||
}
|
||||
|
||||
void
|
||||
ut_handle_close(
|
||||
ut_handle_t hdl,
|
||||
struct ut_handlelink *link)
|
||||
{
|
||||
struct ut_handlelink *info = link;
|
||||
ut_handle_retcode_t ret = UT_HANDLE_OK;
|
||||
|
||||
assert(hs);
|
||||
|
||||
ddsrt_mutex_lock(&hs->mutex);
|
||||
if (info == NULL) {
|
||||
ret = lookup_handle(hdl, UT_HANDLE_DONTCARE_KIND, &info);
|
||||
}
|
||||
if (ret == UT_HANDLE_OK) {
|
||||
assert(info);
|
||||
assert(hdl == info->hdl);
|
||||
info->flags |= HDL_FLAG_CLOSED;
|
||||
}
|
||||
ddsrt_mutex_unlock(&hs->mutex);
|
||||
}
|
||||
|
||||
ut_handle_retcode_t
|
||||
ut_handle_delete(
|
||||
ut_handle_t hdl,
|
||||
struct ut_handlelink *link,
|
||||
dds_time_t timeout)
|
||||
{
|
||||
struct ut_handlelink *info = link;
|
||||
ut_handle_retcode_t ret = UT_HANDLE_OK;
|
||||
|
||||
assert(hs);
|
||||
|
||||
ddsrt_mutex_lock(&hs->mutex);
|
||||
if (info == NULL) {
|
||||
ret = lookup_handle(hdl, UT_HANDLE_DONTCARE_KIND, &info);
|
||||
}
|
||||
if (ret == UT_HANDLE_OK) {
|
||||
assert(info);
|
||||
assert(hdl == info->hdl);
|
||||
info->flags |= HDL_FLAG_CLOSED;
|
||||
|
||||
/* FIXME: Replace this polling with conditional wait. */
|
||||
ddsrt_mutex_unlock(&hs->mutex);
|
||||
{
|
||||
dds_duration_t delay = DDS_MSECS(10);
|
||||
while ((info->cnt != 0) && timeout > 0) {
|
||||
dds_sleepfor(delay);
|
||||
timeout = (delay < timeout ? timeout - delay : 0);
|
||||
}
|
||||
}
|
||||
ddsrt_mutex_lock(&hs->mutex);
|
||||
|
||||
if (info->cnt == 0) {
|
||||
delete_handle(hdl & UT_HANDLE_IDX_MASK);
|
||||
} else {
|
||||
ret = UT_HANDLE_TIMEOUT;
|
||||
}
|
||||
}
|
||||
ddsrt_mutex_unlock(&hs->mutex);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
ut_handle_retcode_t
|
||||
ut_handle_status(
|
||||
ut_handle_t hdl,
|
||||
struct ut_handlelink *link,
|
||||
int32_t kind)
|
||||
{
|
||||
struct ut_handlelink *info = link;
|
||||
ut_handle_retcode_t ret = UT_HANDLE_OK;
|
||||
|
||||
if (hs == NULL) {
|
||||
return (ut_handle_t)UT_HANDLE_INVALID;
|
||||
}
|
||||
|
||||
ddsrt_mutex_lock(&hs->mutex);
|
||||
if (info == NULL) {
|
||||
ret = lookup_handle(hdl, kind, &info);
|
||||
}
|
||||
if (ret == UT_HANDLE_OK) {
|
||||
assert(info);
|
||||
assert(hdl == info->hdl);
|
||||
if (info->flags & HDL_FLAG_CLOSED) {
|
||||
ret = UT_HANDLE_CLOSED;
|
||||
}
|
||||
}
|
||||
ddsrt_mutex_unlock(&hs->mutex);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
ut_handle_retcode_t
|
||||
ut_handle_claim(
|
||||
ut_handle_t hdl,
|
||||
struct ut_handlelink *link,
|
||||
int32_t kind,
|
||||
void **arg)
|
||||
{
|
||||
struct ut_handlelink *info = link;
|
||||
ut_handle_retcode_t ret = UT_HANDLE_OK;
|
||||
|
||||
if (arg != NULL) {
|
||||
*arg = NULL;
|
||||
}
|
||||
|
||||
if (hs == NULL) {
|
||||
return (ut_handle_t)UT_HANDLE_INVALID;
|
||||
}
|
||||
|
||||
ddsrt_mutex_lock(&hs->mutex);
|
||||
if (info == NULL) {
|
||||
ret = lookup_handle(hdl, kind, &info);
|
||||
}
|
||||
if (ret == UT_HANDLE_OK) {
|
||||
assert(info);
|
||||
assert(hdl == info->hdl);
|
||||
if (info->flags & HDL_FLAG_CLOSED) {
|
||||
ret = UT_HANDLE_CLOSED;
|
||||
}
|
||||
}
|
||||
if (ret == UT_HANDLE_OK) {
|
||||
info->cnt++;
|
||||
if (arg != NULL) {
|
||||
*arg = info->arg;
|
||||
}
|
||||
}
|
||||
ddsrt_mutex_unlock(&hs->mutex);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ut_handle_release(
|
||||
ut_handle_t hdl,
|
||||
struct ut_handlelink *link)
|
||||
{
|
||||
struct ut_handlelink *info = link;
|
||||
ut_handle_retcode_t ret = UT_HANDLE_OK;
|
||||
|
||||
assert(hs);
|
||||
|
||||
ddsrt_mutex_lock(&hs->mutex);
|
||||
if (info == NULL) {
|
||||
ret = lookup_handle(hdl, UT_HANDLE_DONTCARE_KIND, &info);
|
||||
}
|
||||
if (ret == UT_HANDLE_OK) {
|
||||
assert(info);
|
||||
assert(hdl == info->hdl);
|
||||
assert(info->cnt > 0);
|
||||
info->cnt--;
|
||||
}
|
||||
ddsrt_mutex_unlock(&hs->mutex);
|
||||
}
|
||||
|
||||
bool
|
||||
ut_handle_is_closed(
|
||||
ut_handle_t hdl,
|
||||
struct ut_handlelink *link)
|
||||
{
|
||||
struct ut_handlelink *info = link;
|
||||
ut_handle_retcode_t ret = UT_HANDLE_OK;
|
||||
|
||||
assert(hs);
|
||||
|
||||
ddsrt_mutex_lock(&hs->mutex);
|
||||
if (info == NULL) {
|
||||
ret = lookup_handle(hdl, UT_HANDLE_DONTCARE_KIND, &info);
|
||||
}
|
||||
if (ret == UT_HANDLE_OK) {
|
||||
assert(info);
|
||||
assert(hdl == info->hdl);
|
||||
if (info->flags & HDL_FLAG_CLOSED) {
|
||||
ret = UT_HANDLE_CLOSED;
|
||||
}
|
||||
}
|
||||
ddsrt_mutex_unlock(&hs->mutex);
|
||||
|
||||
/* Simulate closed for every error. */
|
||||
return (ret != UT_HANDLE_OK);
|
||||
}
|
||||
|
||||
struct ut_handlelink*
|
||||
ut_handle_get_link(
|
||||
ut_handle_t hdl)
|
||||
{
|
||||
struct ut_handlelink *info;
|
||||
ut_handle_retcode_t ret;
|
||||
|
||||
assert(hs);
|
||||
|
||||
ddsrt_mutex_lock(&hs->mutex);
|
||||
ret = lookup_handle(hdl, UT_HANDLE_DONTCARE_KIND, &info);
|
||||
assert(((ret == UT_HANDLE_OK) && (info != NULL)) ||
|
||||
((ret != UT_HANDLE_OK) && (info == NULL)) );
|
||||
(void)ret;
|
||||
ddsrt_mutex_unlock(&hs->mutex);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
static ut_handle_retcode_t
|
||||
lookup_handle(
|
||||
ut_handle_t hdl,
|
||||
int32_t kind,
|
||||
ut_handlelink **link)
|
||||
{
|
||||
ut_handle_retcode_t ret;
|
||||
*link = NULL;
|
||||
ret = check_handle(hdl, kind);
|
||||
if (ret == UT_HANDLE_OK) {
|
||||
int32_t idx = (hdl & UT_HANDLE_IDX_MASK);
|
||||
assert(idx < MAX_NR_OF_HANDLES);
|
||||
*link = hs->hdls[idx];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ut_handle_t
|
||||
check_handle(
|
||||
ut_handle_t hdl,
|
||||
int32_t kind)
|
||||
{
|
||||
/* When handle is negative, it contains a retcode. */
|
||||
ut_handle_retcode_t ret = UT_HANDLE_OK;
|
||||
if (hdl > 0) {
|
||||
if (hdl & UT_HANDLE_KIND_MASK) {
|
||||
int32_t idx = (hdl & UT_HANDLE_IDX_MASK);
|
||||
if (idx < hs->last) {
|
||||
assert(idx < MAX_NR_OF_HANDLES);
|
||||
ut_handlelink *info = hs->hdls[idx];
|
||||
if (info != NULL) {
|
||||
if ((info->hdl & UT_HANDLE_KIND_MASK) == (hdl & UT_HANDLE_KIND_MASK)) {
|
||||
if ((kind != UT_HANDLE_DONTCARE_KIND) &&
|
||||
(kind != (hdl & UT_HANDLE_KIND_MASK))) {
|
||||
/* It's a valid handle, but the caller expected a different kind. */
|
||||
ret = UT_HANDLE_UNEQUAL_KIND;
|
||||
}
|
||||
} else {
|
||||
ret = UT_HANDLE_UNEQUAL_KIND;
|
||||
}
|
||||
} else {
|
||||
ret = UT_HANDLE_DELETED;
|
||||
}
|
||||
} else {
|
||||
ret = UT_HANDLE_INVALID;
|
||||
}
|
||||
} else {
|
||||
ret = UT_HANDLE_INVALID;
|
||||
}
|
||||
} else if (hdl == 0) {
|
||||
ret = UT_HANDLE_INVALID;
|
||||
} else {
|
||||
/* When handle is negative, it contains a retcode. */
|
||||
ret = (ut_handle_retcode_t)hdl;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
delete_handle(int32_t idx)
|
||||
{
|
||||
assert(hs);
|
||||
assert(idx < MAX_NR_OF_HANDLES);
|
||||
ddsrt_free(hs->hdls[idx]);
|
||||
hs->hdls[idx] = NULL;
|
||||
}
|
|
@ -11,19 +11,5 @@
|
|||
#
|
||||
include(CUnit)
|
||||
|
||||
add_cunit_executable(cunit_util "handleserver.c")
|
||||
target_link_libraries(cunit_util PRIVATE util)
|
||||
target_link_libraries(cunit_util PRIVATE ddsrt)
|
||||
|
||||
# Create a dummy export header. generate_export_header can only be used with
|
||||
# library targets, but since the targets are linked statically,
|
||||
# __declspec(dllimport) is not required anyway.
|
||||
set(export_dir "${CMAKE_CURRENT_BINARY_DIR}/include/dds")
|
||||
set(export_header "${export_dir}/export.h")
|
||||
if(NOT EXISTS "${export_header}")
|
||||
file(MAKE_DIRECTORY "${export_dir}")
|
||||
file(WRITE "${export_header}" "#define DDS_EXPORT\n")
|
||||
endif()
|
||||
|
||||
target_include_directories(
|
||||
cunit_util PRIVATE "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>")
|
||||
#add_cunit_executable(CUnit_util "handleserver.c")
|
||||
#target_link_libraries(CUnit_util util)
|
||||
|
|
|
@ -1,304 +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 "dds/util/ut_handleserver.h"
|
||||
#include "CUnit/Test.h"
|
||||
#include "dds/ddsrt/retcode.h"
|
||||
#include "dds/ddsrt/threads.h"
|
||||
#include "dds/ddsrt/time.h"
|
||||
|
||||
/*****************************************************************************************/
|
||||
CU_Test(util_handleserver, basic)
|
||||
{
|
||||
int32_t kind = 0x10000000;
|
||||
ut_handle_retcode_t ret;
|
||||
ut_handle_t hdl;
|
||||
int arg = 1;
|
||||
void *argx;
|
||||
|
||||
ret = ut_handleserver_init();
|
||||
CU_ASSERT_EQUAL_FATAL(ret, UT_HANDLE_OK);
|
||||
|
||||
hdl = ut_handle_create(kind, (void*)&arg);
|
||||
CU_ASSERT_FATAL(hdl > 0);
|
||||
|
||||
ret = ut_handle_claim(hdl, NULL, kind, &argx);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, UT_HANDLE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(argx, &arg);
|
||||
|
||||
ut_handle_release(hdl, NULL);
|
||||
|
||||
ret = ut_handle_delete(hdl, NULL, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, UT_HANDLE_OK);
|
||||
|
||||
ret = ut_handle_claim(hdl, NULL, kind, &argx);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, UT_HANDLE_DELETED);
|
||||
|
||||
ut_handleserver_fini();
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************************/
|
||||
CU_Test(util_handleserver, close)
|
||||
{
|
||||
int32_t kind = 0x10000000;
|
||||
ut_handle_retcode_t ret;
|
||||
ut_handle_t hdl;
|
||||
int arg = 1;
|
||||
void *argx;
|
||||
bool closed;
|
||||
|
||||
ret = ut_handleserver_init();
|
||||
CU_ASSERT_EQUAL_FATAL(ret, UT_HANDLE_OK);
|
||||
|
||||
hdl = ut_handle_create(kind, (void*)&arg);
|
||||
CU_ASSERT_FATAL(hdl > 0);
|
||||
|
||||
closed = ut_handle_is_closed(hdl, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(closed, false);
|
||||
|
||||
ut_handle_close(hdl, NULL);
|
||||
|
||||
closed = ut_handle_is_closed(hdl, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(closed, true);
|
||||
|
||||
ret = ut_handle_claim(hdl, NULL, kind, &argx);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, UT_HANDLE_CLOSED);
|
||||
|
||||
ret = ut_handle_delete(hdl, NULL, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, UT_HANDLE_OK);
|
||||
|
||||
ret = ut_handle_claim(hdl, NULL, kind, &argx);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, UT_HANDLE_DELETED);
|
||||
|
||||
ut_handleserver_fini();
|
||||
}
|
||||
|
||||
/*****************************************************************************************/
|
||||
CU_Test(util_handleserver, link)
|
||||
{
|
||||
int32_t kind = 0x10000000;
|
||||
ut_handle_retcode_t ret;
|
||||
struct ut_handlelink *link;
|
||||
ut_handle_t hdl;
|
||||
int arg = 1;
|
||||
void *argx;
|
||||
|
||||
ret = ut_handleserver_init();
|
||||
CU_ASSERT_EQUAL_FATAL(ret, UT_HANDLE_OK);
|
||||
|
||||
hdl = ut_handle_create(kind, (void*)&arg);
|
||||
CU_ASSERT_FATAL(hdl > 0);
|
||||
|
||||
link = ut_handle_get_link(hdl);
|
||||
CU_ASSERT_NOT_EQUAL_FATAL(link, NULL);
|
||||
|
||||
ret = ut_handle_claim(hdl, link, kind, &argx);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, UT_HANDLE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(argx, &arg);
|
||||
|
||||
ut_handle_release(hdl, link);
|
||||
|
||||
ret = ut_handle_delete(hdl, link, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, UT_HANDLE_OK);
|
||||
|
||||
link = ut_handle_get_link(hdl);
|
||||
CU_ASSERT_EQUAL_FATAL(link, NULL);
|
||||
|
||||
ut_handleserver_fini();
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************************/
|
||||
CU_Test(util_handleserver, types)
|
||||
{
|
||||
int32_t kind1 = 0x10000000;
|
||||
int32_t kind2 = 0x20000000;
|
||||
ut_handle_retcode_t ret;
|
||||
ut_handle_t hdl1a;
|
||||
ut_handle_t hdl1b;
|
||||
ut_handle_t hdl2;
|
||||
int arg1a = (int)'a';
|
||||
int arg1b = (int)'b';
|
||||
int arg2 = (int)'2';
|
||||
void *argx;
|
||||
|
||||
ret = ut_handleserver_init();
|
||||
CU_ASSERT_EQUAL_FATAL(ret, UT_HANDLE_OK);
|
||||
|
||||
hdl1a = ut_handle_create(kind1, (void*)&arg1a);
|
||||
CU_ASSERT_FATAL(hdl1a > 0);
|
||||
|
||||
hdl1b = ut_handle_create(kind1, (void*)&arg1b);
|
||||
CU_ASSERT_FATAL(hdl1b > 0);
|
||||
|
||||
hdl2 = ut_handle_create(kind2, (void*)&arg2);
|
||||
CU_ASSERT_FATAL(hdl2 > 0);
|
||||
|
||||
ret = ut_handle_claim(hdl1a, NULL, kind1, &argx);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, UT_HANDLE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(argx, &arg1a);
|
||||
|
||||
ret = ut_handle_claim(hdl1b, NULL, kind1, &argx);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, UT_HANDLE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(argx, &arg1b);
|
||||
|
||||
ret = ut_handle_claim(hdl2, NULL, kind2, &argx);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, UT_HANDLE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(argx, &arg2);
|
||||
|
||||
ret = ut_handle_claim(hdl1a, NULL, kind2, &argx);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, UT_HANDLE_UNEQUAL_KIND);
|
||||
|
||||
ret = ut_handle_claim(hdl1a, NULL, kind2, &argx);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, UT_HANDLE_UNEQUAL_KIND);
|
||||
|
||||
ret = ut_handle_claim(hdl2, NULL, kind1, &argx);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, UT_HANDLE_UNEQUAL_KIND);
|
||||
|
||||
ut_handle_release(hdl1a, NULL);
|
||||
ut_handle_release(hdl1b, NULL);
|
||||
ut_handle_release(hdl2, NULL);
|
||||
|
||||
ret = ut_handle_delete(hdl1a, NULL, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, UT_HANDLE_OK);
|
||||
ret = ut_handle_delete(hdl1b, NULL, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, UT_HANDLE_OK);
|
||||
ret = ut_handle_delete(hdl2, NULL, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, UT_HANDLE_OK);
|
||||
|
||||
ut_handleserver_fini();
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************************/
|
||||
CU_Test(util_handleserver, timeout)
|
||||
{
|
||||
int32_t kind = 0x10000000;
|
||||
ut_handle_retcode_t ret;
|
||||
ut_handle_t hdl;
|
||||
int arg = 1;
|
||||
void *argx;
|
||||
|
||||
ret = ut_handleserver_init();
|
||||
CU_ASSERT_EQUAL_FATAL(ret, UT_HANDLE_OK);
|
||||
|
||||
hdl = ut_handle_create(kind, (void*)&arg);
|
||||
CU_ASSERT_FATAL(hdl > 0);
|
||||
|
||||
ret = ut_handle_claim(hdl, NULL, kind, &argx);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, UT_HANDLE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(argx, &arg);
|
||||
|
||||
ret = ut_handle_delete(hdl, NULL, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, UT_HANDLE_TIMEOUT);
|
||||
|
||||
ut_handle_release(hdl, NULL);
|
||||
|
||||
ret = ut_handle_delete(hdl, NULL, 0);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, UT_HANDLE_OK);
|
||||
|
||||
ut_handleserver_fini();
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************************/
|
||||
typedef enum thread_state_t {
|
||||
STARTING,
|
||||
DELETING,
|
||||
STOPPED
|
||||
} thread_state_t;
|
||||
|
||||
typedef struct thread_arg_t {
|
||||
thread_state_t state;
|
||||
ut_handle_t hdl;
|
||||
} thread_arg_t;
|
||||
|
||||
static uint32_t
|
||||
deleting_thread(void *a)
|
||||
{
|
||||
thread_arg_t *arg = (thread_arg_t*)a;
|
||||
const dds_time_t ten = DDS_SECS(10);
|
||||
ut_handle_t ret;
|
||||
|
||||
arg->state = DELETING;
|
||||
/* This should block until the main test released all claims. */
|
||||
ret = ut_handle_delete(arg->hdl, NULL, ten);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, UT_HANDLE_OK);
|
||||
arg->state = STOPPED;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
dds_retcode_t
|
||||
thread_reached_state(thread_state_t *actual, thread_state_t expected, int32_t msec)
|
||||
{
|
||||
/* Convenience function. */
|
||||
dds_time_t msec10 = DDS_MSECS(10);
|
||||
while ((msec > 0) && (*actual != expected)) {
|
||||
dds_sleepfor(msec10);
|
||||
msec -= 10;
|
||||
}
|
||||
return (*actual == expected) ? DDS_RETCODE_OK : DDS_RETCODE_TIMEOUT;
|
||||
}
|
||||
|
||||
CU_Test(util_handleserver, wakeup)
|
||||
{
|
||||
int32_t kind = 0x10000000;
|
||||
ut_handle_retcode_t ret;
|
||||
ut_handle_t hdl;
|
||||
int arg = 1;
|
||||
void *argx;
|
||||
|
||||
ddsrt_thread_t thread_id;
|
||||
thread_arg_t thread_arg;
|
||||
ddsrt_threadattr_t thread_attr;
|
||||
dds_retcode_t rc;
|
||||
|
||||
ret = ut_handleserver_init();
|
||||
CU_ASSERT_EQUAL_FATAL(ret, UT_HANDLE_OK);
|
||||
|
||||
hdl = ut_handle_create(kind, (void*)&arg);
|
||||
CU_ASSERT_FATAL(hdl > 0);
|
||||
|
||||
ret = ut_handle_claim(hdl, NULL, kind, &argx);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, UT_HANDLE_OK);
|
||||
|
||||
ret = ut_handle_claim(hdl, NULL, kind, &argx);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, UT_HANDLE_OK);
|
||||
|
||||
/* Try deleting in other thread, which should block. */
|
||||
thread_arg.hdl = hdl;
|
||||
thread_arg.state = STARTING;
|
||||
ddsrt_threadattr_init(&thread_attr);
|
||||
rc = ddsrt_thread_create(&thread_id, "deleting_thread", &thread_attr, deleting_thread, (void*)&thread_arg);
|
||||
CU_ASSERT_EQUAL_FATAL(rc, DDS_RETCODE_OK);
|
||||
rc = thread_reached_state(&thread_arg.state, DELETING, 1000);
|
||||
CU_ASSERT_EQUAL_FATAL(rc, DDS_RETCODE_OK);
|
||||
rc = thread_reached_state(&thread_arg.state, STOPPED, 500);
|
||||
CU_ASSERT_EQUAL_FATAL(rc, DDS_RETCODE_TIMEOUT);
|
||||
|
||||
/* First release of the hdl should not unblock the thread. */
|
||||
ut_handle_release(hdl, NULL);
|
||||
rc = thread_reached_state(&thread_arg.state, STOPPED, 500);
|
||||
CU_ASSERT_EQUAL_FATAL(rc, DDS_RETCODE_TIMEOUT);
|
||||
|
||||
/* Second release of the hdl should unblock the thread. */
|
||||
ut_handle_release(hdl, NULL);
|
||||
rc = thread_reached_state(&thread_arg.state, STOPPED, 500);
|
||||
CU_ASSERT_EQUAL_FATAL(rc, DDS_RETCODE_OK);
|
||||
ddsrt_thread_join(thread_id, NULL);
|
||||
|
||||
/* The handle is deleted within the thread. */
|
||||
|
||||
ut_handleserver_fini();
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue