Skip to content

Commit fc92b76

Browse files
committed
leader: fix on read overflow or end in execute_read, fix offset write for execute_write
1 parent f6286a1 commit fc92b76

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/network/leader.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ void execute_read(struct leader_resources *l_r) {
273273
size_t nb_read_size = 0;
274274
size_t x = d_r->size;
275275
size_t offset = 0;
276-
for (size_t i = part_s; i < c_a->number_parts; i++) {
276+
for (size_t i = part_s; x > 0 && i < c_a->number_parts; i++) {
277277
// TODO handle size overflow
278278
struct block *b = c_a->parts[i];
279279
// compute size to read for this block
@@ -334,6 +334,7 @@ void execute_write(struct leader_resources *l_r) {
334334
// (Warning to size bigger than block)
335335
size_t to_write_address_v = d_w->address;
336336
size_t x = d_w->size;
337+
size_t offset = 0;
337338
for (size_t i = part_s; x > 0 && i < c_a->number_parts; i++) {
338339
// TODO handle size overflow
339340
struct block *b = c_a->parts[i];
@@ -368,7 +369,8 @@ void execute_write(struct leader_resources *l_r) {
368369
MPI_Recv(&m2, sizeof(struct message), MPI_BYTE, b->id, 3, MPI_COMM_WORLD, &st);
369370
debug("Send Data", l_r->id);
370371
// debug_n(d_w->data, l_r->id, d_w->size);
371-
MPI_Send(d_w->data, to_write_size, MPI_BYTE, b->id, 4, MPI_COMM_WORLD);
372+
MPI_Send((void*)((char*)d_w->data + offset), to_write_size, MPI_BYTE, b->id, 4, MPI_COMM_WORLD);
373+
offset += to_write_size;
372374
}
373375

374376
if (x > 0) {

0 commit comments

Comments
 (0)