(gras_msg_procdata_t) gras_libdata_by_id(gras_msg_libdata_id);
unsigned int cpt;
- xbt_assert0(msg_got, "msg_got is an output parameter");
+ xbt_assert(msg_got, "msg_got is an output parameter");
start = gras_os_time();
XBT_VERB("Waiting for message '%s' for %fs",
gras_msg_wait_ext_(timeout, msgt_want, NULL, NULL, NULL, &msg);
if (msgt_want->ctn_type) {
- xbt_assert1(payload,
+ xbt_assert(payload,
"Message type '%s' convey a payload that you must accept",
msgt_want->name);
} else {
- xbt_assert1(!payload,
+ xbt_assert(!payload,
"No payload was declared for message type '%s' (don't expect one)",
msgt_want->name);
}
&gras_msg_wait_or_filter, (void *) msgt_want, &msg);
if (msg.type->ctn_type) {
- xbt_assert1(payload,
+ xbt_assert(payload,
"Message type '%s' convey a payload you must accept",
msg.type->name);
}
{
if (msgtype->ctn_type) {
- xbt_assert1(payload,
+ xbt_assert(payload,
"Message type '%s' convey a payload you must provide",
msgtype->name);
} else {
- xbt_assert1(!payload,
+ xbt_assert(!payload,
"No payload was declared for message type '%s'",
msgtype->name);
}
*
* @sa gras_msg_handleall().
*/
-void gras_msg_handle(double timeOut)
+void gras_msg_handle(volatile double timeOut)
{
double untiltimer;
unsigned int cpt;
- int volatile ran_ok;
+ volatile int ran_ok;
s_gras_msg_t msg;
gras_msg_cb_t cb;
s_gras_msg_cb_ctx_t ctx;
- int timerexpected, timeouted;
+ volatile int timerexpected, timeouted;
xbt_ex_t e;
XBT_VERB("Handling message within the next %.2fs", timeOut);
/* get a message (from the queue or from the net) */
timeouted = 0;
- if (xbt_dynar_length(pd->msg_queue)) {
+ if (!xbt_dynar_is_empty(pd->msg_queue)) {
XBT_DEBUG("Get a message from the queue");
xbt_dynar_shift(pd->msg_queue, &msg);
} else {
/* we served a timer, we're done */
return;
} else {
- xbt_assert1(untiltimer > 0, "Negative timer (%f). I'm 'puzzeled'",
+ xbt_assert(untiltimer > 0, "Negative timer (%f). I'm 'puzzeled'",
untiltimer);
XBT_WARN
("No timer elapsed, in contrary to expectations (next in %f sec)",
ran_ok = 0;
TRY {
xbt_dynar_foreach(list->cbs, cpt, cb) {
+ volatile unsigned int cpt2 = cpt;
if (!ran_ok) {
XBT_DEBUG
("Use the callback #%d (@%p) for incomming msg '%s' (payload_size=%d)",
cpt + 1, cb, msg.type->name, msg.payl_size);
- if (!(*cb) (&ctx, msg.payl)) {
+ if (!cb(&ctx, msg.payl)) {
/* cb handled the message */
free(msg.payl);
ran_ok = 1;
}
}
+ cpt = cpt2;
}
}
CATCH(e) {
}
}
- xbt_assert1(!ctx.answer_due,
+ xbt_assert(!ctx.answer_due,
"Bug in user code: RPC callback to message '%s' didn't call gras_msg_rpcreturn",
msg.type->name);
if (ctx.answer_due)