From 680826e96992ab1205d723d0cc09e106a9452226 Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Tue, 7 Aug 2007 08:07:19 +0000 Subject: [PATCH] upnp fixes --- libtorrent/src/upnp.cpp | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/libtorrent/src/upnp.cpp b/libtorrent/src/upnp.cpp index 42c62166e..5dbd0c5b2 100644 --- a/libtorrent/src/upnp.cpp +++ b/libtorrent/src/upnp.cpp @@ -659,7 +659,7 @@ void upnp::on_upnp_xml(asio::error_code const& e d.upnp_connection.reset(); } - if (e) + if (e && e != asio::error::eof) { #ifdef TORRENT_UPNP_LOGGING m_log << time_now_string() @@ -672,7 +672,16 @@ void upnp::on_upnp_xml(asio::error_code const& e { #ifdef TORRENT_UPNP_LOGGING m_log << time_now_string() - << " <== incomplete http message" << std::endl; + << " <== error while fetching control url: incomplete http message" << std::endl; +#endif + return; + } + + if (p.status_code() != 200) + { +#ifdef TORRENT_UPNP_LOGGING + m_log << time_now_string() + << " <== error while fetching control url: " << p.message() << std::endl; #endif return; } @@ -791,7 +800,7 @@ void upnp::on_upnp_map_response(asio::error_code const& e d.upnp_connection.reset(); } - if (e) + if (e && e != asio::error::eof) { #ifdef TORRENT_UPNP_LOGGING m_log << time_now_string() @@ -824,12 +833,22 @@ void upnp::on_upnp_map_response(asio::error_code const& e { #ifdef TORRENT_UPNP_LOGGING m_log << time_now_string() - << " <== incomplete http message" << std::endl; + << " <== error while adding portmap: incomplete http message" << std::endl; #endif m_devices.erase(d); return; } + if (p.status_code() != 200) + { +#ifdef TORRENT_UPNP_LOGGING + m_log << time_now_string() + << " <== error while adding portmap: " << p.message() << std::endl; +#endif + m_devices.erase(d); + return; + } + error_code_parse_state s; xml_parse((char*)p.get_body().begin, (char*)p.get_body().end , m_strand.wrap(bind(&find_error_code, _1, _2, boost::ref(s)))); @@ -933,7 +952,7 @@ void upnp::on_upnp_unmap_response(asio::error_code const& e d.upnp_connection.reset(); } - if (e) + if (e && e != asio::error::eof) { #ifdef TORRENT_UPNP_LOGGING m_log << time_now_string() @@ -945,11 +964,21 @@ void upnp::on_upnp_unmap_response(asio::error_code const& e { #ifdef TORRENT_UPNP_LOGGING m_log << time_now_string() - << " <== incomplete http message" << std::endl; + << " <== error while deleting portmap: incomplete http message" << std::endl; #endif return; } + if (p.status_code() != 200) + { +#ifdef TORRENT_UPNP_LOGGING + m_log << time_now_string() + << " <== error while deleting portmap: " << p.message() << std::endl; +#endif + m_devices.erase(d); + return; + } + #ifdef TORRENT_UPNP_LOGGING m_log << time_now_string() << " <== unmap response: " << std::string(p.get_body().begin, p.get_body().end)