pvlist debugging
This commit is contained in:
@ -331,7 +331,7 @@ bool discoverServers(double timeOut)
|
||||
sendBuffer.putByte(PVA_MAGIC);
|
||||
sendBuffer.putByte(PVA_VERSION);
|
||||
sendBuffer.putByte((EPICS_BYTE_ORDER == EPICS_ENDIAN_BIG) ? 0x80 : 0x00); // data + 7-bit endianess
|
||||
sendBuffer.putByte((int8_t)3); // search
|
||||
sendBuffer.putByte((int8_t)CMD_SEARCH); // search
|
||||
sendBuffer.putInt(4+1+3+16+2+1+2); // "zero" payload
|
||||
|
||||
sendBuffer.putInt(0); // sequenceId
|
||||
@ -343,13 +343,18 @@ bool discoverServers(double timeOut)
|
||||
encodeAsIPv6Address(&sendBuffer, &responseAddress);
|
||||
sendBuffer.putShort((int16_t)ntohs(responseAddress.ia.sin_port));
|
||||
|
||||
sendBuffer.putByte((int8_t)0x00); // no restriction on protocol
|
||||
sendBuffer.putShort((int16_t)0); // count
|
||||
sendBuffer.putByte((int8_t)0x00); // protocol count
|
||||
sendBuffer.putShort((int16_t)0); // name count
|
||||
|
||||
bool oneOK = false;
|
||||
for (size_t i = 0; i < broadcastAddresses.size(); i++)
|
||||
{
|
||||
// send the packet
|
||||
if(pvAccessIsLoggable(logLevelDebug)) {
|
||||
char strBuffer[64];
|
||||
sockAddrToDottedIP(&broadcastAddresses[i].sa, strBuffer, sizeof(strBuffer));
|
||||
LOG(logLevelDebug, "UDP Tx (%zu) -> %s", sendBuffer.getPosition(), strBuffer);
|
||||
}
|
||||
|
||||
status = ::sendto(socket, sendBuffer.getArray(), sendBuffer.getPosition(), 0,
|
||||
&broadcastAddresses[i].sa, sizeof(sockaddr));
|
||||
if (status < 0)
|
||||
@ -385,6 +390,11 @@ bool discoverServers(double timeOut)
|
||||
|
||||
if (bytesRead > 0)
|
||||
{
|
||||
if(pvAccessIsLoggable(logLevelDebug)) {
|
||||
char strBuffer[64];
|
||||
sockAddrToDottedIP(&fromAddress.sa, strBuffer, sizeof(strBuffer));
|
||||
LOG(logLevelDebug, "UDP Rx (%d) <- %s", bytesRead, strBuffer);
|
||||
}
|
||||
receiveBuffer.setPosition(bytesRead);
|
||||
receiveBuffer.flip();
|
||||
|
||||
|
@ -322,6 +322,7 @@ void ServerSearchHandler::handleResponse(osiSockAddr* responseFrom,
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
// regular name search
|
||||
for (int32 i = 0; i < count; i++)
|
||||
{
|
||||
transport->ensureData(4);
|
||||
@ -344,16 +345,16 @@ void ServerSearchHandler::handleResponse(osiSockAddr* responseFrom,
|
||||
}
|
||||
else
|
||||
{
|
||||
// server discovery ping by pvlist
|
||||
if (allowed)
|
||||
{
|
||||
// TODO constant
|
||||
// ~random hold-off to reduce impact of all servers responding...
|
||||
#define MAX_SERVER_SEARCH_RESPONSE_DELAY_MS 100
|
||||
double period = (rand() % MAX_SERVER_SEARCH_RESPONSE_DELAY_MS)/(double)1000;
|
||||
|
||||
std::tr1::shared_ptr<ServerChannelFindRequesterImpl> tp(new ServerChannelFindRequesterImpl(_context, 1));
|
||||
tp->set("", searchSequenceId, 0, responseAddress, true, true);
|
||||
|
||||
// TODO use std::make_shared
|
||||
TimerCallback::shared_pointer tc = tp;
|
||||
_context->getTimer()->scheduleAfterDelay(tc, period);
|
||||
}
|
||||
|
Reference in New Issue
Block a user