X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/2472771bffee0a2c29b69a2e2b6206f0bb819af1..2d16ebcee6bde01575b4cd88a853e1ac1c2532bf:/examples/gras/p2p/chord/chord.c diff --git a/examples/gras/p2p/chord/chord.c b/examples/gras/p2p/chord/chord.c index 7060096d6a..528db0cec0 100644 --- a/examples/gras/p2p/chord/chord.c +++ b/examples/gras/p2p/chord/chord.c @@ -23,7 +23,7 @@ typedef enum msg_typus { STD, } msg_typus; -/*GRAS_DEFINE_TYPE(s_pbio, +/*XBT_DEFINE_TYPE(s_pbio, struct s_pbio{ msg_typus type; int dest; @@ -32,14 +32,14 @@ typedef enum msg_typus { ); typedef struct s_pbio pbio_t;*/ -/*GRAS_DEFINE_TYPE(s_ping,*/ +/*XBT_DEFINE_TYPE(s_ping,*/ struct s_ping { int id; }; /*);*/ typedef struct s_ping ping_t; -/*GRAS_DEFINE_TYPE(s_pong,*/ +/*XBT_DEFINE_TYPE(s_pong,*/ struct s_pong { int id; int failed; @@ -47,17 +47,17 @@ struct s_pong { /*);*/ typedef struct s_pong pong_t; -GRAS_DEFINE_TYPE(s_notify, struct s_notify { +XBT_DEFINE_TYPE(s_notify, struct s_notify { int id; char host[1024]; int port;};); typedef struct s_notify notify_t; -GRAS_DEFINE_TYPE(s_get_suc, struct s_get_suc { +XBT_DEFINE_TYPE(s_get_suc, struct s_get_suc { int id;};); typedef struct s_get_suc get_suc_t; -GRAS_DEFINE_TYPE(s_rep_suc, struct s_rep_suc { +XBT_DEFINE_TYPE(s_rep_suc, struct s_rep_suc { int id; char host[1024]; int port;};); typedef struct s_rep_suc rep_suc_t; @@ -72,17 +72,17 @@ typedef struct finger_elem { static void register_messages() { -/* gras_msgtype_declare("chord",gras_datadesc_by_symbol(s_pbio));*/ +/* gras_msgtype_declare("chord",xbt_datadesc_by_symbol(s_pbio));*/ gras_msgtype_declare("chord_get_suc", - gras_datadesc_by_symbol(s_get_suc)); + xbt_datadesc_by_symbol(s_get_suc)); gras_msgtype_declare("chord_rep_suc", - gras_datadesc_by_symbol(s_rep_suc)); - gras_msgtype_declare("chord_notify", gras_datadesc_by_symbol(s_notify)); + xbt_datadesc_by_symbol(s_rep_suc)); + gras_msgtype_declare("chord_notify", xbt_datadesc_by_symbol(s_notify)); } /* Global private data */ typedef struct { - gras_socket_t sock; /* server socket on which I'm listening */ + xbt_socket_t sock; /* server socket on which I'm listening */ int id; /* my id number */ char host[1024]; /* my host name */ int port; /* port on which I'm listening FIXME */ @@ -97,13 +97,13 @@ typedef struct { int node(int argc, char **argv); -/*static int node_cb_chord_handler(gras_socket_t expeditor,void *payload_data){ +/*static int node_cb_chord_handler(xbt_socket_t expeditor,void *payload_data){ xbt_ex_t e; pbio_t pbio_i=*(pbio_t*)payload_data; node_data_t *globals=(node_data_t*)gras_userdata_get(); - XBT_INFO(">>> %d : received %d message from %s to %d <<<",globals->id,pbio_i.type,gras_socket_peer_name(expeditor),pbio_i.dest); + XBT_INFO(">>> %d : received %d message from %s to %d <<<",globals->id,pbio_i.type,xbt_socket_peer_name(expeditor),pbio_i.dest); @@ -112,12 +112,12 @@ int node(int argc, char **argv); static int node_cb_get_suc_handler(gras_msg_cb_ctx_t ctx, void *payload_data) { - gras_socket_t expeditor = gras_msg_cb_ctx_from(ctx); + xbt_socket_t expeditor = gras_msg_cb_ctx_from(ctx); get_suc_t incoming = *(get_suc_t *) payload_data; rep_suc_t outgoing; node_data_t *globals = (node_data_t *) gras_userdata_get(); XBT_INFO("Received a get_successor message from %s for %d", - gras_socket_peer_name(expeditor), incoming.id); + xbt_socket_peer_name(expeditor), incoming.id); if ((globals->id == globals->finger[0].id) || (incoming.id > globals->id && incoming.id <= globals->finger[0].id)) { @@ -126,7 +126,7 @@ static int node_cb_get_suc_handler(gras_msg_cb_ctx_t ctx, outgoing.port = globals->finger[0].port; XBT_INFO("My successor is his successor!"); } else { - gras_socket_t temp_sock; + xbt_socket_t temp_sock; int contact = closest_preceding_node(incoming.id); if (contact == -1) { outgoing.id = globals->finger[0].id; @@ -159,7 +159,7 @@ static int node_cb_get_suc_handler(gras_msg_cb_ctx_t ctx, } CATCH_ANONYMOUS { RETHROWF("%s:Timeout sending successor information to %s: %s", - globals->host, gras_socket_peer_name(expeditor)); + globals->host, xbt_socket_peer_name(expeditor)); } gras_socket_close(expeditor); return 0; @@ -181,12 +181,12 @@ static int closest_preceding_node(int id) static int node_cb_notify_handler(gras_msg_cb_ctx_t ctx, void *payload_data) { - gras_socket_t expeditor = gras_msg_cb_ctx_from(ctx); + xbt_socket_t expeditor = gras_msg_cb_ctx_from(ctx); /*xbt_ex_t e; */ notify_t incoming = *(notify_t *) payload_data; node_data_t *globals = (node_data_t *) gras_userdata_get(); XBT_INFO("Received a notifying message from %s as %d", - gras_socket_peer_name(expeditor), incoming.id); + xbt_socket_peer_name(expeditor), incoming.id); if (globals->pre_id == -1 || (incoming.id > globals->pre_id && incoming.id < globals->id)) { globals->pre_id = incoming.id; @@ -200,8 +200,8 @@ static int node_cb_notify_handler(gras_msg_cb_ctx_t ctx, static void fix_fingers() { get_suc_t get_suc_msg; - gras_socket_t temp_sock = NULL; - gras_socket_t temp_sock2 = NULL; + xbt_socket_t temp_sock = NULL; + xbt_socket_t temp_sock2 = NULL; rep_suc_t rep_suc_msg; node_data_t *globals = (node_data_t *) gras_userdata_get(); @@ -241,7 +241,7 @@ static void fix_fingers() static void check_predecessor() { node_data_t *globals = (node_data_t *) gras_userdata_get(); - gras_socket_t temp_sock; + xbt_socket_t temp_sock; ping_t ping; pong_t pong; xbt_ex_t e; @@ -283,8 +283,8 @@ static void check_predecessor() int node(int argc, char **argv) { node_data_t *globals = NULL; - gras_socket_t temp_sock = NULL; - gras_socket_t temp_sock2 = NULL; + xbt_socket_t temp_sock = NULL; + xbt_socket_t temp_sock2 = NULL; get_suc_t get_suc_msg; rep_suc_t rep_suc_msg;