Address Coverity, Clang static analyzer warnings
* Fix type of num reliable readers (int to int32_t)
* Conversion codes in debug monitor printf formats
* Dead code elimination
* Skipping a test case where SIZE_MAX is assumed > INT32_MAX if
assumption is false on target platform
* Error handling in os_sockWaitsetNew
* Stick to unsigned in fragment size calculations
This check is actually guarded by valid_DataFrag and was safe for
datagrams up to 2GB, but the unintended and implicit conversion to is
still best eliminated.
* A "server" connection never has an invalid socket in TCP wrapper
* Handle error return from gethostname in SPDP write (CID 248183)
* Handle extended retcodes in dds_strretcode
CID 248131, introduced by 19aec98b8a
* Remove dead code in ddsrt logging test (CID 248195)
* Validate command-line argument in process test (CID 248117)
* Allow for extremely delayed store in test
Test is constructed to have the events trigger only at the appropriate
times, but it does assume that the store to cb_called becomes visible
prior to the listener callback. I'm pretty sure that will always be
the case in practice, but I'm also pretty sure there is no formal
guarantee without a memory barrier, which mutex_unlock provides.
CID 248088, 248136, 248177, 253590, 253591, 253593
* Check unsetenv return value in test (CID 248099)
Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
parent
2996a6b5f8
commit
94483e3371
23 changed files with 121 additions and 96 deletions
|
@ -169,7 +169,6 @@ static dds_return_t dds_domain_init (dds_domain *domain, dds_domainid_t domain_i
|
||||||
dds_entity_init_complete (&domain->m_entity);
|
dds_entity_init_complete (&domain->m_entity);
|
||||||
return DDS_RETCODE_OK;
|
return DDS_RETCODE_OK;
|
||||||
|
|
||||||
rtps_stop (&domain->gv);
|
|
||||||
fail_rtps_start:
|
fail_rtps_start:
|
||||||
if (domain->gv.config.liveliness_monitoring && dds_global.threadmon_count == 1)
|
if (domain->gv.config.liveliness_monitoring && dds_global.threadmon_count == 1)
|
||||||
ddsi_threadmon_stop (dds_global.threadmon);
|
ddsi_threadmon_stop (dds_global.threadmon);
|
||||||
|
|
|
@ -403,14 +403,17 @@ dds_return_t dds_delete_impl_pinned (dds_entity *e, enum delete_impl_state delst
|
||||||
ddsrt_mutex_unlock (&p->m_mutex);
|
ddsrt_mutex_unlock (&p->m_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Do some specific deletion when needed. Bootstrapping and its inverse are always a
|
/* Do some specific deletion when needed */
|
||||||
tricky business, and here it is no different: deleting the pseudo-top-level object
|
|
||||||
tears down all kinds of stuff that is supposed to remain in existence (like the
|
|
||||||
entire platform abstraction) and so it must be the final call. Thus, we rely on it
|
|
||||||
to call "dds_entity_final_deinit_before_free" and return a special error code. */
|
|
||||||
ret = dds_entity_deriver_delete (e);
|
ret = dds_entity_deriver_delete (e);
|
||||||
if (ret == DDS_RETCODE_NO_DATA)
|
if (ret == DDS_RETCODE_NO_DATA)
|
||||||
|
{
|
||||||
|
/* Bootstrapping and its inverse are always a tricky business, and here it is no different:
|
||||||
|
deleting the pseudo-top-level object tears down all kinds of stuff that is supposed to
|
||||||
|
remain in existence (like the entire platform abstraction) and so it must be the final
|
||||||
|
call. Thus, we rely on it to call "dds_entity_final_deinit_before_free" and return a
|
||||||
|
special error code that we don't pass on to the caller. */
|
||||||
ret = DDS_RETCODE_OK;
|
ret = DDS_RETCODE_OK;
|
||||||
|
}
|
||||||
else if (ret != DDS_RETCODE_OK)
|
else if (ret != DDS_RETCODE_OK)
|
||||||
{
|
{
|
||||||
if (parent_to_delete)
|
if (parent_to_delete)
|
||||||
|
@ -423,6 +426,8 @@ dds_return_t dds_delete_impl_pinned (dds_entity *e, enum delete_impl_state delst
|
||||||
dds_free (e);
|
dds_free (e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert (ret == DDS_RETCODE_OK);
|
||||||
|
(void) ret;
|
||||||
return (parent_to_delete != NULL) ? dds_delete_impl_pinned (parent_to_delete, DIS_IMPLICIT) : DDS_RETCODE_OK;
|
return (parent_to_delete != NULL) ? dds_delete_impl_pinned (parent_to_delete, DIS_IMPLICIT) : DDS_RETCODE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1696,7 +1696,7 @@ static bool prtf_simple_array (char * __restrict *buf, size_t * __restrict bufsi
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
cont = prtf (buf, bufsize, ",");
|
(void) prtf (buf, bufsize, ",");
|
||||||
cont = prtf_simple (buf, bufsize, is, type);
|
cont = prtf_simple (buf, bufsize, is, type);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -1708,7 +1708,7 @@ static bool prtf_simple_array (char * __restrict *buf, size_t * __restrict bufsi
|
||||||
for (size_t i = 0; cont && i < num; i++)
|
for (size_t i = 0; cont && i < num; i++)
|
||||||
{
|
{
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
cont = prtf (buf, bufsize, ",");
|
(void) prtf (buf, bufsize, ",");
|
||||||
cont = prtf_simple (buf, bufsize, is, type);
|
cont = prtf_simple (buf, bufsize, is, type);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -366,6 +366,7 @@ CU_Test(ddsc_entity_get_children, null, .init=hierarchy_init, .fini=hierarchy_fi
|
||||||
/*************************************************************************************************/
|
/*************************************************************************************************/
|
||||||
|
|
||||||
/*************************************************************************************************/
|
/*************************************************************************************************/
|
||||||
|
#if SIZE_MAX > INT32_MAX
|
||||||
CU_Test(ddsc_entity_get_children, invalid_size, .init=hierarchy_init, .fini=hierarchy_fini)
|
CU_Test(ddsc_entity_get_children, invalid_size, .init=hierarchy_init, .fini=hierarchy_fini)
|
||||||
{
|
{
|
||||||
dds_return_t ret;
|
dds_return_t ret;
|
||||||
|
@ -373,6 +374,7 @@ CU_Test(ddsc_entity_get_children, invalid_size, .init=hierarchy_init, .fini=hier
|
||||||
ret = dds_get_children(g_participant, &child, SIZE_MAX);
|
ret = dds_get_children(g_participant, &child, SIZE_MAX);
|
||||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
/*************************************************************************************************/
|
/*************************************************************************************************/
|
||||||
|
|
||||||
/*************************************************************************************************/
|
/*************************************************************************************************/
|
||||||
|
|
|
@ -132,6 +132,7 @@ CU_Test(ddsc_instance_get_key, registered_instance, .init=setup, .fini=teardown)
|
||||||
ret = dds_instance_get_key(writer, handle, &key_data);
|
ret = dds_instance_get_key(writer, handle, &key_data);
|
||||||
|
|
||||||
CU_ASSERT_PTR_NOT_NULL_FATAL(key_data.ip);
|
CU_ASSERT_PTR_NOT_NULL_FATAL(key_data.ip);
|
||||||
|
assert (key_data.ip != NULL); /* for the benefit of clang's static analyzer */
|
||||||
CU_ASSERT_STRING_EQUAL_FATAL(key_data.ip, data.ip);
|
CU_ASSERT_STRING_EQUAL_FATAL(key_data.ip, data.ip);
|
||||||
CU_ASSERT_EQUAL_FATAL(key_data.port, data.port);
|
CU_ASSERT_EQUAL_FATAL(key_data.port, data.port);
|
||||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||||
|
@ -162,6 +163,7 @@ CU_Test(ddsc_instance_get_key, readcondition, .init=setup, .fini=teardown)
|
||||||
ret = dds_instance_get_key(readcondition, handle, &key_data);
|
ret = dds_instance_get_key(readcondition, handle, &key_data);
|
||||||
|
|
||||||
CU_ASSERT_PTR_NOT_NULL_FATAL(key_data.ip);
|
CU_ASSERT_PTR_NOT_NULL_FATAL(key_data.ip);
|
||||||
|
assert (key_data.ip != NULL); /* for the benefit of clang's static analyzer */
|
||||||
CU_ASSERT_STRING_EQUAL_FATAL(key_data.ip, data.ip);
|
CU_ASSERT_STRING_EQUAL_FATAL(key_data.ip, data.ip);
|
||||||
CU_ASSERT_EQUAL_FATAL(key_data.port, data.port);
|
CU_ASSERT_EQUAL_FATAL(key_data.port, data.port);
|
||||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||||
|
@ -192,6 +194,7 @@ CU_Test(ddsc_instance_get_key, querycondition, .init=setup, .fini=teardown)
|
||||||
ret = dds_instance_get_key(querycondition, handle, &key_data);
|
ret = dds_instance_get_key(querycondition, handle, &key_data);
|
||||||
|
|
||||||
CU_ASSERT_PTR_NOT_NULL_FATAL(key_data.ip);
|
CU_ASSERT_PTR_NOT_NULL_FATAL(key_data.ip);
|
||||||
|
assert (key_data.ip != NULL); /* for the benefit of clang's static analyzer */
|
||||||
CU_ASSERT_STRING_EQUAL_FATAL(key_data.ip, data.ip);
|
CU_ASSERT_STRING_EQUAL_FATAL(key_data.ip, data.ip);
|
||||||
CU_ASSERT_EQUAL_FATAL(key_data.port, data.port);
|
CU_ASSERT_EQUAL_FATAL(key_data.port, data.port);
|
||||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||||
|
|
|
@ -727,7 +727,9 @@ CU_Test(ddsc_listener, publication_matched, .init=init_triggering_test, .fini=fi
|
||||||
CU_ASSERT_EQUAL_FATAL(publication_matched.last_subscription_handle, reader_hdl);
|
CU_ASSERT_EQUAL_FATAL(publication_matched.last_subscription_handle, reader_hdl);
|
||||||
|
|
||||||
/* Reset the trigger flags. */
|
/* Reset the trigger flags. */
|
||||||
|
ddsrt_mutex_lock(&g_mutex);
|
||||||
cb_called = 0;
|
cb_called = 0;
|
||||||
|
ddsrt_mutex_unlock(&g_mutex);
|
||||||
|
|
||||||
/* Un-match the publication by deleting the reader. */
|
/* Un-match the publication by deleting the reader. */
|
||||||
dds_delete(g_reader);
|
dds_delete(g_reader);
|
||||||
|
@ -789,7 +791,9 @@ CU_Test(ddsc_listener, subscription_matched, .init=init_triggering_test, .fini=f
|
||||||
CU_ASSERT_EQUAL_FATAL(subscription_matched.last_publication_handle, writer_hdl);
|
CU_ASSERT_EQUAL_FATAL(subscription_matched.last_publication_handle, writer_hdl);
|
||||||
|
|
||||||
/* Reset the trigger flags. */
|
/* Reset the trigger flags. */
|
||||||
|
ddsrt_mutex_lock(&g_mutex);
|
||||||
cb_called = 0;
|
cb_called = 0;
|
||||||
|
ddsrt_mutex_unlock(&g_mutex);
|
||||||
|
|
||||||
/* Un-match the subscription by deleting the writer. */
|
/* Un-match the subscription by deleting the writer. */
|
||||||
dds_delete(g_writer);
|
dds_delete(g_writer);
|
||||||
|
@ -903,8 +907,10 @@ CU_Test(ddsc_listener, data_available, .init=init_triggering_test, .fini=fini_tr
|
||||||
|
|
||||||
/* Deleting the writer causes unregisters (or dispose+unregister), and those
|
/* Deleting the writer causes unregisters (or dispose+unregister), and those
|
||||||
should trigger DATA_AVAILABLE as well */
|
should trigger DATA_AVAILABLE as well */
|
||||||
|
ddsrt_mutex_lock(&g_mutex);
|
||||||
cb_called = 0;
|
cb_called = 0;
|
||||||
cb_reader = 0;
|
cb_reader = 0;
|
||||||
|
ddsrt_mutex_unlock(&g_mutex);
|
||||||
ret = dds_delete (g_writer);
|
ret = dds_delete (g_writer);
|
||||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||||
g_writer = 0;
|
g_writer = 0;
|
||||||
|
@ -942,8 +948,10 @@ CU_Test(ddsc_listener, data_available_delete_writer, .init=init_triggering_test,
|
||||||
CU_ASSERT_EQUAL_FATAL(cb_reader, g_reader);
|
CU_ASSERT_EQUAL_FATAL(cb_reader, g_reader);
|
||||||
|
|
||||||
/* Deleting the writer must trigger DATA_AVAILABLE as well */
|
/* Deleting the writer must trigger DATA_AVAILABLE as well */
|
||||||
|
ddsrt_mutex_lock(&g_mutex);
|
||||||
cb_called = 0;
|
cb_called = 0;
|
||||||
cb_reader = 0;
|
cb_reader = 0;
|
||||||
|
ddsrt_mutex_unlock(&g_mutex);
|
||||||
ret = dds_delete (g_writer);
|
ret = dds_delete (g_writer);
|
||||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||||
g_writer = 0;
|
g_writer = 0;
|
||||||
|
@ -991,8 +999,10 @@ CU_Test(ddsc_listener, data_available_delete_writer_disposed, .init=init_trigger
|
||||||
} while (ret > 0);
|
} while (ret > 0);
|
||||||
|
|
||||||
/* Deleting the writer should not trigger DATA_AVAILABLE with all instances empty & disposed */
|
/* Deleting the writer should not trigger DATA_AVAILABLE with all instances empty & disposed */
|
||||||
|
ddsrt_mutex_lock(&g_mutex);
|
||||||
cb_called = 0;
|
cb_called = 0;
|
||||||
cb_reader = 0;
|
cb_reader = 0;
|
||||||
|
ddsrt_mutex_unlock(&g_mutex);
|
||||||
ret = dds_delete (g_writer);
|
ret = dds_delete (g_writer);
|
||||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||||
g_writer = 0;
|
g_writer = 0;
|
||||||
|
@ -1174,7 +1184,9 @@ CU_Test(ddsc_listener, liveliness_changed, .init=init_triggering_test, .fini=fin
|
||||||
CU_ASSERT_EQUAL_FATAL(liveliness_changed.last_publication_handle, writer_hdl);
|
CU_ASSERT_EQUAL_FATAL(liveliness_changed.last_publication_handle, writer_hdl);
|
||||||
|
|
||||||
/* Reset the trigger flags. */
|
/* Reset the trigger flags. */
|
||||||
|
ddsrt_mutex_lock(&g_mutex);
|
||||||
cb_called = 0;
|
cb_called = 0;
|
||||||
|
ddsrt_mutex_unlock(&g_mutex);
|
||||||
|
|
||||||
/* Change liveliness again by deleting the writer. */
|
/* Change liveliness again by deleting the writer. */
|
||||||
dds_delete(g_writer);
|
dds_delete(g_writer);
|
||||||
|
|
|
@ -47,7 +47,8 @@ CU_Test(ddsc_participant, create_with_no_conf_no_env)
|
||||||
dds_domainid_t domain_id;
|
dds_domainid_t domain_id;
|
||||||
dds_domainid_t valid_domain=3;
|
dds_domainid_t valid_domain=3;
|
||||||
|
|
||||||
ddsrt_unsetenv(DDS_PROJECT_NAME_NOSPACE_CAPS"_URI");
|
status = ddsrt_unsetenv(DDS_PROJECT_NAME_NOSPACE_CAPS"_URI");
|
||||||
|
CU_ASSERT_EQUAL_FATAL(status, DDS_RETCODE_OK);
|
||||||
|
|
||||||
//valid specific domain value
|
//valid specific domain value
|
||||||
participant2 = dds_create_participant (valid_domain, NULL, NULL);
|
participant2 = dds_create_participant (valid_domain, NULL, NULL);
|
||||||
|
|
|
@ -91,7 +91,7 @@ struct wr_prd_match {
|
||||||
seqno_t min_seq; /* smallest ack'd seq nr in subtree */
|
seqno_t min_seq; /* smallest ack'd seq nr in subtree */
|
||||||
seqno_t max_seq; /* sort-of highest ack'd seq nr in subtree (see augment function) */
|
seqno_t max_seq; /* sort-of highest ack'd seq nr in subtree (see augment function) */
|
||||||
seqno_t seq; /* highest acknowledged seq nr */
|
seqno_t seq; /* highest acknowledged seq nr */
|
||||||
int num_reliable_readers_where_seq_equals_max;
|
int32_t num_reliable_readers_where_seq_equals_max;
|
||||||
ddsi_guid_t arbitrary_unacked_reader;
|
ddsi_guid_t arbitrary_unacked_reader;
|
||||||
nn_count_t next_acknack; /* next acceptable acknack sequence number */
|
nn_count_t next_acknack; /* next acceptable acknack sequence number */
|
||||||
nn_count_t next_nackfrag; /* next acceptable nackfrag sequence number */
|
nn_count_t next_nackfrag; /* next acceptable nackfrag sequence number */
|
||||||
|
@ -260,7 +260,7 @@ struct writer
|
||||||
uint32_t whc_low, whc_high; /* watermarks for WHC in bytes (counting only unack'd data) */
|
uint32_t whc_low, whc_high; /* watermarks for WHC in bytes (counting only unack'd data) */
|
||||||
nn_etime_t t_rexmit_end; /* time of last 1->0 transition of "retransmitting" */
|
nn_etime_t t_rexmit_end; /* time of last 1->0 transition of "retransmitting" */
|
||||||
nn_etime_t t_whc_high_upd; /* time "whc_high" was last updated for controlled ramp-up of throughput */
|
nn_etime_t t_whc_high_upd; /* time "whc_high" was last updated for controlled ramp-up of throughput */
|
||||||
int num_reliable_readers; /* number of matching reliable PROXY readers */
|
int32_t num_reliable_readers; /* number of matching reliable PROXY readers */
|
||||||
ddsrt_avl_tree_t readers; /* all matching PROXY readers, see struct wr_prd_match */
|
ddsrt_avl_tree_t readers; /* all matching PROXY readers, see struct wr_prd_match */
|
||||||
ddsrt_avl_tree_t local_readers; /* all matching LOCAL readers, see struct wr_rd_match */
|
ddsrt_avl_tree_t local_readers; /* all matching LOCAL readers, see struct wr_rd_match */
|
||||||
#ifdef DDSI_INCLUDE_NETWORK_PARTITIONS
|
#ifdef DDSI_INCLUDE_NETWORK_PARTITIONS
|
||||||
|
@ -356,8 +356,8 @@ struct proxy_writer {
|
||||||
struct entity_common e;
|
struct entity_common e;
|
||||||
struct proxy_endpoint_common c;
|
struct proxy_endpoint_common c;
|
||||||
ddsrt_avl_tree_t readers; /* matching LOCAL readers, see pwr_rd_match */
|
ddsrt_avl_tree_t readers; /* matching LOCAL readers, see pwr_rd_match */
|
||||||
int n_reliable_readers; /* number of those that are reliable */
|
int32_t n_reliable_readers; /* number of those that are reliable */
|
||||||
int n_readers_out_of_sync; /* number of those that require special handling (accepting historical data, waiting for historical data set to become complete) */
|
int32_t n_readers_out_of_sync; /* number of those that require special handling (accepting historical data, waiting for historical data set to become complete) */
|
||||||
seqno_t last_seq; /* highest known seq published by the writer, not last delivered */
|
seqno_t last_seq; /* highest known seq published by the writer, not last delivered */
|
||||||
uint32_t last_fragnum; /* last known frag for last_seq, or ~0u if last_seq not partial */
|
uint32_t last_fragnum; /* last known frag for last_seq, or ~0u if last_seq not partial */
|
||||||
nn_count_t nackfragcount; /* last nackfrag seq number */
|
nn_count_t nackfragcount; /* last nackfrag seq number */
|
||||||
|
|
|
@ -211,7 +211,12 @@ static ddsi_tran_conn_t ddsi_raweth_create_conn (ddsi_tran_factory_t fact, uint3
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uc = (ddsi_raweth_conn_t) ddsrt_malloc (sizeof (*uc));
|
if ((uc = (ddsi_raweth_conn_t) ddsrt_malloc (sizeof (*uc))) == NULL)
|
||||||
|
{
|
||||||
|
ddsrt_close(sock);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
memset (uc, 0, sizeof (*uc));
|
memset (uc, 0, sizeof (*uc));
|
||||||
uc->m_sock = sock;
|
uc->m_sock = sock;
|
||||||
uc->m_ifindex = addr.sll_ifindex;
|
uc->m_ifindex = addr.sll_ifindex;
|
||||||
|
@ -226,7 +231,7 @@ static ddsi_tran_conn_t ddsi_raweth_create_conn (ddsi_tran_factory_t fact, uint3
|
||||||
uc->m_base.m_disable_multiplexing_fn = 0;
|
uc->m_base.m_disable_multiplexing_fn = 0;
|
||||||
|
|
||||||
DDS_CTRACE (&fact->gv->logconfig, "ddsi_raweth_create_conn %s socket %d port %u\n", mcast ? "multicast" : "unicast", uc->m_sock, uc->m_base.m_base.m_port);
|
DDS_CTRACE (&fact->gv->logconfig, "ddsi_raweth_create_conn %s socket %d port %u\n", mcast ? "multicast" : "unicast", uc->m_sock, uc->m_base.m_base.m_port);
|
||||||
return uc ? &uc->m_base : NULL;
|
return &uc->m_base;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int isbroadcast(const nn_locator_t *loc)
|
static int isbroadcast(const nn_locator_t *loc)
|
||||||
|
|
|
@ -554,8 +554,9 @@ static ssize_t ddsi_tcp_conn_write (ddsi_tran_conn_t base, const nn_locator_t *d
|
||||||
|
|
||||||
/* If not connected attempt to conect */
|
/* If not connected attempt to conect */
|
||||||
|
|
||||||
if ((conn->m_sock == DDSRT_INVALID_SOCKET) && ! conn->m_base.m_server)
|
if (conn->m_sock == DDSRT_INVALID_SOCKET)
|
||||||
{
|
{
|
||||||
|
assert (!conn->m_base.m_server);
|
||||||
ddsi_tcp_conn_connect (conn, &msg);
|
ddsi_tcp_conn_connect (conn, &msg);
|
||||||
if (conn->m_sock == DDSRT_INVALID_SOCKET)
|
if (conn->m_sock == DDSRT_INVALID_SOCKET)
|
||||||
{
|
{
|
||||||
|
|
|
@ -265,7 +265,7 @@ void ddsi_threadmon_unregister_domain (struct ddsi_threadmon *sl, const struct q
|
||||||
dummy.gv = gv;
|
dummy.gv = gv;
|
||||||
struct threadmon_domain *tmdom = ddsrt_hh_lookup (sl->domains, &dummy);
|
struct threadmon_domain *tmdom = ddsrt_hh_lookup (sl->domains, &dummy);
|
||||||
assert (tmdom);
|
assert (tmdom);
|
||||||
ddsrt_hh_remove (sl->domains, tmdom);
|
(void) ddsrt_hh_remove (sl->domains, tmdom);
|
||||||
ddsrt_mutex_unlock (&sl->lock);
|
ddsrt_mutex_unlock (&sl->lock);
|
||||||
ddsrt_free (tmdom);
|
ddsrt_free (tmdom);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1012,6 +1012,8 @@ static size_t cfg_note_vsnprintf (struct cfg_note_buf *bb, const char *fmt, va_l
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void cfg_note_snprintf (struct cfg_note_buf *bb, const char *fmt, ...) ddsrt_attribute_format ((printf, 2, 3));
|
||||||
|
|
||||||
static void cfg_note_snprintf (struct cfg_note_buf *bb, const char *fmt, ...)
|
static void cfg_note_snprintf (struct cfg_note_buf *bb, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
/* The reason the 2nd call to os_vsnprintf is here and not inside
|
/* The reason the 2nd call to os_vsnprintf is here and not inside
|
||||||
|
@ -1123,6 +1125,8 @@ static size_t cfg_note (struct cfgst *cfgst, uint32_t cat, size_t bsz, const cha
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void cfg_warning (struct cfgst *cfgst, const char *fmt, ...) ddsrt_attribute_format ((printf, 2, 3));
|
||||||
|
|
||||||
static void cfg_warning (struct cfgst *cfgst, const char *fmt, ...)
|
static void cfg_warning (struct cfgst *cfgst, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
@ -1134,6 +1138,8 @@ static void cfg_warning (struct cfgst *cfgst, const char *fmt, ...)
|
||||||
} while (bsz > 0);
|
} while (bsz > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static enum update_result cfg_error (struct cfgst *cfgst, const char *fmt, ...) ddsrt_attribute_format ((printf, 2, 3));
|
||||||
|
|
||||||
static enum update_result cfg_error (struct cfgst *cfgst, const char *fmt, ...)
|
static enum update_result cfg_error (struct cfgst *cfgst, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
@ -1146,6 +1152,8 @@ static enum update_result cfg_error (struct cfgst *cfgst, const char *fmt, ...)
|
||||||
return URES_ERROR;
|
return URES_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void cfg_logelem (struct cfgst *cfgst, uint32_t sources, const char *fmt, ...) ddsrt_attribute_format ((printf, 3, 4));
|
||||||
|
|
||||||
static void cfg_logelem (struct cfgst *cfgst, uint32_t sources, const char *fmt, ...)
|
static void cfg_logelem (struct cfgst *cfgst, uint32_t sources, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
/* 89 = 1 + 2 + 31 + 1 + 10 + 2*22: the number of characters in
|
/* 89 = 1 + 2 + 31 + 1 + 10 + 2*22: the number of characters in
|
||||||
|
@ -1444,7 +1452,7 @@ static void pf_int64_unit (struct cfgst *cfgst, int64_t value, uint32_t sources,
|
||||||
}
|
}
|
||||||
assert (m > 0);
|
assert (m > 0);
|
||||||
assert (unit != NULL);
|
assert (unit != NULL);
|
||||||
cfg_logelem (cfgst, sources, "%lld %s", value / m, unit);
|
cfg_logelem (cfgst, sources, "%"PRId64" %s", value / m, unit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "dds/ddsrt/md5.h"
|
#include "dds/ddsrt/md5.h"
|
||||||
#include "dds/ddsrt/sync.h"
|
#include "dds/ddsrt/sync.h"
|
||||||
#include "dds/ddsrt/avl.h"
|
#include "dds/ddsrt/avl.h"
|
||||||
|
#include "dds/ddsrt/string.h"
|
||||||
#include "dds/ddsi/q_protocol.h"
|
#include "dds/ddsi/q_protocol.h"
|
||||||
#include "dds/ddsi/q_rtps.h"
|
#include "dds/ddsi/q_rtps.h"
|
||||||
#include "dds/ddsi/q_misc.h"
|
#include "dds/ddsi/q_misc.h"
|
||||||
|
@ -302,8 +303,8 @@ int spdp_write (struct participant *pp)
|
||||||
ps.prismtech_participant_version_info.flags |= NN_PRISMTECH_FL_PARTICIPANT_IS_DDSI2;
|
ps.prismtech_participant_version_info.flags |= NN_PRISMTECH_FL_PARTICIPANT_IS_DDSI2;
|
||||||
ddsrt_mutex_unlock (&pp->e.gv->privileged_pp_lock);
|
ddsrt_mutex_unlock (&pp->e.gv->privileged_pp_lock);
|
||||||
|
|
||||||
ddsrt_gethostname(node, sizeof(node)-1);
|
if (ddsrt_gethostname(node, sizeof(node)-1) < 0)
|
||||||
node[sizeof(node)-1] = '\0';
|
ddsrt_strlcpy (node, "unknown", sizeof (node));
|
||||||
size = strlen(node) + strlen(DDS_VERSION) + strlen(DDS_HOST_NAME) + strlen(DDS_TARGET_NAME) + 4; /* + ///'\0' */
|
size = strlen(node) + strlen(DDS_VERSION) + strlen(DDS_HOST_NAME) + strlen(DDS_TARGET_NAME) + 4; /* + ///'\0' */
|
||||||
ps.prismtech_participant_version_info.internals = ddsrt_malloc(size);
|
ps.prismtech_participant_version_info.internals = ddsrt_malloc(size);
|
||||||
(void) snprintf(ps.prismtech_participant_version_info.internals, size, "%s/%s/%s/%s", node, DDS_VERSION, DDS_HOST_NAME, DDS_TARGET_NAME);
|
(void) snprintf(ps.prismtech_participant_version_info.internals, size, "%s/%s/%s/%s", node, DDS_VERSION, DDS_HOST_NAME, DDS_TARGET_NAME);
|
||||||
|
|
|
@ -57,6 +57,8 @@ struct debug_monitor {
|
||||||
int stop;
|
int stop;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int cpf (ddsi_tran_conn_t conn, const char *fmt, ...) ddsrt_attribute_format ((printf, 2, 3));
|
||||||
|
|
||||||
static int cpf (ddsi_tran_conn_t conn, const char *fmt, ...)
|
static int cpf (ddsi_tran_conn_t conn, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
nn_locator_t loc;
|
nn_locator_t loc;
|
||||||
|
@ -110,7 +112,7 @@ static int print_addrset_if_notempty (ddsi_tran_conn_t conn, const char *prefix,
|
||||||
static int print_any_endpoint_common (ddsi_tran_conn_t conn, const char *label, const struct entity_common *e, const struct dds_qos *xqos)
|
static int print_any_endpoint_common (ddsi_tran_conn_t conn, const char *label, const struct entity_common *e, const struct dds_qos *xqos)
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
x += cpf (conn, " %s %x:%x:%x:%x ", label, PGUID (e->guid));
|
x += cpf (conn, " %s "PGUIDFMT" ", label, PGUID (e->guid));
|
||||||
if (xqos->present & QP_PARTITION)
|
if (xqos->present & QP_PARTITION)
|
||||||
{
|
{
|
||||||
if (xqos->partition.n > 1) cpf (conn, "{");
|
if (xqos->partition.n > 1) cpf (conn, "{");
|
||||||
|
@ -150,7 +152,7 @@ static int print_participants (struct thread_state1 * const ts1, struct q_global
|
||||||
while ((p = ephash_enum_participant_next (&e)) != NULL)
|
while ((p = ephash_enum_participant_next (&e)) != NULL)
|
||||||
{
|
{
|
||||||
ddsrt_mutex_lock (&p->e.lock);
|
ddsrt_mutex_lock (&p->e.lock);
|
||||||
x += cpf (conn, "pp %x:%x:%x:%x %s%s\n", PGUID (p->e.guid), p->e.name, p->is_ddsi2_pp ? " [ddsi2]" : "");
|
x += cpf (conn, "pp "PGUIDFMT" %s%s\n", PGUID (p->e.guid), p->e.name, p->is_ddsi2_pp ? " [ddsi2]" : "");
|
||||||
ddsrt_mutex_unlock (&p->e.lock);
|
ddsrt_mutex_unlock (&p->e.lock);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -169,7 +171,7 @@ static int print_participants (struct thread_state1 * const ts1, struct q_global
|
||||||
x += print_addrset_if_notempty (conn, " as", r->as, "\n");
|
x += print_addrset_if_notempty (conn, " as", r->as, "\n");
|
||||||
#endif
|
#endif
|
||||||
for (m = ddsrt_avl_iter_first (&rd_writers_treedef, &r->writers, &writ); m; m = ddsrt_avl_iter_next (&writ))
|
for (m = ddsrt_avl_iter_first (&rd_writers_treedef, &r->writers, &writ); m; m = ddsrt_avl_iter_next (&writ))
|
||||||
x += cpf (conn, " pwr %x:%x:%x:%x\n", PGUID (m->pwr_guid));
|
x += cpf (conn, " pwr "PGUIDFMT"\n", PGUID (m->pwr_guid));
|
||||||
ddsrt_mutex_unlock (&r->e.lock);
|
ddsrt_mutex_unlock (&r->e.lock);
|
||||||
}
|
}
|
||||||
ephash_enum_reader_fini (&er);
|
ephash_enum_reader_fini (&er);
|
||||||
|
@ -189,20 +191,20 @@ static int print_participants (struct thread_state1 * const ts1, struct q_global
|
||||||
ddsrt_mutex_lock (&w->e.lock);
|
ddsrt_mutex_lock (&w->e.lock);
|
||||||
print_endpoint_common (conn, "wr", &w->e, &w->c, w->xqos);
|
print_endpoint_common (conn, "wr", &w->e, &w->c, w->xqos);
|
||||||
whc_get_state(w->whc, &whcst);
|
whc_get_state(w->whc, &whcst);
|
||||||
x += cpf (conn, " whc [%lld,%lld] unacked %"PRIuSIZE"%s [%u,%u] seq %lld seq_xmit %lld cs_seq %lld\n",
|
x += cpf (conn, " whc [%"PRId64",%"PRId64"] unacked %"PRIuSIZE"%s [%"PRIu32",%"PRIu32"] seq %"PRId64" seq_xmit %"PRId64" cs_seq %"PRId64"\n",
|
||||||
whcst.min_seq, whcst.max_seq, whcst.unacked_bytes,
|
whcst.min_seq, whcst.max_seq, whcst.unacked_bytes,
|
||||||
w->throttling ? " THROTTLING" : "",
|
w->throttling ? " THROTTLING" : "",
|
||||||
w->whc_low, w->whc_high,
|
w->whc_low, w->whc_high,
|
||||||
w->seq, READ_SEQ_XMIT(w), w->cs_seq);
|
w->seq, READ_SEQ_XMIT(w), w->cs_seq);
|
||||||
if (w->reliable)
|
if (w->reliable)
|
||||||
{
|
{
|
||||||
x += cpf (conn, " hb %u ackhb %lld hb %lld wr %lld sched %lld #rel %d\n",
|
x += cpf (conn, " hb %"PRIu32" ackhb %"PRId64" hb %"PRId64" wr %"PRId64" sched %"PRId64" #rel %"PRId32"\n",
|
||||||
w->hbcontrol.hbs_since_last_write, w->hbcontrol.t_of_last_ackhb,
|
w->hbcontrol.hbs_since_last_write, w->hbcontrol.t_of_last_ackhb.v,
|
||||||
w->hbcontrol.t_of_last_hb, w->hbcontrol.t_of_last_write,
|
w->hbcontrol.t_of_last_hb.v, w->hbcontrol.t_of_last_write.v,
|
||||||
w->hbcontrol.tsched, w->num_reliable_readers);
|
w->hbcontrol.tsched.v, w->num_reliable_readers);
|
||||||
x += cpf (conn, " #acks %u #nacks %u #rexmit %u #lost %u #throttle %u\n",
|
x += cpf (conn, " #acks %"PRIu32" #nacks %"PRIu32" #rexmit %"PRIu32" #lost %"PRIu32" #throttle %"PRIu32"\n",
|
||||||
w->num_acks_received, w->num_nacks_received, w->rexmit_count, w->rexmit_lost_count, w->throttle_count);
|
w->num_acks_received, w->num_nacks_received, w->rexmit_count, w->rexmit_lost_count, w->throttle_count);
|
||||||
x += cpf (conn, " max-drop-seq %lld\n", writer_max_drop_seq (w));
|
x += cpf (conn, " max-drop-seq %"PRId64"\n", writer_max_drop_seq (w));
|
||||||
}
|
}
|
||||||
x += print_addrset_if_notempty (conn, " as", w->as, "\n");
|
x += print_addrset_if_notempty (conn, " as", w->as, "\n");
|
||||||
for (m = ddsrt_avl_iter_first (&wr_readers_treedef, &w->readers, &rdit); m; m = ddsrt_avl_iter_next (&rdit))
|
for (m = ddsrt_avl_iter_first (&wr_readers_treedef, &w->readers, &rdit); m; m = ddsrt_avl_iter_next (&rdit))
|
||||||
|
@ -212,7 +214,7 @@ static int print_participants (struct thread_state1 * const ts1, struct q_global
|
||||||
wr_prd_flags[1] = m->assumed_in_sync ? 's' : '.';
|
wr_prd_flags[1] = m->assumed_in_sync ? 's' : '.';
|
||||||
wr_prd_flags[2] = m->has_replied_to_hb ? 'a' : '.'; /* a = ack seen */
|
wr_prd_flags[2] = m->has_replied_to_hb ? 'a' : '.'; /* a = ack seen */
|
||||||
wr_prd_flags[3] = 0;
|
wr_prd_flags[3] = 0;
|
||||||
x += cpf (conn, " prd %x:%x:%x:%x %s @ %lld [%lld,%lld] #nacks %u\n",
|
x += cpf (conn, " prd "PGUIDFMT" %s @ %"PRId64" [%"PRId64",%"PRId64"] #nacks %"PRIu32"\n",
|
||||||
PGUID (m->prd_guid), wr_prd_flags, m->seq, m->min_seq, m->max_seq, m->rexmit_requests);
|
PGUID (m->prd_guid), wr_prd_flags, m->seq, m->min_seq, m->max_seq, m->rexmit_requests);
|
||||||
}
|
}
|
||||||
ddsrt_mutex_unlock (&w->e.lock);
|
ddsrt_mutex_unlock (&w->e.lock);
|
||||||
|
@ -235,7 +237,7 @@ static int print_proxy_participants (struct thread_state1 * const ts1, struct q_
|
||||||
while ((p = ephash_enum_proxy_participant_next (&e)) != NULL)
|
while ((p = ephash_enum_proxy_participant_next (&e)) != NULL)
|
||||||
{
|
{
|
||||||
ddsrt_mutex_lock (&p->e.lock);
|
ddsrt_mutex_lock (&p->e.lock);
|
||||||
x += cpf (conn, "proxypp %x:%x:%x:%x%s\n", PGUID (p->e.guid), p->is_ddsi2_pp ? " [ddsi2]" : "");
|
x += cpf (conn, "proxypp "PGUIDFMT"%s\n", PGUID (p->e.guid), p->is_ddsi2_pp ? " [ddsi2]" : "");
|
||||||
ddsrt_mutex_unlock (&p->e.lock);
|
ddsrt_mutex_unlock (&p->e.lock);
|
||||||
x += print_addrset (conn, " as data", p->as_default, "");
|
x += print_addrset (conn, " as data", p->as_default, "");
|
||||||
x += print_addrset (conn, " meta", p->as_default, "\n");
|
x += print_addrset (conn, " meta", p->as_default, "\n");
|
||||||
|
@ -253,7 +255,7 @@ static int print_proxy_participants (struct thread_state1 * const ts1, struct q_
|
||||||
ddsrt_mutex_lock (&r->e.lock);
|
ddsrt_mutex_lock (&r->e.lock);
|
||||||
print_proxy_endpoint_common (conn, "prd", &r->e, &r->c);
|
print_proxy_endpoint_common (conn, "prd", &r->e, &r->c);
|
||||||
for (m = ddsrt_avl_iter_first (&rd_writers_treedef, &r->writers, &writ); m; m = ddsrt_avl_iter_next (&writ))
|
for (m = ddsrt_avl_iter_first (&rd_writers_treedef, &r->writers, &writ); m; m = ddsrt_avl_iter_next (&writ))
|
||||||
x += cpf (conn, " wr %x:%x:%x:%x\n", PGUID (m->wr_guid));
|
x += cpf (conn, " wr "PGUIDFMT"\n", PGUID (m->wr_guid));
|
||||||
ddsrt_mutex_unlock (&r->e.lock);
|
ddsrt_mutex_unlock (&r->e.lock);
|
||||||
}
|
}
|
||||||
ephash_enum_proxy_reader_fini (&er);
|
ephash_enum_proxy_reader_fini (&er);
|
||||||
|
@ -271,20 +273,20 @@ static int print_proxy_participants (struct thread_state1 * const ts1, struct q_
|
||||||
continue;
|
continue;
|
||||||
ddsrt_mutex_lock (&w->e.lock);
|
ddsrt_mutex_lock (&w->e.lock);
|
||||||
print_proxy_endpoint_common (conn, "pwr", &w->e, &w->c);
|
print_proxy_endpoint_common (conn, "pwr", &w->e, &w->c);
|
||||||
x += cpf (conn, " last_seq %lld last_fragnum %u\n", w->last_seq, w->last_fragnum);
|
x += cpf (conn, " last_seq %"PRId64" last_fragnum %"PRIu32"\n", w->last_seq, w->last_fragnum);
|
||||||
for (m = ddsrt_avl_iter_first (&wr_readers_treedef, &w->readers, &rdit); m; m = ddsrt_avl_iter_next (&rdit))
|
for (m = ddsrt_avl_iter_first (&wr_readers_treedef, &w->readers, &rdit); m; m = ddsrt_avl_iter_next (&rdit))
|
||||||
{
|
{
|
||||||
x += cpf (conn, " rd %x:%x:%x:%x (nack %lld %lld)\n",
|
x += cpf (conn, " rd "PGUIDFMT" (nack %"PRId64" %"PRId64")\n",
|
||||||
PGUID (m->rd_guid), m->seq_last_nack, m->t_last_nack);
|
PGUID (m->rd_guid), m->seq_last_nack, m->t_last_nack.v);
|
||||||
switch (m->in_sync)
|
switch (m->in_sync)
|
||||||
{
|
{
|
||||||
case PRMSS_SYNC:
|
case PRMSS_SYNC:
|
||||||
break;
|
break;
|
||||||
case PRMSS_TLCATCHUP:
|
case PRMSS_TLCATCHUP:
|
||||||
x += cpf (conn, " tl-catchup end_of_tl_seq %lld\n", m->u.not_in_sync.end_of_tl_seq);
|
x += cpf (conn, " tl-catchup end_of_tl_seq %"PRId64"\n", m->u.not_in_sync.end_of_tl_seq);
|
||||||
break;
|
break;
|
||||||
case PRMSS_OUT_OF_SYNC:
|
case PRMSS_OUT_OF_SYNC:
|
||||||
x += cpf (conn, " out-of-sync end_of_tl_seq %lld\n", m->u.not_in_sync.end_of_tl_seq);
|
x += cpf (conn, " out-of-sync end_of_tl_seq %"PRId64"\n", m->u.not_in_sync.end_of_tl_seq);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1071,7 +1071,7 @@ static void handle_Heartbeat_helper (struct pwr_rd_match * const wn, struct hand
|
||||||
refseq = nn_reorder_next_seq (pwr->reorder) - 1;
|
refseq = nn_reorder_next_seq (pwr->reorder) - 1;
|
||||||
else
|
else
|
||||||
refseq = nn_reorder_next_seq (wn->u.not_in_sync.reorder) - 1;
|
refseq = nn_reorder_next_seq (wn->u.not_in_sync.reorder) - 1;
|
||||||
RSTTRACE (" "PGUIDFMT"@%"PRId64"%s", PGUID (wn->rd_guid), refseq, (wn->in_sync == PRMSS_SYNC) ? "(sync)" : (wn->in_sync == PRMSS_TLCATCHUP) ? "(tlcatchup)" : "");
|
RSTTRACE (" "PGUIDFMT"@%"PRId64"%s", PGUID (wn->rd_guid), refseq, (wn->in_sync == PRMSS_SYNC) ? "(sync)" : (wn->in_sync == PRMSS_TLCATCHUP) ? "(tlcatchup)" : "");
|
||||||
|
|
||||||
/* Reschedule AckNack transmit if deemed appropriate; unreliable
|
/* Reschedule AckNack transmit if deemed appropriate; unreliable
|
||||||
readers have acknack_xevent == NULL and can't do this.
|
readers have acknack_xevent == NULL and can't do this.
|
||||||
|
@ -2437,7 +2437,7 @@ static int handle_DataFrag (struct receiver_state *rst, nn_etime_t tnow, struct
|
||||||
payload_offset = submsg_offset + (unsigned) size;
|
payload_offset = submsg_offset + (unsigned) size;
|
||||||
|
|
||||||
begin = (msg->fragmentStartingNum - 1) * msg->fragmentSize;
|
begin = (msg->fragmentStartingNum - 1) * msg->fragmentSize;
|
||||||
if (msg->fragmentSize * msg->fragmentsInSubmessage > ((unsigned char *) msg + size - datap)) {
|
if ((uint32_t) msg->fragmentSize * msg->fragmentsInSubmessage > (uint32_t) ((unsigned char *) msg + size - datap)) {
|
||||||
/* this happens for the last fragment (which usually is short) --
|
/* this happens for the last fragment (which usually is short) --
|
||||||
and is included here merely as a sanity check, because that
|
and is included here merely as a sanity check, because that
|
||||||
would mean the computed endp1'd be larger than the sample
|
would mean the computed endp1'd be larger than the sample
|
||||||
|
|
|
@ -618,12 +618,23 @@ static void os_sockWaitsetNewSet (os_sockWaitsetSet * set)
|
||||||
set->n = 1;
|
set->n = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void os_sockWaitsetFreeSet (os_sockWaitsetSet * set)
|
||||||
|
{
|
||||||
|
ddsrt_free (set->fds);
|
||||||
|
ddsrt_free (set->conns);
|
||||||
|
}
|
||||||
|
|
||||||
static void os_sockWaitsetNewCtx (os_sockWaitsetCtx ctx)
|
static void os_sockWaitsetNewCtx (os_sockWaitsetCtx ctx)
|
||||||
{
|
{
|
||||||
os_sockWaitsetNewSet (&ctx->set);
|
os_sockWaitsetNewSet (&ctx->set);
|
||||||
FD_ZERO (&ctx->rdset);
|
FD_ZERO (&ctx->rdset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void os_sockWaitsetFreeCtx (os_sockWaitsetCtx ctx)
|
||||||
|
{
|
||||||
|
os_sockWaitsetFreeSet (&ctx->set);
|
||||||
|
}
|
||||||
|
|
||||||
os_sockWaitset os_sockWaitsetNew (void)
|
os_sockWaitset os_sockWaitsetNew (void)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
@ -642,40 +653,16 @@ os_sockWaitset os_sockWaitsetNew (void)
|
||||||
ws->pipe[0] = -1;
|
ws->pipe[0] = -1;
|
||||||
ws->pipe[1] = -1;
|
ws->pipe[1] = -1;
|
||||||
result = 0;
|
result = 0;
|
||||||
#elif defined(__VXWORKS__)
|
|
||||||
int make_pipe (int pfd[2])
|
|
||||||
{
|
|
||||||
char pipename[OSPL_PIPENAMESIZE];
|
|
||||||
int pipecount=0;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
snprintf ((char*)&pipename, sizeof(pipename), "/pipe/ospl%d", pipecount++ );
|
|
||||||
}
|
|
||||||
while ((result = pipeDevCreate ((char*) &pipename, 1, 1)) == -1 && os_getErrno() == EINVAL);
|
|
||||||
if (result != -1)
|
|
||||||
{
|
|
||||||
result = open ((char*) &pipename, O_RDWR, 0644);
|
|
||||||
if (result != -1)
|
|
||||||
{
|
|
||||||
ws->pipe[0] = result;
|
|
||||||
result = open ((char*) &pipename, O_RDWR, 0644);
|
|
||||||
if (result != -1)
|
|
||||||
{
|
|
||||||
ws->pipe[1] = result;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
close (ws->pipe[0]);
|
|
||||||
pipeDevDelete (pipename, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
result = make_pipe (ws->pipe);
|
result = make_pipe (ws->pipe);
|
||||||
#endif
|
#endif
|
||||||
assert (result != -1);
|
if (result == -1)
|
||||||
(void) result;
|
{
|
||||||
|
os_sockWaitsetFreeCtx (&ws->ctx);
|
||||||
|
os_sockWaitsetFreeSet (&ws->set);
|
||||||
|
ddsrt_free (ws);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
#if !defined(LWIP_SOCKET)
|
#if !defined(LWIP_SOCKET)
|
||||||
ws->set.fds[0] = ws->pipe[0];
|
ws->set.fds[0] = ws->pipe[0];
|
||||||
|
@ -685,8 +672,8 @@ os_sockWaitset os_sockWaitsetNew (void)
|
||||||
ws->set.conns[0] = NULL;
|
ws->set.conns[0] = NULL;
|
||||||
|
|
||||||
#if !defined(__VXWORKS__) && !defined(_WIN32) && !defined(LWIP_SOCKET)
|
#if !defined(__VXWORKS__) && !defined(_WIN32) && !defined(LWIP_SOCKET)
|
||||||
fcntl (ws->pipe[0], F_SETFD, fcntl (ws->pipe[0], F_GETFD) | FD_CLOEXEC);
|
(void) fcntl (ws->pipe[0], F_SETFD, fcntl (ws->pipe[0], F_GETFD) | FD_CLOEXEC);
|
||||||
fcntl (ws->pipe[1], F_SETFD, fcntl (ws->pipe[1], F_GETFD) | FD_CLOEXEC);
|
(void) fcntl (ws->pipe[1], F_SETFD, fcntl (ws->pipe[1], F_GETFD) | FD_CLOEXEC);
|
||||||
#endif
|
#endif
|
||||||
#if !defined(LWIP_SOCKET)
|
#if !defined(LWIP_SOCKET)
|
||||||
FD_SET (ws->set.fds[0], &ws->ctx.rdset);
|
FD_SET (ws->set.fds[0], &ws->ctx.rdset);
|
||||||
|
@ -707,17 +694,6 @@ static void os_sockWaitsetGrow (os_sockWaitsetSet * set)
|
||||||
set->fds = ddsrt_realloc (set->fds, set->sz * sizeof (*set->fds));
|
set->fds = ddsrt_realloc (set->fds, set->sz * sizeof (*set->fds));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void os_sockWaitsetFreeSet (os_sockWaitsetSet * set)
|
|
||||||
{
|
|
||||||
ddsrt_free (set->fds);
|
|
||||||
ddsrt_free (set->conns);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void os_sockWaitsetFreeCtx (os_sockWaitsetCtx ctx)
|
|
||||||
{
|
|
||||||
os_sockWaitsetFreeSet (&ctx->set);
|
|
||||||
}
|
|
||||||
|
|
||||||
void os_sockWaitsetFree (os_sockWaitset ws)
|
void os_sockWaitsetFree (os_sockWaitset ws)
|
||||||
{
|
{
|
||||||
#if defined(__VXWORKS__) && defined(__RTP__)
|
#if defined(__VXWORKS__) && defined(__RTP__)
|
||||||
|
|
|
@ -163,7 +163,7 @@ struct nn_xmsg *writer_hbcontrol_create_heartbeat (struct writer *wr, const stru
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const int n_unacked = wr->num_reliable_readers - root_rdmatch (wr)->num_reliable_readers_where_seq_equals_max;
|
const int32_t n_unacked = wr->num_reliable_readers - root_rdmatch (wr)->num_reliable_readers_where_seq_equals_max;
|
||||||
assert (n_unacked >= 0);
|
assert (n_unacked >= 0);
|
||||||
if (n_unacked == 0)
|
if (n_unacked == 0)
|
||||||
prd_guid = NULL;
|
prd_guid = NULL;
|
||||||
|
@ -182,7 +182,7 @@ struct nn_xmsg *writer_hbcontrol_create_heartbeat (struct writer *wr, const stru
|
||||||
ETRACE (wr, "multicasting ");
|
ETRACE (wr, "multicasting ");
|
||||||
else
|
else
|
||||||
ETRACE (wr, "unicasting to prd "PGUIDFMT" ", PGUID (*prd_guid));
|
ETRACE (wr, "unicasting to prd "PGUIDFMT" ", PGUID (*prd_guid));
|
||||||
ETRACE (wr, "(rel-prd %d seq-eq-max %d seq %"PRId64" maxseq %"PRId64")\n",
|
ETRACE (wr, "(rel-prd %"PRId32" seq-eq-max %"PRId32" seq %"PRId64" maxseq %"PRId64")\n",
|
||||||
wr->num_reliable_readers,
|
wr->num_reliable_readers,
|
||||||
ddsrt_avl_is_empty (&wr->readers) ? -1 : root_rdmatch (wr)->num_reliable_readers_where_seq_equals_max,
|
ddsrt_avl_is_empty (&wr->readers) ? -1 : root_rdmatch (wr)->num_reliable_readers_where_seq_equals_max,
|
||||||
wr->seq,
|
wr->seq,
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
#include "dds/ddsrt/retcode.h"
|
#include "dds/ddsrt/retcode.h"
|
||||||
|
#include "dds/ddsrt/static_assert.h"
|
||||||
|
|
||||||
static const char *retcodes[] = {
|
static const char *retcodes[] = {
|
||||||
"Success",
|
"Success",
|
||||||
|
@ -45,6 +46,7 @@ const char *dds_strretcode (dds_return_t rc)
|
||||||
{
|
{
|
||||||
const dds_return_t nretcodes = (dds_return_t) (sizeof (retcodes) / sizeof (retcodes[0]));
|
const dds_return_t nretcodes = (dds_return_t) (sizeof (retcodes) / sizeof (retcodes[0]));
|
||||||
const dds_return_t nxretcodes = (dds_return_t) (sizeof (xretcodes) / sizeof (xretcodes[0]));
|
const dds_return_t nxretcodes = (dds_return_t) (sizeof (xretcodes) / sizeof (xretcodes[0]));
|
||||||
|
DDSRT_STATIC_ASSERT (DDS_XRETCODE_BASE < 0);
|
||||||
/* Retcodes used to be positive, but return values from the API would be a negative
|
/* Retcodes used to be positive, but return values from the API would be a negative
|
||||||
and so there are/were/may be places outside the core library where dds_strretcode
|
and so there are/were/may be places outside the core library where dds_strretcode
|
||||||
is called with a -N for N a API return value, so ... play it safe and use the
|
is called with a -N for N a API return value, so ... play it safe and use the
|
||||||
|
@ -53,8 +55,8 @@ const char *dds_strretcode (dds_return_t rc)
|
||||||
rc = -rc;
|
rc = -rc;
|
||||||
if (rc >= 0 && rc < nretcodes)
|
if (rc >= 0 && rc < nretcodes)
|
||||||
return retcodes[rc];
|
return retcodes[rc];
|
||||||
else if (rc >= DDS_XRETCODE_BASE && rc < DDS_XRETCODE_BASE + nxretcodes)
|
else if (rc >= (-DDS_XRETCODE_BASE) && rc < (-DDS_XRETCODE_BASE) + nxretcodes)
|
||||||
return xretcodes[rc - DDS_XRETCODE_BASE];
|
return xretcodes[rc - (-DDS_XRETCODE_BASE)];
|
||||||
else
|
else
|
||||||
return "Unknown return code";
|
return "Unknown return code";
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#include "CUnit/Theory.h"
|
#include "CUnit/Theory.h"
|
||||||
#include "dds/ddsrt/environ.h"
|
#include "dds/ddsrt/environ.h"
|
||||||
|
@ -49,11 +50,13 @@ CU_Test(ddsrt_environ, setenv)
|
||||||
CU_ASSERT_EQUAL(rc, DDS_RETCODE_OK);
|
CU_ASSERT_EQUAL(rc, DDS_RETCODE_OK);
|
||||||
ptr = getenv(name);
|
ptr = getenv(name);
|
||||||
CU_ASSERT_PTR_NOT_NULL(ptr);
|
CU_ASSERT_PTR_NOT_NULL(ptr);
|
||||||
|
assert (ptr != NULL); /* for the benefit of clang's static analyzer */
|
||||||
CU_ASSERT_STRING_EQUAL(ptr, "bar");
|
CU_ASSERT_STRING_EQUAL(ptr, "bar");
|
||||||
/* Ensure value is copied into the environment. */
|
/* Ensure value is copied into the environment. */
|
||||||
value[2] = 'z';
|
value[2] = 'z';
|
||||||
ptr = getenv(name);
|
ptr = getenv(name);
|
||||||
CU_ASSERT_PTR_NOT_NULL(ptr);
|
CU_ASSERT_PTR_NOT_NULL(ptr);
|
||||||
|
assert (ptr != NULL); /* for the benefit of clang's static analyzer */
|
||||||
CU_ASSERT_STRING_EQUAL(ptr, "bar");
|
CU_ASSERT_STRING_EQUAL(ptr, "bar");
|
||||||
rc = ddsrt_setenv(name, "");
|
rc = ddsrt_setenv(name, "");
|
||||||
CU_ASSERT_EQUAL(rc, DDS_RETCODE_OK);
|
CU_ASSERT_EQUAL(rc, DDS_RETCODE_OK);
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
#include <assert.h>
|
||||||
#include "dds/ddsrt/cdtors.h"
|
#include "dds/ddsrt/cdtors.h"
|
||||||
#include "dds/ddsrt/ifaddrs.h"
|
#include "dds/ddsrt/ifaddrs.h"
|
||||||
#include "dds/ddsrt/retcode.h"
|
#include "dds/ddsrt/retcode.h"
|
||||||
|
@ -73,6 +74,7 @@ CU_Test(ddsrt_getifaddrs, ipv4)
|
||||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||||
for (ifa = ifa_root; ifa; ifa = ifa->next) {
|
for (ifa = ifa_root; ifa; ifa = ifa->next) {
|
||||||
CU_ASSERT_PTR_NOT_EQUAL_FATAL(ifa->addr, NULL);
|
CU_ASSERT_PTR_NOT_EQUAL_FATAL(ifa->addr, NULL);
|
||||||
|
assert (ifa->addr != NULL); /* for the benefit of clang's static analyzer */
|
||||||
CU_ASSERT_EQUAL(ifa->addr->sa_family, AF_INET);
|
CU_ASSERT_EQUAL(ifa->addr->sa_family, AF_INET);
|
||||||
if (ifa->addr->sa_family == AF_INET) {
|
if (ifa->addr->sa_family == AF_INET) {
|
||||||
if (ifa->flags & IFF_LOOPBACK) {
|
if (ifa->flags & IFF_LOOPBACK) {
|
||||||
|
@ -130,6 +132,7 @@ CU_Test(ddsrt_getifaddrs, ipv6)
|
||||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||||
for (ifa = ifa_root; ifa; ifa = ifa->next) {
|
for (ifa = ifa_root; ifa; ifa = ifa->next) {
|
||||||
CU_ASSERT_PTR_NOT_EQUAL_FATAL(ifa->addr, NULL);
|
CU_ASSERT_PTR_NOT_EQUAL_FATAL(ifa->addr, NULL);
|
||||||
|
assert (ifa->addr != NULL); /* for the benefit of clang's static analyzer */
|
||||||
CU_ASSERT_EQUAL(ifa->addr->sa_family, AF_INET6);
|
CU_ASSERT_EQUAL(ifa->addr->sa_family, AF_INET6);
|
||||||
if (ifa->addr->sa_family == AF_INET6) {
|
if (ifa->addr->sa_family == AF_INET6) {
|
||||||
have_ipv6 = 1;
|
have_ipv6 = 1;
|
||||||
|
@ -170,6 +173,7 @@ CU_Test(ddsrt_getifaddrs, ipv4_n_ipv6)
|
||||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
|
||||||
for (ifa = ifa_root; ifa; ifa = ifa->next) {
|
for (ifa = ifa_root; ifa; ifa = ifa->next) {
|
||||||
CU_ASSERT_PTR_NOT_EQUAL_FATAL(ifa->addr, NULL);
|
CU_ASSERT_PTR_NOT_EQUAL_FATAL(ifa->addr, NULL);
|
||||||
|
assert (ifa->addr != NULL); /* for the benefit of clang's static analyzer */
|
||||||
CU_ASSERT(ifa->addr->sa_family == AF_INET ||
|
CU_ASSERT(ifa->addr->sa_family == AF_INET ||
|
||||||
ifa->addr->sa_family == AF_INET6);
|
ifa->addr->sa_family == AF_INET6);
|
||||||
if (ifa->addr->sa_family == AF_INET) {
|
if (ifa->addr->sa_family == AF_INET) {
|
||||||
|
|
|
@ -254,11 +254,8 @@ CU_Test(dds_log, no_sink, .init=setup, .fini=teardown)
|
||||||
ptr = NULL;
|
ptr = NULL;
|
||||||
DDS_ERROR("foobaz\n");
|
DDS_ERROR("foobaz\n");
|
||||||
ret = fseek(fh, 0, SEEK_SET);
|
ret = fseek(fh, 0, SEEK_SET);
|
||||||
|
CU_ASSERT_EQUAL_FATAL(ret, 0);
|
||||||
CU_ASSERT_PTR_NULL(ptr);
|
CU_ASSERT_PTR_NULL(ptr);
|
||||||
if (ptr != NULL) {
|
|
||||||
ddsrt_free(ptr);
|
|
||||||
ptr = NULL;
|
|
||||||
}
|
|
||||||
buf[0]= '\0';
|
buf[0]= '\0';
|
||||||
cnt[1] = fread(buf, 1, sizeof(buf) - 1, fh);
|
cnt[1] = fread(buf, 1, sizeof(buf) - 1, fh);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
|
@ -29,9 +29,13 @@ static int test_sleep(int argi, int argc, char **argv)
|
||||||
argi++;
|
argi++;
|
||||||
if (argi < argc) {
|
if (argi < argc) {
|
||||||
long long dorment;
|
long long dorment;
|
||||||
ddsrt_strtoll(argv[argi], NULL, 0, &dorment);
|
if (ddsrt_strtoll(argv[argi], NULL, 0, &dorment) != DDS_RETCODE_OK || dorment < 0 || dorment > INT32_MAX) {
|
||||||
printf(" Process: sleep %d seconds.\n", (int)dorment);
|
printf(" Process: invalid --sleep argument.\n");
|
||||||
dds_sleepfor(DDS_SECS((int64_t)dorment));
|
return TEST_EXIT_WRONG_ARGS;
|
||||||
|
} else {
|
||||||
|
printf(" Process: sleep %d seconds.\n", (int)dorment);
|
||||||
|
dds_sleepfor(DDS_SECS((int64_t)dorment));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
printf(" Process: no --sleep value.\n");
|
printf(" Process: no --sleep value.\n");
|
||||||
return TEST_EXIT_WRONG_ARGS;
|
return TEST_EXIT_WRONG_ARGS;
|
||||||
|
|
|
@ -355,7 +355,7 @@ MPT_ProcessEntry (rwud,
|
||||||
size_t chkusz = 0;
|
size_t chkusz = 0;
|
||||||
if (!qget (chk, &chkud, &chkusz))
|
if (!qget (chk, &chkud, &chkusz))
|
||||||
MPT_ASSERT (0, "Check QoS: no %s present\n", qname);
|
MPT_ASSERT (0, "Check QoS: no %s present\n", qname);
|
||||||
MPT_ASSERT (chkusz == expusz && (expusz == 0 || memcmp (chkud, expud, expusz) == 0),
|
MPT_ASSERT (chkusz == expusz && (expusz == 0 || (chkud != NULL && memcmp (chkud, expud, expusz) == 0)),
|
||||||
"Retrieved %s differs from group data just set (%zu/%s vs %zu/%s)\n", qname,
|
"Retrieved %s differs from group data just set (%zu/%s vs %zu/%s)\n", qname,
|
||||||
chkusz, chkud ? (char *) chkud : "(null)", expusz, expud ? (char *) expud : "(null)");
|
chkusz, chkud ? (char *) chkud : "(null)", expusz, expud ? (char *) expud : "(null)");
|
||||||
dds_free (chkud);
|
dds_free (chkud);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue