From e781e6eac1e3f45c143d9db303bf394a17191ba2 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 28 Nov 2012 00:15:03 +0900 Subject: [PATCH] Made socket non-blocking mode in SocketCore::beginListen() --- src/FtpConnection.cc | 1 - src/HttpListenCommand.cc | 1 - src/PeerListenCommand.cc | 1 - src/SocketCore.cc | 1 + test/FtpConnectionTest.cc | 1 + test/MSEHandshakeTest.cc | 1 + 6 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/FtpConnection.cc b/src/FtpConnection.cc index 88a6f78a..d05872cf 100644 --- a/src/FtpConnection.cc +++ b/src/FtpConnection.cc @@ -206,7 +206,6 @@ SharedHandle FtpConnection::createServerSocket() SharedHandle serverSocket(new SocketCore()); serverSocket->bind(addrinfo.first.c_str(), 0, AF_UNSPEC); serverSocket->beginListen(); - serverSocket->setNonBlockingMode(); return serverSocket; } diff --git a/src/HttpListenCommand.cc b/src/HttpListenCommand.cc index b3d78bd9..6ee061d3 100644 --- a/src/HttpListenCommand.cc +++ b/src/HttpListenCommand.cc @@ -106,7 +106,6 @@ bool HttpListenCommand::bindPort(uint16_t port) } serverSocket_->bind(0, port, family_, flags); serverSocket_->beginListen(); - serverSocket_->setNonBlockingMode(); A2_LOG_INFO(fmt(MSG_LISTENING_PORT, getCuid(), port)); e_->addSocketForReadCheck(serverSocket_, this); diff --git a/src/PeerListenCommand.cc b/src/PeerListenCommand.cc index 54e7d7eb..ee192a95 100644 --- a/src/PeerListenCommand.cc +++ b/src/PeerListenCommand.cc @@ -79,7 +79,6 @@ bool PeerListenCommand::bindPort(uint16_t& port, SegList& sgl) try { socket_->bind(0, port, family_); socket_->beginListen(); - socket_->setNonBlockingMode(); A2_LOG_NOTICE(fmt(_("IPv%d BitTorrent: listening to port %u"), ipv, port)); return true; diff --git a/src/SocketCore.cc b/src/SocketCore.cc index 1c65a733..9edd2c41 100644 --- a/src/SocketCore.cc +++ b/src/SocketCore.cc @@ -353,6 +353,7 @@ void SocketCore::beginListen() int errNum = SOCKET_ERRNO; throw DL_ABORT_EX(fmt(EX_SOCKET_LISTEN, errorMsg(errNum).c_str())); } + setNonBlockingMode(); } SharedHandle SocketCore::acceptConnection() const diff --git a/test/FtpConnectionTest.cc b/test/FtpConnectionTest.cc index bf7fd4f3..b8291f6e 100644 --- a/test/FtpConnectionTest.cc +++ b/test/FtpConnectionTest.cc @@ -52,6 +52,7 @@ public: SharedHandle listenSocket(new SocketCore()); listenSocket->bind(0); listenSocket->beginListen(); + listenSocket->setBlockingMode(); std::pair addrinfo; listenSocket->getAddrInfo(addrinfo); listenPort_ = addrinfo.second; diff --git a/test/MSEHandshakeTest.cc b/test/MSEHandshakeTest.cc index d2369296..46f96306 100644 --- a/test/MSEHandshakeTest.cc +++ b/test/MSEHandshakeTest.cc @@ -53,6 +53,7 @@ createSocketPair() SocketCore receiverServerSock; receiverServerSock.bind(0); receiverServerSock.beginListen(); + receiverServerSock.setBlockingMode(); std::pair receiverAddrInfo; receiverServerSock.getAddrInfo(receiverAddrInfo);