version 1.132, 2012/07/03 11:53:22
|
version 1.138, 2015/06/10 12:36:01
|
|
|
reinterpret_cast<struct sockaddr*>(new struct sockaddr_un); | reinterpret_cast<struct sockaddr*>(new struct sockaddr_un); |
address_size = sizeof(struct sockaddr_un); | address_size = sizeof(struct sockaddr_un); |
#else | #else |
PEGASUS_ASSERT(false); |
PEGASUS_UNREACHABLE(PEGASUS_ASSERT(false);) |
#endif | #endif |
} | } |
#ifdef PEGASUS_ENABLE_IPV6 | #ifdef PEGASUS_ENABLE_IPV6 |
|
|
} | } |
else | else |
{ | { |
PEGASUS_ASSERT(false); |
PEGASUS_UNREACHABLE(PEGASUS_ASSERT(false);) |
} | } |
} | } |
| |
|
|
{ | { |
case SOCKET_MESSAGE: | case SOCKET_MESSAGE: |
{ | { |
SocketMessage* socketMessage = (SocketMessage*)message; |
|
|
|
// If this is a connection request: | // If this is a connection request: |
PEGASUS_ASSERT(socketMessage->socket == _rep->socket); |
PEGASUS_ASSERT(((SocketMessage*)message)->socket == _rep->socket); |
| |
PEGASUS_ASSERT(socketMessage->events & SocketMessage::READ); |
PEGASUS_ASSERT( |
|
((SocketMessage*)message)->events & SocketMessage::READ); |
| |
_acceptConnection(); | _acceptConnection(); |
| |
|
|
} | } |
| |
default: | default: |
PEGASUS_ASSERT(false); |
PEGASUS_UNREACHABLE(PEGASUS_ASSERT(false);) |
break; | break; |
} | } |
| |
|
|
strcpy(reinterpret_cast<struct sockaddr_un*>(_rep->address)->sun_path, | strcpy(reinterpret_cast<struct sockaddr_un*>(_rep->address)->sun_path, |
PEGASUS_LOCAL_DOMAIN_SOCKET_PATH); | PEGASUS_LOCAL_DOMAIN_SOCKET_PATH); |
#else | #else |
PEGASUS_ASSERT(false); |
PEGASUS_UNREACHABLE(PEGASUS_ASSERT(false);) |
#endif | #endif |
} | } |
#ifdef PEGASUS_ENABLE_IPV6 | #ifdef PEGASUS_ENABLE_IPV6 |
|
|
memset(&in6addr, 0, sizeof(sockaddr_in6)); | memset(&in6addr, 0, sizeof(sockaddr_in6)); |
if(_listenAddress ->isHostAddLinkLocal()) | if(_listenAddress ->isHostAddLinkLocal()) |
{ | { |
::inet_pton(AF_INET6, |
HostAddress::convertTextToBinary(AF_INET6, |
(const char*)ip, | (const char*)ip, |
&in6addr.sin6_addr); | &in6addr.sin6_addr); |
reinterpret_cast<struct sockaddr_in6*>( | reinterpret_cast<struct sockaddr_in6*>( |
|
|
} | } |
else | else |
{ | { |
::inet_pton(AF_INET6, |
HostAddress::convertTextToBinary(AF_INET6, |
(const char*)ip, | (const char*)ip, |
&in6addr.sin6_addr); | &in6addr.sin6_addr); |
reinterpret_cast<struct sockaddr_in6*>( | reinterpret_cast<struct sockaddr_in6*>( |
|
|
String hostAdd = _listenAddress->getHost(); | String hostAdd = _listenAddress->getHost(); |
CString ip = hostAdd.getCString(); | CString ip = hostAdd.getCString(); |
struct sockaddr_in addrs; | struct sockaddr_in addrs; |
::inet_pton( |
HostAddress::convertTextToBinary( |
AF_INET, | AF_INET, |
(const char*)ip, | (const char*)ip, |
&addrs.sin_addr); | &addrs.sin_addr); |
|
|
} | } |
else | else |
{ | { |
PEGASUS_ASSERT(false); |
PEGASUS_UNREACHABLE(PEGASUS_ASSERT(false);) |
} | } |
| |
// Create socket: | // Create socket: |
|
|
} | } |
else | else |
{ | { |
PEGASUS_ASSERT(false); |
PEGASUS_UNREACHABLE(PEGASUS_ASSERT(false);) |
} | } |
| |
if (_rep->socket < 0) | if (_rep->socket < 0) |
|
|
| |
if (-1 == ( _entry_index = _monitor->solicitSocketMessages( | if (-1 == ( _entry_index = _monitor->solicitSocketMessages( |
_rep->socket, | _rep->socket, |
SocketMessage::READ | SocketMessage::EXCEPTION, |
|
getQueueId(), | getQueueId(), |
MonitorEntry::TYPE_ACCEPTOR))) | MonitorEntry::TYPE_ACCEPTOR))) |
{ | { |
|
|
reinterpret_cast<struct sockaddr_un*> | reinterpret_cast<struct sockaddr_un*> |
(_rep->address)->sun_path); | (_rep->address)->sun_path); |
#else | #else |
PEGASUS_ASSERT(false); |
PEGASUS_UNREACHABLE(PEGASUS_ASSERT(false);) |
#endif | #endif |
} | } |
} | } |
|
|
reinterpret_cast<struct sockaddr_un*>( | reinterpret_cast<struct sockaddr_un*>( |
_rep->address)->sun_path); | _rep->address)->sun_path); |
#else | #else |
PEGASUS_ASSERT(false); |
PEGASUS_UNREACHABLE(PEGASUS_ASSERT(false);) |
#endif | #endif |
} | } |
// open the socket | // open the socket |
|
|
return count; | return count; |
} | } |
| |
|
/** |
|
getListenAddress - Returns bind address |
|
*/ |
|
String HTTPAcceptor::getListenAddress() const |
|
{ |
|
return _listenAddress ? _listenAddress->getHost() : String(); |
|
} |
| |
/** | /** |
getPortNumber - returns the port number used for the connection | getPortNumber - returns the port number used for the connection |
|
|
reinterpret_cast<struct sockaddr_un*> | reinterpret_cast<struct sockaddr_un*> |
(_rep->address)->sun_path); | (_rep->address)->sun_path); |
#else | #else |
PEGASUS_ASSERT(false); |
PEGASUS_UNREACHABLE(PEGASUS_ASSERT(false);) |
#endif | #endif |
} | } |
| |
|
|
reinterpret_cast<struct sockaddr*>(new struct sockaddr_un); | reinterpret_cast<struct sockaddr*>(new struct sockaddr_un); |
address_size = sizeof(struct sockaddr_un); | address_size = sizeof(struct sockaddr_un); |
#else | #else |
PEGASUS_ASSERT(false); |
PEGASUS_UNREACHABLE(PEGASUS_ASSERT(false);) |
#endif | #endif |
} | } |
else | else |
|
|
{ | { |
#ifdef PEGASUS_ENABLE_IPV6 | #ifdef PEGASUS_ENABLE_IPV6 |
char ipBuffer[PEGASUS_INET6_ADDRSTR_LEN]; | char ipBuffer[PEGASUS_INET6_ADDRSTR_LEN]; |
int rc; |
if (System::getNameInfo(accept_address, |
if ((rc = System::getNameInfo(accept_address, |
|
address_size, | address_size, |
ipBuffer, | ipBuffer, |
PEGASUS_INET6_ADDRSTR_LEN, | PEGASUS_INET6_ADDRSTR_LEN, |
0, | 0, |
0, | 0, |
NI_NUMERICHOST))) |
NI_NUMERICHOST)) |
{ | { |
PEG_TRACE(( |
|
TRC_DISCARDED_DATA, |
|
Tracer::LEVEL1, |
|
"HTTPAcceptor: getnameinfo() failed. rc: %d", |
|
rc)); |
|
delete accept_address; | delete accept_address; |
return; | return; |
} | } |
|
|
| |
if (-1 == (index = _monitor->solicitSocketMessages( | if (-1 == (index = _monitor->solicitSocketMessages( |
connection->getSocket(), | connection->getSocket(), |
SocketMessage::READ | SocketMessage::EXCEPTION, |
|
connection->getQueueId(), MonitorEntry::TYPE_CONNECTION)) ) | connection->getQueueId(), MonitorEntry::TYPE_CONNECTION)) ) |
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, | PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |