Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-31968 Increase ECLWatch upload buffer size to 1MB #18721

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions esp/bindings/http/platform/httptransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2123,22 +2123,23 @@ int CHttpRequest::processHeaders(IMultiException *me)

bool CHttpRequest::readContentToBuffer(MemoryBuffer& buffer, __int64& bytesNotRead)
{
char buf[1024 + 1];
__int64 buflen = 1024;
if (buflen > bytesNotRead)
buflen = bytesNotRead;

int readlen = m_bufferedsocket->read(buf, (int) buflen);
if(readlen < 0)
DBGLOG("Failed to read from socket");

if(readlen <= 0)
return false;

buf[readlen] = 0;
buffer.append(readlen, buf);//'buffer' may have some left-over from previous read
constexpr size32_t readChunkSize = 0x100000;
size32_t sizeToRead = bytesNotRead > readChunkSize ? readChunkSize: (size32_t)bytesNotRead;
size32_t prevLen = buffer.length();

// BufferedSocket::read buffer must be at least one larger than its maxlen argument
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well spotted (and that is a terrible interface!)

char * target = (char *)buffer.reserve(sizeToRead + 1);
int readLen = m_bufferedsocket->read(target, sizeToRead);
if(readLen <= 0)
{
if(readLen < 0)
DBGLOG("Failed to read from socket");
buffer.setLength(prevLen);
return false;
}

bytesNotRead -= readlen;
buffer.setLength(prevLen + readLen);
bytesNotRead -= readLen;
return true;
}

Expand Down
Loading