mirror of https://github.com/aria2/aria2
2010-01-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed compile error with i586-mingw32msvc-gcc 4.4.2, without any additional libraries. * src/MultiUrlRequestInfo.cc * src/NameResolver.cc * src/SelectEventPoll.cc * src/SelectEventPoll.h * src/SocketCore.cc * src/SocketCore.h * src/a2netcompat.h * src/daemon.cc * src/main.ccpull/1/head
parent
b950da1841
commit
be20b46c19
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2010-01-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Fixed compile error with i586-mingw32msvc-gcc 4.4.2, without any
|
||||
additional libraries.
|
||||
* src/MultiUrlRequestInfo.cc
|
||||
* src/NameResolver.cc
|
||||
* src/SelectEventPoll.cc
|
||||
* src/SelectEventPoll.h
|
||||
* src/SocketCore.cc
|
||||
* src/SocketCore.h
|
||||
* src/a2netcompat.h
|
||||
* src/daemon.cc
|
||||
* src/main.cc
|
||||
|
||||
2010-01-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Fixed typo.
|
||||
|
|
|
@ -160,8 +160,9 @@ downloadresultcode::RESULT MultiUrlRequestInfo::execute()
|
|||
(_option->getAsInt(PREF_SERVER_STAT_TIMEOUT));
|
||||
}
|
||||
e->setStatCalc(_statCalc);
|
||||
|
||||
#ifdef SIGHUP
|
||||
util::setGlobalSignalHandler(SIGHUP, handler, 0);
|
||||
#endif // SIGHUP
|
||||
util::setGlobalSignalHandler(SIGINT, handler, 0);
|
||||
util::setGlobalSignalHandler(SIGTERM, handler, 0);
|
||||
|
||||
|
@ -191,7 +192,9 @@ downloadresultcode::RESULT MultiUrlRequestInfo::execute()
|
|||
} catch(RecoverableException& e) {
|
||||
_logger->error(EX_EXCEPTION_CAUGHT, e);
|
||||
}
|
||||
#ifdef SIGHUP
|
||||
util::setGlobalSignalHandler(SIGHUP, SIG_DFL, 0);
|
||||
#endif // SIGHUP
|
||||
util::setGlobalSignalHandler(SIGINT, SIG_DFL, 0);
|
||||
util::setGlobalSignalHandler(SIGTERM, SIG_DFL, 0);
|
||||
return returnValue;
|
||||
|
|
|
@ -56,7 +56,7 @@ void NameResolver::resolve(std::deque<std::string>& resolvedAddresses,
|
|||
throw DL_ABORT_EX(StringFormat(EX_RESOLVE_HOSTNAME,
|
||||
hostname.c_str(), gai_strerror(s)).str());
|
||||
}
|
||||
auto_delete<struct addrinfo*> resDeleter(res, freeaddrinfo);
|
||||
WSAAPI_AUTO_DELETE<struct addrinfo*> resDeleter(res, freeaddrinfo);
|
||||
struct addrinfo* rp;
|
||||
for(rp = res; rp; rp = rp->ai_next) {
|
||||
std::pair<std::string, uint16_t> addressPort
|
||||
|
|
|
@ -153,7 +153,7 @@ SelectEventPoll::SelectEventPoll():_logger(LogFactory::getInstance())
|
|||
{
|
||||
#ifdef __MINGW32__
|
||||
_dummySocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
assert(_dummySocket != -1);
|
||||
assert(_dummySocket != (sock_t)-1);
|
||||
#endif // __MINGW32__
|
||||
updateFdSet();
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ private:
|
|||
|
||||
fd_set _rfdset;
|
||||
fd_set _wfdset;
|
||||
int _fdmax;
|
||||
sock_t _fdmax;
|
||||
|
||||
std::deque<SharedHandle<SocketEntry> > _socketEntries;
|
||||
#ifdef ENABLE_ASYNC_DNS
|
||||
|
|
|
@ -198,7 +198,7 @@ static sock_t bindTo
|
|||
error = gai_strerror(s);
|
||||
return -1;
|
||||
}
|
||||
auto_delete<struct addrinfo*> resDeleter(res, freeaddrinfo);
|
||||
WSAAPI_AUTO_DELETE<struct addrinfo*> resDeleter(res, freeaddrinfo);
|
||||
struct addrinfo* rp;
|
||||
for(rp = res; rp; rp = rp->ai_next) {
|
||||
sock_t fd = bindInternal(rp->ai_family, rp->ai_socktype, rp->ai_protocol,
|
||||
|
@ -310,7 +310,7 @@ void SocketCore::establishConnection(const std::string& host, uint16_t port)
|
|||
throw DL_ABORT_EX(StringFormat(EX_RESOLVE_HOSTNAME,
|
||||
host.c_str(), gai_strerror(s)).str());
|
||||
}
|
||||
auto_delete<struct addrinfo*> resDeleter(res, freeaddrinfo);
|
||||
WSAAPI_AUTO_DELETE<struct addrinfo*> resDeleter(res, freeaddrinfo);
|
||||
struct addrinfo* rp;
|
||||
for(rp = res; rp; rp = rp->ai_next) {
|
||||
sock_t fd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
|
||||
|
@ -1055,7 +1055,7 @@ ssize_t SocketCore::writeData(const char* data, size_t len,
|
|||
if(s) {
|
||||
throw DL_ABORT_EX(StringFormat(EX_SOCKET_SEND, gai_strerror(s)).str());
|
||||
}
|
||||
auto_delete<struct addrinfo*> resDeleter(res, freeaddrinfo);
|
||||
WSAAPI_AUTO_DELETE<struct addrinfo*> resDeleter(res, freeaddrinfo);
|
||||
struct addrinfo* rp;
|
||||
ssize_t r = -1;
|
||||
for(rp = res; rp; rp = rp->ai_next) {
|
||||
|
@ -1139,17 +1139,17 @@ void SocketCore::useSelect()
|
|||
_pollMethod = SocketCore::POLL_METHOD_SELECT;
|
||||
}
|
||||
|
||||
void SocketCore::bindAddress(const std::string& interface)
|
||||
void SocketCore::bindAddress(const std::string& iface)
|
||||
{
|
||||
std::vector<std::pair<struct sockaddr_storage, socklen_t> > bindAddrs;
|
||||
LogFactory::getInstance()->debug("Finding interface %s", interface.c_str());
|
||||
LogFactory::getInstance()->debug("Finding interface %s", iface.c_str());
|
||||
#ifdef HAVE_GETIFADDRS
|
||||
// First find interface in interface addresses
|
||||
struct ifaddrs* ifaddr = 0;
|
||||
if(getifaddrs(&ifaddr) == -1) {
|
||||
throw DL_ABORT_EX
|
||||
(StringFormat(MSG_INTERFACE_NOT_FOUND,
|
||||
interface.c_str(), strerror(errno)).str());
|
||||
iface.c_str(), strerror(errno)).str());
|
||||
} else {
|
||||
auto_delete<struct ifaddrs*> ifaddrDeleter(ifaddr, freeifaddrs);
|
||||
for(struct ifaddrs* ifa = ifaddr; ifa; ifa = ifa->ifa_next) {
|
||||
|
@ -1172,7 +1172,7 @@ void SocketCore::bindAddress(const std::string& interface)
|
|||
} else {
|
||||
continue;
|
||||
}
|
||||
if(std::string(ifa->ifa_name) == interface) {
|
||||
if(std::string(ifa->ifa_name) == iface) {
|
||||
socklen_t bindAddrLen =
|
||||
family == AF_INET?sizeof(struct sockaddr_in):
|
||||
sizeof(struct sockaddr_in6);
|
||||
|
@ -1187,14 +1187,14 @@ void SocketCore::bindAddress(const std::string& interface)
|
|||
if(bindAddrs.empty()) {
|
||||
struct addrinfo* res;
|
||||
int s;
|
||||
s = callGetaddrinfo(&res, interface.c_str(), 0, _protocolFamily,
|
||||
s = callGetaddrinfo(&res, iface.c_str(), 0, _protocolFamily,
|
||||
SOCK_STREAM, 0, 0);
|
||||
if(s) {
|
||||
throw DL_ABORT_EX
|
||||
(StringFormat(MSG_INTERFACE_NOT_FOUND,
|
||||
interface.c_str(), gai_strerror(s)).str());
|
||||
iface.c_str(), gai_strerror(s)).str());
|
||||
} else {
|
||||
auto_delete<struct addrinfo*> resDeleter(res, freeaddrinfo);
|
||||
WSAAPI_AUTO_DELETE<struct addrinfo*> resDeleter(res, freeaddrinfo);
|
||||
struct addrinfo* rp;
|
||||
for(rp = res; rp; rp = rp->ai_next) {
|
||||
socklen_t bindAddrLen = rp->ai_addrlen;
|
||||
|
@ -1217,7 +1217,7 @@ void SocketCore::bindAddress(const std::string& interface)
|
|||
if(bindAddrs.empty()) {
|
||||
throw DL_ABORT_EX
|
||||
(StringFormat(MSG_INTERFACE_NOT_FOUND,
|
||||
interface.c_str(), "not available").str());
|
||||
iface.c_str(), "not available").str());
|
||||
} else {
|
||||
_bindAddrs = bindAddrs;
|
||||
for(std::vector<std::pair<struct sockaddr_storage, socklen_t> >::
|
||||
|
|
|
@ -360,7 +360,10 @@ public:
|
|||
// interface is not found or binding socket is failed, exception
|
||||
// will be thrown. Set _protocolFamily before calling this function
|
||||
// if you limit protocol family.
|
||||
static void bindAddress(const std::string& interface);
|
||||
//
|
||||
// We cannot use interface as an argument because it is a reserved
|
||||
// keyword in MSVC.
|
||||
static void bindAddress(const std::string& iface);
|
||||
};
|
||||
|
||||
// Set default ai_flags. hints.ai_flags is initialized with this
|
||||
|
|
|
@ -103,4 +103,24 @@
|
|||
# define DEFAULT_AI_FLAGS 0
|
||||
#endif // !AI_ADDRCONFIG
|
||||
|
||||
#ifdef __MINGW32__
|
||||
template<typename T>
|
||||
class wsaapi_auto_delete {
|
||||
private:
|
||||
T _obj;
|
||||
void (WSAAPI*_deleter)(T);
|
||||
public:
|
||||
wsaapi_auto_delete(T obj, void (WSAAPI*deleter)(T)):
|
||||
_obj(obj), _deleter(deleter) {}
|
||||
|
||||
~wsaapi_auto_delete()
|
||||
{
|
||||
_deleter(_obj);
|
||||
}
|
||||
};
|
||||
# define WSAAPI_AUTO_DELETE wsaapi_auto_delete
|
||||
#else // !__MINGW32__
|
||||
# define WSAAPI_AUTO_DELETE auto_delete
|
||||
#endif // !__MINGW32__
|
||||
|
||||
#endif // _D_A2NETCOMPAT_H_
|
||||
|
|
|
@ -42,8 +42,8 @@ namespace aria2 {
|
|||
|
||||
int daemon(int nochdir, int noclose)
|
||||
{
|
||||
pid_t pid;
|
||||
#ifdef HAVE_WORKING_FORK
|
||||
pid_t pid;
|
||||
pid = fork();
|
||||
if(pid == -1) {
|
||||
return -1;
|
||||
|
|
|
@ -216,8 +216,8 @@ downloadresultcode::RESULT main(int argc, char* argv[])
|
|||
}
|
||||
// Bind interface
|
||||
if(!op->get(PREF_INTERFACE).empty()) {
|
||||
std::string interface = op->get(PREF_INTERFACE);
|
||||
SocketCore::bindAddress(interface);
|
||||
std::string iface = op->get(PREF_INTERFACE);
|
||||
SocketCore::bindAddress(iface);
|
||||
}
|
||||
|
||||
#ifdef SIGPIPE
|
||||
|
|
Loading…
Reference in New Issue