Skip to content

Commit b303a08

Browse files
authored
Merge pull request #39 from SidoShiro/dev
Last Hotfix
2 parents d43cf75 + 5de2f2f commit b303a08

File tree

11 files changed

+21
-15
lines changed

11 files changed

+21
-15
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.0)
22

33
set(CMAKE_C_COMPILER "mpicc")
4-
set(CMAKE_C_FLAGS "-O3 -std=c11 -Werror -Wall -Wextra -pedantic -fsanitize=address")
4+
set(CMAKE_C_FLAGS "-O3 -std=c11 -Werror -Wall -Wextra -pedantic") # -fsanitize=address")
55

66
project(DistributedMalloc)
77

@@ -30,7 +30,7 @@ set(MAIN src/main/main.c)
3030

3131
set(TEST_MAIN test/main_test.c)
3232

33-
set(FAILURE_DEMO src/demo/main_election_with_failures.c)
33+
set(FAILURE_DEMO demo/main_election_with_failures.c)
3434

3535

3636
include_directories("include/")
File renamed without changes.
File renamed without changes.
File renamed without changes.

hostfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
localhost slots=1000
1+
localhost slots=100

include/globals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef DISTRIBUTEDMALLOC_GLOBALS_H
22
#define DISTRIBUTEDMALLOC_GLOBALS_H
33

4-
#define DEF_NODE_SIZE 10000
4+
#define DEF_NODE_SIZE 1024
55
#define DEF_NODE_USER 0
66
#define DEF_NODE_LEADER 1
77

run.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
mkdir build/
12
rm -rf build/*
23
cd build
34
cmake ..

src/cli/cli.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,6 @@ char **split_cmd(char *cmd) {
6565
return tokens;
6666
}
6767

68-
void print_args(char **args) {
69-
char *tok;
70-
ssize_t i = 0;
71-
do {
72-
tok = args[i];
73-
i++;
74-
if (tok != NULL)
75-
printf("%s\n", tok);
76-
} while (tok != NULL);
77-
}
78-
7968
void error_msg(char *msg) {
8069
warnx("%s\n", msg);
8170
}
@@ -196,6 +185,9 @@ void execute(char **args, unsigned short leader) {
196185
struct data_write *d_w = generate_data_write(address, datasize, buffer_write_file);
197186
send_command(OP_WRITE, d_w, leader);
198187
// OLD error_msg("w requires an argument 'datasize' which can be casted as a positive integer");
188+
fclose(file_write);
189+
free(d_w->data);
190+
free(d_w);
199191
}
200192
} else {
201193
error_msg("w requires an argument 'address' which can be casted as a positive integer");
@@ -253,6 +245,9 @@ void execute(char **args, unsigned short leader) {
253245
if (r_c != d_w->size)
254246
error_msg("WARNING: file bytes write different from bytes asked");
255247
// OLD error_msg("r requires an argument 'datasize' which can be casted as a positive integer");
248+
free(d_w->data);
249+
free(d_w);
250+
fclose(file_read);
256251
}
257252
} else {
258253
error_msg("r require an argument 'address' which can be casted as a positive integer");
@@ -314,6 +309,7 @@ void execute(char **args, unsigned short leader) {
314309
struct data_id *d_i = generate_data_id(id);
315310
printf("Execute Kill on %zu \n", id);
316311
send_command(OP_KILL, d_i, leader);
312+
free(d_i);
317313
} else {
318314
error_msg("k require an argument 'node_id' which can be casted as a positive integer");
319315
}
@@ -333,6 +329,7 @@ void execute(char **args, unsigned short leader) {
333329
struct data_id *d_i = generate_data_id(id);
334330
printf("Execute Revive on %zu \n", id);
335331
send_command(OP_REVIVE, d_i, leader);
332+
free(d_i);
336333
} else {
337334
error_msg("revive require an argument 'node_id' which can be casted as a positive integer");
338335
}

src/cli/user.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ void send_read(void *data, unsigned short leader) {
8181
struct message m2;
8282
MPI_Status st2;
8383
MPI_Recv(&m2, sizeof(struct message), MPI_BYTE, m->id_t, TAG_MSG, MPI_COMM_WORLD, &st2);
84+
if (m2.size == 0 && d_r->size != 0) {
85+
debug("Impossible to read, may have been an error", 0);
86+
free(m);
87+
return;
88+
}
8489
debug("RECV OK with datasize read", 0);
8590
size_t real_data_size = m2.size;
8691
MPI_Status st3;

0 commit comments

Comments
 (0)