1
0
Fork 0

Don't ask

This commit is contained in:
Oreste Panaia 2012-09-28 18:53:17 +08:00
parent 6bdf3ae565
commit 928ee5525a
2 changed files with 12 additions and 30 deletions

View File

@ -165,28 +165,21 @@ Endpoint* Endpoint::factory (const Endpoint::Type type,
Encryption encryption = ENCRYPTION_NONE;
string domainType = StringUtils::tolower(copy.substr(0, 7));
if (StringUtils::isPrefix(domainType, "unix://")) {
// unix socket
#ifdef TRI_HAVE_LINUX_SOCKETS
return new EndpointUnix(type, protocol, specification, copy.substr(strlen("unix://")));
#else
return 0;
#endif
}
else if (StringUtils::isPrefix(domainType, "ssl://")) {
if (StringUtils::isPrefix(domainType, "ssl://")) {
// ssl
encryption = ENCRYPTION_SSL;
}
#if TRI_HAVE_LINUX_SOCKETS
else if (StringUtils::isPrefix(domainType, "unix://")) {
// unix socket
return new EndpointUnix(type, protocol, specification, listenBacklog, copy.substr(strlen("unix://")));
}
#endif
else if (! StringUtils::isPrefix(domainType, "tcp://")) {
// invalid type
return 0;
}
}
// tcp/ip or ssl
copy = copy.substr(strlen("tcp://"), copy.length());
@ -250,8 +243,8 @@ void Endpoint::setTimeout (socket_t s, double timeout) {
tv.tv_sec = (uint64_t) timeout;
tv.tv_usec = ((uint64_t) (timeout * 1000000.0)) % 1000000;
setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (const char*)(&tv), sizeof(tv));
setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, (const char*)(&tv), sizeof(tv));
setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv));
}
////////////////////////////////////////////////////////////////////////////////
@ -722,14 +715,9 @@ bool EndpointIp::initIncoming (socket_t incoming) {
EndpointIpV4::EndpointIpV4 (const Endpoint::Type type,
const Endpoint::Protocol protocol,
const Endpoint::Encryption encryption,
<<<<<<< HEAD
const std::string& specification,
const std::string& host,
=======
string const& specification,
int listenBacklog,
string const& host,
>>>>>>> a487f9478eb5e948fbdaae9d0c348f386baa2e34
const uint16_t port) :
EndpointIp(type, ENDPOINT_IPV4, protocol, encryption, specification, listenBacklog, host, port) {
}
@ -765,14 +753,9 @@ EndpointIpV4::~EndpointIpV4 () {
EndpointIpV6::EndpointIpV6 (const Endpoint::Type type,
const Endpoint::Protocol protocol,
const Endpoint::Encryption encryption,
<<<<<<< HEAD
const std::string& specification,
const std::string& host,
=======
string const& specification,
int listenBacklog,
string const& host,
>>>>>>> a487f9478eb5e948fbdaae9d0c348f386baa2e34
const uint16_t port) :
EndpointIp(type, ENDPOINT_IPV6, protocol, encryption, specification, listenBacklog, host, port) {
}

View File

@ -32,6 +32,7 @@
#include <Basics/StringUtils.h>
#ifdef TRI_HAVE_LINUX_SOCKETS
#include <arpa/inet.h>
#include <netinet/in.h>
@ -44,8 +45,6 @@
#ifdef TRI_HAVE_WINSOCK2_H
#include <winsock2.h>
#include <ws2tcpip.h>
#endif