cleaning up
This commit is contained in:
@@ -115,16 +115,6 @@ int CASG::block ( double timeout )
|
||||
}
|
||||
this->mutex.unlock ();
|
||||
|
||||
/*
|
||||
* Exit if the timeout has expired
|
||||
* (dont wait forever for an itsy bitsy
|
||||
* delay which will not be updated if
|
||||
* select is called with no delay)
|
||||
*
|
||||
* current time is only updated by
|
||||
* cac_select_io() if we specify
|
||||
* at non-zero delay
|
||||
*/
|
||||
remaining = timeout - delay;
|
||||
if ( remaining <= CAC_SIGNIFICANT_SELECT_DELAY ) {
|
||||
/*
|
||||
|
||||
@@ -36,7 +36,7 @@ threadPrivateId cacRecursionLock;
|
||||
|
||||
static threadOnceId caClientContextIdOnce = OSITHREAD_ONCE_INIT;
|
||||
|
||||
extern "C" void ca_client_exit_handler ()
|
||||
void ca_client_exit_handler ()
|
||||
{
|
||||
if ( caClientContextId ) {
|
||||
threadPrivateDelete ( caClientContextId );
|
||||
@@ -84,7 +84,7 @@ int fetchClientContext (cac **ppcac)
|
||||
/*
|
||||
* Default Exception Handler
|
||||
*/
|
||||
extern "C" void ca_default_exception_handler (struct exception_handler_args args)
|
||||
void ca_default_exception_handler (struct exception_handler_args args)
|
||||
{
|
||||
if (args.chid && args.op != CA_OP_OTHER) {
|
||||
ca_signal_formated (
|
||||
@@ -157,33 +157,29 @@ epicsShareFunc int epicsShareAPI ca_register_service ( cacServiceIO *pService )
|
||||
return ECA_NORMAL;
|
||||
}
|
||||
|
||||
/*
|
||||
* CA_MODIFY_HOST_NAME()
|
||||
*
|
||||
* Modify or override the default
|
||||
* client host name.
|
||||
*
|
||||
* This entry point was changed to a NOOP
|
||||
*/
|
||||
//
|
||||
// ca_modify_host_name ()
|
||||
//
|
||||
// defunct
|
||||
//
|
||||
int epicsShareAPI ca_modify_host_name (const char *)
|
||||
{
|
||||
return ECA_NORMAL;
|
||||
}
|
||||
|
||||
/*
|
||||
* ca_modify_user_name()
|
||||
*
|
||||
* Modify or override the default
|
||||
* client user name.
|
||||
*
|
||||
* This entry point was changed to a NOOP
|
||||
*/
|
||||
//
|
||||
// ca_modify_user_name()
|
||||
//
|
||||
// defunct
|
||||
//
|
||||
int epicsShareAPI ca_modify_user_name (const char *)
|
||||
{
|
||||
return ECA_NORMAL;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// ca_context_destroy (void)
|
||||
//
|
||||
epicsShareFunc int epicsShareAPI ca_context_destroy (void)
|
||||
{
|
||||
cac *pcac;
|
||||
@@ -338,16 +334,7 @@ int epicsShareAPI ca_add_exception_event (caExceptionHandler *pfunc, void *arg)
|
||||
return caStatus;
|
||||
}
|
||||
|
||||
pcac->lock ();
|
||||
if ( pfunc ) {
|
||||
pcac->ca_exception_func = pfunc;
|
||||
pcac->ca_exception_arg = arg;
|
||||
}
|
||||
else {
|
||||
pcac->ca_exception_func = ca_default_exception_handler;
|
||||
pcac->ca_exception_arg = NULL;
|
||||
}
|
||||
pcac->unlock ();
|
||||
pcac->changeExceptionEvent ( pfunc, arg );
|
||||
|
||||
return ECA_NORMAL;
|
||||
}
|
||||
@@ -494,43 +481,6 @@ int epicsShareAPI ca_test_io ()
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* genLocalExcepWFL ()
|
||||
* (generate local exception with file and line number)
|
||||
*/
|
||||
void genLocalExcepWFL (cac *pcac, long stat, const char *ctx, const char *pFile, unsigned lineNo)
|
||||
{
|
||||
struct exception_handler_args args;
|
||||
|
||||
args.chid = NULL;
|
||||
args.type = -1;
|
||||
args.count = 0u;
|
||||
args.addr = NULL;
|
||||
args.stat = stat;
|
||||
args.op = CA_OP_OTHER;
|
||||
args.ctx = ctx;
|
||||
args.pFile = pFile;
|
||||
args.lineNo = lineNo;
|
||||
|
||||
/*
|
||||
* dont lock if there is no CA context
|
||||
*/
|
||||
if (pcac==NULL) {
|
||||
args.usr = NULL;
|
||||
ca_default_exception_handler (args);
|
||||
}
|
||||
/*
|
||||
* NOOP if they disable exceptions
|
||||
*/
|
||||
else if (pcac->ca_exception_func!=NULL) {
|
||||
args.usr = pcac->ca_exception_arg;
|
||||
|
||||
pcac->lock ();
|
||||
(*pcac->ca_exception_func) (args);
|
||||
pcac->unlock ();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* CA_SIGNAL()
|
||||
*/
|
||||
|
||||
140
src/ca/cac.cpp
140
src/ca/cac.cpp
@@ -43,6 +43,9 @@ cac::cac ( bool enablePreemptiveCallbackIn ) :
|
||||
sgTable ( 128 ),
|
||||
fdRegFunc ( 0 ),
|
||||
fdRegArg ( 0 ),
|
||||
pudpiiu ( 0 ),
|
||||
pSearchTmr ( 0 ),
|
||||
pRepeaterSubscribeTmr ( 0 ),
|
||||
pndrecvcnt ( 0 ),
|
||||
enablePreemptiveCallback ( enablePreemptiveCallbackIn )
|
||||
{
|
||||
@@ -80,7 +83,6 @@ cac::cac ( bool enablePreemptiveCallbackIn ) :
|
||||
ellInit (&this->fdInfoFreeList);
|
||||
ellInit (&this->fdInfoList);
|
||||
this->ca_printf_func = errlogVprintf;
|
||||
this->pudpiiu = NULL;
|
||||
this->ca_exception_func = ca_default_exception_handler;
|
||||
this->ca_exception_arg = NULL;
|
||||
this->ca_number_iiu_in_fc = 0u;
|
||||
@@ -217,6 +219,8 @@ cac::~cac ()
|
||||
( this->fdRegArg, this->pudpiiu->getSock (), FALSE );
|
||||
}
|
||||
}
|
||||
delete this->pSearchTmr;
|
||||
delete this->pRepeaterSubscribeTmr;
|
||||
delete this->pudpiiu;
|
||||
}
|
||||
|
||||
@@ -568,7 +572,9 @@ void cac::beaconNotify ( const inetAddrID &addr )
|
||||
delay /= MSEC_PER_SEC;
|
||||
delay += CA_RECAST_DELAY;
|
||||
|
||||
this->pudpiiu->searchTmr.reset ( delay );
|
||||
if ( this->pSearchTmr ) {
|
||||
this->pSearchTmr->reset ( delay );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -767,14 +773,14 @@ baseNMIU * cac::lookupIO (unsigned id)
|
||||
return pmiu;
|
||||
}
|
||||
|
||||
void cac::installChannel (nciu &chan)
|
||||
void cac::registerChannel (nciu &chan)
|
||||
{
|
||||
this->defaultMutex.lock ();
|
||||
this->chanTable.add ( chan );
|
||||
this->defaultMutex.unlock ();
|
||||
}
|
||||
|
||||
void cac::uninstallChannel (nciu &chan)
|
||||
void cac::unregisterChannel (nciu &chan)
|
||||
{
|
||||
this->defaultMutex.lock ();
|
||||
this->chanTable.remove ( chan );
|
||||
@@ -844,19 +850,9 @@ bool cac::createChannelIO (const char *pName, cacChannel &chan)
|
||||
pIO = cacGlobalServiceList.createChannelIO ( pName, chan );
|
||||
if ( ! pIO ) {
|
||||
if ( ! this->pudpiiu ) {
|
||||
this->defaultMutex.lock ();
|
||||
this->pudpiiu = new udpiiu ( this );
|
||||
if ( ! this->pudpiiu ) {
|
||||
this->defaultMutex.unlock ();
|
||||
if ( ! this->setupUDP () ) {
|
||||
return false;
|
||||
}
|
||||
if ( ! this->enablePreemptiveCallback ) {
|
||||
if ( this->fdRegFunc ) {
|
||||
( *this->fdRegFunc )
|
||||
( this->fdRegArg, this->pudpiiu->getSock (), TRUE );
|
||||
}
|
||||
}
|
||||
this->defaultMutex.unlock ();
|
||||
}
|
||||
nciu *pNetChan = new nciu ( this, chan, pName );
|
||||
if ( pNetChan ) {
|
||||
@@ -879,6 +875,49 @@ bool cac::createChannelIO (const char *pName, cacChannel &chan)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cac::setupUDP ()
|
||||
{
|
||||
this->defaultMutex.lock ();
|
||||
|
||||
if ( this->pudpiiu ) {
|
||||
this->defaultMutex.unlock ();
|
||||
return true;
|
||||
}
|
||||
|
||||
this->pudpiiu = new udpiiu ( this );
|
||||
if ( ! this->pudpiiu ) {
|
||||
this->defaultMutex.unlock ();
|
||||
return false;
|
||||
}
|
||||
|
||||
this->pSearchTmr = new searchTimer ( *this->pudpiiu, *this->pTimerQueue );
|
||||
if ( ! this->pSearchTmr ) {
|
||||
delete this->pudpiiu;
|
||||
this->pudpiiu = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
this->pRepeaterSubscribeTmr = new repeaterSubscribeTimer ( *this->pudpiiu, *this->pTimerQueue );
|
||||
if ( ! this->pRepeaterSubscribeTmr ) {
|
||||
delete this->pSearchTmr;
|
||||
delete this->pudpiiu;
|
||||
this->pudpiiu = 0;
|
||||
this->defaultMutex.unlock ();
|
||||
return false;
|
||||
}
|
||||
|
||||
this->defaultMutex.unlock ();
|
||||
|
||||
if ( ! this->enablePreemptiveCallback ) {
|
||||
if ( this->fdRegFunc ) {
|
||||
( *this->fdRegFunc )
|
||||
( this->fdRegArg, this->pudpiiu->getSock (), TRUE );
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void cac::lock () const
|
||||
{
|
||||
this->defaultMutex.lock ();
|
||||
@@ -906,3 +945,74 @@ void cac::disableCallbackPreemption ()
|
||||
{
|
||||
this->pProcThread->disable ();
|
||||
}
|
||||
|
||||
void cac::changeExceptionEvent ( caExceptionHandler *pfunc, void *arg )
|
||||
{
|
||||
this->defaultMutex.lock ();
|
||||
if ( pfunc ) {
|
||||
this->ca_exception_func = pfunc;
|
||||
this->ca_exception_arg = arg;
|
||||
}
|
||||
else {
|
||||
this->ca_exception_func = ca_default_exception_handler;
|
||||
this->ca_exception_arg = NULL;
|
||||
}
|
||||
this->defaultMutex.unlock ();
|
||||
}
|
||||
|
||||
//
|
||||
// cac::genLocalExcepWFL ()
|
||||
// (generate local exception with file and line number)
|
||||
//
|
||||
void cac::genLocalExcepWFL (long stat, const char *ctx, const char *pFile, unsigned lineNo)
|
||||
{
|
||||
struct exception_handler_args args;
|
||||
caExceptionHandler *pExceptionFunc;
|
||||
|
||||
/*
|
||||
* NOOP if they disable exceptions
|
||||
*/
|
||||
if ( this->ca_exception_func ) {
|
||||
args.chid = NULL;
|
||||
args.type = -1;
|
||||
args.count = 0u;
|
||||
args.addr = NULL;
|
||||
args.stat = stat;
|
||||
args.op = CA_OP_OTHER;
|
||||
args.ctx = ctx;
|
||||
args.pFile = pFile;
|
||||
args.lineNo = lineNo;
|
||||
|
||||
this->defaultMutex.lock ();
|
||||
pExceptionFunc = this->ca_exception_func;
|
||||
args.usr = this->ca_exception_arg;
|
||||
this->defaultMutex.unlock ();
|
||||
|
||||
(*pExceptionFunc) (args);
|
||||
}
|
||||
}
|
||||
|
||||
void cac::installDisconnectedChannel ( nciu &chan )
|
||||
{
|
||||
|
||||
assert ( this->pudpiiu && this->pSearchTmr );
|
||||
|
||||
this->defaultMutex.lock ();
|
||||
this->pudpiiu->addToChanList ( chan );
|
||||
this->pSearchTmr->reset ( CA_RECAST_DELAY );
|
||||
this->defaultMutex.unlock ();
|
||||
}
|
||||
|
||||
void cac::notifySearchResponse ( unsigned short retrySeqNo )
|
||||
{
|
||||
if ( this->pSearchTmr ) {
|
||||
this->pSearchTmr->notifySearchResponse ( retrySeqNo );
|
||||
}
|
||||
}
|
||||
|
||||
void cac::repeaterSubscribeConfirmNotify ()
|
||||
{
|
||||
if ( this->pRepeaterSubscribeTmr ) {
|
||||
this->pRepeaterSubscribeTmr->confirmNotify ();
|
||||
}
|
||||
}
|
||||
@@ -351,9 +351,9 @@ public:
|
||||
virtual bool ca_v41_ok () const = 0;
|
||||
virtual int pushStreamMsg (const caHdr *pmsg, const void *pext, bool BlockingOk) = 0;
|
||||
virtual int pushDatagramMsg (const caHdr *pMsg, const void *pExt, ca_uint16_t extsize) = 0;
|
||||
virtual void addToChanList (nciu *chan) = 0;
|
||||
virtual void removeFromChanList (nciu *chan) = 0;
|
||||
virtual void disconnect (nciu *chan) = 0;
|
||||
virtual void addToChanList ( nciu &chan ) = 0;
|
||||
virtual void removeFromChanList ( nciu &chan ) = 0;
|
||||
virtual void disconnect ( nciu &chan ) = 0;
|
||||
|
||||
tsDLList <nciu> chidList;
|
||||
};
|
||||
@@ -364,7 +364,7 @@ class searchTimer : public osiTimer {
|
||||
|
||||
public:
|
||||
searchTimer (udpiiu &iiu, osiTimerQueue &queue);
|
||||
void notifySearchResponse (nciu *pChan);
|
||||
void notifySearchResponse ( unsigned short retrySeqNo );
|
||||
void reset (double delayToNextTry);
|
||||
|
||||
private:
|
||||
@@ -416,9 +416,9 @@ public:
|
||||
void hostName ( char *pBuf, unsigned bufLength ) const;
|
||||
bool ca_v42_ok () const;
|
||||
bool ca_v41_ok () const;
|
||||
void addToChanList (nciu *chan);
|
||||
void removeFromChanList (nciu *chan);
|
||||
void disconnect (nciu *chan);
|
||||
void addToChanList ( nciu &chan );
|
||||
void removeFromChanList ( nciu &chan );
|
||||
void disconnect ( nciu &chan );
|
||||
int recvMsg ();
|
||||
int post_msg (const struct sockaddr_in *pnet_addr,
|
||||
char *pInBuf, unsigned long blockSize);
|
||||
@@ -431,8 +431,6 @@ public:
|
||||
osiTime recvTime;
|
||||
char xmitBuf[MAX_UDP];
|
||||
char recvBuf[ETHERNET_MAX_UDP];
|
||||
searchTimer searchTmr;
|
||||
repeaterSubscribeTimer repeaterSubscribeTmr;
|
||||
semMutexId xmitBufLock;
|
||||
ELLLIST dest;
|
||||
semBinaryId recvThreadExitSignal;
|
||||
@@ -511,10 +509,10 @@ public:
|
||||
bool ca_v41_ok () const;
|
||||
int pushStreamMsg ( const caHdr *pmsg, const void *pext, bool BlockingOk );
|
||||
int post_msg (char *pInBuf, unsigned long blockSize);
|
||||
void addToChanList (nciu *chan);
|
||||
void removeFromChanList (nciu *chan);
|
||||
void addToChanList ( nciu &chan );
|
||||
void removeFromChanList ( nciu &chan );
|
||||
void connect ();
|
||||
void disconnect (nciu *chan);
|
||||
void disconnect ( nciu &chan );
|
||||
bool fullyConstructed () const;
|
||||
void recvMsg ();
|
||||
void flush ();
|
||||
@@ -735,8 +733,8 @@ public:
|
||||
void installIO (baseNMIU &io);
|
||||
void uninstallIO (baseNMIU &io);
|
||||
nciu * lookupChan (unsigned id);
|
||||
void installChannel (nciu &chan);
|
||||
void uninstallChannel (nciu &chan);
|
||||
void registerChannel (nciu &chan);
|
||||
void unregisterChannel (nciu &chan);
|
||||
CASG * lookupCASG (unsigned id);
|
||||
void installCASG (CASG &);
|
||||
void uninstallCASG (CASG &);
|
||||
@@ -747,6 +745,11 @@ public:
|
||||
void unlock () const;
|
||||
void enableCallbackPreemption ();
|
||||
void disableCallbackPreemption ();
|
||||
void changeExceptionEvent ( caExceptionHandler *pfunc, void *arg );
|
||||
void genLocalExcepWFL (long stat, const char *ctx, const char *pFile, unsigned lineNo);
|
||||
void installDisconnectedChannel ( nciu &chan );
|
||||
void notifySearchResponse ( unsigned short retrySeqNo );
|
||||
void repeaterSubscribeConfirmNotify ();
|
||||
|
||||
osiTimerQueue *pTimerQueue;
|
||||
ELLLIST activeCASGOP;
|
||||
@@ -755,7 +758,6 @@ public:
|
||||
ELLLIST fdInfoList;
|
||||
osiTime programBeginTime;
|
||||
ca_real ca_connectTMO;
|
||||
udpiiu *pudpiiu;
|
||||
caExceptionHandler *ca_exception_func;
|
||||
void *ca_exception_arg;
|
||||
caPrintfFunc *ca_printf_func;
|
||||
@@ -771,7 +773,6 @@ public:
|
||||
unsigned ca_nextSlowBucketId;
|
||||
unsigned ca_number_iiu_in_fc;
|
||||
unsigned short ca_server_port;
|
||||
char ca_sprintf_buf[256];
|
||||
char ca_new_err_code_msg_buf[128u];
|
||||
|
||||
ELLLIST ca_taskVarList;
|
||||
@@ -792,10 +793,14 @@ private:
|
||||
processThread *pProcThread;
|
||||
CAFDHANDLER *fdRegFunc;
|
||||
void *fdRegArg;
|
||||
udpiiu *pudpiiu;
|
||||
searchTimer *pSearchTmr;
|
||||
repeaterSubscribeTimer *pRepeaterSubscribeTmr;
|
||||
unsigned pndrecvcnt;
|
||||
bool enablePreemptiveCallback;
|
||||
|
||||
int pendPrivate (double timeout, int early);
|
||||
bool setupUDP ();
|
||||
};
|
||||
|
||||
extern const caHdr cacnullmsg;
|
||||
@@ -808,17 +813,15 @@ int ca_printf (const char *pformat, ...);
|
||||
int ca_vPrintf (const char *pformat, va_list args);
|
||||
void manage_conn (cac *pcac);
|
||||
epicsShareFunc void epicsShareAPI ca_repeater (void);
|
||||
int cac_select_io (cac *pcac, double maxDelay, int flags);
|
||||
|
||||
char *localHostName (void);
|
||||
|
||||
bhe *lookupBeaconInetAddr(cac *pcac,
|
||||
const struct sockaddr_in *pnet_addr);
|
||||
|
||||
void genLocalExcepWFL (cac *pcac, long stat, const char *ctx,
|
||||
const char *pFile, unsigned line);
|
||||
#define genLocalExcep(PCAC, STAT, PCTX) \
|
||||
genLocalExcepWFL (PCAC, STAT, PCTX, __FILE__, __LINE__)
|
||||
#define genLocalExcep( PCAC, STAT, PCTX ) \
|
||||
(PCAC)->genLocalExcepWFL ( STAT, PCTX, __FILE__, __LINE__ )
|
||||
|
||||
double cac_fetch_poll_period (cac *pcac);
|
||||
tcpiiu * constructTCPIIU (cac *pcac, const struct sockaddr_in *pina,
|
||||
unsigned minorVersion);
|
||||
|
||||
@@ -40,8 +40,6 @@ nciu::nciu ( cac *pcac, cacChannel &chan, const char *pNameIn ) :
|
||||
}
|
||||
strcpy ( this->pNameStr, pNameIn );
|
||||
|
||||
pcac->lock ();
|
||||
|
||||
this->typeCode = USHRT_MAX; /* invalid initial type */
|
||||
this->count = 0; /* invalid initial count */
|
||||
this->sid = UINT_MAX; /* invalid initial server id */
|
||||
@@ -49,17 +47,14 @@ nciu::nciu ( cac *pcac, cacChannel &chan, const char *pNameIn ) :
|
||||
this->nameLength = strcnt;
|
||||
this->previousConn = 0;
|
||||
this->f_connected = false;
|
||||
|
||||
pcac->installChannel ( *this );
|
||||
pcac->pudpiiu->addToChanList ( this );
|
||||
|
||||
/*
|
||||
* reset broadcasted search counters
|
||||
*/
|
||||
pcac->pudpiiu->searchTmr.reset ( CA_RECAST_DELAY );
|
||||
|
||||
this->f_fullyConstructed = true;
|
||||
|
||||
pcac->lock ();
|
||||
|
||||
pcac->registerChannel ( *this );
|
||||
|
||||
pcac->installDisconnectedChannel ( *this );
|
||||
|
||||
chan.attachIO ( *this );
|
||||
|
||||
pcac->unlock ();
|
||||
@@ -105,11 +100,11 @@ nciu::~nciu ()
|
||||
iter = next;
|
||||
}
|
||||
|
||||
this->piiu->pcas->uninstallChannel (*this);
|
||||
this->piiu->pcas->unregisterChannel ( *this );
|
||||
|
||||
this->piiu->removeFromChanList ( this );
|
||||
this->piiu->removeFromChanList ( *this );
|
||||
|
||||
free ( reinterpret_cast <void *> (this->pNameStr) );
|
||||
free ( reinterpret_cast <void *> ( this->pNameStr ) );
|
||||
|
||||
piiuCopy->pcas->unlock (); // remove clears this->piiu
|
||||
}
|
||||
@@ -670,7 +665,7 @@ void nciu::disconnect ()
|
||||
|
||||
this->piiu->pcas->unlock ();
|
||||
|
||||
this->piiu->disconnect ( this );
|
||||
this->piiu->disconnect ( *this );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -681,11 +676,7 @@ int nciu::searchMsg ()
|
||||
int status;
|
||||
caHdr msg;
|
||||
|
||||
if ( this->piiu != static_cast<netiiu *> (this->piiu->pcas->pudpiiu) ) {
|
||||
return ECA_INTERNAL;
|
||||
}
|
||||
|
||||
if (this->nameLength > 0xffff) {
|
||||
if ( this->nameLength > 0xffff ) {
|
||||
return ECA_STRTOBIG;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ void repeaterSubscribeTimer::expire ()
|
||||
{
|
||||
static const unsigned nTriesToMsg = 50;
|
||||
this->attempts++;
|
||||
|
||||
printf ("pinging repeater\n");
|
||||
if ( this->attempts > nTriesToMsg && ! this->once ) {
|
||||
ca_printf (
|
||||
"Unable to contact CA repeater after %u tries\n", nTriesToMsg);
|
||||
|
||||
@@ -105,11 +105,11 @@ void searchTimer::setRetryInterval (unsigned retryNo)
|
||||
// at least one response. However, dont reset this delay if we
|
||||
// get a delayed response to an old search request.
|
||||
//
|
||||
void searchTimer::notifySearchResponse (nciu *pChan)
|
||||
void searchTimer::notifySearchResponse ( unsigned short retrySeqNo )
|
||||
{
|
||||
this->iiu.pcas->lock ();
|
||||
|
||||
if ( this->retrySeqNoAtListBegin <= pChan->retrySeqNo ) {
|
||||
if ( this->retrySeqNoAtListBegin <= retrySeqNo ) {
|
||||
if ( this->searchResponses < ULONG_MAX ) {
|
||||
this->searchResponses++;
|
||||
}
|
||||
@@ -117,7 +117,7 @@ void searchTimer::notifySearchResponse (nciu *pChan)
|
||||
|
||||
this->iiu.pcas->unlock ();
|
||||
|
||||
if ( pChan->retrySeqNo == this->retrySeqNo ) {
|
||||
if ( retrySeqNo == this->retrySeqNo ) {
|
||||
this->reschedule (0.0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ tcpiiu * constructTCPIIU (cac *pcac, const struct sockaddr_in *pina,
|
||||
}
|
||||
}
|
||||
|
||||
piiu = new tcpiiu (pcac, *pina, minorVersion, *pBHE);
|
||||
piiu = new tcpiiu ( pcac, *pina, minorVersion, *pBHE );
|
||||
if (!piiu) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -551,7 +551,7 @@ tcpiiu::~tcpiiu ()
|
||||
|
||||
chanDisconnectCount = ellCount (&this->chidList);
|
||||
if ( chanDisconnectCount ) {
|
||||
genLocalExcep (this->pcas, ECA_DISCONN, this->host_name_str);
|
||||
genLocalExcep ( this->pcas, ECA_DISCONN, this->host_name_str );
|
||||
}
|
||||
|
||||
tsDLIterBD <nciu> iter ( this->chidList.first () );
|
||||
@@ -595,16 +595,13 @@ bool tcpiiu::compareIfTCP ( nciu &chan, const sockaddr_in &addr ) const
|
||||
{
|
||||
if ( this->dest.ia.sin_addr.s_addr != addr.sin_addr.s_addr ||
|
||||
this->dest.ia.sin_port != addr.sin_port ) {
|
||||
|
||||
char rej[64];
|
||||
char buf[256];
|
||||
|
||||
ipAddrToA ( &addr, rej, sizeof (rej) );
|
||||
this->pcas->lock ();
|
||||
sprintf ( this->pcas->ca_sprintf_buf,
|
||||
"Channel: %s Accepted: %s Rejected: %s ",
|
||||
sprintf ( buf, "Channel: %64s Accepted: %64s Rejected: %64s",
|
||||
chan.pName (), this->host_name_str, rej );
|
||||
genLocalExcep (this->pcas, ECA_DBLCHNL, this->pcas->ca_sprintf_buf);
|
||||
this->pcas->unlock ();
|
||||
genLocalExcep ( this->pcas, ECA_DBLCHNL, buf );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1441,20 +1438,20 @@ int tcpiiu::pushDatagramMsg (const caHdr * /* pMsg */,
|
||||
* have sent the claim message (after which we
|
||||
* move it to the end of the list)
|
||||
*/
|
||||
void tcpiiu::addToChanList (nciu *chan)
|
||||
void tcpiiu::addToChanList ( nciu &chan )
|
||||
{
|
||||
this->pcas->lock ();
|
||||
chan->claimPending = TRUE;
|
||||
this->chidList.push (*chan);
|
||||
chan->piiu = this;
|
||||
chan.claimPending = TRUE;
|
||||
this->chidList.push ( chan );
|
||||
chan.piiu = this;
|
||||
this->pcas->unlock ();
|
||||
}
|
||||
|
||||
void tcpiiu::removeFromChanList (nciu *chan)
|
||||
void tcpiiu::removeFromChanList ( nciu &chan )
|
||||
{
|
||||
this->pcas->lock ();
|
||||
this->chidList.remove (*chan);
|
||||
chan->piiu = NULL;
|
||||
this->chidList.remove ( chan );
|
||||
chan.piiu = NULL;
|
||||
this->pcas->unlock ();
|
||||
|
||||
if ( this->chidList.count () == 0 ) {
|
||||
@@ -1462,16 +1459,11 @@ void tcpiiu::removeFromChanList (nciu *chan)
|
||||
}
|
||||
}
|
||||
|
||||
void tcpiiu::disconnect (nciu *chan)
|
||||
void tcpiiu::disconnect ( nciu &chan )
|
||||
{
|
||||
this->pcas->lock ();
|
||||
this->removeFromChanList (chan);
|
||||
/*
|
||||
* try to reconnect
|
||||
*/
|
||||
assert (this->pcas->pudpiiu);
|
||||
this->pcas->pudpiiu->addToChanList ( chan );
|
||||
this->pcas->pudpiiu->searchTmr.reset ( CA_RECAST_DELAY );
|
||||
this->pcas->installDisconnectedChannel ( chan );
|
||||
this->pcas->unlock ();
|
||||
}
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ void udpiiu::repeaterRegistrationMessage ( unsigned attemptNumber )
|
||||
# endif
|
||||
|
||||
status = sendto ( this->sock, (char *) &msg, len,
|
||||
0, (struct sockaddr *)&saddr, sizeof (saddr) );
|
||||
0, (struct sockaddr *) &saddr, sizeof ( saddr ) );
|
||||
if ( status < 0 ) {
|
||||
int errnoCpy = SOCKERRNO;
|
||||
if ( errnoCpy != SOCK_EINTR &&
|
||||
@@ -182,8 +182,7 @@ void udpiiu::repeaterRegistrationMessage ( unsigned attemptNumber )
|
||||
* the repeater isnt running
|
||||
*/
|
||||
errnoCpy != SOCK_ECONNREFUSED ) {
|
||||
ca_printf (
|
||||
"CAC: error sending to repeater was \"%s\"\n",
|
||||
ca_printf ( "CAC: error sending to repeater was \"%s\"\n",
|
||||
SOCKERRSTR (errnoCpy) );
|
||||
}
|
||||
}
|
||||
@@ -258,8 +257,6 @@ int repeater_installed (udpiiu *piiu)
|
||||
//
|
||||
udpiiu::udpiiu ( cac *pcac ) :
|
||||
netiiu ( pcac ),
|
||||
searchTmr ( *this, *pcac->pTimerQueue ),
|
||||
repeaterSubscribeTmr ( *this, *pcac->pTimerQueue ),
|
||||
shutdownCmd ( false )
|
||||
{
|
||||
static const unsigned short PORT_ANY = 0u;
|
||||
@@ -340,7 +337,7 @@ udpiiu::udpiiu ( cac *pcac ) :
|
||||
ellInit ( &this->dest );
|
||||
configureChannelAccessAddressList (&this->dest, this->sock, pcac->ca_server_port);
|
||||
if ( ellCount ( &this->dest ) == 0 ) {
|
||||
genLocalExcep ( NULL, ECA_NOSEARCHADDR, NULL );
|
||||
genLocalExcep ( this->pcas, ECA_NOSEARCHADDR, NULL );
|
||||
}
|
||||
|
||||
{
|
||||
@@ -397,8 +394,6 @@ udpiiu::~udpiiu ()
|
||||
{
|
||||
nciu *pChan, *pNext;
|
||||
|
||||
this->searchTmr.cancel ();
|
||||
|
||||
// closes the udp socket
|
||||
this->shutdown ();
|
||||
|
||||
@@ -553,7 +548,7 @@ LOCAL void search_resp_action (udpiiu *piiu, caHdr *pMsg, const struct sockaddr_
|
||||
allocpiiu->hostNameSetMsg ();
|
||||
}
|
||||
|
||||
piiu->searchTmr.notifySearchResponse (chan);
|
||||
piiu->pcas->notifySearchResponse ( chan->retrySeqNo );
|
||||
|
||||
/*
|
||||
* Assume that we have access once connected briefly
|
||||
@@ -570,7 +565,7 @@ LOCAL void search_resp_action (udpiiu *piiu, caHdr *pMsg, const struct sockaddr_
|
||||
/*
|
||||
* remove it from the broadcast niiu
|
||||
*/
|
||||
chan->piiu->removeFromChanList ( chan );
|
||||
chan->piiu->removeFromChanList ( *chan );
|
||||
|
||||
/*
|
||||
* chan->piiu must be correctly set prior to issuing the
|
||||
@@ -582,7 +577,7 @@ LOCAL void search_resp_action (udpiiu *piiu, caHdr *pMsg, const struct sockaddr_
|
||||
*
|
||||
* claim pending flag is set here
|
||||
*/
|
||||
allocpiiu->addToChanList ( chan );
|
||||
allocpiiu->addToChanList ( *chan );
|
||||
|
||||
if ( CA_V42 ( CA_PROTOCOL_VERSION, minorVersion ) ) {
|
||||
chan->searchReplySetUp ( pMsg->m_cid, USHRT_MAX, 0 );
|
||||
@@ -652,7 +647,7 @@ LOCAL void beacon_action ( udpiiu * piiu,
|
||||
LOCAL void repeater_ack_action (udpiiu * piiu,
|
||||
caHdr * /* pMsg */, const struct sockaddr_in * /* pnet_addr */)
|
||||
{
|
||||
piiu->repeaterSubscribeTmr.confirmNotify ();
|
||||
piiu->pcas->repeaterSubscribeConfirmNotify ();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -814,7 +809,7 @@ bool udpiiu::compareIfTCP (nciu &, const sockaddr_in &) const
|
||||
* one chan on the B cast iiu list is pointed to by
|
||||
* ca_pEndOfBCastList
|
||||
*/
|
||||
void udpiiu::addToChanList (nciu *chan)
|
||||
void udpiiu::addToChanList ( nciu &chan )
|
||||
{
|
||||
this->pcas->lock ();
|
||||
|
||||
@@ -822,39 +817,40 @@ void udpiiu::addToChanList (nciu *chan)
|
||||
* add to the beginning of the list so that search requests for
|
||||
* this channel will be sent first (since the retry count is zero)
|
||||
*/
|
||||
if ( ellCount (&this->chidList) == 0 ) {
|
||||
this->pcas->endOfBCastList = tsDLIterBD<nciu>(chan);
|
||||
if ( ellCount ( &this->chidList ) == 0 ) {
|
||||
this->pcas->endOfBCastList = tsDLIterBD <nciu> ( &chan );
|
||||
}
|
||||
/*
|
||||
* add to the front of the list so that
|
||||
* search requests for new channels will be sent first
|
||||
*/
|
||||
chan->retry = 0u;
|
||||
this->chidList.push (*chan);
|
||||
chan->piiu = this;
|
||||
chan.retry = 0u;
|
||||
this->chidList.push ( chan );
|
||||
chan.piiu = this;
|
||||
|
||||
this->pcas->unlock ();
|
||||
}
|
||||
|
||||
void udpiiu::removeFromChanList (nciu *chan)
|
||||
void udpiiu::removeFromChanList ( nciu &chan )
|
||||
{
|
||||
tsDLIterBD<nciu> iter (chan);
|
||||
tsDLIterBD <nciu> iter ( &chan );
|
||||
|
||||
this->pcas->lock ();
|
||||
if ( chan->piiu->pcas->endOfBCastList == iter ) {
|
||||
if ( chan.piiu->pcas->endOfBCastList == iter ) {
|
||||
if ( iter.itemBefore () != tsDLIterBD<nciu>::eol () ) {
|
||||
chan->piiu->pcas->endOfBCastList = iter.itemBefore ();
|
||||
chan.piiu->pcas->endOfBCastList = iter.itemBefore ();
|
||||
}
|
||||
else {
|
||||
chan->piiu->pcas->endOfBCastList =
|
||||
tsDLIterBD<nciu> (chan->piiu->chidList.last());
|
||||
chan.piiu->pcas->endOfBCastList =
|
||||
tsDLIterBD<nciu> ( chan.piiu->chidList.last () );
|
||||
}
|
||||
}
|
||||
chan->piiu->chidList.remove (*chan);
|
||||
chan->piiu = NULL;
|
||||
chan.piiu->chidList.remove ( chan );
|
||||
chan.piiu = NULL;
|
||||
this->pcas->unlock ();
|
||||
}
|
||||
|
||||
void udpiiu::disconnect ( nciu * /* chan */ )
|
||||
void udpiiu::disconnect ( nciu & /* chan */ )
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user