Fix incorrect future returns for pure virtuals

This commit is contained in:
Vinnie Falco
2013-08-16 14:41:15 -07:00
parent 7fe3d3dc1b
commit 191562c13c
3 changed files with 34 additions and 45 deletions

View File

@@ -17,6 +17,12 @@
*/
//==============================================================================
boost::system::error_code SocketBase::pure_virtual_error ()
{
return boost::system::errc::make_error_code (
boost::system::errc::function_not_supported);
}
void SocketBase::pure_virtual ()
{
fatal_error ("A beast::Socket function was called on an object that doesn't support the interface");
@@ -25,6 +31,6 @@ void SocketBase::pure_virtual ()
boost::system::error_code SocketBase::pure_virtual (boost::system::error_code& ec)
{
pure_virtual ();
return ec = boost::system::errc::make_error_code (
boost::system::errc::function_not_supported);
ec = pure_virtual_error ();
return ec;
}

View File

@@ -25,8 +25,9 @@
*/
struct SocketBase
{
static void pure_virtual ();
static boost::system::error_code pure_virtual_error ();
static boost::system::error_code pure_virtual (boost::system::error_code& ec);
static void pure_virtual ();
/** Called when the underlying object does not support the interface. */
void throw_error (boost::system::error_code const& ec)

View File

@@ -394,18 +394,15 @@ public:
boost::asio::detail::async_result_init<
AcceptHandler, void (error_code)> init(
BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler));
error_code ec;
ec = pure_virtual (ec);
// init.handler is copied
get_io_service ().post (CompletionCall (
AcceptHandler (init.handler), ec));
AcceptHandler (init.handler), pure_virtual_error ()));
return init.result.get();
#else
error_code ec;
ec = pure_virtual (ec);
get_io_service ().post (boost::bind (
BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler), ec));
get_io_service ().post (CompletionCall (
BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler),
pure_virtual_error ()));
#endif
}
@@ -493,18 +490,15 @@ public:
boost::asio::detail::async_result_init<
ReadHandler, void (error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
error_code ec;
ec = pure_virtual (ec);
// init.handler is copied
get_io_service ().post (CompletionCall (
ReadHandler (init.handler), ec, 0));
ReadHandler (init.handler), pure_virtual_error (), 0));
return init.result.get();
#else
error_code ec;
ec = pure_virtual (ec);
get_io_service ().post (boost::bind (
BOOST_ASIO_MOVE_CAST(ReadHandler)(handler), ec, 0));
get_io_service ().post (CompletionCall (
BOOST_ASIO_MOVE_CAST(ReadHandler)(handler),
pure_virtual_error (), 0));
#endif
}
@@ -537,18 +531,15 @@ public:
boost::asio::detail::async_result_init<
TransferCall, void (error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(TransferCall)(handler));
error_code ec;
ec = pure_virtual (ec);
// init.handler is copied
get_io_service ().post (CompletionCall (
TransferCall (init.handler), ec, 0));
TransferCall (init.handler), pure_virtual_error (), 0));
return init.result.get();
#else
error_code ec;
ec = pure_virtual (ec);
get_io_service ().post (boost::bind (
BOOST_ASIO_MOVE_CAST(TransferCall)(handler), ec, 0));
get_io_service ().post (CompletionCall (
BOOST_ASIO_MOVE_CAST(TransferCall)(handler),
pure_virtual_error (), 0));
#endif
}
@@ -619,17 +610,14 @@ public:
boost::asio::detail::async_result_init<
ErrorCall, void (error_code)> init(
BOOST_ASIO_MOVE_CAST(ErrorCall)(handler));
error_code ec;
ec = pure_virtual (ec);
// init.handler is copied
get_io_service ().post (CompletionCall (
ErrorCall (init.handler), ec));
ErrorCall (init.handler), pure_virtual_error ()));
return init.result.get();
#else
error_code ec;
ec = pure_virtual (ec);
get_io_service ().post (boost::bind (
BOOST_ASIO_MOVE_CAST(ErrorCall)(handler), ec));
get_io_service ().post (CompletionCall (
BOOST_ASIO_MOVE_CAST(ErrorCall)(handler),
pure_virtual_error ()));
#endif
}
@@ -686,18 +674,15 @@ public:
boost::asio::detail::async_result_init<
TransferCall, void (error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(TransferCall)(handler));
error_code ec;
ec = pure_virtual (ec);
// init.handler is copied
get_io_service ().post (CompletionCall (
TransferCall (init.handler), ec, 0));
TransferCall (init.handler), pure_virtual_error (), 0));
return init.result.get();
#else
error_code ec;
ec = pure_virtual (ec);
get_io_service ().post (boost::bind (
BOOST_ASIO_MOVE_CAST(TransferCall)(handler), ec, 0));
get_io_service ().post (CompletionCall (
BOOST_ASIO_MOVE_CAST(TransferCall)(handler),
pure_virtual_error (), 0));
#endif
}
@@ -753,18 +738,15 @@ public:
boost::asio::detail::async_result_init<
ErrorCall, void (error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(ErrorCall)(handler));
error_code ec;
ec = pure_virtual (ec);
// init.handler is copied
get_io_service ().post (CompletionCall (
ErrorCall (init.handler), ec));
ErrorCall (init.handler), pure_virtual_error ()));
return init.result.get();
#else
error_code ec;
ec = pure_virtual (ec);
get_io_service ().post (boost::bind (
BOOST_ASIO_MOVE_CAST(ErrorCall)(handler), ec));
get_io_service ().post (CompletionCall (
BOOST_ASIO_MOVE_CAST(ErrorCall)(handler),
pure_virtual_error ()));
#endif
}