UDP shutdown on linux
This commit is contained in:
@@ -210,6 +210,8 @@ namespace epics {
|
||||
std::auto_ptr<ResponseHandler> _responseHandler;
|
||||
|
||||
virtual void processRead();
|
||||
|
||||
void wakeupMessage();
|
||||
|
||||
private:
|
||||
static void threadRunner(void* param);
|
||||
|
||||
@@ -52,6 +52,24 @@ namespace epics {
|
||||
_threadId(0)
|
||||
{
|
||||
PVDATA_REFCOUNT_MONITOR_CONSTRUCT(blockingUDPTransport);
|
||||
|
||||
/*
|
||||
osiSockAddr tmpAddr;
|
||||
osiSocklen_t saddr_length = sizeof (tmpAddr);
|
||||
int status = ::getsockname(_channel, &tmpAddr.sa, &saddr_length);
|
||||
if (status < 0)
|
||||
{
|
||||
char strBuffer[64];
|
||||
epicsSocketConvertErrnoToString(strBuffer, sizeof(strBuffer));
|
||||
errlogSevPrintf(errlogMinor, "getsockname error: %s", strBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
int localPort = ntohs(tmpAddr.ia.sin_port);
|
||||
}
|
||||
*/
|
||||
//errlogSevPrintf(errlogInfo, "UDP bind adrr port: %d", ntohs(_bindAddress.ia.sin_port));
|
||||
|
||||
}
|
||||
|
||||
BlockingUDPTransport::~BlockingUDPTransport() {
|
||||
@@ -87,6 +105,9 @@ namespace epics {
|
||||
if(_closed) return;
|
||||
_closed = true;
|
||||
|
||||
// to get out of blocking receive
|
||||
wakeupMessage();
|
||||
|
||||
errlogSevPrintf(errlogInfo,
|
||||
"UDP socket %s closed.",
|
||||
inetAddressToString(_bindAddress).c_str());
|
||||
@@ -94,6 +115,7 @@ namespace epics {
|
||||
epicsSocketDestroy(_channel);
|
||||
}
|
||||
|
||||
|
||||
// wait for send thread to exit cleanly
|
||||
if (waitForThreadToComplete)
|
||||
_shutdownEvent.wait();
|
||||
@@ -264,6 +286,20 @@ namespace epics {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void BlockingUDPTransport::wakeupMessage()
|
||||
{
|
||||
osiSockAddr addr;
|
||||
addr.ia.sin_family = AF_INET;
|
||||
addr.ia.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
||||
addr.ia.sin_port = _bindAddress.ia.sin_port;
|
||||
|
||||
// send a wakeup msg so the UDP recv thread will exit
|
||||
sendto(_channel, static_cast<char*>(0),
|
||||
0, 0, &addr.sa, sizeof(addr.sa ));
|
||||
}
|
||||
|
||||
|
||||
bool BlockingUDPTransport::send(ByteBuffer* buffer) {
|
||||
if(!_sendAddresses) return false;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
TOP = ..
|
||||
include $(TOP)/configure/CONFIG
|
||||
DIRS += utils
|
||||
#DIRS += client
|
||||
DIRS += client
|
||||
DIRS += remote
|
||||
include $(TOP)/configure/RULES_DIRS
|
||||
|
||||
@@ -2,18 +2,22 @@ TOP=../..
|
||||
|
||||
include $(TOP)/configure/CONFIG
|
||||
|
||||
PROD_HOST += testChannelAccessFactory
|
||||
testChannelAccessFactory_SRCS += testChannelAccessFactory.cpp
|
||||
testChannelAccessFactory_LIBS += pvData pvAccess Com
|
||||
#PROD_HOST += testChannelAccessFactory
|
||||
testChannelAccessFactory_SRCS = testChannelAccessFactory.cpp
|
||||
testChannelAccessFactory_LIBS = pvData pvAccess Com
|
||||
|
||||
PROD_HOST += testCreateRequest
|
||||
testCreateRequest_SRCS += testCreateRequest.cpp
|
||||
testCreateRequest_LIBS += pvData pvAccess Com
|
||||
#PROD_HOST += testCreateRequest
|
||||
testCreateRequest_SRCS = testCreateRequest.cpp
|
||||
testCreateRequest_LIBS = pvData pvAccess Com
|
||||
|
||||
PROD_HOST += testMockClient
|
||||
#PROD_HOST += testMockClient
|
||||
testMockClient_SRCS = testMockClient.cpp MockClientImpl.cpp
|
||||
testMockClient_LIBS = pvData pvAccess Com
|
||||
|
||||
PROD_HOST += testStartStop
|
||||
testStartStop_SRCS = testStartStop.cpp
|
||||
testStartStop_LIBS = pvData pvAccess Com
|
||||
|
||||
include $(TOP)/configure/RULES
|
||||
#----------------------------------------
|
||||
# ADD RULES AFTER THIS LINE
|
||||
|
||||
Reference in New Issue
Block a user