mirror of https://github.com/aria2/aria2
Fix failure to set TCP_NODELAY on Windows
On Windows setting TCP_NODELAY after non-blocking connect fails at least on Windows 7.pull/46/head
parent
1c9cfccac4
commit
98e7018599
|
@ -95,7 +95,6 @@ Command* FtpInitiateConnectionCommand::createNextCommand
|
|||
getCuid(), addr.c_str(), port));
|
||||
createSocket();
|
||||
getSocket()->establishConnection(addr, port);
|
||||
getSocket()->setTcpNodelay(true);
|
||||
|
||||
getRequest()->setConnectedAddrInfo(hostname, addr, port);
|
||||
if(proxyMethod == V_GET) {
|
||||
|
@ -164,7 +163,6 @@ Command* FtpInitiateConnectionCommand::createNextCommand
|
|||
getCuid(), addr.c_str(), port));
|
||||
createSocket();
|
||||
getSocket()->establishConnection(addr, port);
|
||||
getSocket()->setTcpNodelay(true);
|
||||
FtpNegotiationCommand* c =
|
||||
new FtpNegotiationCommand(getCuid(), getRequest(), getFileEntry(),
|
||||
getRequestGroup(), getDownloadEngine(),
|
||||
|
|
|
@ -682,8 +682,7 @@ bool FtpNegotiationCommand::preparePasvConnect() {
|
|||
dataAddr.first.c_str(),
|
||||
pasvPort_));
|
||||
dataSocket_.reset(new SocketCore());
|
||||
dataSocket_->establishConnection(dataAddr.first, pasvPort_);
|
||||
dataSocket_->setTcpNodelay(true);
|
||||
dataSocket_->establishConnection(dataAddr.first, pasvPort_, false);
|
||||
disableReadCheckSocket();
|
||||
setWriteCheckSocket(dataSocket_);
|
||||
sequence_ = SEQ_SEND_REST_PASV;
|
||||
|
@ -705,7 +704,6 @@ bool FtpNegotiationCommand::resolveProxy()
|
|||
proxyAddr_.c_str(), proxyReq->getPort()));
|
||||
dataSocket_.reset(new SocketCore());
|
||||
dataSocket_->establishConnection(proxyAddr_, proxyReq->getPort());
|
||||
dataSocket_->setTcpNodelay(true);
|
||||
disableReadCheckSocket();
|
||||
setWriteCheckSocket(dataSocket_);
|
||||
SharedHandle<SocketRecvBuffer> socketRecvBuffer
|
||||
|
@ -741,7 +739,6 @@ bool FtpNegotiationCommand::sendTunnelRequest()
|
|||
getCuid(),
|
||||
proxyAddr_.c_str(), proxyReq->getPort()));
|
||||
dataSocket_->establishConnection(proxyAddr_, proxyReq->getPort());
|
||||
dataSocket_->setTcpNodelay(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -870,7 +867,6 @@ bool FtpNegotiationCommand::waitConnection()
|
|||
disableReadCheckSocket();
|
||||
setReadCheckSocket(getSocket());
|
||||
dataSocket_ = serverSocket_->acceptConnection();
|
||||
dataSocket_->setTcpNodelay(true);
|
||||
sequence_ = SEQ_NEGOTIATION_COMPLETED;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -82,7 +82,6 @@ Command* HttpInitiateConnectionCommand::createNextCommand
|
|||
getCuid(), addr.c_str(), port));
|
||||
createSocket();
|
||||
getSocket()->establishConnection(addr, port);
|
||||
getSocket()->setTcpNodelay(true);
|
||||
|
||||
getRequest()->setConnectedAddrInfo(hostname, addr, port);
|
||||
if(proxyMethod == V_TUNNEL) {
|
||||
|
@ -140,7 +139,6 @@ Command* HttpInitiateConnectionCommand::createNextCommand
|
|||
getCuid(), addr.c_str(), port));
|
||||
createSocket();
|
||||
getSocket()->establishConnection(addr, port);
|
||||
getSocket()->setTcpNodelay(true);
|
||||
|
||||
getRequest()->setConnectedAddrInfo(hostname, addr, port);
|
||||
} else {
|
||||
|
|
|
@ -82,7 +82,7 @@ bool PeerInitiateConnectionCommand::executeInternal() {
|
|||
getPeer()->getPort()));
|
||||
createSocket();
|
||||
getSocket()->establishConnection(getPeer()->getIPAddress(),
|
||||
getPeer()->getPort());
|
||||
getPeer()->getPort(), false);
|
||||
if(mseHandshakeEnabled_) {
|
||||
InitiatorMSEHandshakeCommand* c =
|
||||
new InitiatorMSEHandshakeCommand(getCuid(), requestGroup_, getPeer(),
|
||||
|
|
|
@ -409,7 +409,8 @@ int SocketCore::getPeerInfo(std::pair<std::string, uint16_t>& peerinfo) const
|
|||
return sockaddr.storage.ss_family;
|
||||
}
|
||||
|
||||
void SocketCore::establishConnection(const std::string& host, uint16_t port)
|
||||
void SocketCore::establishConnection(const std::string& host, uint16_t port,
|
||||
bool tcpNodelay)
|
||||
{
|
||||
closeConnection();
|
||||
std::string error;
|
||||
|
@ -461,6 +462,9 @@ void SocketCore::establishConnection(const std::string& host, uint16_t port)
|
|||
sockfd_ = fd;
|
||||
// make socket non-blocking mode
|
||||
setNonBlockingMode();
|
||||
if(tcpNodelay) {
|
||||
setTcpNodelay(true);
|
||||
}
|
||||
if(connect(fd, rp->ai_addr, rp->ai_addrlen) == -1 &&
|
||||
SOCKET_ERRNO != A2_EINPROGRESS) {
|
||||
errNum = SOCKET_ERRNO;
|
||||
|
|
|
@ -207,8 +207,10 @@ public:
|
|||
* the connection is established.
|
||||
* @param host hostname or ip address to connect to
|
||||
* @param port service port number to connect to
|
||||
* @param tcpNodelay true to disable Nagle algorithm
|
||||
*/
|
||||
void establishConnection(const std::string& host, uint16_t port);
|
||||
void establishConnection(const std::string& host, uint16_t port,
|
||||
bool tcpNodelay = true);
|
||||
|
||||
void setNonBlockingMode();
|
||||
|
||||
|
|
Loading…
Reference in New Issue