- TRY(gras_trp_select(timeOut, &expeditor));
- TRY(gras_msg_recv(expeditor, &msgtype, &payload, &payload_size));
+ TRY {
+ expeditor = gras_trp_select(timeOut);
+ } CATCH(e) {
+ if (e.category != timeout_error)
+ RETHROW;
+ xbt_ex_free(e);
+ timeouted = 1;
+ }
+
+ if (!timeouted) {
+ TRY {
+ gras_msg_recv(expeditor, &msgtype, &payload, &payload_size);
+ } CATCH(e) {
+ RETHROW1("Error caught while receiving a message on select()ed socket %p: %s",
+ expeditor);
+ }
+ }
+ }
+
+ if (timeouted) {
+ if (timerexpected) {
+
+ /* 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) {
+ /* we served a timer, we're done */
+ return;
+ } else {
+ xbt_assert1(untiltimer>0, "Negative timer (%f). I'm 'puzzeled'", untiltimer);
+ WARN1("No timer elapsed, in contrary to expectations (next in %f sec)",
+ untiltimer);
+ THROW1(timeout_error,0,
+ "No timer elapsed, in contrary to expectations (next in %f sec)",
+ untiltimer);
+ }
+
+ } else {
+ /* select timeouted, and no timer elapsed. Nothing to do */
+ THROW0(timeout_error, 0, "No new message or timer");
+ }
+