TCP acceptor and validation fixed, logs and dot consistency
This commit is contained in:
@@ -41,7 +41,7 @@ namespace pvAccess {
|
||||
const epics::pvData::int16 PVA_MESSAGE_HEADER_SIZE = 8;
|
||||
|
||||
/** All messages must be aligned to 8-bytes (64-bit). */
|
||||
const epics::pvData::int32 PVA_ALIGNMENT = 1; // TODO
|
||||
const epics::pvData::int32 PVA_ALIGNMENT = 1;
|
||||
|
||||
/**
|
||||
* UDP maximum send message size.
|
||||
|
||||
@@ -205,12 +205,17 @@ namespace pvAccess {
|
||||
|
||||
// validate connection
|
||||
if(!validateConnection(transport, ipAddrStr)) {
|
||||
// TODO
|
||||
// wait for negative response to be sent back and
|
||||
// hold off the client for retrying at very high rate
|
||||
epicsThreadSleep(1.0);
|
||||
|
||||
transport->close();
|
||||
LOG(
|
||||
logLevelDebug,
|
||||
"Connection to PVA client %s failed to be validated, closing it.",
|
||||
ipAddrStr);
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
LOG(logLevelDebug, "Serving to PVA client: %s.", ipAddrStr);
|
||||
@@ -223,9 +228,7 @@ namespace pvAccess {
|
||||
|
||||
bool BlockingTCPAcceptor::validateConnection(Transport::shared_pointer const & transport, const char* address) {
|
||||
try {
|
||||
// TODO constant
|
||||
transport->verify(5000);
|
||||
return true;
|
||||
return transport->verify(5000);
|
||||
} catch(...) {
|
||||
LOG(logLevelDebug, "Validation of %s failed.", address);
|
||||
return false;
|
||||
|
||||
@@ -155,7 +155,7 @@ namespace epics {
|
||||
client, transportRevision, _heartbeatInterval, priority);
|
||||
|
||||
// verify
|
||||
if(!transport->verify(3000)) {
|
||||
if(!transport->verify(5000)) {
|
||||
LOG(
|
||||
logLevelDebug,
|
||||
"Connection to PVA server %s failed to be validated, closing it.",
|
||||
|
||||
@@ -22,14 +22,14 @@ namespace epics {
|
||||
auto_ptr<ResponseHandler>& responseHandler, osiSockAddr& bindAddress,
|
||||
int8 transportRevision, int16 /*priority*/) {
|
||||
|
||||
LOG(logLevelDebug, "Creating datagram socket to: %s",
|
||||
LOG(logLevelDebug, "Creating datagram socket to: %s.",
|
||||
inetAddressToString(bindAddress).c_str());
|
||||
|
||||
SOCKET socket = epicsSocketCreate(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
if(socket==INVALID_SOCKET) {
|
||||
char errStr[64];
|
||||
epicsSocketConvertErrnoToString(errStr, sizeof(errStr));
|
||||
LOG(logLevelError, "Error creating socket: %s", errStr);
|
||||
LOG(logLevelError, "Error creating socket: %s.", errStr);
|
||||
return Transport::shared_pointer();
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace epics {
|
||||
{
|
||||
char errStr[64];
|
||||
epicsSocketConvertErrnoToString(errStr, sizeof(errStr));
|
||||
LOG(logLevelError, "Error setting SO_BROADCAST: %s", errStr);
|
||||
LOG(logLevelError, "Error setting SO_BROADCAST: %s.", errStr);
|
||||
epicsSocketDestroy (socket);
|
||||
return Transport::shared_pointer();
|
||||
}
|
||||
@@ -62,7 +62,7 @@ namespace epics {
|
||||
if(retval<0) {
|
||||
char errStr[64];
|
||||
epicsSocketConvertErrnoToString(errStr, sizeof(errStr));
|
||||
LOG(logLevelError, "Error binding socket: %s", errStr);
|
||||
LOG(logLevelError, "Error binding socket: %s.", errStr);
|
||||
epicsSocketDestroy (socket);
|
||||
return Transport::shared_pointer();
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ inline int sendto(int s, const char *buf, size_t len, int flags, const struct so
|
||||
|
||||
char strBuffer[64];
|
||||
epicsSocketConvertErrnoToString(strBuffer, sizeof(strBuffer));
|
||||
LOG(logLevelDebug, "getsockname error: %s", strBuffer);
|
||||
LOG(logLevelDebug, "getsockname error: %s.", strBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -557,6 +557,17 @@ namespace epics {
|
||||
_socketBuffer->setPosition(newpos);
|
||||
}
|
||||
|
||||
static const char PADDING_BYTES[] =
|
||||
{
|
||||
static_cast<char>(0xFF),
|
||||
static_cast<char>(0xFF),
|
||||
static_cast<char>(0xFF),
|
||||
static_cast<char>(0xFF),
|
||||
static_cast<char>(0xFF),
|
||||
static_cast<char>(0xFF),
|
||||
static_cast<char>(0xFF),
|
||||
static_cast<char>(0xFF)
|
||||
};
|
||||
|
||||
void AbstractCodec::alignBuffer(std::size_t alignment) {
|
||||
|
||||
@@ -566,9 +577,15 @@ namespace epics {
|
||||
if (pos == newpos)
|
||||
return;
|
||||
|
||||
/*
|
||||
// there is always enough of space
|
||||
// since sendBuffer capacity % PVA_ALIGNMENT == 0
|
||||
_sendBuffer->setPosition(newpos);
|
||||
*/
|
||||
|
||||
// for safety reasons we really pad (override previous message data)
|
||||
std::size_t padCount = newpos - pos;
|
||||
_sendBuffer->put(PADDING_BYTES, 0, padCount);
|
||||
}
|
||||
|
||||
|
||||
@@ -1426,7 +1443,7 @@ namespace epics {
|
||||
|
||||
|
||||
bool BlockingTCPTransportCodec::verify(epics::pvData::int32 timeoutMs) {
|
||||
return _verifiedEvent.wait(timeoutMs/1000.0);
|
||||
return _verifiedEvent.wait(timeoutMs/1000.0) && _verified;
|
||||
}
|
||||
|
||||
void BlockingTCPTransportCodec::verified(epics::pvData::Status const & status) {
|
||||
|
||||
@@ -4240,7 +4240,7 @@ TODO
|
||||
|
||||
for (size_t i = 0; broadcastAddresses.get() && i < broadcastAddresses->size(); i++)
|
||||
LOG(logLevelDebug,
|
||||
"Broadcast address #%d: %s", i, inetAddressToString((*broadcastAddresses)[i]).c_str());
|
||||
"Broadcast address #%d: %s.", i, inetAddressToString((*broadcastAddresses)[i]).c_str());
|
||||
|
||||
// where to bind (listen) address
|
||||
osiSockAddr listenLocalAddress;
|
||||
|
||||
Reference in New Issue
Block a user