From a08fc2c5514db04ecdcea0f85be367139028823d Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Wed, 29 May 2002 00:19:31 +0000 Subject: [PATCH] large array modifications --- src/cas/build/Makefile | 1 + src/cas/example/simple/exPV.cc | 5 ++-- src/cas/example/simple/exVectorPV.cc | 4 +-- src/cas/example/simple/main.cc | 18 ++++++++++-- src/cas/io/bsdSocket/casDGIntfIO.cc | 44 +++++++++++++++++++--------- src/cas/io/bsdSocket/casIOD.h | 20 ++++++------- src/cas/io/bsdSocket/casIntfIO.cc | 2 +- src/cas/io/bsdSocket/casStreamIO.cc | 41 +++++++++++++++----------- 8 files changed, 86 insertions(+), 49 deletions(-) diff --git a/src/cas/build/Makefile b/src/cas/build/Makefile index c9b0688aa..02aacac9f 100644 --- a/src/cas/build/Makefile +++ b/src/cas/build/Makefile @@ -47,6 +47,7 @@ LIBSRCS += outBuf.cc LIBSRCS += casCtx.cc LIBSRCS += casEventMask.cc LIBSRCS += ioBlocked.cc +LIBSRCS += casBufferFactory.cc LIBSRCS += caServerOS.cc LIBSRCS += casIntfOS.cc diff --git a/src/cas/example/simple/exPV.cc b/src/cas/example/simple/exPV.cc index 8e116ee63..bfd3748d3 100644 --- a/src/cas/example/simple/exPV.cc +++ b/src/cas/example/simple/exPV.cc @@ -101,7 +101,7 @@ epicsTimerNotify::expireStatus exPV::expire ( const epicsTime & /*currentTime*/ ) // X aCC 361 { this->scan(); - if ( this->scanOn ) { + if ( this->scanOn && this->getScanPeriod() > 0.0 ) { return expireStatus ( restart, this->getScanPeriod() ); } else { @@ -130,7 +130,8 @@ caStatus exPV::interestRegister() this->interest = true; - if ( this->scanOn && this->getScanPeriod() < this->timer.getExpireDelay() ) { + if ( this->scanOn && this->getScanPeriod() > 0.0 && + this->getScanPeriod() < this->timer.getExpireDelay() ) { this->timer.start ( *this, this->getScanPeriod() ); } diff --git a/src/cas/example/simple/exVectorPV.cc b/src/cas/example/simple/exVectorPV.cc index 91c01f449..b7a2c4412 100644 --- a/src/cas/example/simple/exVectorPV.cc +++ b/src/cas/example/simple/exVectorPV.cc @@ -190,7 +190,7 @@ caStatus exVectorPV::updateValue(smartConstGDDPointer pValueIn) return S_casApp_outOfBounds; } - aitFloat32 *pF; + aitFloat64 *pF; int gddStatus; // @@ -214,7 +214,7 @@ caStatus exVectorPV::updateValue(smartConstGDDPointer pValueIn) // // allocate array buffer // - pF = new aitFloat32 [this->info.getElementCount()]; + pF = new aitFloat64 [this->info.getElementCount()]; if (!pF) { return S_casApp_noMemory; } diff --git a/src/cas/example/simple/main.cc b/src/cas/example/simple/main.cc index 4653f7119..bb0465e1b 100644 --- a/src/cas/example/simple/main.cc +++ b/src/cas/example/simple/main.cc @@ -1,4 +1,6 @@ +#include "envDefs.h" + #include "exServer.h" #include "fdManager.h" @@ -15,12 +17,13 @@ extern int main (int argc, const char **argv) char pvPrefix[128] = ""; unsigned aliasCount = 1u; unsigned scanOnAsUnsignedInt = true; + char arraySize[64] = ""; bool scanOn; bool forever = true; int i; - for (i=1; i -t -p -c] -s<1=scan on (default), 0=scan off]>\n", + "usage: %s [-d -t -p " + "-c -s<1=scan on (default), 0=scan off]> " + "-a]\n", argv[0]); return (1); } + if ( arraySize[0] != '\0' ) { + epicsEnvSet ( "EPICS_CA_MAX_ARRAY_BYTES", arraySize ); + } + if (scanOnAsUnsignedInt) { scanOn = true; } diff --git a/src/cas/io/bsdSocket/casDGIntfIO.cc b/src/cas/io/bsdSocket/casDGIntfIO.cc index 50e71a0d4..345f38a7b 100644 --- a/src/cas/io/bsdSocket/casDGIntfIO.cc +++ b/src/cas/io/bsdSocket/casDGIntfIO.cc @@ -125,11 +125,19 @@ casDGIntfIO::casDGIntfIO (caServerI &serverIn, const caNetAddr &addr, serverBCastAddr.ia = pAddr->addr.ia; serverBCastAddr.ia.sin_port = htons (this->dgPort); - if (autoBeaconAddr) { - forcePort (&BCastAddrList,beaconPort); + if ( autoBeaconAddr ) { + forcePort ( &BCastAddrList, beaconPort ); } else { - ellFree (&BCastAddrList); + // avoid use of ellFree because problems on windows occur if the + // free is in a different DLL than the malloc + ELLNODE * nnode = BCastAddrList.node.next; + while ( nnode ) + { + ELLNODE * pnode = nnode; + nnode = nnode->next; + free ( pnode ); + } } } @@ -236,7 +244,15 @@ casDGIntfIO::~casDGIntfIO() socket_close ( this->beaconSock ); } - ellFree ( &this->beaconAddrList ); + // avoid use of ellFree because problems on windows occur if the + // free is in a different DLL than the malloc + ELLNODE * nnode = this->beaconAddrList.node.next; + while ( nnode ) + { + ELLNODE * pnode = nnode; + nnode = nnode->next; + free ( pnode ); + } osiSockRelease (); } @@ -270,9 +286,9 @@ void casDGIntfIO::xSetNonBlocking() // // casDGIntfIO::osdRecv() // -inBuf::fillCondition -casDGIntfIO::osdRecv(char *pBufIn, bufSizeT size, // X aCC 361 - fillParameter parm, bufSizeT &actualSize, caNetAddr &fromOut) +inBufClient::fillCondition +casDGIntfIO::osdRecv ( char * pBufIn, bufSizeT size, // X aCC 361 + fillParameter parm, bufSizeT & actualSize, caNetAddr & fromOut ) { int status; osiSocklen_t addrSize; @@ -309,9 +325,9 @@ casDGIntfIO::osdRecv(char *pBufIn, bufSizeT size, // X aCC 361 // // casDGIntfIO::osdSend() // -outBuf::flushCondition -casDGIntfIO::osdSend (const char *pBufIn, bufSizeT size, // X aCC 361 - const caNetAddr &to) +outBufClient::flushCondition +casDGIntfIO::osdSend ( const char * pBufIn, bufSizeT size, // X aCC 361 + const caNetAddr & to ) { int status; @@ -323,7 +339,7 @@ casDGIntfIO::osdSend (const char *pBufIn, bufSizeT size, // X aCC 361 &dest, sizeof(dest)); if (status>=0) { assert ( size == (unsigned) status ); - return outBuf::flushProgress; + return outBufClient::flushProgress; } else { int errnoCpy = SOCKERRNO; @@ -334,7 +350,7 @@ casDGIntfIO::osdSend (const char *pBufIn, bufSizeT size, // X aCC 361 "CAS: UDP socket send to \"%s\" failed because \"%s\"\n", buf, SOCKERRSTR(errnoCpy)); } - return outBuf::flushNone; + return outBufClient::flushNone; } } @@ -366,8 +382,8 @@ bufSizeT casDGIntfIO::incomingBytesPresent () const // X aCC 361 // // casDGIntfIO::sendBeaconIO() // -void casDGIntfIO::sendBeaconIO (char &msg, unsigned length, - aitUint16 &portField, aitUint32 &addrField) +void casDGIntfIO::sendBeaconIO ( char &msg, unsigned length, + aitUint16 & portField, aitUint32 & addrField ) { caNetAddr addr = this->serverAddress (); struct sockaddr_in inetAddr = addr.getSockIP(); diff --git a/src/cas/io/bsdSocket/casIOD.h b/src/cas/io/bsdSocket/casIOD.h index 4131d0928..e38eaaada 100644 --- a/src/cas/io/bsdSocket/casIOD.h +++ b/src/cas/io/bsdSocket/casIOD.h @@ -36,11 +36,11 @@ public: aitUint16 &portField, aitUint32 &addrField); casIOState state () const; - outBuf::flushCondition osdSend (const char *pBuf, bufSizeT nBytesReq, - const caNetAddr &addr); - inBuf::fillCondition osdRecv (char *pBuf, bufSizeT nBytesReq, - fillParameter parm, bufSizeT &nBytesActual, caNetAddr &addr); - virtual void show (unsigned level) const; + outBufClient::flushCondition osdSend ( const char * pBuf, bufSizeT nBytesReq, + const caNetAddr & addr); + inBufClient::fillCondition osdRecv ( char * pBuf, bufSizeT nBytesReq, + inBufClient::fillParameter parm, bufSizeT & nBytesActual, caNetAddr & addr ); + virtual void show ( unsigned level ) const; static bufSizeT optimumOutBufferSize (); static bufSizeT optimumInBufferSize (); @@ -76,12 +76,12 @@ public: void xSetNonBlocking(); casIOState state() const; - void clientHostName (char *pBuf, unsigned bufSize) const; + void hostName (char *pBuf, unsigned bufSize) const; - outBuf::flushCondition osdSend (const char *pBuf, bufSizeT nBytesReq, - bufSizeT &nBytesActual); - inBuf::fillCondition osdRecv (char *pBuf, bufSizeT nBytesReq, - bufSizeT &nBytesActual); + outBufClient::flushCondition osdSend ( const char *pBuf, bufSizeT nBytesReq, + bufSizeT & nBytesActual ); + inBufClient::fillCondition osdRecv ( char *pBuf, bufSizeT nBytesReq, + bufSizeT & nBytesActual ); xBlockingStatus blockingState() const; diff --git a/src/cas/io/bsdSocket/casIntfIO.cc b/src/cas/io/bsdSocket/casIntfIO.cc index 1d4f678f3..fb89da23c 100644 --- a/src/cas/io/bsdSocket/casIntfIO.cc +++ b/src/cas/io/bsdSocket/casIntfIO.cc @@ -179,7 +179,7 @@ casStreamOS *casIntfIO::newStreamClient(caServerI &cas) const if ( cas.getDebugLevel()>0u) { char pName[64u]; - pOS->clientHostName (pName, sizeof (pName)); + pOS->hostName (pName, sizeof (pName)); errlogPrintf("CAS: allocated client object for \"%s\"\n", pName); } } diff --git a/src/cas/io/bsdSocket/casStreamIO.cc b/src/cas/io/bsdSocket/casStreamIO.cc index a75e0dbd8..ef89a6ef6 100644 --- a/src/cas/io/bsdSocket/casStreamIO.cc +++ b/src/cas/io/bsdSocket/casStreamIO.cc @@ -5,6 +5,9 @@ // // // $Log$ +// Revision 1.23 2002/02/25 15:19:51 lange +// All HPUX warnings fixed. +// // Revision 1.22 2001/07/11 23:31:45 jhill // adapt to new timer API // @@ -175,14 +178,14 @@ casStreamIO::~casStreamIO() // // casStreamIO::osdSend() // -outBuf::flushCondition casStreamIO::osdSend (const char *pInBuf, bufSizeT nBytesReq, - bufSizeT &nBytesActual) +outBufClient::flushCondition casStreamIO::osdSend ( const char *pInBuf, bufSizeT nBytesReq, + bufSizeT &nBytesActual ) { int status; status = send (this->sock, (char *) pInBuf, nBytesReq, 0); if (status == 0) { - return outBuf::flushDisconnect; + return outBufClient::flushDisconnect; } else if (status<0) { int anerrno = SOCKERRNO; @@ -192,25 +195,27 @@ outBuf::flushCondition casStreamIO::osdSend (const char *pInBuf, bufSizeT nBytes int errnoCpy = SOCKERRNO; ipAddrToA (&this->addr, buf, sizeof(buf)); - errlogPrintf( + if ( errnoCpy != SOCK_ECONNRESET ) { + errlogPrintf( "CAS: TCP socket send to \"%s\" failed because \"%s\"\n", - buf, SOCKERRSTR(errnoCpy)); - return outBuf::flushDisconnect; + buf, SOCKERRSTR(errnoCpy)); + } + return outBufClient::flushDisconnect; } else { - return outBuf::flushNone; + return outBufClient::flushNone; } } nBytesActual = (bufSizeT) status; - return outBuf::flushProgress; + return outBufClient::flushProgress; } // // casStreamIO::osdRecv() // -inBuf::fillCondition -casStreamIO::osdRecv (char *pInBuf, bufSizeT nBytes, // X aCC 361 - bufSizeT &nBytesActual) +inBufClient::fillCondition +casStreamIO::osdRecv ( char * pInBuf, bufSizeT nBytes, // X aCC 361 + bufSizeT & nBytesActual ) { int nchars; @@ -226,10 +231,12 @@ casStreamIO::osdRecv (char *pInBuf, bufSizeT nBytes, // X aCC 361 return casFillNone; } else { - ipAddrToA (&this->addr, buf, sizeof(buf)); - errlogPrintf( - "CAS: client %s disconnected because \"%s\"\n", - buf, SOCKERRSTR(myerrno)); + if ( myerrno != SOCK_ECONNRESET ) { + ipAddrToA (&this->addr, buf, sizeof(buf)); + errlogPrintf( + "CAS: client %s disconnected because \"%s\"\n", + buf, SOCKERRSTR(myerrno)); + } return casFillDisconnect; } } @@ -309,9 +316,9 @@ bufSizeT casStreamIO::incomingBytesPresent() const // X aCC 361 } // -// casStreamIO::clientHostName() +// casStreamIO::hostName() // -void casStreamIO::clientHostName (char *pInBuf, unsigned bufSizeIn) const +void casStreamIO::hostName (char *pInBuf, unsigned bufSizeIn) const { ipAddrToA (&this->addr, pInBuf, bufSizeIn); }