From 0aa689099c18a92ec871b1dd0ec1b77825094edd Mon Sep 17 00:00:00 2001 From: mquinson Date: Wed, 15 Mar 2006 16:29:16 +0000 Subject: [PATCH] Let it compile on my box git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@1947 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- examples/gras/p2p/chord/chord.c | 39 ++++++++++++++++++------------ examples/gras/p2p/chord/chord.h | 13 +++++----- examples/gras/p2p/chord/test_sg.in | 6 ++--- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/examples/gras/p2p/chord/chord.c b/examples/gras/p2p/chord/chord.c index 37d061e5df..b74944e071 100644 --- a/examples/gras/p2p/chord/chord.c +++ b/examples/gras/p2p/chord/chord.c @@ -4,6 +4,14 @@ #include "chord.h" +static int closest_preceding_node(int id); +static void check_predecessor(void); + +XBT_LOG_NEW_DEFAULT_CATEGORY(chord,"Messages specific to this example"); + + + + static void register_messages(){ /* gras_msgtype_declare("chord",gras_datadesc_by_symbol(s_pbio));*/ gras_msgtype_declare("chord_get_suc",gras_datadesc_by_symbol(s_get_suc)); @@ -55,12 +63,12 @@ static int node_cb_get_suc_handler(gras_socket_t expeditor,void *payload_data){ TRY{ temp_sock=gras_socket_client(globals->finger[contact].host,globals->finger[contact].port); }CATCH(e){ - RETHROW0("Unable to connect!"); + RETHROW0("Unable to connect!: %s"); } TRY{ gras_msg_send(temp_sock,gras_msgtype_by_name("chord_get_suc"),&asking); }CATCH(e){ - RETHROW0("Unable to ask!"); + RETHROW0("Unable to ask!: %s"); } gras_msg_wait(10.0,gras_msgtype_by_name("chord_rep_suc"),&temp_sock,&outgoing); } @@ -69,13 +77,13 @@ static int node_cb_get_suc_handler(gras_socket_t expeditor,void *payload_data){ gras_msg_send(expeditor,gras_msgtype_by_name("chord_rep_suc"),&outgoing); INFO0("Successor information sent!"); }CATCH(e){ - RETHROW2("%s:Timeout sending successor information to %s",globals->host,gras_socket_peer_name(expeditor)); + RETHROW2("%s:Timeout sending successor information to %s: %s",globals->host,gras_socket_peer_name(expeditor)); } gras_socket_close(expeditor); return(1); } -int closest_preceding_node(int id){ +static int closest_preceding_node(int id){ node_data_t *globals=(node_data_t*)gras_userdata_get(); int i; for(i=globals->fingers-1;i>=0;i--){ @@ -87,10 +95,10 @@ int closest_preceding_node(int id){ } -void check_predecessor() -{ -node_data_t *globals = (node_data_t*)gras_userdata_get(); -gras_socket_t temp_sock; +static void check_predecessor() { + node_data_t *globals = (node_data_t*)gras_userdata_get(); + gras_socket_t temp_sock; + xbt_ex_t e; if (globals->pre_host[0] == 0) { return; @@ -106,7 +114,7 @@ CATCH(e) } ping_t ping_kong; pong_t king_pong; -ping_kong->id = 0; +ping_kong.id = 0; TRY { gras_msg_send( temp_sock, gras_msgtype_by_name("chord_ping"),&ping_kong); @@ -130,12 +138,13 @@ gras_socket_close(temp_sock); int node(int argc,char **argv){ node_data_t *globals=NULL; - gras_socket_t temp_sock,temp_sock2; + gras_socket_t temp_sock=NULL; + gras_socket_t temp_sock2=NULL; xbt_ex_t e; int create=0; - int other_port; + int other_port=-1; char *other_host; /* 1. Init the GRAS infrastructure and declare my globals */ @@ -154,7 +163,7 @@ int node(int argc,char **argv){ if(argc==3){ create=1; }else{ - other_host=strndup(argv[3],1024); + asprintf(&other_host,"%s",argv[3]); other_port=atoi(argv[4]); } @@ -177,21 +186,21 @@ int node(int argc,char **argv){ TRY{ temp_sock=gras_socket_client(other_host,other_port); }CATCH(e){ - RETHROW0("Unable to contact known host!"); + RETHROW0("Unable to contact known host!: %s"); } get_suc_t get_suc_msg;get_suc_msg.id=globals->id; TRY{ gras_msg_send(temp_sock,gras_msgtype_by_name("chord_get_suc"),&get_suc_msg); }CATCH(e){ gras_socket_close(temp_sock); - RETHROW0("Unable to contact known host to get successor!"); + RETHROW0("Unable to contact known host to get successor!: %s"); } rep_suc_t rep_suc_msg; TRY{ INFO0("Waiting for reply!"); gras_msg_wait(6000,gras_msgtype_by_name("chord_rep_suc"),&temp_sock2,&rep_suc_msg); }CATCH(e){ - RETHROW2("%s: Error waiting for successor:%s",globals->host,e.msg); + RETHROW1("%s: Error waiting for successor:%s",globals->host); } globals->finger[0].id=rep_suc_msg.id; snprintf(globals->finger[0].host,1024,rep_suc_msg.host); diff --git a/examples/gras/p2p/chord/chord.h b/examples/gras/p2p/chord/chord.h index 0cd2d37efc..ede9e912bb 100644 --- a/examples/gras/p2p/chord/chord.h +++ b/examples/gras/p2p/chord/chord.h @@ -2,9 +2,10 @@ * vim:ts=2:sw=2:noexpandtab */ -#include +#include "xbt/sysdep.h" +#include "gras.h" + -XBT_LOG_NEW_DEFAULT_CATEGORY(chord,"Messages specific to this example"); typedef enum msg_typus{ PING, @@ -25,19 +26,19 @@ typedef enum msg_typus{ ); typedef struct s_pbio pbio_t;*/ -GRAS_DEFINE_TYPE(s_ping, +//GRAS_DEFINE_TYPE(s_ping, struct s_ping{ int id; }; -); +//); typedef struct s_ping ping_t; -GRAS_DEFINE_TYPE(s_pong, +//GRAS_DEFINE_TYPE(s_pong, struct s_pong{ int id; int failed; }; -); +//); typedef struct s_pong pong_t; GRAS_DEFINE_TYPE(s_get_suc, diff --git a/examples/gras/p2p/chord/test_sg.in b/examples/gras/p2p/chord/test_sg.in index 67d9c2405a..c54aa517d8 100755 --- a/examples/gras/p2p/chord/test_sg.in +++ b/examples/gras/p2p/chord/test_sg.in @@ -1,10 +1,8 @@ #!/bin/bash -if [ x = x ] ; then +if [ x@EXEEXT@ = x ] ; then exenv=$SG_TEST_EXENV else exenv=wine fi -top_srcdir=/home/illogict/progs/simgrid/simgrid-3.0.1 -srcdir=`pwd` -exec $exenv ./chord_simulator /home/illogict/progs/simgrid/simgrid-3.0.1/examples/msg/msg_platform.xml ~/progs/simgrid/simgrid-3.0.1/examples/gras/p2p/chord_t/chord_deployment.xml $@ +exec $exenv ./chord_simulator @top_srcdir@/examples/msg/msg_platform.xml @srcdir@/chord_deployment.xml $@ -- 2.20.1