mirror of https://github.com/aria2/aria2
2009-05-06 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added static member _protocolFamily to SocketCore. By default, SocketCore uses AF_UNSPEC for getaddrinfo hints to resolve address. Sometime SocketCore::bind() and SocketCore::establishConnection() use difference protocl family and latter cannot connect to former. To avoid this situation, we limit protocol family to AF_INET for unit tests. * src/SocketCore.cc * src/SocketCore.h * test/AllTest.ccpull/1/head
parent
47b08786eb
commit
d05d8bbddc
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2009-05-06 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Added static member _protocolFamily to SocketCore. By default,
|
||||
SocketCore uses AF_UNSPEC for getaddrinfo hints to resolve
|
||||
address. Sometime SocketCore::bind() and
|
||||
SocketCore::establishConnection() use difference protocl family
|
||||
and latter cannot connect to former. To avoid this situation, we
|
||||
limit protocol family to AF_INET for unit tests.
|
||||
* src/SocketCore.cc
|
||||
* src/SocketCore.h
|
||||
* test/AllTest.cc
|
||||
|
||||
2009-05-06 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Avoid std::bad_alloc for negative bencode string length.
|
||||
|
|
|
@ -49,7 +49,6 @@
|
|||
#include "DlAbortEx.h"
|
||||
#include "StringFormat.h"
|
||||
#include "Util.h"
|
||||
#include "LogFactory.h"
|
||||
#include "TimeA2.h"
|
||||
#include "a2functional.h"
|
||||
#ifdef ENABLE_SSL
|
||||
|
@ -82,6 +81,8 @@ SocketCore::PollMethod SocketCore::_pollMethod = SocketCore::POLL_METHOD_EPOLL;
|
|||
SocketCore::PollMethod SocketCore::_pollMethod = SocketCore::POLL_METHOD_SELECT;
|
||||
#endif // !HAVE_EPOLL
|
||||
|
||||
int SocketCore::_protocolFamily = AF_UNSPEC;
|
||||
|
||||
#ifdef ENABLE_SSL
|
||||
SharedHandle<TLSContext> SocketCore::_tlsContext;
|
||||
|
||||
|
@ -165,7 +166,7 @@ void SocketCore::bind(uint16_t port)
|
|||
struct addrinfo hints;
|
||||
struct addrinfo* res;
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_family = _protocolFamily;
|
||||
hints.ai_socktype = _sockType;
|
||||
hints.ai_flags = AI_PASSIVE;
|
||||
hints.ai_protocol = 0;
|
||||
|
@ -246,7 +247,7 @@ void SocketCore::establishConnection(const std::string& host, uint16_t port)
|
|||
struct addrinfo hints;
|
||||
struct addrinfo* res;
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_family = _protocolFamily;
|
||||
hints.ai_socktype = _sockType;
|
||||
hints.ai_flags = 0;
|
||||
hints.ai_protocol = 0;
|
||||
|
@ -976,7 +977,7 @@ ssize_t SocketCore::writeData(const char* data, size_t len,
|
|||
struct addrinfo hints;
|
||||
struct addrinfo* res;
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_family = _protocolFamily;
|
||||
hints.ai_socktype = _sockType;
|
||||
hints.ai_flags = 0;
|
||||
hints.ai_protocol = 0;
|
||||
|
|
|
@ -90,6 +90,8 @@ private:
|
|||
|
||||
static PollMethod _pollMethod;
|
||||
|
||||
static int _protocolFamily;
|
||||
|
||||
bool blocking;
|
||||
int secure;
|
||||
|
||||
|
@ -341,6 +343,11 @@ public:
|
|||
#ifdef ENABLE_SSL
|
||||
static void setTLSContext(const SharedHandle<TLSContext>& tlsContext);
|
||||
#endif // ENABLE_SSL
|
||||
|
||||
static void setProtocolFamily(int protocolFamily)
|
||||
{
|
||||
_protocolFamily = protocolFamily;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace aria2
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
#include "Platform.h"
|
||||
#include "common.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <cppunit/CompilerOutputter.h>
|
||||
#include <cppunit/extensions/TestFactoryRegistry.h>
|
||||
#include <cppunit/ui/text/TestRunner.h>
|
||||
|
||||
#include "Platform.h"
|
||||
#include "SocketCore.h"
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
aria2::Platform platform;
|
||||
|
||||
|
@ -13,6 +18,13 @@ int main(int argc, char* argv[]) {
|
|||
setlocale (LC_MESSAGES, "C");
|
||||
#endif // ENABLE_NLS
|
||||
|
||||
// By default, SocketCore uses AF_UNSPEC for getaddrinfo hints to
|
||||
// resolve address. Sometime SocketCore::bind() and
|
||||
// SocketCore::establishConnection() use difference protocl family
|
||||
// and latter cannot connect to former. To avoid this situation, we
|
||||
// limit protocol family to AF_INET for unit tests.
|
||||
aria2::SocketCore::setProtocolFamily(AF_INET);
|
||||
|
||||
CppUnit::Test* suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
runner.addTest(suite);
|
||||
|
|
Loading…
Reference in New Issue