clean up tcp_server accept api, removing unused return value
This commit is contained in:
parent
a69abee4c4
commit
ef2b0453cd
3 changed files with 11 additions and 18 deletions
|
|
@ -44,7 +44,7 @@ namespace fc {
|
|||
~tcp_server();
|
||||
|
||||
void close();
|
||||
bool accept( tcp_socket& s );
|
||||
void accept( tcp_socket& s );
|
||||
void listen( uint16_t port );
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -58,11 +58,12 @@ namespace fc { namespace http {
|
|||
}catch(...){}
|
||||
}
|
||||
void accept_loop() {
|
||||
http::connection_ptr con = std::make_shared<http::connection>();
|
||||
while( tcp_serv.accept( con->get_socket() ) ) {
|
||||
while( !accept_complete.canceled() )
|
||||
{
|
||||
http::connection_ptr con = std::make_shared<http::connection>();
|
||||
tcp_serv.accept( con->get_socket() );
|
||||
ilog( "Accept Connection" );
|
||||
fc::async( [=](){ handle_connection( con, on_req ); } );
|
||||
con = std::make_shared<http::connection>();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,25 +86,17 @@ namespace fc {
|
|||
}
|
||||
|
||||
|
||||
bool tcp_server::accept( tcp_socket& s ) {
|
||||
void tcp_server::accept( tcp_socket& s )
|
||||
{
|
||||
try
|
||||
{
|
||||
if( !my ) return false;
|
||||
|
||||
FC_ASSERT( my != nullptr );
|
||||
fc::asio::tcp::accept( my->_accept, s.my->_sock );
|
||||
/*
|
||||
fc::promise<void>::ptr p( new promise<void>("tcp::accept") );
|
||||
my->_accept.async_accept( s.my->_sock, [=]( const boost::system::error_code& e ) {
|
||||
p->set_value(e);
|
||||
} );
|
||||
auto ec = p->wait();
|
||||
if( ec ) FC_THROW_EXCEPTION( exception, "system error: ${message}", ("message", fc::string(boost::system::system_error(ec).what()) ));
|
||||
return true;
|
||||
*/
|
||||
return true;
|
||||
} FC_RETHROW_EXCEPTIONS( warn, "Unable to accept connection on socket." );
|
||||
}
|
||||
void tcp_server::listen( uint16_t port ) {
|
||||
|
||||
void tcp_server::listen( uint16_t port )
|
||||
{
|
||||
if( my ) delete my;
|
||||
my = new impl(port);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue