@@ -3087,7 +3087,7 @@ class InternalClientContextImpl :
30873087 ChannelRequester::shared_pointer const & channelRequester,
30883088 short priority) OVERRIDE FINAL
30893089 {
3090- return createChannel (channelName, channelRequester, priority, std::string () );
3090+ return createChannel (channelName, channelRequester, priority, m_addressList );
30913091 }
30923092
30933093 virtual Channel::shared_pointer createChannel (
@@ -3097,7 +3097,7 @@ class InternalClientContextImpl :
30973097 std::string const & addressesStr) OVERRIDE FINAL
30983098 {
30993099 InetAddrVector addresses;
3100- getSocketAddressList (addresses, addressesStr, PVA_SERVER_PORT );
3100+ getSocketAddressList (addresses, addressesStr, m_serverPort );
31013101
31023102 Channel::shared_pointer channel = createChannelInternal (channelName, channelRequester, priority, addresses);
31033103 if (channel.get ())
@@ -3567,6 +3567,7 @@ class InternalClientContextImpl :
35673567
35683568#define STATIC_SEARCH_BASE_DELAY_SEC 5
35693569#define STATIC_SEARCH_MAX_MULTIPLIER 10
3570+ #define STATIC_SEARCH_MIN_DELAY_SEC 1
35703571
35713572 /* *
35723573 * Initiate search (connect) procedure.
@@ -3577,21 +3578,28 @@ class InternalClientContextImpl :
35773578
35783579 m_allowCreation = true ;
35793580
3580- if (m_addresses.empty ())
3581- {
3582- m_context-> getChannelSearchManager ()-> registerSearchInstance ( internal_from_this (), penalize );
3583- }
3584- else
3585- {
3586- m_context-> getTimer ()-> scheduleAfterDelay ( internal_from_this (),
3587- (m_addressIndex / m_addresses. size ())*STATIC_SEARCH_BASE_DELAY_SEC );
3581+ if (! m_addresses.empty ()) {
3582+ char strBuffer[ 24 ];
3583+ int index = m_addressIndex % m_addresses. size ( );
3584+ osiSockAddr* serverAddress = &m_addresses[index];
3585+ ipAddrToDottedIP (&serverAddress-> ia , strBuffer, sizeof (strBuffer));
3586+ double delay = (m_addressIndex / m_addresses. size ())*STATIC_SEARCH_BASE_DELAY_SEC+STATIC_SEARCH_MIN_DELAY_SEC;
3587+ LOG (logLevelDebug, " Scheduling channel search for address %s with delay of %.3f seconds. " , strBuffer, delay);
3588+ m_context-> getTimer ()-> scheduleAfterDelay ( internal_from_this (), delay );
35883589 }
3590+ m_context->getChannelSearchManager ()->registerSearchInstance (internal_from_this (), penalize);
35893591 }
35903592
35913593 virtual void callback () OVERRIDE FINAL {
35923594 // TODO cancellaction?!
35933595 // TODO not in this timer thread !!!
35943596 // TODO boost when a server (from address list) is started!!! IP vs address !!!
3597+ Transport::shared_pointer transport (m_transport);
3598+ if (transport) {
3599+ LOG (logLevelDebug, " Transport for channel %s is already active, channel search cancelled." , transport->getRemoteName ().c_str ());
3600+ return ;
3601+ }
3602+
35953603 int ix = m_addressIndex % m_addresses.size ();
35963604 m_addressIndex++;
35973605 if (m_addressIndex >= static_cast <int >(m_addresses.size ()*(STATIC_SEARCH_MAX_MULTIPLIER+1 )))
@@ -3957,7 +3965,7 @@ class InternalClientContextImpl :
39573965 static size_t num_instances;
39583966
39593967 InternalClientContextImpl (const Configuration::shared_pointer& conf) :
3960- m_addressList (" " ), m_autoAddressList(true ), m_connectionTimeout(30 .0f ), m_beaconPeriod(15 .0f ),
3968+ m_addressList (" " ), m_autoAddressList(true ), m_serverPort(PVA_SERVER_PORT), m_connectionTimeout(30 .0f ), m_beaconPeriod(15 .0f ),
39613969 m_broadcastPort (PVA_BROADCAST_PORT), m_receiveBufferSize(MAX_TCP_RECV),
39623970 m_lastCID (0x10203040 ),
39633971 m_lastIOID (0x80706050 ),
@@ -4019,6 +4027,7 @@ class InternalClientContextImpl :
40194027 out << " VERSION : " << m_version.getVersionString () << std::endl;
40204028 out << " ADDR_LIST : " << m_addressList << std::endl;
40214029 out << " AUTO_ADDR_LIST : " << (m_autoAddressList ? " true" : " false" ) << std::endl;
4030+ out << " SERVER_PORT : " << m_serverPort << std::endl;
40224031 out << " CONNECTION_TIMEOUT : " << m_connectionTimeout << std::endl;
40234032 out << " BEACON_PERIOD : " << m_beaconPeriod << std::endl;
40244033 out << " BROADCAST_PORT : " << m_broadcastPort << std::endl;;
@@ -4111,6 +4120,7 @@ class InternalClientContextImpl :
41114120
41124121 m_addressList = m_configuration->getPropertyAsString (" EPICS_PVA_ADDR_LIST" , m_addressList);
41134122 m_autoAddressList = m_configuration->getPropertyAsBoolean (" EPICS_PVA_AUTO_ADDR_LIST" , m_autoAddressList);
4123+ m_serverPort = m_configuration->getPropertyAsInteger (" EPICS_PVA_SERVER_PORT" , m_serverPort);
41144124 m_connectionTimeout = m_configuration->getPropertyAsFloat (" EPICS_PVA_CONN_TMO" , m_connectionTimeout);
41154125 m_beaconPeriod = m_configuration->getPropertyAsFloat (" EPICS_PVA_BEACON_PERIOD" , m_beaconPeriod);
41164126 m_broadcastPort = m_configuration->getPropertyAsInteger (" EPICS_PVA_BROADCAST_PORT" , m_broadcastPort);
@@ -4430,6 +4440,11 @@ class InternalClientContextImpl :
44304440 */
44314441 bool m_autoAddressList;
44324442
4443+ /* *
4444+ * Define server port
4445+ */
4446+ int m_serverPort;
4447+
44334448 /* *
44344449 * If the context doesn't see a beacon from a server that it is connected to for
44354450 * connectionTimeout seconds then a state-of-health message is sent to the server over TCP/IP.
0 commit comments