Endpoints are now reset after listen failure. fixes #390

This commit is contained in:
Peter Thorson
2015-01-22 08:20:13 -05:00
parent 681c2331a1
commit 31c761a0a9
3 changed files with 34 additions and 4 deletions
+2
View File
@@ -36,6 +36,8 @@ HEAD
Schebb for reporting, code, and testing.
- Bug: Fixes an issue where `websocketpp::exception::what()` could return an out
of scope pointer. #397 Thank you fabioang for reporting.
- Bug: Fixes an issue where endpoints were not reset properly after a call to
`endpoint::listen` failed. #390 Thank you wyyqyl for reporting.
0.4.0 - 2014-11-04
- BREAKING API CHANGE: All WebSocket++ methods now throw an exception of type
+29 -4
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Peter Thorson. All rights reserved.
* Copyright (c) 2015, Peter Thorson. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -94,8 +94,33 @@ struct stub_config : public websocketpp::config::core {
BOOST_AUTO_TEST_CASE( endpoint_extensions ) {
websocketpp::server<stub_config> s;
BOOST_CHECK( s.extension_value == 5 );
BOOST_CHECK( s.extension_method() == 5 );
BOOST_CHECK_EQUAL( s.extension_value, 5 );
BOOST_CHECK_EQUAL( s.extension_method(), 5 );
BOOST_CHECK( s.is_server() == true );
BOOST_CHECK( s.is_server() );
}
BOOST_AUTO_TEST_CASE( listen_after_listen_failure ) {
using websocketpp::transport::asio::error::make_error_code;
using websocketpp::transport::asio::error::pass_through;
websocketpp::server<websocketpp::config::asio> server1;
websocketpp::server<websocketpp::config::asio> server2;
websocketpp::lib::error_code ec;
server1.init_asio();
server2.init_asio();
boost::asio::ip::tcp::endpoint ep1(boost::asio::ip::address::from_string("127.0.0.1"), 12345);
boost::asio::ip::tcp::endpoint ep2(boost::asio::ip::address::from_string("127.0.0.1"), 23456);
server1.listen(ep1, ec);
BOOST_CHECK(!ec);
server2.listen(ep1, ec);
BOOST_REQUIRE_EQUAL(ec, make_error_code(pass_through));
server2.listen(ep2, ec);
BOOST_CHECK(!ec);
}
+3
View File
@@ -362,6 +362,9 @@ public:
m_acceptor->listen(m_listen_backlog,bec);
}
if (bec) {
if (m_acceptor->is_open()) {
m_acceptor->close();
}
log_err(log::elevel::info,"asio listen",bec);
ec = make_error_code(error::pass_through);
} else {