post alerts for socks failures. fix unit tests

This commit is contained in:
Arvid Norberg
2010-08-25 06:22:49 +00:00
parent 58574c236a
commit b44f71e217
5 changed files with 45 additions and 30 deletions

View File

@@ -1363,6 +1363,13 @@ namespace aux {
listen_socket_t s;
s.sock.reset(new socket_acceptor(m_io_service));
s.sock->open(ep.protocol(), ec);
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
if (ec)
{
(*m_logger) << "failed to open socket: " << print_endpoint(ep)
<< ": " << ec.message() << "\n" << "\n";
}
#endif
if (reuse_address)
s.sock->set_option(socket_acceptor::reuse_address(true), ec);
#if TORRENT_USE_IPV6
@@ -1382,6 +1389,12 @@ namespace aux {
s.sock->bind(ep, ec);
while (ec && retries > 0)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
char msg[200];
snprintf(msg, 200, "failed to bind to interface \"%s\": %s"
, print_endpoint(ep).c_str(), ec.message().c_str());
(*m_logger) << msg << "\n";
#endif
ec = error_code();
TORRENT_ASSERT(!ec);
--retries;
@@ -1454,15 +1467,11 @@ namespace aux {
if (s.sock)
{
// if we're configured to listen on port 0 (i.e. let the
// OS decide), update the listen_interface member with the
// update the listen_interface member with the
// actual port we ended up listening on, so that the other
// sockets can be bound to the same one
if (m_listen_interface.port() == 0)
{
error_code ec;
m_listen_interface.port(s.sock->local_endpoint(ec).port());
}
error_code ec;
m_listen_interface.port(s.sock->local_endpoint(ec).port());
m_listen_sockets.push_back(s);
async_accept(s.sock);