From fb931434bd83949cb0c014703dee54eb8459a4fc Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Wed, 24 Nov 2004 22:11:20 +0000 Subject: [PATCH] fix for mantis 159 --- src/cas/generic/st/casStreamOS.cc | 35 +++++++++++++++---------------- src/cas/generic/st/casStreamOS.h | 4 ++-- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/cas/generic/st/casStreamOS.cc b/src/cas/generic/st/casStreamOS.cc index 5de20bf4b..1bb27308b 100644 --- a/src/cas/generic/st/casStreamOS.cc +++ b/src/cas/generic/st/casStreamOS.cc @@ -115,8 +115,8 @@ inline casStreamWriteReg::~casStreamWriteReg () // // casStreamEvWakeup() // -casStreamEvWakeup::casStreamEvWakeup () : - timer ( fileDescriptorManager.createTimer() ), pOS ( 0 ) +casStreamEvWakeup::casStreamEvWakeup ( casStreamOS & osIn ) : + timer ( fileDescriptorManager.createTimer() ), os ( osIn ) { } @@ -144,12 +144,9 @@ void casStreamEvWakeup::show(unsigned level) const // epicsTimerNotify::expireStatus casStreamEvWakeup::expire ( const epicsTime & /* currentTime */ ) { - casStreamOS & os = *this->pOS; - this->pOS = 0; - casEventSys::processStatus ps = os.eventSysProcess (); if ( ps.nAccepted > 0u ) { - os.eventFlush (); + this->os.eventFlush (); } if ( ps.cond != casProcOk ) { // @@ -160,7 +157,7 @@ epicsTimerNotify::expireStatus casStreamEvWakeup::expire ( const epicsTime & /* // called from a client member function // higher up on the stack // - delete & os; + delete & this->os; // // must not touch the "this" pointer @@ -175,13 +172,13 @@ epicsTimerNotify::expireStatus casStreamEvWakeup::expire ( const epicsTime & /* // void casStreamEvWakeup::start( casStreamOS &os ) { - if ( this->pOS ) { - assert ( this->pOS == &os ); - } - else { - this->pOS = &os; - this->timer.start ( *this, 0.0 ); - } + // care is needed here because this is called + // asynchronously by postEvent + // + // there is some overhead here but care is taken + // in the caller of this routine to call this + // only when its the 2nd event on the queue + this->timer.start ( *this, 0.0 ); } // @@ -317,10 +314,12 @@ void casStreamOS::eventFlush() // // casStreamOS::casStreamOS() // -casStreamOS::casStreamOS ( caServerI & cas, clientBufMemoryManager & bufMgrIn, - const ioArgsToNewStreamIO & ioArgs ) : - casStreamIO ( cas, bufMgrIn, ioArgs ), - pWtReg ( 0 ), pRdReg ( 0 ), sendBlocked ( false ) +casStreamOS::casStreamOS ( + caServerI & cas, clientBufMemoryManager & bufMgrIn, + const ioArgsToNewStreamIO & ioArgs ) : + casStreamIO ( cas, bufMgrIn, ioArgs ), + evWk ( *this ), pWtReg ( 0 ), pRdReg ( 0 ), + sendBlocked ( false ) { this->xSetNonBlocking (); this->armRecv (); diff --git a/src/cas/generic/st/casStreamOS.h b/src/cas/generic/st/casStreamOS.h index dc41c8f97..91d8c39cd 100644 --- a/src/cas/generic/st/casStreamOS.h +++ b/src/cas/generic/st/casStreamOS.h @@ -48,13 +48,13 @@ private: class casStreamEvWakeup : public epicsTimerNotify { public: - casStreamEvWakeup (); + casStreamEvWakeup ( casStreamOS & ); virtual ~casStreamEvWakeup (); void show ( unsigned level ) const; void start ( class casStreamOS & osIn ); private: epicsTimer & timer; - casStreamOS * pOS; + casStreamOS & os; expireStatus expire ( const epicsTime & currentTime ); casStreamEvWakeup ( const casStreamEvWakeup & ); casStreamEvWakeup & operator = ( const casStreamEvWakeup & );