Skip to content

Commit

Permalink
consolidate
Browse files Browse the repository at this point in the history
  • Loading branch information
eisenhauer committed Mar 6, 2024
1 parent 8c2ef6f commit 78bd9ba
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion source/adios2/toolkit/remote/remote_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,25 @@ static void ReadRequestHandler(CManager cm, CMConnection conn, void *vevent, voi
f->m_CurrentOffset = ReadMsg->Offset;
}
char *tmp = (char *)malloc(ReadMsg->Size);
read(f->m_FileDescriptor, tmp, ReadMsg->Size);
size_t remaining = ReadMsg->Size;
char *pointer = tmp;
while (remaining > 0)
{
ssize_t ret = read(f->m_FileDescriptor, pointer, remaining);
if (ret <= 0)
{
// EOF or error, should send a message back, but we haven't define error handling yet
std::cout << "Read failed! BAD!" << std::endl;
// instead free tmp and return;
free(tmp);
return;
}
else
{
remaining -= ret;
pointer += ret;
}
}
f->m_CurrentOffset += ReadMsg->Size;
_ReadResponseMsg Response;
memset(&Response, 0, sizeof(Response));
Expand Down

0 comments on commit 78bd9ba

Please sign in to comment.