/* * verifyClients() */ static void verifyClients ( tsFreeList < repeaterClient, 0x20 > & freeList ) { static tsDLList < repeaterClient > theClients; repeaterClient *pclient; while ( ( pclient = client_list.get () ) ) { if ( pclient->verify () ) { theClients.add ( *pclient ); } else { pclient->~repeaterClient (); freeList.release ( pclient ); } } client_list.add ( theClients ); }
/* * fanOut() */ static void fanOut ( const osiSockAddr & from, const void * pMsg, unsigned msgSize, tsFreeList < repeaterClient, 0x20 > & freeList ) { static tsDLList < repeaterClient > theClients; repeaterClient *pclient; while ( ( pclient = client_list.get () ) ) { theClients.add ( *pclient ); /* Dont reflect back to sender */ if ( pclient->identicalAddress ( from ) ) { continue; } if ( ! pclient->sendMessage ( pMsg, msgSize ) ) { if ( ! pclient->verify () ) { theClients.remove ( *pclient ); pclient->~repeaterClient (); freeList.release ( pclient ); } } } client_list.add ( theClients ); }
inline void ipAddrToAsciiTransactionPrivate::operator delete ( void * pTrans, tsFreeList < ipAddrToAsciiTransactionPrivate, 0x80 > & freeList ) { freeList.release ( pTrans ); }
/* * register_new_client() */ static void register_new_client ( osiSockAddr & from, tsFreeList < repeaterClient, 0x20 > & freeList ) { bool newClient = false; int status; if ( from.sa.sa_family != AF_INET ) { return; } /* * the repeater and its clients must be on the same host */ if ( INADDR_LOOPBACK != ntohl ( from.ia.sin_addr.s_addr ) ) { static SOCKET testSock = INVALID_SOCKET; static bool init = false; if ( ! init ) { SOCKET sock; if ( ! makeSocket ( PORT_ANY, true, & sock ) ) { char sockErrBuf[64]; epicsSocketConvertErrnoToString ( sockErrBuf, sizeof ( sockErrBuf ) ); fprintf ( stderr, "%s: Unable to create repeater bind test socket because \"%s\"\n", __FILE__, sockErrBuf ); } else { testSock = sock; } init = true; } /* * Unfortunately on 3.13 beta 11 and before the * repeater would not always allow the loopback address * as a local client address so current clients alternate * between the address of the first non-loopback interface * found and the loopback addresss when subscribing with * the CA repeater until all CA repeaters have been updated * to current code. */ if ( testSock != INVALID_SOCKET ) { osiSockAddr addr; addr = from; addr.ia.sin_port = PORT_ANY; /* we can only bind to a local address */ status = bind ( testSock, &addr.sa, sizeof ( addr ) ); if ( status ) { return; } } else { return; } } tsDLIter < repeaterClient > pclient = client_list.firstIter (); while ( pclient.valid () ) { if ( pclient->identicalPort ( from ) ) { break; } pclient++; } repeaterClient *pNewClient; if ( pclient.valid () ) { pNewClient = pclient.pointer (); } else { pNewClient = new ( freeList ) repeaterClient ( from ); if ( ! pNewClient ) { fprintf ( stderr, "%s: no memory for new client\n", __FILE__ ); return; } if ( ! pNewClient->connect () ) { pNewClient->~repeaterClient (); freeList.release ( pNewClient ); return; } client_list.add ( *pNewClient ); newClient = true; } if ( ! pNewClient->sendConfirm () ) { client_list.remove ( *pNewClient ); pNewClient->~repeaterClient (); freeList.release ( pNewClient ); # ifdef DEBUG epicsUInt16 port = ntohs ( from.ia.sin_port ); debugPrintf ( ( "Deleted repeater client=%u (error while sending ack)\n", port ) ); # endif } /* * send a noop message to all other clients so that we dont * accumulate sockets when there are no beacons */ caHdr noop; memset ( (char *) &noop, '\0', sizeof ( noop ) ); AlignedWireRef < epicsUInt16 > ( noop.m_cmmd ) = CA_PROTO_VERSION; fanOut ( from, &noop, sizeof ( noop ), freeList ); if ( newClient ) { /* * For HPUX and Solaris we need to verify that the clients * have not gone away - because an ICMP error return does not * get through to send(), which returns no error code. * * This is done each time that a new client is created. * See also the note in the file header. * * This is done here in order to avoid deleting a client * prior to sending its confirm message. */ verifyClients ( freeList ); } }
void repeaterClient::operator delete ( void *pCadaver, tsFreeList < repeaterClient, 0x20 > & freeList ) { freeList.release ( pCadaver ); }
void msgForMultiplyDefinedPV::operator delete ( void *pCadaver, tsFreeList < class msgForMultiplyDefinedPV, 16 > & freeList ) { freeList.release ( pCadaver, sizeof ( msgForMultiplyDefinedPV ) ); }
void dbSubscriptionIO::operator delete ( void * pCadaver, tsFreeList < dbSubscriptionIO, 256, epicsMutexNOOP > & freeList ) { freeList.release ( pCadaver ); }
void syncGroupReadNotify::operator delete ( void *pCadaver, tsFreeList < class syncGroupReadNotify, 128, epicsMutexNOOP > &freeList ) { freeList.release ( pCadaver ); }