diff --git a/src/cas/io/bsdSocket/casDGIntfIO.cc b/src/cas/io/bsdSocket/casDGIntfIO.cc index b2520c83e..fe434c84c 100644 --- a/src/cas/io/bsdSocket/casDGIntfIO.cc +++ b/src/cas/io/bsdSocket/casDGIntfIO.cc @@ -500,38 +500,21 @@ bufSizeT casDGIntfIO::optimumInBufferSize () #endif } -bufSizeT casDGIntfIO::optimumOutBufferSize () +bufSizeT casDGIntfIO :: + osSendBufferSize () const { - -#if 1 - // - // must update client before the message size can be - // increased here - // - return MAX_UDP_SEND; -#else - int n; - int size; - int status; - - /* fetch the TCP send buffer size */ - n = sizeof(size); - status = getsockopt( - this->sock, - SOL_SOCKET, - SO_SNDBUF, - (char *)&size, - &n); - if(status < 0 || n != sizeof(size)){ + int size = MAX_UDP_SEND; + int n = sizeof ( size ); + int status = getsockopt( this->sock, SOL_SOCKET, SO_SNDBUF, + reinterpret_cast < char * > ( & size ), & n ); + if ( status < 0 || n != sizeof(size) ) { size = MAX_UDP_SEND; } - - if (size<=0) { + if ( size <= MAX_UDP_SEND ) { size = MAX_UDP_SEND; } - return (bufSizeT) size; -#endif + return static_cast < bufSizeT > ( size ); } SOCKET casDGIntfIO::makeSockDG () diff --git a/src/cas/io/bsdSocket/casDGIntfIO.h b/src/cas/io/bsdSocket/casDGIntfIO.h index e970cbd36..bf11183c6 100644 --- a/src/cas/io/bsdSocket/casDGIntfIO.h +++ b/src/cas/io/bsdSocket/casDGIntfIO.h @@ -39,10 +39,10 @@ public: inBufClient::fillParameter parm, bufSizeT & nBytesActual, caNetAddr & addr ); virtual void show ( unsigned level ) const; - static bufSizeT optimumOutBufferSize (); static bufSizeT optimumInBufferSize (); bufSizeT incomingBytesPresent () const; + bufSizeT osSendBufferSize () const ; private: tsFreeList < ipIgnoreEntry, 128 > ipIgnoreEntryFreeList; diff --git a/src/cas/io/bsdSocket/casIntfIO.cc b/src/cas/io/bsdSocket/casIntfIO.cc index d3262d0f1..4b32e1162 100644 --- a/src/cas/io/bsdSocket/casIntfIO.cc +++ b/src/cas/io/bsdSocket/casIntfIO.cc @@ -236,4 +236,3 @@ caNetAddr casIntfIO::serverAddress () const { return caNetAddr (this->addr); } - diff --git a/src/cas/io/bsdSocket/casIntfIO.h b/src/cas/io/bsdSocket/casIntfIO.h index 2c7024c04..913f8b557 100644 --- a/src/cas/io/bsdSocket/casIntfIO.h +++ b/src/cas/io/bsdSocket/casIntfIO.h @@ -53,7 +53,7 @@ public: clientBufMemoryManager & ) const; caNetAddr serverAddress () const; - + private: SOCKET sock; struct sockaddr_in addr; diff --git a/src/cas/io/bsdSocket/casStreamIO.cc b/src/cas/io/bsdSocket/casStreamIO.cc index ce07ddc34..d0a43a02e 100644 --- a/src/cas/io/bsdSocket/casStreamIO.cc +++ b/src/cas/io/bsdSocket/casStreamIO.cc @@ -19,7 +19,8 @@ casStreamIO::casStreamIO ( caServerI & cas, clientBufMemoryManager & bufMgr, const ioArgsToNewStreamIO & args ) : casStrmClient ( cas, bufMgr ), sock ( args.sock ), addr ( args.addr), - blockingFlag ( xIsBlocking ), sockHasBeenShutdown ( false ) + _osSendBufferSize ( MAX_TCP ), blockingFlag ( xIsBlocking ), + sockHasBeenShutdown ( false ) { assert ( sock >= 0 ); int yes = true; @@ -91,7 +92,19 @@ casStreamIO::casStreamIO ( caServerI & cas, clientBufMemoryManager & bufMgr, throw S_cas_internal; } #endif - + + /* cache the TCP send buffer size */ + int size = MAX_TCP; + int n = sizeof ( size ) ; + status = getsockopt ( this->sock, SOL_SOCKET, + SO_SNDBUF, reinterpret_cast < char * > ( & size ), & n ); + if ( status < 0 || n != sizeof ( size ) ) { + size = MAX_TCP; + } + if ( size <= MAX_TCP ) { + size = MAX_TCP; + } + _osSendBufferSize = static_cast < bufSizeT > ( size ); } // casStreamIO::~casStreamIO() @@ -255,8 +268,9 @@ xBlockingStatus casStreamIO::blockingState() const return this->blockingFlag; } -// casStreamIO::incomingBytesPresent() -bufSizeT casStreamIO::incomingBytesPresent () const // X aCC 361 + +// casStreamIO :: incomingBytesPresent() +bufSizeT casStreamIO :: incomingBytesPresent () const { int status; osiSockIoctl_t nchars = 0; @@ -293,32 +307,10 @@ void casStreamIO::hostName ( char * pInBuf, unsigned bufSizeIn ) const ipAddrToA ( & this->addr, pInBuf, bufSizeIn ); } -// casStreamIO:::optimumBufferSize() -bufSizeT casStreamIO::optimumBufferSize () +// casStreamIO :: osSendBufferSize () +bufSizeT casStreamIO :: osSendBufferSize () const { - -#if 0 - int n; - int size; - int status; - - /* fetch the TCP send buffer size */ - n = sizeof ( size) ; - status = getsockopt ( this->sock, SOL_SOCKET, - SO_SNDBUF, (char *) & size, & n ); - if ( status < 0 || n != sizeof ( size ) ) { - size = 0x400; - } - - if (size<=0) { - size = 0x400; - } -printf("the tcp buf size is %d\n", size); - return (bufSizeT) size; -#else -// this needs to be MAX_TCP (until we fix the array problem) - return (bufSizeT) MAX_TCP; // X aCC 392 -#endif + return _osSendBufferSize; } // casStreamIO::getFD() diff --git a/src/cas/io/bsdSocket/casStreamIO.h b/src/cas/io/bsdSocket/casStreamIO.h index f952910b2..46d5084d4 100644 --- a/src/cas/io/bsdSocket/casStreamIO.h +++ b/src/cas/io/bsdSocket/casStreamIO.h @@ -31,16 +31,16 @@ public: void xSetNonBlocking (); const caNetAddr getAddr() const; void hostName ( char *pBuf, unsigned bufSize ) const; - + bufSizeT incomingBytesPresent () const; + bufSizeT osSendBufferSize () const; private: SOCKET sock; struct sockaddr_in addr; + bufSizeT _osSendBufferSize; xBlockingStatus blockingFlag; bool sockHasBeenShutdown; xBlockingStatus blockingState() const; - bufSizeT incomingBytesPresent() const; - static bufSizeT optimumBufferSize (); void osdShow ( unsigned level ) const; outBufClient::flushCondition osdSend ( const char *pBuf, bufSizeT nBytesReq, bufSizeT & nBytesActual );