pcas: support larger than max array bytes
clientBufMemoryManager already supports allocations larger than max array bytes, adjust callers inBuf/outBuf to actually request larger allocations.
This commit is contained in:
@@ -205,7 +205,7 @@ caStatus casStrmClient :: processMsg ()
|
||||
if ( bytesLeft < msgSize ) {
|
||||
status = S_cas_success;
|
||||
if ( msgSize > this->in.bufferSize() ) {
|
||||
this->in.expandBuffer ();
|
||||
this->in.expandBuffer (msgSize);
|
||||
// msg to large - set up message drain
|
||||
if ( msgSize > this->in.bufferSize() ) {
|
||||
caServerI::dumpMsg ( this->pHostName, this->pUserName, & msgTmp, 0,
|
||||
|
||||
@@ -16,11 +16,6 @@
|
||||
#define epicsExportSharedSymbols
|
||||
#include "clientBufMemoryManager.h"
|
||||
|
||||
bufSizeT clientBufMemoryManager::maxSize () const
|
||||
{
|
||||
return bufferFactory.largeBufferSize ();
|
||||
}
|
||||
|
||||
casBufferParm clientBufMemoryManager::allocate ( bufSizeT newMinSize )
|
||||
{
|
||||
casBufferParm parm;
|
||||
|
||||
@@ -39,9 +39,9 @@ struct casBufferParm {
|
||||
|
||||
class clientBufMemoryManager {
|
||||
public:
|
||||
//! @throws std::bad_alloc on failure
|
||||
casBufferParm allocate ( bufSizeT newMinSize );
|
||||
void release ( char * pBuf, bufSizeT bufSize );
|
||||
bufSizeT maxSize () const;
|
||||
private:
|
||||
casBufferFactory bufferFactory;
|
||||
};
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
* 505 665 1831
|
||||
*/
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -155,11 +157,17 @@ bufSizeT inBuf::popCtx ( const inBufCtx &ctx )
|
||||
}
|
||||
}
|
||||
|
||||
void inBuf::expandBuffer ()
|
||||
void inBuf::expandBuffer (bufSizeT needed)
|
||||
{
|
||||
bufSizeT max = this->memMgr.maxSize();
|
||||
if ( this->bufSize < max ) {
|
||||
casBufferParm bufParm = this->memMgr.allocate ( max );
|
||||
if (needed > bufSize) {
|
||||
casBufferParm bufParm;
|
||||
try {
|
||||
bufParm = this->memMgr.allocate ( needed );
|
||||
} catch (std::bad_alloc& e) {
|
||||
// caller must check that buffer size has expended
|
||||
return;
|
||||
}
|
||||
|
||||
bufSizeT unprocessedBytes = this->bytesPresent ();
|
||||
memcpy ( bufParm.pBuf, &this->pBuf[this->nextReadIndex], unprocessedBytes );
|
||||
this->bytesInBuffer = unprocessedBytes;
|
||||
@@ -170,7 +178,7 @@ void inBuf::expandBuffer ()
|
||||
}
|
||||
}
|
||||
|
||||
unsigned inBuf::bufferSize () const
|
||||
bufSizeT inBuf::bufferSize() const
|
||||
{
|
||||
return this->bufSize;
|
||||
}
|
||||
|
||||
@@ -82,8 +82,8 @@ public:
|
||||
//
|
||||
const inBufCtx pushCtx ( bufSizeT headerSize, bufSizeT bodySize );
|
||||
bufSizeT popCtx ( const inBufCtx & ); // returns actual size
|
||||
unsigned bufferSize () const;
|
||||
void expandBuffer ();
|
||||
bufSizeT bufferSize () const;
|
||||
void expandBuffer (bufSizeT needed);
|
||||
private:
|
||||
class inBufClient & client;
|
||||
class clientBufMemoryManager & memMgr;
|
||||
|
||||
@@ -59,7 +59,7 @@ caStatus outBuf::allocRawMsg ( bufSizeT msgsize, void **ppMsg )
|
||||
msgsize = CA_MESSAGE_ALIGN ( msgsize );
|
||||
|
||||
if ( msgsize > this->bufSize ) {
|
||||
this->expandBuffer ();
|
||||
this->expandBuffer (msgsize);
|
||||
if ( msgsize > this->bufSize ) {
|
||||
return S_cas_hugeRequest;
|
||||
}
|
||||
@@ -316,11 +316,17 @@ void outBuf::show (unsigned level) const
|
||||
}
|
||||
}
|
||||
|
||||
void outBuf::expandBuffer ()
|
||||
void outBuf::expandBuffer (bufSizeT needed)
|
||||
{
|
||||
bufSizeT max = this->memMgr.maxSize();
|
||||
if ( this->bufSize < max ) {
|
||||
casBufferParm bufParm = this->memMgr.allocate ( max );
|
||||
if (needed > bufSize) {
|
||||
casBufferParm bufParm;
|
||||
try {
|
||||
bufParm = this->memMgr.allocate ( needed );
|
||||
} catch (std::bad_alloc& e) {
|
||||
// caller must check that buffer size has expended
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy ( bufParm.pBuf, this->pBuf, this->stack );
|
||||
this->memMgr.release ( this->pBuf, this->bufSize );
|
||||
this->pBuf = bufParm.pBuf;
|
||||
|
||||
@@ -122,7 +122,7 @@ private:
|
||||
bufSizeT stack;
|
||||
unsigned ctxRecursCount;
|
||||
|
||||
void expandBuffer ();
|
||||
void expandBuffer (bufSizeT needed);
|
||||
|
||||
outBuf ( const outBuf & );
|
||||
outBuf & operator = ( const outBuf & );
|
||||
|
||||
Reference in New Issue
Block a user