-/* $Id$ */
-
/* rl_transport - RL specific functions for transport */
-/* Copyright (c) 2004 Martin Quinson. All rights reserved. */
+/* Copyright (c) 2004, 2005, 2006, 2007, 2009, 2010. The SimGrid Team.
+ * All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
gras_socket_t gras_trp_select(double timeout)
{
xbt_dynar_t sockets =
- ((gras_trp_procdata_t) gras_libdata_by_id(gras_trp_libdata_id))->sockets;
+ ((gras_trp_procdata_t)
+ gras_libdata_by_id(gras_trp_libdata_id))->sockets;
int done = -1;
double wakeup = gras_os_time() + timeout;
double now = 0;
/* Check whether there is more data to read from the socket we selected last time.
This can happen with tcp buffered sockets since we try to get as much data as we can for them */
- if (_gras_lastly_selected_socket && _gras_lastly_selected_socket->moredata) {
+ if (_gras_lastly_selected_socket
+ && _gras_lastly_selected_socket->moredata) {
VERB0
- ("Returning _gras_lastly_selected_socket since there is more data on it");
+ ("Returning _gras_lastly_selected_socket since there is more data on it");
return _gras_lastly_selected_socket;
}
fd_setsize = getdtablesize();
# else
fd_setsize = FD_SETSIZE;
-# endif /* !USE_SYSCONF */
+# endif /* !USE_SYSCONF */
#endif
}
max_fds = fd_setsize;
#endif
+ tout.tv_sec = tout.tv_usec = 0;
if (timeout > 0) {
/* set the timeout */
tout.tv_sec = (unsigned long) (wakeup - now);
tout.tv_usec =
- ((wakeup - now) - ((unsigned long) (wakeup - now))) * 1000000;
+ ((wakeup - now) - ((unsigned long) (wakeup - now))) * 1000000;
p_tout = &tout;
} else if (timeout == 0) {
/* polling only */
p_tout = NULL;
}
- DEBUG2("Selecting over %d socket(s); timeout=%f", max_fds - 1, timeout);
+ DEBUG2("Selecting over %d socket(s); timeout=%f", max_fds - 1,
+ timeout);
ready = select(max_fds, &FDS, NULL, NULL, p_tout);
DEBUG1("select returned %d", ready);
if (ready == -1) {