void upnp::discover_device() { mutex::scoped_lock l(m_mutex); if (m_socket.num_send_sockets() == 0) log("No network interfaces to broadcast to", l); discover_device_impl(l); }
void upnp::discover_device() { TORRENT_ASSERT(is_single_thread()); if (m_socket.num_send_sockets() == 0) log("No network interfaces to broadcast to"); discover_device_impl(); }
void upnp::resend_request(error_code const& ec) { #if defined TORRENT_ASIO_DEBUGGING complete_async("upnp::resend_request"); #endif if (ec) return; boost::shared_ptr<upnp> me(self()); mutex::scoped_lock l(m_mutex); if (m_closing) return; if (m_retry_count < 12 && (m_devices.empty() || m_retry_count < 4)) { discover_device_impl(l); return; } if (m_devices.empty()) { disable(errors::no_router, l); return; } for (std::set<rootdevice>::iterator i = m_devices.begin() , end(m_devices.end()); i != end; ++i) { if (i->control_url.empty() && !i->upnp_connection && !i->disabled) { // we don't have a WANIP or WANPPP url for this device, // ask for it rootdevice& d = const_cast<rootdevice&>(*i); TORRENT_ASSERT(d.magic == 1337); TORRENT_TRY { char msg[500]; snprintf(msg, sizeof(msg), "connecting to: %s", d.url.c_str()); log(msg, l); if (d.upnp_connection) d.upnp_connection->close(); d.upnp_connection.reset(new http_connection(m_io_service , m_resolver , boost::bind(&upnp::on_upnp_xml, self(), _1, _2 , boost::ref(d), _5))); d.upnp_connection->get(d.url, seconds(30), 1); } TORRENT_CATCH (std::exception& exc) { TORRENT_DECLARE_DUMMY(std::exception, exc); char msg[500]; snprintf(msg, sizeof(msg), "connection failed to: %s %s", d.url.c_str(), exc.what()); log(msg, l); d.disabled = true; } }