use connect to AF_UNSPEC to not allow incomming messages to beacon sock

This commit is contained in:
Jeff Hill
2005-11-01 20:55:33 +00:00
parent d99f868f54
commit 422fd9ebd0
2 changed files with 34 additions and 20 deletions

View File

@@ -64,16 +64,6 @@ casDGIntfIO::casDGIntfIO ( caServerI & serverIn, clientBufMemoryManager & memMgr
epicsSocketDestroy (this->sock);
throw S_cas_internal;
}
status = shutdown ( this->beaconSock, SHUT_RD );
if ( status ) {
char sockErrBuf[64];
epicsSocketConvertErrnoToString (
sockErrBuf, sizeof ( sockErrBuf ) );
errlogPrintf (
"casDGIntfIO::casDGIntfIO() beacon sock UDP read shutdown error was %s\n",
sockErrBuf );
}
//
// Fetch port configuration from EPICS environment variables
@@ -460,6 +450,22 @@ void casDGIntfIO::sendBeaconIO ( char & msg, unsigned length,
}
}
}
{
// disconnect so that bogus messages arriving at the ephemeral port
// do not consume resources
osiSockAddr sockAddr;
memset ( &sockAddr, 0, sizeof ( sockAddr ) );
sockAddr.sa.sa_family = AF_UNSPEC;
status = connect ( this->beaconSock,
& sockAddr.sa, sizeof ( sockAddr.sa ) );
if ( status < 0 ) {
char sockErrBuf[64];
epicsSocketConvertErrnoToString ( sockErrBuf, sizeof ( sockErrBuf ) );
errlogPrintf ( "%s: CA beacon socket disconnect error was \"%s\"\n",
__FILE__, sockErrBuf );
}
}
}
bufSizeT casDGIntfIO::optimumInBufferSize ()

View File

@@ -107,16 +107,6 @@ void rsrv_online_notify_task(void *pParm)
errlogPrintf ("CAS: online socket creation error\n");
epicsThreadSuspendSelf ();
}
status = shutdown ( sock, SHUT_RD );
if ( status ) {
char sockErrBuf[64];
epicsSocketConvertErrnoToString (
sockErrBuf, sizeof ( sockErrBuf ) );
errlogPrintf (
"online notify: beacon sock UDP read shutdown error was %s\n",
sockErrBuf );
}
status = setsockopt (sock, SOL_SOCKET, SO_BROADCAST,
(char *)&true, sizeof(true));
@@ -271,6 +261,24 @@ void rsrv_online_notify_task(void *pParm)
pNode = (osiSockAddrNode *) pNode->node.next;
}
{
/*
* disconnect so that bogus messages arriving at the ephemeral port
* do not consume resources
*/
osiSockAddr sockAddr;
memset ( &sockAddr, 0, sizeof ( sockAddr ) );
sockAddr.sa.sa_family = AF_UNSPEC;
status = connect ( sock,
& sockAddr.sa, sizeof ( sockAddr.sa ) );
if ( status < 0 ) {
char sockErrBuf[64];
epicsSocketConvertErrnoToString ( sockErrBuf, sizeof ( sockErrBuf ) );
errlogPrintf ( "%s: CA beacon socket disconnect error was \"%s\"\n",
__FILE__, sockErrBuf );
}
}
epicsThreadSleep(delay);
if (delay<maxdelay) {
delay *= 2.0;