Skip to content

Commit 7d1c87e

Browse files
committed
leader: fixes in execute_malloc (out of memory errors)
1 parent 8de9291 commit 7d1c87e

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/network/leader.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,27 @@ void execute_malloc(struct leader_resources *l_r) {
220220
struct data_size *d_s = peek_command(l_r->leader_command_queue);
221221
if (!d_s) {
222222
debug("ERROR allocation data_size for OP MALLOC execution [LEADER]", l_r->id);
223+
return;
223224
}
224225
size_t v_addr = alloc_memory(d_s->size, l_r);
225226
size_t sss = d_s->size;
226-
if (v_addr == 999 || v_addr == 1999) {
227+
if (v_addr == 999 || v_addr == 1999 || v_addr == SIZE_MAX) {
228+
if (v_addr == SIZE_MAX) {
229+
debug("Out of memory", l_r->id);
230+
struct message *m = generate_message(l_r->id, DEF_NODE_USER, DEF_NODE_USER, SIZE_MAX, 0, OP_MALLOC);
231+
MPI_Request r;
232+
MPI_Isend((void *) m, sizeof(struct message), MPI_BYTE, m->id_t, 0, MPI_COMM_WORLD, &r);
233+
free(m);
234+
return;
235+
}
227236
debug("FATAL ERROR", l_r->id);
228237
if (v_addr == 1999) {
229238
debug("SEC", l_r->id);
230239
}
240+
struct message *m = generate_message(l_r->id, DEF_NODE_USER, DEF_NODE_USER, SIZE_MAX, SIZE_MAX, OP_MALLOC);
241+
MPI_Request r;
242+
MPI_Isend((void *) m, sizeof(struct message), MPI_BYTE, m->id_t, 0, MPI_COMM_WORLD, &r);
243+
free(m);
231244
return;
232245
}
233246
debug("Allocation at ", l_r->id);

0 commit comments

Comments
 (0)