* under the terms of the license (GNU LGPL) which comes with this package. */
#include "xbt/ex.h"
+#include "xbt/xbt_socket_private.h" /* FIXME */
#include "portable.h"
#include "gras/Transport/transport_private.h"
+
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(gras_trp);
/* check transport_private.h for an explanation of this variable */
-gras_socket_t _gras_lastly_selected_socket = NULL;
+xbt_socket_t _gras_lastly_selected_socket = NULL;
/**
* gras_trp_select:
*
* if timeout>0 and no message there, wait at most that amount of time before giving up.
*/
-gras_socket_t gras_trp_select(double timeout)
+xbt_socket_t gras_trp_select(double timeout)
{
xbt_dynar_t sockets =
((gras_trp_procdata_t)
int ready; /* return of select: number of socket ready to be serviced */
static int fd_setsize = -1; /* FD_SETSIZE not always defined. Get this portably */
- gras_socket_t sock_iter; /* iterating over all sockets */
+ xbt_socket_t sock_iter; /* iterating over all sockets */
unsigned int cursor; /* iterating over all sockets */
/* Check whether there is more data to read from the socket we selected last time.
XBT_DEBUG("wakeup=%f now=%f", wakeup, now);
if (now == -1 || now >= wakeup) {
/* didn't find anything; no need to update _gras_lastly_selected_socket since its moredata is 0 (or we would have returned it directly) */
- THROW1(timeout_error, 0,
- "Timeout (%f) elapsed with selecting for incomming connexions",
+ THROWF(timeout_error, 0,
+ "Timeout (%f) elapsed with selecting for incoming connections",
timeout);
}
}
continue;
if (sock_iter->incoming) {
- XBT_DEBUG("Considering socket %d for select", sock_iter->sd);
+ //XBT_DEBUG("Considering socket %d for select", sock_iter->sd);
#ifndef HAVE_WINSOCK_H
if (max_fds < sock_iter->sd)
max_fds = sock_iter->sd;
if (timeout > 0) {
XBT_DEBUG("No socket to select onto. Sleep %f sec instead.", timeout);
gras_os_sleep(timeout);
- THROW1(timeout_error, 0,
+ THROWF(timeout_error, 0,
"No socket to select onto. Sleep %f sec instead", timeout);
} else {
XBT_DEBUG("No socket to select onto. Return directly.");
- THROW0(timeout_error, 0,
+ THROWF(timeout_error, 0,
"No socket to select onto. Return directly.");
}
}
/* if we cared, we would have set an handler */
continue;
case EINVAL: /* invalid value */
- THROW3(system_error, EINVAL,
+ THROWF(system_error, EINVAL,
"invalid select: nb fds: %d, timeout: %d.%d", max_fds,
(int) tout.tv_sec, (int) tout.tv_usec);
case ENOMEM:
xbt_die("Malloc error during the select");
default:
- THROW2(system_error, errno, "Error during select: %s (%d)",
+ THROWF(system_error, errno, "Error during select: %s (%d)",
strerror(errno), errno);
}
THROW_IMPOSSIBLE;
if (sock_iter->accepting && sock_iter->plugin->socket_accept) {
/* not a socket but an ear. accept on it and serve next socket */
- gras_socket_t accepted = NULL;
+ xbt_socket_t accepted = NULL;
/* release mutex before accept; it will change the sockets dynar, so we have to break the foreach asap */
xbt_dynar_cursor_unlock(sockets);
/* No socket found. Maybe we had timeout=0 and nothing to do */
XBT_DEBUG("TIMEOUT");
- THROW0(timeout_error, 0, "Timeout");
+ THROWF(timeout_error, 0, "Timeout");
}
-void gras_trp_sg_setup(gras_trp_plugin_t plug)
+/* to make the linker happy in SG mode */
+void gras_trp_sg_setup(xbt_trp_plugin_t plug)
{
- THROW0(mismatch_error, 0, "No SG transport on live platforms");
+ THROWF(mismatch_error, 0, "No SG transport on live platforms");
}