- TRY(gras_trp_select(timeOut, &expeditor));
- TRY(gras_msg_recv(expeditor, &msgtype, &payload, &payload_size));
+ errcode = gras_trp_select(MIN(timeOut,untiltimer), &expeditor);
+ if (errcode != no_error && errcode != timeout_error)
+ return errcode;
+ if (errcode != timeout_error)
+ TRY(gras_msg_recv(expeditor, &msgtype, &payload, &payload_size));
+ }
+
+ if (errcode == timeout_error && untiltimer < timeOut) {
+ /* A timer elapsed before the arrival of any message even if we select()ed a bit */
+ untiltimer = gras_msg_timer_handle();
+ if (untiltimer == 0.0) {
+ return no_error;
+ } else {
+ WARN1("Weird. I computed that a timer should elapse shortly, but none did (I still should wait %f sec)",
+ untiltimer);
+ return timeout_error;
+ }