A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
(wip) Move the MCed public API in the same file
[simgrid.git]
/
src
/
mc
/
mc_client.c
diff --git
a/src/mc/mc_client.c
b/src/mc/mc_client.c
index
120c05b
..
6a8d4ee
100644
(file)
--- a/
src/mc/mc_client.c
+++ b/
src/mc/mc_client.c
@@
-13,18
+13,27
@@
#include <xbt/log.h>
#include <xbt/sysdep.h>
#include <xbt/log.h>
#include <xbt/sysdep.h>
+#include <xbt/mmalloc.h>
#include "mc_protocol.h"
#include "mc_client.h"
#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"
+
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_client, mc, "MC client logic");
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_client, mc, "MC client logic");
-
s_
mc_client_t mc_client;
+mc_client_t mc_client;
void MC_client_init(void)
{
void MC_client_init(void)
{
- mc_client.fd = -1;
- mc_client.active = 1;
+ if (mc_client) {
+ XBT_WARN("MC_client_init called more than once.");
+ return;
+ }
+
char* fd_env = getenv(MC_ENV_SOCKET_FD);
if (!fd_env)
xbt_die("MC socket not found");
char* fd_env = getenv(MC_ENV_SOCKET_FD);
if (!fd_env)
xbt_die("MC socket not found");
@@
-40,17
+49,25
@@
void MC_client_init(void)
xbt_die("Unexpected socket type %i", type);
XBT_DEBUG("Model-checked application found expected socket type");
xbt_die("Unexpected socket type %i", type);
XBT_DEBUG("Model-checked application found expected socket type");
- mc_client.fd = fd;
+ mc_client = xbt_new0(s_mc_client_t, 1);
+ mc_client->fd = fd;
+ mc_client->active = 1;
}
void MC_client_hello(void)
{
XBT_DEBUG("Greeting the MC server");
}
void MC_client_hello(void)
{
XBT_DEBUG("Greeting the MC server");
- if (MC_protocol_hello(mc_client
.
fd) != 0)
+ if (MC_protocol_hello(mc_client
->
fd) != 0)
xbt_die("Could not say hello the MC server");
XBT_DEBUG("Greeted the MC server");
}
xbt_die("Could not say hello the MC server");
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) {
void MC_client_handle_messages(void)
{
while (1) {
@@
-58,7
+75,7
@@
void MC_client_handle_messages(void)
char message_buffer[MC_MESSAGE_LENGTH];
size_t s;
char message_buffer[MC_MESSAGE_LENGTH];
size_t s;
- if ((s = recv(mc_client
.
fd, &message_buffer, sizeof(message_buffer), 0)) == -1)
+ if ((s = recv(mc_client
->
fd, &message_buffer, sizeof(message_buffer), 0)) == -1)
xbt_die("Could not receive commands from the model-checker: %s",
strerror(errno));
xbt_die("Could not receive commands from the model-checker: %s",
strerror(errno));