Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
If the timeout is negative, the user wants to block
[simgrid.git] / src / gras / Transport / sg_transport.c
index 50b7dfe..b77eae4 100644 (file)
@@ -36,20 +36,19 @@ gras_socket_t gras_trp_select(double timeout) {
   gras_socket_t active_socket = NULL;
   gras_trp_sg_sock_data_t *active_socket_data;
   gras_socket_t sock_iter; /* iterating over all sockets */
-       xbt_ex_t e;
   int cursor;
 
   DEBUG3("select on %s@%s with timeout=%f",
         SIMIX_process_get_name(SIMIX_process_self()),
         SIMIX_host_get_name(SIMIX_host_self()),
         timeout);
-
-       TRY {
-               xbt_queue_shift_timed(pd->msg_selectable_sockets,
-                                                               &active_socket, timeout);
-       } CATCH(e) {
-               RETHROW;
-       }
+   if (timeout>=0) {
+      xbt_queue_shift_timed(pd->msg_selectable_sockets,
+                           &active_socket, timeout);
+   } else {
+      xbt_queue_shift(pd->msg_selectable_sockets, &active_socket);
+   }
+   
   if (active_socket == NULL) {
     DEBUG0("TIMEOUT");
     THROW0(timeout_error,0,"Timeout");
@@ -70,6 +69,7 @@ gras_socket_t gras_trp_select(double timeout) {
 
     if ( (sock_data->to_socket == active_socket) && 
         (sock_data->to_host == SIMIX_process_get_host(active_socket_data->from_process)) ) {
+                       xbt_dynar_cursor_unlock(pd->sockets);   
       return sock_iter;
     }
   }