Fix rtps_start error handling on thread creation
Signed-off-by: Erik Boasson <eb@ilities.com> Use static assert instead of run-time assert Signed-off-by: Erik Boasson <eb@ilities.com> Use static assertion to verify nn_rmsg offset calc Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
parent
9a3a377327
commit
482e1cd006
4 changed files with 16 additions and 6 deletions
|
@ -167,6 +167,7 @@ static dds_entity_t dds_domain_init (dds_domain *domain, dds_domainid_t domain_i
|
||||||
return domh;
|
return domh;
|
||||||
|
|
||||||
fail_rtps_start:
|
fail_rtps_start:
|
||||||
|
dds__builtin_fini (domain);
|
||||||
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);
|
||||||
fail_threadmon_start:
|
fail_threadmon_start:
|
||||||
|
|
|
@ -98,6 +98,7 @@ struct nn_rmsg {
|
||||||
|
|
||||||
struct nn_rmsg_chunk chunk;
|
struct nn_rmsg_chunk chunk;
|
||||||
};
|
};
|
||||||
|
DDSRT_STATIC_ASSERT (sizeof (struct nn_rmsg) == offsetof (struct nn_rmsg, chunk) + sizeof (struct nn_rmsg_chunk));
|
||||||
#define NN_RMSG_PAYLOAD(m) ((unsigned char *) (m + 1))
|
#define NN_RMSG_PAYLOAD(m) ((unsigned char *) (m + 1))
|
||||||
#define NN_RMSG_PAYLOADOFF(m, o) (NN_RMSG_PAYLOAD (m) + (o))
|
#define NN_RMSG_PAYLOADOFF(m, o) (NN_RMSG_PAYLOAD (m) + (o))
|
||||||
|
|
||||||
|
|
|
@ -1454,13 +1454,22 @@ int rtps_start (struct q_globals *gv)
|
||||||
if (gv->listener)
|
if (gv->listener)
|
||||||
{
|
{
|
||||||
if (create_thread (&gv->listen_ts, gv, "listen", (uint32_t (*) (void *)) listen_thread, gv->listener) != DDS_RETCODE_OK)
|
if (create_thread (&gv->listen_ts, gv, "listen", (uint32_t (*) (void *)) listen_thread, gv->listener) != DDS_RETCODE_OK)
|
||||||
GVERROR ("rtps_start: can't create listener thread\n");
|
{
|
||||||
/* FIXME: error handling */
|
GVERROR ("failed to create TCP listener thread\n");
|
||||||
|
ddsi_listener_free (gv->listener);
|
||||||
|
gv->listener = NULL;
|
||||||
|
rtps_stop (gv);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (gv->config.monitor_port >= 0)
|
if (gv->config.monitor_port >= 0)
|
||||||
{
|
{
|
||||||
gv->debmon = new_debug_monitor (gv, gv->config.monitor_port);
|
if ((gv->debmon = new_debug_monitor (gv, gv->config.monitor_port)) == NULL)
|
||||||
/* FIXME: clean up */
|
{
|
||||||
|
GVERROR ("failed to create debug monitor thread\n");
|
||||||
|
rtps_stop (gv);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -2894,8 +2894,7 @@ static bool do_packet (struct thread_state1 * const ts1, struct q_globals *gv, d
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(sizeof(struct nn_rmsg) == offsetof(struct nn_rmsg, chunk) + sizeof(struct nn_rmsg_chunk));
|
DDSRT_STATIC_ASSERT (sizeof (struct nn_rmsg) == offsetof (struct nn_rmsg, chunk) + sizeof (struct nn_rmsg_chunk));
|
||||||
|
|
||||||
buff = (unsigned char *) NN_RMSG_PAYLOAD (rmsg);
|
buff = (unsigned char *) NN_RMSG_PAYLOAD (rmsg);
|
||||||
hdr = (Header_t*) buff;
|
hdr = (Header_t*) buff;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue