/* Global private data */
typedef struct {
- gras_socket_t sock; /* server socket on which I hear */
+ xbt_socket_t sock; /* server socket on which I hear */
int remaining_loop; /* number of loops to do until done */
int create; /* whether I have to create the token */
- gras_socket_t tosuccessor; /* how to connect to the successor on ring */
+ xbt_socket_t tosuccessor; /* how to connect to the successor on ring */
double start_time; /* to measure the elapsed time. Only used by the
node that creates the token */
} node_data_t;
/* Callback function */
static int node_cb_stoken_handler(gras_msg_cb_ctx_t ctx, void *payload)
{
-
- xbt_ex_t e;
-
/* 1. Get the payload into the msg variable, and retrieve my caller */
int msg = *(int *) payload;
- gras_socket_t expeditor = gras_msg_cb_ctx_from(ctx);
+ xbt_socket_t expeditor = gras_msg_cb_ctx_from(ctx);
/* 2. Retrieve the node's state (globals) */
XBT_INFO("Begin a new loop. Still to do: %d", globals->remaining_loop);
} else if (!(globals->remaining_loop % supersteps)) {
XBT_VERB("Got token(%d) from %s remaining_loop=%d",
- msg, gras_socket_peer_name(expeditor), globals->remaining_loop);
+ msg, xbt_socket_peer_name(expeditor), globals->remaining_loop);
}
/* 4. If the right shouldn't be stopped yet */
msg += 1;
XBT_DEBUG("Send token(%d) to %s:%d", msg,
- gras_socket_peer_name(globals->tosuccessor),
- gras_socket_peer_port(globals->tosuccessor));
+ xbt_socket_peer_name(globals->tosuccessor),
+ xbt_socket_peer_port(globals->tosuccessor));
/* 5. Send the token as payload of a stoken message to the successor */
TRY {
/* 6. Deal with errors */
}
- CATCH(e) {
+ CATCH_ANONYMOUS {
gras_socket_close(globals->sock);
- RETHROW0("Unable to forward token: %s");
+ RETHROWF("Unable to forward token: %s");
}
}
int myport;
int peerport;
- xbt_ex_t e;
-
/* 1. Init the GRAS infrastructure and declare my globals */
gras_init(&argc, argv);
globals = gras_userdata_new(node_data_t);
myport, host, peerport);
/* 4. Register the known messages. */
- gras_msgtype_declare("stoken", gras_datadesc_by_name("int"));
+ gras_msgtype_declare("stoken", xbt_datadesc_by_name("int"));
/* 5. Create my master socket for listening */
globals->sock = gras_socket_server(myport);
TRY {
gras_msg_send(globals->tosuccessor, "stoken", &token);
- } CATCH(e) {
- RETHROW0("Unable to send the freshly created token: %s");
+ }
+ CATCH_ANONYMOUS {
+ RETHROWF("Unable to send the freshly created token: %s");
}
}
- /* 8. Wait up to 10 seconds for an incomming message to handle */
+ /* 8. Wait up to 10 seconds for an incoming message to handle */
while (globals->remaining_loop > (globals->create ? -1 : 0)) {
gras_msg_handle(-1);