Merge pull request #134 from eboasson/ddsrt-oi

Some minor things from issues and restoring OpenIndiana support
This commit is contained in:
eboasson 2019-03-25 12:58:47 +01:00 committed by GitHub
commit 758bdb4b8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 327 additions and 98 deletions

View file

@ -127,7 +127,7 @@ script:
-DBUILD_TESTING=on -DBUILD_TESTING=on
-G "${GENERATOR}" ../src -G "${GENERATOR}" ../src
- cmake --build . --config ${BUILD_TYPE} --target install - cmake --build . --config ${BUILD_TYPE} --target install
- ctest -T test -C ${BUILD_TYPE} - CYCLONEDDS_URI='<CycloneDDS><DDSI2E><Internal><EnableExpensiveChecks>all</EnableExpensiveChecks></Internal></DDSI2E></CycloneDDS>' ctest -T test -C ${BUILD_TYPE}
- if [ "${USE_SANITIZER}" != "none" ]; then - if [ "${USE_SANITIZER}" != "none" ]; then
CMAKE_LINKER_FLAGS="-DCMAKE_LINKER_FLAGS=-fsanitize=${USE_SANITIZER}"; CMAKE_LINKER_FLAGS="-DCMAKE_LINKER_FLAGS=-fsanitize=${USE_SANITIZER}";
CMAKE_C_FLAGS="-DCMAKE_C_FLAGS=-fsanitize=${USE_SANITIZER}"; CMAKE_C_FLAGS="-DCMAKE_C_FLAGS=-fsanitize=${USE_SANITIZER}";

View file

@ -37,13 +37,14 @@ build_script:
- cd build - cd build
- conan install -s arch=%ARCH% -s build_type=%CONFIGURATION% .. - conan install -s arch=%ARCH% -s build_type=%CONFIGURATION% ..
- cmake -DBUILD_TESTING=on -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DCMAKE_INSTALL_PREFIX=%CD%/install -G "%GENERATOR%" ../src - cmake -DBUILD_TESTING=on -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DCMAKE_INSTALL_PREFIX=%CD%/install -G "%GENERATOR%" ../src
- cmake --build . --config %CONFIGURATION% --target install - cmake --build . --config %CONFIGURATION% --target install -- /maxcpucount
- cd install/share/CycloneDDS/examples/helloworld - cd install/share/CycloneDDS/examples/helloworld
- mkdir build - mkdir build
- cd build - cd build
- cmake -DCMAKE_BUILD_TYPE=%CONFIGURATION% -G "%GENERATOR%" .. - cmake -DCMAKE_BUILD_TYPE=%CONFIGURATION% -G "%GENERATOR%" ..
- cmake --build . --config %CONFIGURATION% - cmake --build . --config %CONFIGURATION% -- /maxcpucount
- cd ../../../../../.. - cd ../../../../../..
test_script: test_script:
- set "CYCLONEDDS_URI=<CycloneDDS><DDSI2E><Internal><EnableExpensiveChecks>all</EnableExpensiveChecks></Internal></DDSI2E></CycloneDDS>"
- ctest --test-action test --build-config %CONFIGURATION% - ctest --test-action test --build-config %CONFIGURATION%

View file

@ -53,7 +53,8 @@ if(CMAKE_SYSTEM_NAME STREQUAL "VxWorks")
endif() endif()
if(${CMAKE_C_COMPILER_ID} STREQUAL "SunPro") if(${CMAKE_C_COMPILER_ID} STREQUAL "SunPro")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64 -xc99 -D__restrict=restrict") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64 -xc99 -D__restrict=restrict -D__deprecated__=")
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -m64")
endif() endif()
# Conan # Conan

View file

@ -11,6 +11,7 @@
*/ */
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#include "dds/ddsrt/misc.h"
#include "dds__listener.h" #include "dds__listener.h"
#include "dds__qos.h" #include "dds__qos.h"
#include "dds__err.h" #include "dds__err.h"

View file

@ -11,6 +11,7 @@
*/ */
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#include <limits.h>
#if HAVE_VALGRIND && ! defined (NDEBUG) #if HAVE_VALGRIND && ! defined (NDEBUG)
#include <memcheck.h> #include <memcheck.h>
@ -2625,6 +2626,9 @@ int dds_rhc_takecdr
#define CHECK_MAX_CONDS 64 #define CHECK_MAX_CONDS 64
static int rhc_check_counts_locked (struct rhc *rhc, bool check_conds, bool check_qcmask) static int rhc_check_counts_locked (struct rhc *rhc, bool check_conds, bool check_qcmask)
{ {
if (!(config.enabled_xchecks & DDS_XCHECK_RHC))
return 1;
const uint32_t ncheck = rhc->nconds < CHECK_MAX_CONDS ? rhc->nconds : CHECK_MAX_CONDS; const uint32_t ncheck = rhc->nconds < CHECK_MAX_CONDS ? rhc->nconds : CHECK_MAX_CONDS;
unsigned n_instances = 0, n_nonempty_instances = 0; unsigned n_instances = 0, n_nonempty_instances = 0;
unsigned n_not_alive_disposed = 0, n_not_alive_no_writers = 0, n_new = 0; unsigned n_not_alive_disposed = 0, n_not_alive_no_writers = 0, n_new = 0;

View file

@ -15,6 +15,7 @@
#include "dds/ddsrt/heap.h" #include "dds/ddsrt/heap.h"
#include "dds/ddsrt/sync.h" #include "dds/ddsrt/sync.h"
#include "dds/ddsrt/misc.h"
#include "dds/ddsi/ddsi_serdata.h" #include "dds/ddsi/ddsi_serdata.h"
#include "dds/ddsi/q_unused.h" #include "dds/ddsi/q_unused.h"
#include "dds/ddsi/q_config.h" #include "dds/ddsi/q_config.h"
@ -258,6 +259,7 @@ static void check_whc (const struct whc_impl *whc)
assert (whc->maxseq_node == whc_findmax_procedurally (whc)); assert (whc->maxseq_node == whc_findmax_procedurally (whc));
#if !defined(NDEBUG) #if !defined(NDEBUG)
if (config.enabled_xchecks & DDS_XCHECK_WHC)
{ {
struct whc_intvnode *firstintv; struct whc_intvnode *firstintv;
struct whc_node *cur; struct whc_node *cur;

View file

@ -218,10 +218,15 @@ struct ssl_min_version {
}; };
#endif #endif
/* Expensive checks (compiled in when NDEBUG not defined, enabled only if flag set in xchecks) */
#define DDS_XCHECK_WHC 1u
#define DDS_XCHECK_RHC 2u
struct config struct config
{ {
int valid; int valid;
uint32_t enabled_logcats; uint32_t enabled_logcats;
uint32_t enabled_xchecks;
char *servicename; char *servicename;
char *pcap_file; char *pcap_file;

View file

@ -130,8 +130,10 @@ typedef struct Header {
} Header_t; } Header_t;
#if DDSRT_ENDIAN == DDSRT_LITTLE_ENDIAN #if DDSRT_ENDIAN == DDSRT_LITTLE_ENDIAN
#define NN_PROTOCOLID_AS_UINT32 (((uint32_t)'R' << 0) | ((uint32_t)'T' << 8) | ((uint32_t)'P' << 16) | ((uint32_t)'S' << 24)) #define NN_PROTOCOLID_AS_UINT32 (((uint32_t)'R' << 0) | ((uint32_t)'T' << 8) | ((uint32_t)'P' << 16) | ((uint32_t)'S' << 24))
#else #elif DDSRT_ENDIAN == DDSRT_BIG_ENDIAN
#define NN_PROTOCOLID_AS_UINT32 (((uint32_t)'R' << 24) | ((uint32_t)'T' << 16) | ((uint32_t)'P' << 8) | ((uint32_t)'S' << 0)) #define NN_PROTOCOLID_AS_UINT32 (((uint32_t)'R' << 24) | ((uint32_t)'T' << 16) | ((uint32_t)'P' << 8) | ((uint32_t)'S' << 0))
#else
#error "DDSRT_ENDIAN neither LITTLE nor BIG"
#endif #endif
#define RTPS_MESSAGE_HEADER_SIZE (sizeof (Header_t)) #define RTPS_MESSAGE_HEADER_SIZE (sizeof (Header_t))

View file

@ -13,6 +13,7 @@
#include "dds/ddsi/ddsi_ssl.h" #include "dds/ddsi/ddsi_ssl.h"
#include "dds/ddsi/q_config.h" #include "dds/ddsi/q_config.h"
#include "dds/ddsrt/log.h" #include "dds/ddsrt/log.h"
#include "dds/ddsrt/misc.h"
#ifdef DDSI_INCLUDE_SSL #ifdef DDSI_INCLUDE_SSL

View file

@ -14,6 +14,7 @@
#include "dds/ddsrt/atomics.h" #include "dds/ddsrt/atomics.h"
#include "dds/ddsrt/heap.h" #include "dds/ddsrt/heap.h"
#include "dds/ddsrt/log.h" #include "dds/ddsrt/log.h"
#include "dds/ddsrt/misc.h"
#include "dds/ddsrt/sockets.h" #include "dds/ddsrt/sockets.h"
#include "ddsi_eth.h" #include "ddsi_eth.h"
#include "dds/ddsi/ddsi_tran.h" #include "dds/ddsi/ddsi_tran.h"

View file

@ -16,6 +16,7 @@
#include "dds/ddsrt/heap.h" #include "dds/ddsrt/heap.h"
#include "dds/ddsrt/log.h" #include "dds/ddsrt/log.h"
#include "dds/ddsrt/string.h" #include "dds/ddsrt/string.h"
#include "dds/ddsrt/misc.h"
#include "dds/util/ut_avl.h" #include "dds/util/ut_avl.h"
#include "dds/ddsi/q_log.h" #include "dds/ddsi/q_log.h"
#include "dds/ddsi/q_misc.h" #include "dds/ddsi/q_misc.h"

View file

@ -21,6 +21,7 @@
#include "dds/ddsrt/log.h" #include "dds/ddsrt/log.h"
#include "dds/ddsrt/string.h" #include "dds/ddsrt/string.h"
#include "dds/ddsrt/strtod.h" #include "dds/ddsrt/strtod.h"
#include "dds/ddsrt/misc.h"
#include "dds/ddsi/q_config.h" #include "dds/ddsi/q_config.h"
#include "dds/ddsi/q_log.h" #include "dds/ddsi/q_log.h"
#include "dds/util/ut_avl.h" #include "dds/util/ut_avl.h"
@ -105,6 +106,14 @@ static const uint32_t logcat_codes[] = {
DDS_LC_FATAL, DDS_LC_ERROR, DDS_LC_WARNING, DDS_LC_INFO, DDS_LC_CONFIG, DDS_LC_DISCOVERY, DDS_LC_DATA, DDS_LC_RADMIN, DDS_LC_TIMING, DDS_LC_TRAFFIC, DDS_LC_TOPIC, DDS_LC_TCP, DDS_LC_PLIST, DDS_LC_WHC, DDS_LC_THROTTLE, DDS_LC_RHC, DDS_LC_ALL DDS_LC_FATAL, DDS_LC_ERROR, DDS_LC_WARNING, DDS_LC_INFO, DDS_LC_CONFIG, DDS_LC_DISCOVERY, DDS_LC_DATA, DDS_LC_RADMIN, DDS_LC_TIMING, DDS_LC_TRAFFIC, DDS_LC_TOPIC, DDS_LC_TCP, DDS_LC_PLIST, DDS_LC_WHC, DDS_LC_THROTTLE, DDS_LC_RHC, DDS_LC_ALL
}; };
/* "trace" is special: it enables (nearly) everything */
static const char *xcheck_names[] = {
"whc", "rhc", "all", NULL
};
static const uint32_t xcheck_codes[] = {
DDS_XCHECK_WHC, DDS_XCHECK_RHC, ~(uint32_t)0
};
/* We want the tracing/verbosity settings to be fixed while parsing /* We want the tracing/verbosity settings to be fixed while parsing
the configuration, so we update this variable instead. */ the configuration, so we update this variable instead. */
static unsigned enabled_logcats; static unsigned enabled_logcats;
@ -131,6 +140,7 @@ DUPF(string);
DU(tracingOutputFileName); DU(tracingOutputFileName);
DU(verbosity); DU(verbosity);
DUPF(logcat); DUPF(logcat);
DUPF(xcheck);
DUPF(float); DUPF(float);
DUPF(int); DUPF(int);
DUPF(uint); DUPF(uint);
@ -632,6 +642,12 @@ static const struct cfgelem unsupp_cfgelems[] = {
"<p>Testing options.</p>" }, "<p>Testing options.</p>" },
{ GROUP("Watermarks", unsupp_watermarks_cfgelems), { GROUP("Watermarks", unsupp_watermarks_cfgelems),
"<p>Watermarks for flow-control.</p>" }, "<p>Watermarks for flow-control.</p>" },
{ LEAF("EnableExpensiveChecks"), 1, "", ABSOFF(enabled_xchecks), 0, uf_xcheck, 0, pf_xcheck,
"<p>This element enables expensive checks in builds with assertions enabled and is ignored otherwise. Recognised categories are:</p>\n\
<ul><li><i>whc</i>: writer history cache checking</li>\n\
<li><i>rhc</i>: reader history cache checking</li>\n\
<p>In addition, there is the keyword <i>all</i> that enables all checks.</p>" },
END_MARKER END_MARKER
}; };
@ -1348,24 +1364,33 @@ static void pf_boolean_default (struct cfgst *cfgst, void *parent, struct cfgele
} }
#endif #endif
static int uf_logcat(struct cfgst *cfgst, UNUSED_ARG(void *parent), UNUSED_ARG(struct cfgelem const * const cfgelem), UNUSED_ARG(int first), const char *value) static int do_uint32_bitset(struct cfgst *cfgst, uint32_t *cats, const char **names, const uint32_t *codes, const char *value)
{ {
static const char **vs = logcat_names;
static const uint32_t *lc = logcat_codes;
char *copy = ddsrt_strdup(value), *cursor = copy, *tok; char *copy = ddsrt_strdup(value), *cursor = copy, *tok;
while ( (tok = ddsrt_strsep(&cursor, ",")) != NULL ) { while ( (tok = ddsrt_strsep(&cursor, ",")) != NULL ) {
int idx = list_index(vs, tok); int idx = list_index(names, tok);
if ( idx < 0 ) { if ( idx < 0 ) {
int ret = cfg_error(cfgst, "'%s' in '%s' undefined", tok, value); int ret = cfg_error(cfgst, "'%s' in '%s' undefined", tok, value);
ddsrt_free(copy); ddsrt_free(copy);
return ret; return ret;
} }
enabled_logcats |= lc[idx]; *cats |= codes[idx];
} }
ddsrt_free(copy); ddsrt_free(copy);
return 1; return 1;
} }
static int uf_logcat(struct cfgst *cfgst, UNUSED_ARG(void *parent), UNUSED_ARG(struct cfgelem const * const cfgelem), UNUSED_ARG(int first), const char *value)
{
return do_uint32_bitset (cfgst, &enabled_logcats, logcat_names, logcat_codes, value);
}
static int uf_xcheck(struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG(int first), const char *value)
{
uint32_t *elem = cfg_address(cfgst, parent, cfgelem);
return do_uint32_bitset (cfgst, elem, xcheck_names, xcheck_codes, value);
}
static int uf_verbosity(struct cfgst *cfgst, UNUSED_ARG(void *parent), UNUSED_ARG(struct cfgelem const * const cfgelem), UNUSED_ARG(int first), const char *value) static int uf_verbosity(struct cfgst *cfgst, UNUSED_ARG(void *parent), UNUSED_ARG(struct cfgelem const * const cfgelem), UNUSED_ARG(int first), const char *value)
{ {
static const char *vs[] = { static const char *vs[] = {
@ -2333,45 +2358,76 @@ static void pf_standards_conformance(struct cfgst *cfgst, void *parent, struct c
cfg_log(cfgst, "%s%s", str, is_default ? " [def]" : ""); cfg_log(cfgst, "%s%s", str, is_default ? " [def]" : "");
} }
static void pf_logcat(struct cfgst *cfgst, UNUSED_ARG(void *parent), UNUSED_ARG(struct cfgelem const * const cfgelem), UNUSED_ARG(int is_default)) static unsigned uint32_popcnt (uint32_t x)
{
unsigned n = 0;
while (x != 0)
{
n += ((x & 1u) != 0);
x >>= 1;
}
return n;
}
static void do_print_uint32_bitset (struct cfgst *cfgst, uint32_t mask, size_t ncodes, const char **names, const uint32_t *codes, const char *suffix)
{ {
uint32_t remaining = config.enabled_logcats;
char res[256] = "", *resp = res; char res[256] = "", *resp = res;
const char *prefix = ""; const char *prefix = "";
size_t i;
#ifndef NDEBUG #ifndef NDEBUG
{ {
size_t max; size_t max = 0;
for ( i = 0, max = 0; i < sizeof(logcat_codes) / sizeof(*logcat_codes); i++ ) for (size_t i = 0; i < ncodes; i++ )
max += 1 + strlen(logcat_names[i]); max += 1 + strlen(names[i]);
max += 11; /* ,0x%x */ max += 11; /* ,0x%x */
max += 1; /* \0 */ max += 1; /* \0 */
assert(max <= sizeof(res)); assert(max <= sizeof(res));
} }
#endif #endif
/* TRACE enables ALLCATS, all the others just one */ while (mask) {
if ( (remaining & DDS_LC_ALL) == DDS_LC_ALL ) { size_t i_best = 0;
resp += snprintf(resp, 256, "%strace", prefix); unsigned pc_best = 0;
remaining &= ~DDS_LC_ALL; for (size_t i = 0; i < ncodes; i++) {
prefix = ","; uint32_t m = mask & codes[i];
} if (m == codes[i]) {
for ( i = 0; i < sizeof(logcat_codes) / sizeof(*logcat_codes); i++ ) { unsigned pc = uint32_popcnt (m);
if ( remaining & logcat_codes[i] ) { if (pc > pc_best) {
resp += snprintf(resp, 256, "%s%s", prefix, logcat_names[i]); i_best = i;
remaining &= ~logcat_codes[i]; pc_best = pc;
}
}
}
if (pc_best != 0) {
resp += snprintf(resp, 256, "%s%s", prefix, names[i_best]);
mask &= ~codes[i_best];
prefix = ","; prefix = ",";
} else {
resp += snprintf (resp, 256, "%s0x%x", prefix, (unsigned) mask);
mask = 0;
} }
} }
if ( remaining ) { assert (resp <= res + sizeof(res));
resp += snprintf(resp, 256, "%s0x%x", prefix, (unsigned) remaining); cfg_log (cfgst, "%s%s", res, suffix);
}
assert(resp <= res + sizeof(res));
/* can't do default indicator: user may have specified Verbosity, in
which case EnableCategory is at default, but for these two
settings, I don't mind. */
cfg_log(cfgst, "%s", res);
} }
static void pf_logcat(struct cfgst *cfgst, UNUSED_ARG(void *parent), UNUSED_ARG(struct cfgelem const * const cfgelem), UNUSED_ARG(int is_default))
{
/* can't do default indicator: user may have specified Verbosity, in
which case EnableCategory is at default, but for these two
settings, I don't mind. */
do_print_uint32_bitset (cfgst, config.enabled_logcats, sizeof(logcat_codes) / sizeof(*logcat_codes), logcat_names, logcat_codes, "");
}
static void pf_xcheck(struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, int is_default)
{
const uint32_t *p = cfg_address(cfgst, parent, cfgelem);
#ifndef NDEBUG
const char *suffix = is_default ? " [def]" : "";
#else
const char *suffix = " [ignored]";
(void)is_default;
#endif
do_print_uint32_bitset (cfgst, *p, sizeof(xcheck_codes) / sizeof(*xcheck_codes), xcheck_names, xcheck_codes, suffix);
}
static void print_configitems(struct cfgst *cfgst, void *parent, int isattr, struct cfgelem const * const cfgelem, int unchecked) static void print_configitems(struct cfgst *cfgst, void *parent, int isattr, struct cfgelem const * const cfgelem, int unchecked)
{ {
@ -2772,51 +2828,69 @@ struct cfgst * config_init (const char *configfile)
cfgst->error = 0; cfgst->error = 0;
/* configfile == NULL will get you the default configuration */ /* configfile == NULL will get you the default configuration */
if ( configfile ) { if (configfile) {
char *copy = ddsrt_strdup(configfile), *cursor = copy, *tok; char *copy = ddsrt_strdup(configfile), *cursor = copy;
while ( (tok = ddsrt_strsep(&cursor, ",")) != NULL ) { struct ut_xmlpCallbacks cb;
struct ut_xmlpCallbacks cb;
cb.attr = proc_attr;
cb.elem_close = proc_elem_close;
cb.elem_data = proc_elem_data;
cb.elem_open = proc_elem_open;
cb.error = proc_error;
while (ok && cursor && cursor[0]) {
struct ut_xmlpState *qx; struct ut_xmlpState *qx;
FILE *fp; FILE *fp;
char *tok;
DDSRT_WARNING_MSVC_OFF(4996); tok = cursor;
if ( (fp = fopen(tok, "r")) == NULL ) { if (tok[0] == '<') {
if ( strncmp(tok, "file://", 7) != 0 || (fp = fopen(tok + 7, "r")) == NULL ) { /* Read XML directly from input string */
DDS_ERROR("can't open configuration file %s\n", tok); qx = ut_xmlpNewString (tok, cfgst, &cb);
ddsrt_free(copy); ut_xmlpSetRequireEOF (qx, 0);
ddsrt_free(cfgst); fp = NULL;
return NULL; } else {
char *comma;
if ((comma = strchr (cursor, ',')) == NULL) {
cursor = NULL;
} else {
*comma = 0;
cursor = comma + 1;
} }
} DDSRT_WARNING_MSVC_OFF(4996);
DDSRT_WARNING_MSVC_ON(4996); if ((fp = fopen(tok, "r")) == NULL) {
if (strncmp(tok, "file://", 7) != 0 || (fp = fopen(tok + 7, "r")) == NULL) {
cb.attr = proc_attr; DDS_ERROR("can't open configuration file %s\n", tok);
cb.elem_close = proc_elem_close; ddsrt_free(copy);
cb.elem_data = proc_elem_data; ddsrt_free(cfgst);
cb.elem_open = proc_elem_open; return NULL;
cb.error = proc_error; }
}
if ( (qx = ut_xmlpNewFile(fp, cfgst, &cb)) == NULL ) { DDSRT_WARNING_MSVC_ON(4996);
fclose(fp); qx = ut_xmlpNewFile(fp, cfgst, &cb);
ddsrt_free(copy);
ddsrt_free(cfgst);
return NULL;
} }
cfgst_push(cfgst, 0, &root_cfgelem, &config); cfgst_push(cfgst, 0, &root_cfgelem, &config);
ok = (ut_xmlpParse(qx) >= 0) && !cfgst->error; ok = (ut_xmlpParse(qx) >= 0) && !cfgst->error;
/* Pop until stack empty: error handling is rather brutal */ /* Pop until stack empty: error handling is rather brutal */
assert(!ok || cfgst->path_depth == 1); assert(!ok || cfgst->path_depth == 1);
while ( cfgst->path_depth > 0 ) while (cfgst->path_depth > 0) {
cfgst_pop(cfgst); cfgst_pop(cfgst);
}
if (fp) {
fclose(fp);
} else if (ok) {
cursor = tok + ut_xmlpGetBufpos (qx);
}
ut_xmlpFree(qx); ut_xmlpFree(qx);
fclose(fp); while (cursor && cursor[0] == ',') {
cursor++;
}
} }
ddsrt_free(copy); ddsrt_free(copy);
} }
/* Set defaults for everything not set that we have a default value /* Set defaults for everything not set that we have a default value
for, signal errors for things unset but without a default. */ for, signal errors for things unset but without a default. */
{ {
int ok1 = set_defaults(cfgst, cfgst->cfg, 0, root_cfgelems, 0); int ok1 = set_defaults(cfgst, cfgst->cfg, 0, root_cfgelems, 0);
ok = ok && ok1; ok = ok && ok1;

View file

@ -16,6 +16,7 @@
#include "dds/ddsrt/heap.h" #include "dds/ddsrt/heap.h"
#include "dds/ddsrt/log.h" #include "dds/ddsrt/log.h"
#include "dds/ddsrt/sync.h" #include "dds/ddsrt/sync.h"
#include "dds/ddsrt/misc.h"
#include "dds/util/ut_avl.h" #include "dds/util/ut_avl.h"

View file

@ -18,6 +18,7 @@
#include "dds/ddsrt/sockets.h" #include "dds/ddsrt/sockets.h"
#include "dds/ddsrt/string.h" #include "dds/ddsrt/string.h"
#include "dds/ddsrt/sync.h" #include "dds/ddsrt/sync.h"
#include "dds/ddsrt/misc.h"
#include "dds/ddsi/q_entity.h" #include "dds/ddsi/q_entity.h"
#include "dds/ddsi/q_config.h" #include "dds/ddsi/q_config.h"

View file

@ -13,6 +13,8 @@
#include <assert.h> #include <assert.h>
#include "dds/ddsrt/heap.h" #include "dds/ddsrt/heap.h"
#include "dds/ddsrt/misc.h"
#include "dds/util/ut_hopscotch.h" #include "dds/util/ut_hopscotch.h"
#include "dds/ddsi/q_ephash.h" #include "dds/ddsi/q_ephash.h"
#include "dds/ddsi/q_config.h" #include "dds/ddsi/q_config.h"

View file

@ -12,6 +12,7 @@
#include <stddef.h> #include <stddef.h>
#include "dds/ddsrt/atomics.h" #include "dds/ddsrt/atomics.h"
#include "dds/ddsrt/misc.h"
#include "dds/ddsrt/heap.h" #include "dds/ddsrt/heap.h"
#include "dds/ddsrt/sync.h" #include "dds/ddsrt/sync.h"
#include "dds/ddsrt/threads.h" #include "dds/ddsrt/threads.h"

View file

@ -544,9 +544,7 @@ int find_own_ip (const char *requested_address)
quality = q; quality = q;
} }
/* FIXME: HACK HACK */ if (ifa->addr->sa_family == AF_INET && ifa->netmask)
//ddsi_ipaddr_to_loc(&gv.interfaces[gv.n_interfaces].loc, &tmpip, gv.m_factory->m_kind);
if (ifa->addr->sa_family == AF_INET || ifa->addr->sa_family == AF_INET6)
{ {
ddsi_ipaddr_to_loc(&gv.interfaces[gv.n_interfaces].netmask, ifa->netmask, gv.m_factory->m_kind); ddsi_ipaddr_to_loc(&gv.interfaces[gv.n_interfaces].netmask, ifa->netmask, gv.m_factory->m_kind);
} }

View file

@ -19,6 +19,7 @@
#include "dds/ddsrt/string.h" #include "dds/ddsrt/string.h"
#include "dds/ddsrt/sync.h" #include "dds/ddsrt/sync.h"
#include "dds/ddsrt/threads.h" #include "dds/ddsrt/threads.h"
#include "dds/ddsrt/misc.h"
#include "dds/ddsi/q_thread.h" #include "dds/ddsi/q_thread.h"
#include "dds/ddsi/q_servicelease.h" #include "dds/ddsi/q_servicelease.h"

View file

@ -13,6 +13,7 @@
#include <stdlib.h> #include <stdlib.h>
#include "dds/ddsrt/atomics.h" #include "dds/ddsrt/atomics.h"
#include "dds/ddsrt/misc.h"
#include "dds/ddsi/q_error.h" #include "dds/ddsi/q_error.h"
#include "dds/ddsi/q_log.h" #include "dds/ddsi/q_log.h"

View file

@ -24,6 +24,10 @@
# define ddsrt_clang (0) # define ddsrt_clang (0)
#endif #endif
#ifdef __SUNPRO_C
# define __attribute__(x)
#endif
#if defined(__has_attribute) #if defined(__has_attribute)
# define ddsrt_has_attribute(params) __has_attribute(params) # define ddsrt_has_attribute(params) __has_attribute(params)
#elif ddsrt_gnuc #elif ddsrt_gnuc

View file

@ -32,6 +32,13 @@ extern "C" {
# elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ # elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
# define DDSRT_ENDIAN DDSRT_LITTLE_ENDIAN # define DDSRT_ENDIAN DDSRT_LITTLE_ENDIAN
# endif # endif
# elif defined(__sun)
# include <sys/isa_defs.h>
# if defined(_BIG_ENDIAN)
# define DDSRT_ENDIAN DDSRT_BIG_ENDIAN
# elif defined(_LITTLE_ENDIAN)
# define DDSRT_ENDIAN DDSRT_LITTLE_ENDIAN
# endif
# endif # endif
#endif /* _WIN32 */ #endif /* _WIN32 */

View file

@ -23,6 +23,9 @@
#endif /* __VXWORKS__ */ #endif /* __VXWORKS__ */
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#ifdef __sun
#include <fcntl.h>
#endif
#ifdef __APPLE__ #ifdef __APPLE__
#include <sys/sockio.h> #include <sys/sockio.h>

View file

@ -31,6 +31,7 @@ int main (int argc, char ** argv)
DDS_FATAL("dds_create_write: %s\n", dds_strretcode(-writer)); DDS_FATAL("dds_create_write: %s\n", dds_strretcode(-writer));
printf("=== [Publisher] Waiting for a reader to be discovered ...\n"); printf("=== [Publisher] Waiting for a reader to be discovered ...\n");
fflush (stdout);
rc = dds_set_status_mask(writer, DDS_PUBLICATION_MATCHED_STATUS); rc = dds_set_status_mask(writer, DDS_PUBLICATION_MATCHED_STATUS);
if (rc != DDS_RETCODE_OK) if (rc != DDS_RETCODE_OK)
@ -52,6 +53,7 @@ int main (int argc, char ** argv)
printf ("=== [Publisher] Writing : "); printf ("=== [Publisher] Writing : ");
printf ("Message (%d, %s)\n", msg.userID, msg.message); printf ("Message (%d, %s)\n", msg.userID, msg.message);
fflush (stdout);
rc = dds_write (writer, &msg); rc = dds_write (writer, &msg);
if (rc != DDS_RETCODE_OK) if (rc != DDS_RETCODE_OK)

View file

@ -40,6 +40,7 @@ int main (int argc, char ** argv)
dds_delete_qos(qos); dds_delete_qos(qos);
printf ("\n=== [Subscriber] Waiting for a sample ...\n"); printf ("\n=== [Subscriber] Waiting for a sample ...\n");
fflush (stdout);
/* Initialize sample buffer, by pointing the void pointer within /* Initialize sample buffer, by pointing the void pointer within
* the buffer array to a valid sample memory location. */ * the buffer array to a valid sample memory location. */
@ -61,6 +62,7 @@ int main (int argc, char ** argv)
msg = (HelloWorldData_Msg*) samples[0]; msg = (HelloWorldData_Msg*) samples[0];
printf ("=== [Subscriber] Received : "); printf ("=== [Subscriber] Received : ");
printf ("Message (%d, %s)\n", msg->userID, msg->message); printf ("Message (%d, %s)\n", msg->userID, msg->message);
fflush (stdout);
break; break;
} }
else else

View file

@ -193,6 +193,7 @@ static void data_available(dds_entity_t rd, void *arg)
readAccess.count, readAccess.count,
exampleGetMedianFromTimeStats (&readAccess), exampleGetMedianFromTimeStats (&readAccess),
readAccess.min); readAccess.min);
fflush (stdout);
exampleResetTimeStats (&roundTrip); exampleResetTimeStats (&roundTrip);
exampleResetTimeStats (&writeAccess); exampleResetTimeStats (&writeAccess);
@ -282,11 +283,10 @@ int main (int argc, char *argv[])
} }
prepare_dds(&writer, &reader, &readCond, listener); prepare_dds(&writer, &reader, &readCond, listener);
setvbuf(stdout, NULL, _IONBF, 0);
if (argc - argidx == 1 && strcmp (argv[argidx], "quit") == 0) if (argc - argidx == 1 && strcmp (argv[argidx], "quit") == 0)
{ {
printf ("Sending termination request.\n"); printf ("Sending termination request.\n");
fflush (stdout);
/* pong uses a waitset which is triggered by instance disposal, and /* pong uses a waitset which is triggered by instance disposal, and
quits when it fires. */ quits when it fires. */
dds_sleepfor (DDS_SECS (1)); dds_sleepfor (DDS_SECS (1));
@ -325,6 +325,7 @@ int main (int argc, char *argv[])
if (invalidargs || (argc - argidx == 1 && (strcmp (argv[argidx], "-h") == 0 || strcmp (argv[argidx], "--help") == 0))) if (invalidargs || (argc - argidx == 1 && (strcmp (argv[argidx], "-h") == 0 || strcmp (argv[argidx], "--help") == 0)))
usage(); usage();
printf ("# payloadSize: %" PRIu32 " | numSamples: %" PRIu64 " | timeOut: %" PRIi64 "\n\n", payloadSize, numSamples, timeOut); printf ("# payloadSize: %" PRIu32 " | numSamples: %" PRIu64 " | timeOut: %" PRIi64 "\n\n", payloadSize, numSamples, timeOut);
fflush (stdout);
pub_data.payload._length = payloadSize; pub_data.payload._length = payloadSize;
pub_data.payload._buffer = payloadSize ? dds_alloc (payloadSize) : NULL; pub_data.payload._buffer = payloadSize ? dds_alloc (payloadSize) : NULL;
@ -337,6 +338,7 @@ int main (int argc, char *argv[])
startTime = dds_time (); startTime = dds_time ();
printf ("# Waiting for startup jitter to stabilise\n"); printf ("# Waiting for startup jitter to stabilise\n");
fflush (stdout);
/* Write a sample that pong can send back */ /* Write a sample that pong can send back */
while (!dds_triggered (waitSet) && difference < DDS_SECS(5)) while (!dds_triggered (waitSet) && difference < DDS_SECS(5))
{ {
@ -358,11 +360,10 @@ int main (int argc, char *argv[])
{ {
warmUp = false; warmUp = false;
printf("# Warm up complete.\n\n"); printf("# Warm up complete.\n\n");
printf("# Latency measurements (in us)\n"); printf("# Latency measurements (in us)\n");
printf("# Latency [us] Write-access time [us] Read-access time [us]\n"); printf("# Latency [us] Write-access time [us] Read-access time [us]\n");
printf("# Seconds Count median min 99%% max Count median min Count median min\n"); printf("# Seconds Count median min 99%% max Count median min Count median min\n");
fflush (stdout);
} }
exampleResetTimeStats (&roundTrip); exampleResetTimeStats (&roundTrip);
@ -375,7 +376,7 @@ int main (int argc, char *argv[])
if (status < 0) if (status < 0)
DDS_FATAL("dds_write_ts: %s\n", dds_strretcode(-status)); DDS_FATAL("dds_write_ts: %s\n", dds_strretcode(-status));
postWriteTime = dds_time (); postWriteTime = dds_time ();
for (i = 0; !dds_triggered (waitSet) && (!numSamples || i < numSamples); i++) for (i = 0; !dds_triggered (waitSet) && (!numSamples || i < numSamples) && !(timeOut && elapsed >= timeOut); i++)
{ {
status = dds_waitset_wait (waitSet, wsresults, wsresultsize, waitTimeout); status = dds_waitset_wait (waitSet, wsresults, wsresultsize, waitTimeout);
if (status < 0) if (status < 0)
@ -403,6 +404,7 @@ int main (int argc, char *argv[])
exampleGetMedianFromTimeStats (&readAccessOverall), exampleGetMedianFromTimeStats (&readAccessOverall),
readAccessOverall.min readAccessOverall.min
); );
fflush (stdout);
} }
done: done:

View file

@ -47,10 +47,6 @@ int main (int argc, char **argv)
dds_return_t rc; dds_return_t rc;
ThroughputModule_DataType sample; ThroughputModule_DataType sample;
#if !defined(_WIN32)
setvbuf (stdout, NULL, _IOLBF, 0);
#endif
if (parse_args(argc, argv, &payloadSize, &burstInterval, &burstSize, &timeOut, &partitionName) == EXIT_FAILURE) { if (parse_args(argc, argv, &payloadSize, &burstInterval, &burstSize, &timeOut, &partitionName) == EXIT_FAILURE) {
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -60,6 +56,7 @@ int main (int argc, char **argv)
/* Wait until have a reader */ /* Wait until have a reader */
if (wait_for_reader(writer, participant) == 0) { if (wait_for_reader(writer, participant) == 0) {
printf ("=== [Publisher] Did not discover a reader.\n"); printf ("=== [Publisher] Did not discover a reader.\n");
fflush (stdout);
rc = dds_delete (participant); rc = dds_delete (participant);
if (rc < 0) if (rc < 0)
DDS_FATAL("dds_delete: %s\n", dds_strretcode(-rc)); DDS_FATAL("dds_delete: %s\n", dds_strretcode(-rc));
@ -131,6 +128,7 @@ static int parse_args(
printf ("payloadSize: %u bytes burstInterval: %u ms burstSize: %u timeOut: %u seconds partitionName: %s\n", printf ("payloadSize: %u bytes burstInterval: %u ms burstSize: %u timeOut: %u seconds partitionName: %s\n",
*payloadSize, *burstInterval, *burstSize, *timeOut, *partitionName); *payloadSize, *burstInterval, *burstSize, *timeOut, *partitionName);
fflush (stdout);
return result; return result;
} }
@ -182,6 +180,7 @@ static dds_entity_t prepare_dds(dds_entity_t *writer, const char *partitionName)
static dds_return_t wait_for_reader(dds_entity_t writer, dds_entity_t participant) static dds_return_t wait_for_reader(dds_entity_t writer, dds_entity_t participant)
{ {
printf ("\n=== [Publisher] Waiting for a reader ...\n"); printf ("\n=== [Publisher] Waiting for a reader ...\n");
fflush (stdout);
dds_return_t rc; dds_return_t rc;
dds_entity_t waitset; dds_entity_t waitset;
@ -224,6 +223,7 @@ static void start_writing(
unsigned int burstCount = 0; unsigned int burstCount = 0;
printf ("=== [Publisher] Writing samples...\n"); printf ("=== [Publisher] Writing samples...\n");
fflush (stdout);
while (!done && !timedOut) while (!done && !timedOut)
{ {
@ -277,14 +277,8 @@ static void start_writing(
} }
dds_write_flush (writer); dds_write_flush (writer);
if (done) printf ("=== [Publisher] %s, %llu samples written.\n", done ? "Terminated" : "Timed out", (unsigned long long) sample->count);
{ fflush (stdout);
printf ("=== [Publisher] Terminated, %llu samples written.\n", (unsigned long long) sample->count);
}
else
{
printf ("=== [Publisher] Timed out, %llu samples written.\n", (unsigned long long) sample->count);
}
} }
} }

View file

@ -75,20 +75,18 @@ int main (int argc, char **argv)
dds_entity_t participant; dds_entity_t participant;
dds_entity_t reader; dds_entity_t reader;
#if !defined(_WIN32)
setvbuf (stdout, NULL, _IOLBF, 0);
#endif
if (parse_args(argc, argv, &maxCycles, &partitionName) == EXIT_FAILURE) if (parse_args(argc, argv, &maxCycles, &partitionName) == EXIT_FAILURE)
{ {
return EXIT_FAILURE; return EXIT_FAILURE;
} }
printf ("Cycles: %llu | PollingDelay: %ld | Partition: %s\n", maxCycles, pollingDelay, partitionName); printf ("Cycles: %llu | PollingDelay: %ld | Partition: %s\n", maxCycles, pollingDelay, partitionName);
fflush (stdout);
participant = prepare_dds(&reader, partitionName); participant = prepare_dds(&reader, partitionName);
printf ("=== [Subscriber] Waiting for samples...\n"); printf ("=== [Subscriber] Waiting for samples...\n");
fflush (stdout);
/* Process samples until Ctrl-C is pressed or until maxCycles */ /* Process samples until Ctrl-C is pressed or until maxCycles */
/* has been reached (0 = infinite) */ /* has been reached (0 = infinite) */
@ -280,6 +278,7 @@ static void process_samples(dds_entity_t reader, unsigned long long maxCycles)
deltaTime, payloadSize, total_samples, total_bytes, outOfOrder, deltaTime, payloadSize, total_samples, total_bytes, outOfOrder,
(deltaTime != 0.0) ? ((double)(total_samples - prev_samples) / deltaTime) : 0, (deltaTime != 0.0) ? ((double)(total_samples - prev_samples) / deltaTime) : 0,
(deltaTime != 0.0) ? ((double)((total_bytes - prev_bytes) / BYTES_PER_SEC_TO_MEGABITS_PER_SEC) / deltaTime) : 0); (deltaTime != 0.0) ? ((double)((total_bytes - prev_bytes) / BYTES_PER_SEC_TO_MEGABITS_PER_SEC) / deltaTime) : 0);
fflush (stdout);
cycles++; cycles++;
prev_time = time_now; prev_time = time_now;
prev_bytes = total_bytes; prev_bytes = total_bytes;
@ -300,6 +299,7 @@ static void process_samples(dds_entity_t reader, unsigned long long maxCycles)
printf ("Out of order: %llu samples\n", outOfOrder); printf ("Out of order: %llu samples\n", outOfOrder);
printf ("Average transfer rate: %.2lf samples/s, ", (double)total_samples / deltaTime); printf ("Average transfer rate: %.2lf samples/s, ", (double)total_samples / deltaTime);
printf ("%.2lf Mbit/s\n", (double)(total_bytes / BYTES_PER_SEC_TO_MEGABITS_PER_SEC) / deltaTime); printf ("%.2lf Mbit/s\n", (double)(total_bytes / BYTES_PER_SEC_TO_MEGABITS_PER_SEC) / deltaTime);
fflush (stdout);
} }
static dds_entity_t prepare_dds(dds_entity_t *reader, const char *partitionName) static dds_entity_t prepare_dds(dds_entity_t *reader, const char *partitionName)

View file

@ -62,6 +62,7 @@ enum readermode { MODE_PRINT, MODE_CHECK, MODE_ZEROLOAD, MODE_DUMP, MODE_NONE };
#define PM_STATE 512u #define PM_STATE 512u
static volatile sig_atomic_t termflag = 0; static volatile sig_atomic_t termflag = 0;
static int flushflag = 0;
static int pid; static int pid;
static dds_entity_t termcond; static dds_entity_t termcond;
static unsigned nkeyvals = 1; static unsigned nkeyvals = 1;
@ -885,6 +886,9 @@ static void print_K(dds_time_t *tstart, dds_time_t tnow, dds_entity_t rd, const
} else } else
printf ("get_key_value: error (%s)\n", dds_err_str(result)); printf ("get_key_value: error (%s)\n", dds_err_str(result));
} }
if (flushflag) {
fflush (stdout);
}
ddsrt_mutex_unlock(&output_mutex); ddsrt_mutex_unlock(&output_mutex);
} }
@ -935,6 +939,9 @@ static void print_seq_OU(dds_time_t *tstart, dds_time_t tnow, dds_entity_t rd __
} else { } else {
printf ("NA\n"); printf ("NA\n");
} }
if (flushflag) {
fflush (stdout);
}
ddsrt_mutex_unlock(&output_mutex); ddsrt_mutex_unlock(&output_mutex);
} }
} }
@ -967,10 +974,16 @@ static void rd_on_liveliness_changed(dds_entity_t rd __attribute__ ((unused)), c
status.alive_count, status.alive_count_change, status.alive_count, status.alive_count_change,
status.not_alive_count, status.not_alive_count_change, status.not_alive_count, status.not_alive_count_change,
status.last_publication_handle); status.last_publication_handle);
if (flushflag) {
fflush (stdout);
}
} }
static void rd_on_sample_lost(dds_entity_t rd __attribute__ ((unused)), const dds_sample_lost_status_t status, void* arg __attribute__ ((unused))) { static void rd_on_sample_lost(dds_entity_t rd __attribute__ ((unused)), const dds_sample_lost_status_t status, void* arg __attribute__ ((unused))) {
printf ("[sample-lost: total=(%"PRIu32" change %"PRId32")]\n", status.total_count, status.total_count_change); printf ("[sample-lost: total=(%"PRIu32" change %"PRId32")]\n", status.total_count, status.total_count_change);
if (flushflag) {
fflush (stdout);
}
} }
static void rd_on_sample_rejected(dds_entity_t rd __attribute__ ((unused)), const dds_sample_rejected_status_t status, void* arg __attribute__ ((unused))) { static void rd_on_sample_rejected(dds_entity_t rd __attribute__ ((unused)), const dds_sample_rejected_status_t status, void* arg __attribute__ ((unused))) {
@ -985,6 +998,9 @@ static void rd_on_sample_rejected(dds_entity_t rd __attribute__ ((unused)), cons
status.total_count, status.total_count_change, status.total_count, status.total_count_change,
reasonstr, reasonstr,
status.last_instance_handle); status.last_instance_handle);
if (flushflag) {
fflush (stdout);
}
} }
static void rd_on_subscription_matched(dds_entity_t rd __attribute__((unused)), const dds_subscription_matched_status_t status, void* arg __attribute__((unused))) { static void rd_on_subscription_matched(dds_entity_t rd __attribute__((unused)), const dds_subscription_matched_status_t status, void* arg __attribute__((unused))) {
@ -992,12 +1008,18 @@ static void rd_on_subscription_matched(dds_entity_t rd __attribute__((unused)),
status.total_count, status.total_count_change, status.total_count, status.total_count_change,
status.current_count, status.current_count_change, status.current_count, status.current_count_change,
status.last_publication_handle); status.last_publication_handle);
if (flushflag) {
fflush (stdout);
}
} }
static void rd_on_requested_deadline_missed(dds_entity_t rd __attribute__((unused)), const dds_requested_deadline_missed_status_t status, void* arg __attribute__ ((unused))) { static void rd_on_requested_deadline_missed(dds_entity_t rd __attribute__((unused)), const dds_requested_deadline_missed_status_t status, void* arg __attribute__ ((unused))) {
printf ("[requested-deadline-missed: total=(%"PRIu32" change %"PRId32") handle=%"PRIu64"]\n", printf ("[requested-deadline-missed: total=(%"PRIu32" change %"PRId32") handle=%"PRIu64"]\n",
status.total_count, status.total_count_change, status.total_count, status.total_count_change,
status.last_instance_handle); status.last_instance_handle);
if (flushflag) {
fflush (stdout);
}
} }
static const char *policystr(uint32_t id) { static const char *policystr(uint32_t id) {
@ -1048,21 +1070,33 @@ static const char *policystr(uint32_t id) {
static void rd_on_requested_incompatible_qos(dds_entity_t rd __attribute__((unused)), const dds_requested_incompatible_qos_status_t status, void* arg __attribute__((unused))) { static void rd_on_requested_incompatible_qos(dds_entity_t rd __attribute__((unused)), const dds_requested_incompatible_qos_status_t status, void* arg __attribute__((unused))) {
printf ("[requested-incompatible-qos: total=(%"PRIu32" change %"PRId32") last_policy=%s]\n", printf ("[requested-incompatible-qos: total=(%"PRIu32" change %"PRId32") last_policy=%s]\n",
status.total_count, status.total_count_change, policystr(status.last_policy_id)); status.total_count, status.total_count_change, policystr(status.last_policy_id));
if (flushflag) {
fflush (stdout);
}
} }
static void wr_on_offered_incompatible_qos(dds_entity_t wr __attribute__((unused)), const dds_offered_incompatible_qos_status_t status, void* arg __attribute__((unused))) { static void wr_on_offered_incompatible_qos(dds_entity_t wr __attribute__((unused)), const dds_offered_incompatible_qos_status_t status, void* arg __attribute__((unused))) {
printf ("[offered-incompatible-qos: total=(%"PRIu32" change %"PRId32") last_policy=%s]\n", printf ("[offered-incompatible-qos: total=(%"PRIu32" change %"PRId32") last_policy=%s]\n",
status.total_count, status.total_count_change, policystr(status.last_policy_id)); status.total_count, status.total_count_change, policystr(status.last_policy_id));
if (flushflag) {
fflush (stdout);
}
} }
static void wr_on_liveliness_lost(dds_entity_t wr __attribute__((unused)), const dds_liveliness_lost_status_t status, void* arg __attribute__ ((unused))) { static void wr_on_liveliness_lost(dds_entity_t wr __attribute__((unused)), const dds_liveliness_lost_status_t status, void* arg __attribute__ ((unused))) {
printf ("[liveliness-lost: total=(%"PRIu32" change %"PRId32")]\n", printf ("[liveliness-lost: total=(%"PRIu32" change %"PRId32")]\n",
status.total_count, status.total_count_change); status.total_count, status.total_count_change);
if (flushflag) {
fflush (stdout);
}
} }
static void wr_on_offered_deadline_missed(dds_entity_t wr __attribute__((unused)), const dds_offered_deadline_missed_status_t status, void* arg __attribute__((unused))) { static void wr_on_offered_deadline_missed(dds_entity_t wr __attribute__((unused)), const dds_offered_deadline_missed_status_t status, void* arg __attribute__((unused))) {
printf ("[offered-deadline-missed: total=(%"PRIu32" change %"PRId32") handle=%"PRIu64"]\n", printf ("[offered-deadline-missed: total=(%"PRIu32" change %"PRId32") handle=%"PRIu64"]\n",
status.total_count, status.total_count_change, status.last_instance_handle); status.total_count, status.total_count_change, status.last_instance_handle);
if (flushflag) {
fflush (stdout);
}
} }
static void wr_on_publication_matched(dds_entity_t wr __attribute__((unused)), const dds_publication_matched_status_t status, void* arg __attribute__((unused))) { static void wr_on_publication_matched(dds_entity_t wr __attribute__((unused)), const dds_publication_matched_status_t status, void* arg __attribute__((unused))) {
@ -1070,6 +1104,9 @@ static void wr_on_publication_matched(dds_entity_t wr __attribute__((unused)), c
status.total_count, status.total_count_change, status.total_count, status.total_count_change,
status.current_count, status.current_count_change, status.current_count, status.current_count_change,
status.last_subscription_handle); status.last_subscription_handle);
if (flushflag) {
fflush (stdout);
}
} }
static int register_instance_wrapper(dds_entity_t wr, const void *d, const dds_time_t tstamp) { static int register_instance_wrapper(dds_entity_t wr, const void *d, const dds_time_t tstamp) {
@ -1105,6 +1142,9 @@ static void non_data_operation(char command, dds_entity_t wr) {
switch (command) { switch (command) {
case 'Y': case 'Y':
printf ("Dispose all: not supported\n"); printf ("Dispose all: not supported\n");
if (flushflag) {
fflush (stdout);
}
// TODO Implement application side tracking of alive instances for use with a 'dispose all' function // TODO Implement application side tracking of alive instances for use with a 'dispose all' function
// if ((result = DDS_Topic_dispose_all_data(DDS_DataWriter_get_topic(wr))) != DDS_RETCODE_OK) // if ((result = DDS_Topic_dispose_all_data(DDS_DataWriter_get_topic(wr))) != DDS_RETCODE_OK)
// error ("DDS_Topic_dispose_all: error %d\n", (int) result); // error ("DDS_Topic_dispose_all: error %d\n", (int) result);
@ -1207,6 +1247,9 @@ static void pub_do_auto(const struct writerspec *spec) {
while (!termflag && tprev < tstop) { while (!termflag && tprev < tstop) {
if ((result = dds_write(spec->wr, &d)) != DDS_RETCODE_OK) { if ((result = dds_write(spec->wr, &d)) != DDS_RETCODE_OK) {
printf ("write: error %d (%s)\n", (int) result, dds_err_str(result)); printf ("write: error %d (%s)\n", (int) result, dds_err_str(result));
if (flushflag) {
fflush (stdout);
}
if (result != DDS_RETCODE_TIMEOUT) if (result != DDS_RETCODE_TIMEOUT)
break; break;
} else { } else {
@ -1232,6 +1275,9 @@ static void pub_do_auto(const struct writerspec *spec) {
while (!termflag && tprev < tstop) { while (!termflag && tprev < tstop) {
if ((result = dds_write(spec->wr, &d)) != DDS_RETCODE_OK) { if ((result = dds_write(spec->wr, &d)) != DDS_RETCODE_OK) {
printf ("write: error %d (%s)\n", (int) result, dds_err_str(result)); printf ("write: error %d (%s)\n", (int) result, dds_err_str(result));
if (flushflag) {
fflush (stdout);
}
if (result != DDS_RETCODE_TIMEOUT) if (result != DDS_RETCODE_TIMEOUT)
break; break;
} }
@ -1265,6 +1311,9 @@ static void pub_do_auto(const struct writerspec *spec) {
hist_print(hist, tlast - tfirst, 0); hist_print(hist, tlast - tfirst, 0);
hist_free(hist); hist_free(hist);
printf ("total writes: %" PRId64 " (%e/s)\n", ntot, (double)ntot * 1e9 / (double)(tlast - tfirst0)); printf ("total writes: %" PRId64 " (%e/s)\n", ntot, (double)ntot * 1e9 / (double)(tlast - tfirst0));
if (flushflag) {
fflush (stdout);
}
if (spec->topicsel == KS) { if (spec->topicsel == KS) {
dds_free(d.ks.baggage._buffer); dds_free(d.ks.baggage._buffer);
} }
@ -1319,6 +1368,9 @@ static char *pub_do_nonarb(const struct writerspec *spec, uint32_t *seq) {
tstamp = (tstamp_spec.t % T_SECOND) + ((int) (tstamp_spec.t / T_SECOND) * DDS_NSECS_IN_SEC); tstamp = (tstamp_spec.t % T_SECOND) + ((int) (tstamp_spec.t / T_SECOND) * DDS_NSECS_IN_SEC);
if ((result = fn(spec->wr, &d, tstamp)) != DDS_RETCODE_OK) { if ((result = fn(spec->wr, &d, tstamp)) != DDS_RETCODE_OK) {
printf ("%s %d: error %d (%s)\n", get_write_operstr(command), k, (int) result, dds_err_str(result)); printf ("%s %d: error %d (%s)\n", get_write_operstr(command), k, (int) result, dds_err_str(result));
if (flushflag) {
fflush (stdout);
}
if (!accept_error(command, result)) if (!accept_error(command, result))
exit(1); exit(1);
} }
@ -1326,6 +1378,9 @@ static char *pub_do_nonarb(const struct writerspec *spec, uint32_t *seq) {
dds_write_flush(spec->wr); dds_write_flush(spec->wr);
if (spec->dupwr && (result = fn(spec->dupwr, &d, tstamp)) != DDS_RETCODE_OK) { if (spec->dupwr && (result = fn(spec->dupwr, &d, tstamp)) != DDS_RETCODE_OK) {
printf ("%s %d(dup): error %d (%s)\n", get_write_operstr(command), k, (int) result, dds_err_str(result)); printf ("%s %d(dup): error %d (%s)\n", get_write_operstr(command), k, (int) result, dds_err_str(result));
if (flushflag) {
fflush (stdout);
}
if (!accept_error(command, result)) if (!accept_error(command, result))
exit(1); exit(1);
} }
@ -1337,11 +1392,17 @@ static char *pub_do_nonarb(const struct writerspec *spec, uint32_t *seq) {
break; break;
} }
case 'z': case 'z':
if (spec->topicsel != KS) if (spec->topicsel != KS) {
printf ("payload size cannot be set for selected type\n"); printf ("payload size cannot be set for selected type\n");
else if (k < 12 && k != 0) if (flushflag) {
fflush (stdout);
}
} else if (k < 12 && k != 0) {
printf ("invalid payload size: %d\n", k); printf ("invalid payload size: %d\n", k);
else { if (flushflag) {
fflush (stdout);
}
} else {
uint32_t baggagesize = (k != 0) ? (uint32_t) (k - 12) : 0; uint32_t baggagesize = (k != 0) ? (uint32_t) (k - 12) : 0;
if (d.ks.baggage._buffer) if (d.ks.baggage._buffer)
dds_free (d.ks.baggage._buffer); dds_free (d.ks.baggage._buffer);
@ -1354,9 +1415,12 @@ static char *pub_do_nonarb(const struct writerspec *spec, uint32_t *seq) {
set_pub_partition(spec->pub, arg); set_pub_partition(spec->pub, arg);
break; break;
case 's': case 's':
if (k < 0) if (k < 0) {
printf ("invalid sleep duration: %ds\n", k); printf ("invalid sleep duration: %ds\n", k);
else { if (flushflag) {
fflush (stdout);
}
} else {
dds_sleepfor(DDS_SECS(k)); dds_sleepfor(DDS_SECS(k));
} }
break; break;
@ -1524,6 +1588,9 @@ static uint32_t pubthread(void *vwrspecs) {
cand = cursor; cand = cursor;
else { else {
printf ("%s: ambiguous writer specification\n", nextspec); printf ("%s: ambiguous writer specification\n", nextspec);
if (flushflag) {
fflush (stdout);
}
break; break;
} }
} }
@ -1531,6 +1598,9 @@ static uint32_t pubthread(void *vwrspecs) {
} while (cursor != endm); } while (cursor != endm);
if (cand == NULL) { if (cand == NULL) {
printf ("%s: no matching writer specification\n", nextspec); printf ("%s: no matching writer specification\n", nextspec);
if (flushflag) {
fflush (stdout);
}
} else if (cursor != endm) { /* ambiguous case */ } else if (cursor != endm) { /* ambiguous case */
cursor = endm; cursor = endm;
} else { } else {
@ -1699,6 +1769,9 @@ static uint32_t subthread(void *vspec) {
rc = dds_waitset_wait(ws, xs, nxs, DDS_INFINITY); rc = dds_waitset_wait(ws, xs, nxs, DDS_INFINITY);
if (rc < DDS_RETCODE_OK) { if (rc < DDS_RETCODE_OK) {
printf ("wait: error %d\n", (int) rc); printf ("wait: error %d\n", (int) rc);
if (flushflag) {
fflush (stdout);
}
break; break;
} else if (rc == DDS_RETCODE_OK) { } else if (rc == DDS_RETCODE_OK) {
continue; continue;
@ -1727,6 +1800,9 @@ static uint32_t subthread(void *vspec) {
status.current_count, status.current_count,
status.current_count_change, status.current_count_change,
status.last_publication_handle); status.last_publication_handle);
if (flushflag) {
fflush (stdout);
}
} }
} }
@ -1767,8 +1843,14 @@ static uint32_t subthread(void *vspec) {
; /* expected */ ; /* expected */
} else if (spec->mode == MODE_CHECK || spec->mode == MODE_DUMP || spec->polling) { } else if (spec->mode == MODE_CHECK || spec->mode == MODE_DUMP || spec->polling) {
printf ("%s: %d (%s) on %s\n", (!spec->use_take && spec->mode == MODE_DUMP) ? "read" : "take", (int) nread, dds_err_str(nread), spec->polling ? "poll" : "stcond"); printf ("%s: %d (%s) on %s\n", (!spec->use_take && spec->mode == MODE_DUMP) ? "read" : "take", (int) nread, dds_err_str(nread), spec->polling ? "poll" : "stcond");
if (flushflag) {
fflush (stdout);
}
} else { } else {
printf ("%s: %d (%s) on rdcond%s\n", spec->use_take ? "take" : "read", (int) nread, dds_err_str(nread), (cond == rdcondA) ? "A" : (cond == rdcondD) ? "D" : "?"); printf ("%s: %d (%s) on rdcond%s\n", spec->use_take ? "take" : "read", (int) nread, dds_err_str(nread), (cond == rdcondA) ? "A" : (cond == rdcondD) ? "D" : "?");
if (flushflag) {
fflush (stdout);
}
} }
continue; continue;
} }
@ -1825,6 +1907,9 @@ static uint32_t subthread(void *vspec) {
const double rate_Mbps = (double)(nreceived_bytes - last_nreceived_bytes) * 8 / 1e6; const double rate_Mbps = (double)(nreceived_bytes - last_nreceived_bytes) * 8 / 1e6;
printf ("%"PRId64".%03"PRId64" ntot %lld nseq %lld ndelta %lld rate %.2f Mb/s\n", printf ("%"PRId64".%03"PRId64" ntot %lld nseq %lld ndelta %lld rate %.2f Mb/s\n",
tdelta_s, tdelta_ms, nreceived, out_of_seq, ndelta, rate_Mbps); tdelta_s, tdelta_ms, nreceived, out_of_seq, ndelta, rate_Mbps);
if (flushflag) {
fflush (stdout);
}
last_nreceived = nreceived; last_nreceived = nreceived;
last_nreceived_bytes = nreceived_bytes; last_nreceived_bytes = nreceived_bytes;
tprint = tnow; tprint = tnow;
@ -1854,10 +1939,14 @@ static uint32_t subthread(void *vspec) {
dds_return_t nread; dds_return_t nread;
nread = dds_take_mask(rd, mseq, iseq, spec->read_maxsamples, spec->read_maxsamples, DDS_ANY_STATE); nread = dds_take_mask(rd, mseq, iseq, spec->read_maxsamples, spec->read_maxsamples, DDS_ANY_STATE);
if (nread == 0) { if (nread == 0) {
if (!once_mode) if (!once_mode) {
printf ("-- final take: data reader empty --\n"); printf ("-- final take: data reader empty --\n");
else if (flushflag) {
fflush (stdout);
}
} else {
exitcode = 1; exitcode = 1;
}
} else if (nread < DDS_RETCODE_OK) { } else if (nread < DDS_RETCODE_OK) {
if (!once_mode) { if (!once_mode) {
error_report(rc, "-- final take --\n"); error_report(rc, "-- final take --\n");
@ -1888,8 +1977,12 @@ static uint32_t subthread(void *vspec) {
} }
dds_free(iseq); dds_free(iseq);
dds_free(mseq); dds_free(mseq);
if (spec->mode == MODE_CHECK) if (spec->mode == MODE_CHECK) {
printf ("received: %lld, out of seq: %lld\n", nreceived, out_of_seq); printf ("received: %lld, out of seq: %lld\n", nreceived, out_of_seq);
if (flushflag) {
fflush (stdout);
}
}
fini_eseq_admin(&eseq_admin); fini_eseq_admin(&eseq_admin);
} }
@ -1950,6 +2043,9 @@ static uint32_t autotermthread(void *varg __attribute__((unused))) {
if ((rc = dds_waitset_wait(ws, wsresults, wsresultsize, timeout)) < DDS_RETCODE_OK) { if ((rc = dds_waitset_wait(ws, wsresults, wsresultsize, timeout)) < DDS_RETCODE_OK) {
printf ("wait: error %s\n", dds_err_str(rc)); printf ("wait: error %s\n", dds_err_str(rc));
if (flushflag) {
fflush (stdout);
}
break; break;
} }
tnow = dds_time(); tnow = dds_time();
@ -2020,8 +2116,12 @@ static dds_entity_t find_topic(dds_entity_t dpFindTopic, const char *name, const
// } // }
// TODO Note: the implementation for dds_topic_find blocks infinitely if the topic does not exist in the domain // TODO Note: the implementation for dds_topic_find blocks infinitely if the topic does not exist in the domain
if (!(tp = dds_find_topic(dpFindTopic, name))) if (!(tp = dds_find_topic(dpFindTopic, name))) {
printf ("topic %s not found\n", name); printf ("topic %s not found\n", name);
if (flushflag) {
fflush (stdout);
}
}
// if (!isbuiltin) { // if (!isbuiltin) {
// char *tn = DDS_Topic_get_type_name(tp); // char *tn = DDS_Topic_get_type_name(tp);
@ -2240,7 +2340,7 @@ int main(int argc, char *argv[]) {
wait_for_matching_reader_arg = optarg + pos; wait_for_matching_reader_arg = optarg + pos;
break; break;
case 'F': case 'F':
setvbuf(stdout, (char *) NULL, _IOLBF, 0); flushflag = 1;
break; break;
case 'K': case 'K':
addspec(SPEC_TOPICSEL, &spec_sofar, &specidx, &spec, want_reader); addspec(SPEC_TOPICSEL, &spec_sofar, &specidx, &spec, want_reader);
@ -2629,6 +2729,9 @@ int main(int argc, char *argv[]) {
if (want_writer && wait_for_matching_reader_arg) { if (want_writer && wait_for_matching_reader_arg) {
printf("Wait for matching reader: unsupported\n"); printf("Wait for matching reader: unsupported\n");
if (flushflag) {
fflush (stdout);
}
// TODO Reimplement wait_for_matching_reader functionality via wait on status subscription matched // TODO Reimplement wait_for_matching_reader functionality via wait on status subscription matched
// struct qos *q = NULL; // struct qos *q = NULL;
// uint64_t tnow = dds_time(); // uint64_t tnow = dds_time();

View file

@ -38,6 +38,8 @@ extern "C" {
DDS_EXPORT struct ut_xmlpState *ut_xmlpNewFile (FILE *fp, void *varg, const struct ut_xmlpCallbacks *cb); DDS_EXPORT struct ut_xmlpState *ut_xmlpNewFile (FILE *fp, void *varg, const struct ut_xmlpCallbacks *cb);
DDS_EXPORT struct ut_xmlpState *ut_xmlpNewString (const char *string, void *varg, const struct ut_xmlpCallbacks *cb); DDS_EXPORT struct ut_xmlpState *ut_xmlpNewString (const char *string, void *varg, const struct ut_xmlpCallbacks *cb);
DDS_EXPORT void ut_xmlpSetRequireEOF (struct ut_xmlpState *st, int require_eof);
DDS_EXPORT size_t ut_xmlpGetBufpos (const struct ut_xmlpState *st);
DDS_EXPORT void ut_xmlpFree (struct ut_xmlpState *st); DDS_EXPORT void ut_xmlpFree (struct ut_xmlpState *st);
DDS_EXPORT int ut_xmlpParse (struct ut_xmlpState *st); DDS_EXPORT int ut_xmlpParse (struct ut_xmlpState *st);

View file

@ -49,6 +49,7 @@ struct ut_xmlpState {
size_t tpescp; /* still escape sequences in tpescp .. tpp */ size_t tpescp; /* still escape sequences in tpescp .. tpp */
int nest; /* current nesting level */ int nest; /* current nesting level */
void *varg; /* user argument to callback functions */ void *varg; /* user argument to callback functions */
int require_eof; /* if false, junk may follow top-level closing tag */
struct ut_xmlpCallbacks cb; /* user-supplied callbacks (or stubs) */ struct ut_xmlpCallbacks cb; /* user-supplied callbacks (or stubs) */
}; };
@ -107,6 +108,7 @@ static void ut_xmlpNewCommon (struct ut_xmlpState *st)
st->peekpayload = NULL; st->peekpayload = NULL;
st->nest = 0; st->nest = 0;
st->error = 0; st->error = 0;
st->require_eof = 1;
} }
static void ut_xmlpNewSetCB (struct ut_xmlpState *st, void *varg, const struct ut_xmlpCallbacks *cb) static void ut_xmlpNewSetCB (struct ut_xmlpState *st, void *varg, const struct ut_xmlpCallbacks *cb)
@ -146,6 +148,16 @@ struct ut_xmlpState *ut_xmlpNewString (const char *string, void *varg, const str
return st; return st;
} }
void ut_xmlpSetRequireEOF (struct ut_xmlpState *st, int require_eof)
{
st->require_eof = require_eof;
}
size_t ut_xmlpGetBufpos (const struct ut_xmlpState *st)
{
return st->cbufp;
}
void ut_xmlpFree (struct ut_xmlpState *st) void ut_xmlpFree (struct ut_xmlpState *st)
{ {
if (st->fp != NULL) { if (st->fp != NULL) {
@ -697,7 +709,7 @@ int ut_xmlpParse (struct ut_xmlpState *st)
return 0; return 0;
} else { } else {
int ret = parse_element (st, 0); int ret = parse_element (st, 0);
if (ret < 0 || next_token (st, NULL) == TOK_EOF) { if (ret < 0|| !st->require_eof || next_token (st, NULL) == TOK_EOF ) {
return ret; return ret;
} else { } else {
return -1; return -1;