X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/cf9a823f1cfd8b0098a039bff8ff6567e9beac91..9b7c007d68cc9aabd52746479c68a8287a087fe3:/src/mc/mc_client.c diff --git a/src/mc/mc_client.c b/src/mc/mc_client.c index 55cc2ca388..da8d8c41a4 100644 --- a/src/mc/mc_client.c +++ b/src/mc/mc_client.c @@ -13,10 +13,17 @@ #include #include +#include #include "mc_protocol.h" #include "mc_client.h" +// We won't need those once the separation MCer/MCed is complete: +#include "mc_mmalloc.h" +#include "mc_ignore.h" +#include "mc_model_checker.h" +#include "mc_private.h" // MC_deadlock_check() + XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_client, mc, "MC client logic"); mc_client_t mc_client; @@ -38,7 +45,7 @@ void MC_client_init(void) int type; socklen_t socklen = sizeof(type); if (getsockopt(fd, SOL_SOCKET, SO_TYPE, &type, &socklen) != 0) - xbt_die("Could not check socket type: %s", strerror(errno)); + xbt_die("Could not check socket type"); if (type != SOCK_DGRAM) xbt_die("Unexpected socket type %i", type); XBT_DEBUG("Model-checked application found expected socket type"); @@ -56,6 +63,12 @@ void MC_client_hello(void) XBT_DEBUG("Greeted the MC server"); } +void MC_client_send_message(void* message, size_t size) +{ + if (MC_protocol_send(mc_client->fd, message, size)) + xbt_die("Could not send message %i", (int) ((mc_message_t)message)->type); +} + void MC_client_handle_messages(void) { while (1) { @@ -73,8 +86,21 @@ void MC_client_handle_messages(void) xbt_die("Message is too short"); memcpy(&message, message_buffer, sizeof(message)); switch (message.type) { + + case MC_MESSAGE_DEADLOCK_CHECK: + { + int result = MC_deadlock_check(); + s_mc_int_message_t answer; + answer.type = MC_MESSAGE_DEADLOCK_CHECK_REPLY; + answer.value = result; + if (MC_protocol_send(mc_client->fd, &answer, sizeof(answer))) + xbt_die("Could nor send response"); + } + break; + case MC_MESSAGE_CONTINUE: return; + default: xbt_die("Unexpected message from model-checker %i", message.type); }