Skip to content
Snippets Groups Projects
Commit 2e1b2108 authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Use null character to terminate chunk buffers

parent 3752471c
No related branches found
No related tags found
No related merge requests found
......@@ -324,7 +324,7 @@ void cluster(const string& config_file, const string& data_file, const string& o
delete[] chunk_buffer;
MPI_Recv(&chunk_buffer_size, 1, MPI_INT, rr, 1, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
}
fputc(10, output);
fprintf(output, "\n");
// now get the binary local file
long buffer_size = 0;
......@@ -454,7 +454,7 @@ void cluster(const string& config_file, const string& data_file, const string& o
// If EOF is reached, do not send EOF character.
long ptr_position = partial_output.tellg();
if (ptr_position == partial_output_size) {
chunk_buffer_size--;
chunk_buffer[chunk_buffer_size - 1] = '\0';
}
// Send the size of the buffer that is being transmitted (Node-0 does not know whether it is full or not)
MPI_Send(&chunk_buffer_size, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
......@@ -464,8 +464,11 @@ void cluster(const string& config_file, const string& data_file, const string& o
long ptr_position = partial_output.tellg();
if (ptr_position < partial_output_size) {
// Send the last partial buffer
chunk_buffer_size = partial_output_size - ptr_position - 1;
chunk_buffer_size = partial_output_size - ptr_position;
delete[] chunk_buffer;
chunk_buffer = new char[chunk_buffer_size];
partial_output.read(chunk_buffer, chunk_buffer_size);
chunk_buffer[chunk_buffer_size - 1] = '\0';
// Send the size of the buffer that is being transmitted (Node-0 does not know whether it is full or not)
MPI_Send(&chunk_buffer_size, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
// Actually send the file contents to Node-0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment