mirror of https://github.com/aria2/aria2
Made socket non-blocking mode in SocketCore::acceptConnection()
parent
e1c03e30dd
commit
438f95abae
|
@ -866,8 +866,7 @@ bool FtpNegotiationCommand::waitConnection()
|
||||||
{
|
{
|
||||||
disableReadCheckSocket();
|
disableReadCheckSocket();
|
||||||
setReadCheckSocket(getSocket());
|
setReadCheckSocket(getSocket());
|
||||||
dataSocket_.reset(serverSocket_->acceptConnection());
|
dataSocket_ = serverSocket_->acceptConnection();
|
||||||
dataSocket_->setNonBlockingMode();
|
|
||||||
sequence_ = SEQ_NEGOTIATION_COMPLETED;
|
sequence_ = SEQ_NEGOTIATION_COMPLETED;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,6 @@ bool HttpListenCommand::execute()
|
||||||
try {
|
try {
|
||||||
if(serverSocket_->isReadable(0)) {
|
if(serverSocket_->isReadable(0)) {
|
||||||
SharedHandle<SocketCore> socket(serverSocket_->acceptConnection());
|
SharedHandle<SocketCore> socket(serverSocket_->acceptConnection());
|
||||||
socket->setNonBlockingMode();
|
|
||||||
|
|
||||||
std::pair<std::string, uint16_t> peerInfo;
|
std::pair<std::string, uint16_t> peerInfo;
|
||||||
socket->getPeerInfo(peerInfo);
|
socket->getPeerInfo(peerInfo);
|
||||||
|
|
|
@ -110,12 +110,10 @@ bool PeerListenCommand::execute() {
|
||||||
for(int i = 0; i < 3 && socket_->isReadable(0); ++i) {
|
for(int i = 0; i < 3 && socket_->isReadable(0); ++i) {
|
||||||
SharedHandle<SocketCore> peerSocket;
|
SharedHandle<SocketCore> peerSocket;
|
||||||
try {
|
try {
|
||||||
peerSocket.reset(socket_->acceptConnection());
|
peerSocket = socket_->acceptConnection();
|
||||||
std::pair<std::string, uint16_t> peerInfo;
|
std::pair<std::string, uint16_t> peerInfo;
|
||||||
peerSocket->getPeerInfo(peerInfo);
|
peerSocket->getPeerInfo(peerInfo);
|
||||||
|
|
||||||
peerSocket->setNonBlockingMode();
|
|
||||||
|
|
||||||
SharedHandle<Peer> peer(new Peer(peerInfo.first, peerInfo.second, true));
|
SharedHandle<Peer> peer(new Peer(peerInfo.first, peerInfo.second, true));
|
||||||
cuid_t cuid = e_->newCUID();
|
cuid_t cuid = e_->newCUID();
|
||||||
Command* command =
|
Command* command =
|
||||||
|
|
|
@ -355,7 +355,7 @@ void SocketCore::beginListen()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SocketCore* SocketCore::acceptConnection() const
|
SharedHandle<SocketCore> SocketCore::acceptConnection() const
|
||||||
{
|
{
|
||||||
sockaddr_union sockaddr;
|
sockaddr_union sockaddr;
|
||||||
socklen_t len = sizeof(sockaddr);
|
socklen_t len = sizeof(sockaddr);
|
||||||
|
@ -366,7 +366,9 @@ SocketCore* SocketCore::acceptConnection() const
|
||||||
if(fd == (sock_t) -1) {
|
if(fd == (sock_t) -1) {
|
||||||
throw DL_ABORT_EX(fmt(EX_SOCKET_ACCEPT, errorMsg(errNum).c_str()));
|
throw DL_ABORT_EX(fmt(EX_SOCKET_ACCEPT, errorMsg(errNum).c_str()));
|
||||||
}
|
}
|
||||||
return new SocketCore(fd, sockType_);
|
SharedHandle<SocketCore> sock(new SocketCore(fd, sockType_));
|
||||||
|
sock->setNonBlockingMode();
|
||||||
|
return sock;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SocketCore::getAddrInfo(std::pair<std::string, uint16_t>& addrinfo) const
|
int SocketCore::getAddrInfo(std::pair<std::string, uint16_t>& addrinfo) const
|
||||||
|
|
|
@ -195,9 +195,9 @@ public:
|
||||||
/**
|
/**
|
||||||
* Accepts incoming connection on this socket.
|
* Accepts incoming connection on this socket.
|
||||||
* You must call beginListen() before calling this method.
|
* You must call beginListen() before calling this method.
|
||||||
* @return accepted socket. The caller must delete it after using it.
|
* @return accepted socket.
|
||||||
*/
|
*/
|
||||||
SocketCore* acceptConnection() const;
|
SharedHandle<SocketCore> acceptConnection() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connects to the server named host and the destination port is port.
|
* Connects to the server named host and the destination port is port.
|
||||||
|
|
|
@ -64,7 +64,8 @@ public:
|
||||||
|
|
||||||
while(!clientSocket_->isWritable(0));
|
while(!clientSocket_->isWritable(0));
|
||||||
|
|
||||||
serverSocket_.reset(listenSocket->acceptConnection());
|
serverSocket_ = listenSocket->acceptConnection();
|
||||||
|
serverSocket_->setBlockingMode();
|
||||||
ftp_.reset(new FtpConnection(1, clientSocket_, req_,
|
ftp_.reset(new FtpConnection(1, clientSocket_, req_,
|
||||||
authConfigFactory_->createAuthConfig
|
authConfigFactory_->createAuthConfig
|
||||||
(req_, option_.get()),
|
(req_, option_.get()),
|
||||||
|
|
Loading…
Reference in New Issue