diff --git a/ChangeLog b/ChangeLog index b399ce09..f5b1e42e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2010-01-09 Tatsuhiro Tsujikawa + + 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 Fixed typo. diff --git a/src/MultiUrlRequestInfo.cc b/src/MultiUrlRequestInfo.cc index 95ab5ee5..b9cfab0c 100644 --- a/src/MultiUrlRequestInfo.cc +++ b/src/MultiUrlRequestInfo.cc @@ -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; diff --git a/src/NameResolver.cc b/src/NameResolver.cc index 7271f8ce..7efd066d 100644 --- a/src/NameResolver.cc +++ b/src/NameResolver.cc @@ -56,7 +56,7 @@ void NameResolver::resolve(std::deque& resolvedAddresses, throw DL_ABORT_EX(StringFormat(EX_RESOLVE_HOSTNAME, hostname.c_str(), gai_strerror(s)).str()); } - auto_delete resDeleter(res, freeaddrinfo); + WSAAPI_AUTO_DELETE resDeleter(res, freeaddrinfo); struct addrinfo* rp; for(rp = res; rp; rp = rp->ai_next) { std::pair addressPort diff --git a/src/SelectEventPoll.cc b/src/SelectEventPoll.cc index 19d1eff0..67f95350 100644 --- a/src/SelectEventPoll.cc +++ b/src/SelectEventPoll.cc @@ -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(); } diff --git a/src/SelectEventPoll.h b/src/SelectEventPoll.h index 4db555d3..c55e2602 100644 --- a/src/SelectEventPoll.h +++ b/src/SelectEventPoll.h @@ -155,7 +155,7 @@ private: fd_set _rfdset; fd_set _wfdset; - int _fdmax; + sock_t _fdmax; std::deque > _socketEntries; #ifdef ENABLE_ASYNC_DNS diff --git a/src/SocketCore.cc b/src/SocketCore.cc index cf0cbc4f..6d2f434c 100644 --- a/src/SocketCore.cc +++ b/src/SocketCore.cc @@ -198,7 +198,7 @@ static sock_t bindTo error = gai_strerror(s); return -1; } - auto_delete resDeleter(res, freeaddrinfo); + WSAAPI_AUTO_DELETE 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 resDeleter(res, freeaddrinfo); + WSAAPI_AUTO_DELETE 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 resDeleter(res, freeaddrinfo); + WSAAPI_AUTO_DELETE 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 > 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 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 resDeleter(res, freeaddrinfo); + WSAAPI_AUTO_DELETE 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 >:: diff --git a/src/SocketCore.h b/src/SocketCore.h index 88958f6e..df039355 100644 --- a/src/SocketCore.h +++ b/src/SocketCore.h @@ -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 diff --git a/src/a2netcompat.h b/src/a2netcompat.h index 30d3a5f1..5ea33b02 100644 --- a/src/a2netcompat.h +++ b/src/a2netcompat.h @@ -103,4 +103,24 @@ # define DEFAULT_AI_FLAGS 0 #endif // !AI_ADDRCONFIG +#ifdef __MINGW32__ +template +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_ diff --git a/src/daemon.cc b/src/daemon.cc index 50b21e9a..cfa0ad12 100644 --- a/src/daemon.cc +++ b/src/daemon.cc @@ -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; diff --git a/src/main.cc b/src/main.cc index d7078974..ff8e6531 100644 --- a/src/main.cc +++ b/src/main.cc @@ -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