Commit 3a04bd10 authored by Erwan Jahier's avatar Erwan Jahier
Browse files

Fix a bug in the Alice stub generator: the buffer used to read in I/O declarations

was too small.
parent f2aefc0c
......@@ -56,7 +56,7 @@ amend-a:
amend:
git commit -F log --amend && make gen_version
ci: test
ci:
git commit -F log && make gen_version
......
......@@ -180,7 +180,7 @@ let (gen_h_file : string -> Exp.var list -> Exp.var list -> Exp.var list -> unit
let oc = open_out (fn ^ ".h") in
let put s = output_string oc s in
let putln s = output_string oc (s^"\n") in
let max_buff_size =
let max_buff_size =
(* 10 digits per I/O is enough? *)
let in_nb = List.length in_vars in
let out_nb = List.length out_vars in
......@@ -218,9 +218,10 @@ typedef float _float;
#define _true 1
#endif
";
if option.use_sockets then
if option.use_sockets then (
putln ("#define MAX_BUFF_SIZE "^(string_of_int max_buff_size)^"");
putln ("#define MAX_BUFF_SIZE_4 "^(string_of_int (4*max_buff_size))^"");
);
putln "//--------- Pragmas ----------------";
putln ("//MODULE: " ^ fn ^ " " ^ (string_of_int (List.length in_vars))
^ " " ^ (string_of_int (List.length out_vars)));
......@@ -411,6 +412,7 @@ launch the lutin interpreter and init socket stuff
struct sockaddr_in serv_addr;
struct sockaddr_in cli_addr;
char portno_str[10];
char buff[MAX_BUFF_SIZE_4];
char *sock_addr = \""^option.sock_addr^"\";
const char *args[] = {
#ifdef _WIN32
......@@ -453,7 +455,7 @@ launch the lutin interpreter and init socket stuff
#ifndef _LAUNCH_LUTIN_AUTOMATICALLY
printf(\" >>> Waiting for lutin to connect on %s:%s\\n\", sock_addr, portno_str);
#else
dbg_printf(\"Forking...%i\\n\",portno);
dbg_printf(\"Forking...%d\\n\",portno);
#ifdef _WIN32
_spawnvp(_P_DETACH, args[0], args);
#else
......@@ -473,12 +475,8 @@ launch the lutin interpreter and init socket stuff
newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
if (newsockfd < 0) printf(\"Error: on accept\");
ctx->sock = newsockfd;
memset(ctx->buff, 0, MAX_BUFF_SIZE);
rc = 0;
while (1) {
rc = recv(ctx->sock, ctx->buff, MAX_BUFF_SIZE, 0);
if (rc > 0) break;
}
rc = recv(ctx->sock, buff, MAX_BUFF_SIZE_4, 0);
if (rc<0) { printf(\"Error: cannot read on socket\\n\"); exit(2); }
dbg_printf(\"Skipping '%s'\\n\", ctx->buff);
memset(ctx->buff, 0, MAX_BUFF_SIZE);
......@@ -527,11 +525,9 @@ in
dbg_printf(\"reading inputs\\n\");
rc = 0;
while (1) {
rc = recv(ctx->sock, ctx->buff, MAX_BUFF_SIZE, 0);
dbg_printf(\"reading '%s'\\n\",ctx->buff);
if (rc > 0) break;
}
rc = recv(ctx->sock, ctx->buff, MAX_BUFF_SIZE, 0);
if (rc<0) { printf(\"Error: cannot read on socket\\n\"); exit(2); }
dbg_printf(\"reading '%s'\\n\",ctx->buff);
sscanf(ctx->buff, \"#step %d #outs " ^
let cpt = ref 0 in
let var_to_adress var =
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment