X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/2f02d5fdd1af4cc2f9eaf3c6456c822616c1cb15..b6bd61bc99f93bb0d6e9833f930c701ad04ae446:/src/gras/Msg/rl_msg.c diff --git a/src/gras/Msg/rl_msg.c b/src/gras/Msg/rl_msg.c index 50cf748a94..09c4b7340f 100644 --- a/src/gras/Msg/rl_msg.c +++ b/src/gras/Msg/rl_msg.c @@ -59,7 +59,10 @@ void gras_msg_send_ext(gras_socket_t sock, if (kind == e_gras_msg_kind_rpcerror) { /* error on remote host, carfull, payload is an exception */ gras_datadesc_send(sock, gras_datadesc_by_name("ex_t"),payload); - } else { + } else if (kind == e_gras_msg_kind_rpcanswer) { + if (msgtype->answer_type) + gras_datadesc_send(sock, msgtype->answer_type, payload); + }else { /* regular message */ if (msgtype->ctn_type) gras_datadesc_send(sock, msgtype->ctn_type, payload); @@ -68,6 +71,9 @@ void gras_msg_send_ext(gras_socket_t sock, gras_trp_flush(sock); } +const char *hexa_str(unsigned char *data, int size, int downside); + + /* * receive the next message on the given socket. */ @@ -107,14 +113,12 @@ gras_msg_recv(gras_socket_t sock, for (cpt=0; cpt<4; cpt++) if (header[cpt] != _GRAS_header[cpt]) THROW2(mismatch_error,0, - "Incoming bytes do not look like a GRAS message (header='%.4s' not '%.4s')", - header,_GRAS_header); + "Incoming bytes do not look like a GRAS message (header='%s' not '%.4s')", + hexa_str((unsigned char*)header,4,0),_GRAS_header); if (header[4] != _GRAS_header[4]) THROW2(mismatch_error,0,"GRAS protocol mismatch (got %d, use %d)", (int)header[4], (int)_GRAS_header[4]); r_arch = (int)header[5]; - DEBUG2("Handle an incoming message using protocol %d (remote is %s)", - (int)header[4],gras_datadesc_arch_name(r_arch)); switch (msg->kind) { case e_gras_msg_kind_oneway: @@ -131,6 +135,9 @@ gras_msg_recv(gras_socket_t sock, } gras_datadesc_recv(sock, string_type, r_arch, &msg_name); + DEBUG4("Handle an incoming message '%s' (%s) using protocol %d (remote is %s)", + msg_name, e_gras_msg_kind_names[msg->kind], (int)header[4],gras_datadesc_arch_name(r_arch)); + TRY { msg->type = (gras_msgtype_t)xbt_set_get_by_name(_gras_msgtype_set,msg_name); } CATCH(e) { @@ -146,6 +153,20 @@ gras_msg_recv(gras_socket_t sock, msg->payl=xbt_malloc(msg->payl_size); gras_datadesc_recv(sock, gras_datadesc_by_name("ex_t"), r_arch, msg->payl); + } else if (msg->kind == e_gras_msg_kind_rpcanswer) { + /* answer to RPC */ + if (msg->type->answer_type) { + msg->payl_size=gras_datadesc_size(msg->type->answer_type); + xbt_assert2(msg->payl_size > 0, + "%s %s", + "Dynamic array as payload is forbided for now (FIXME?).", + "Reference to dynamic array is allowed."); + msg->payl = xbt_malloc(msg->payl_size); + gras_datadesc_recv(sock, msg->type->answer_type, r_arch, msg->payl); + } else { + msg->payl = NULL; + msg->payl_size = 0; + } } else { /* regular message */ if (msg->type->ctn_type) {