diff --git a/src/http_tracker_connection.cpp b/src/http_tracker_connection.cpp index 3a1246d6d..4289ab70f 100755 --- a/src/http_tracker_connection.cpp +++ b/src/http_tracker_connection.cpp @@ -142,10 +142,11 @@ namespace libtorrent while (newline != recv_buffer.end && m_state == read_header) { - if (newline == pos) - throw std::runtime_error("unexpected newline in HTTP response"); - - line.assign(pos, newline - 1); + // if the LF character is preceeded by a CR + // charachter, don't copy it into the line string. + char const* line_end = newline; + if (pos != line_end && *(line_end - 1) == '\r') --line_end; + line.assign(pos, line_end); m_recv_pos += newline - pos; boost::get<1>(ret) += newline - pos; pos = newline; @@ -153,6 +154,9 @@ namespace libtorrent std::string::size_type separator = line.find(": "); if (separator == std::string::npos) { + // this means we got a blank line, + // the header is finished and the body + // starts. ++pos; ++m_recv_pos; boost::get<1>(ret) += 1; diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 881534d29..126c64ae8 100755 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -2161,6 +2161,8 @@ namespace libtorrent assert(false); } +// expensive when using checked iterators +/* if (t->valid_metadata()) { int piece_count = std::count(m_have_piece.begin() @@ -2170,7 +2172,7 @@ namespace libtorrent assert(false); } } - +*/ assert(m_write_pos <= int(m_send_buffer[ (m_current_send_buffer + 1) & 1].size())); diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 9bdcfe56d..98ee7d0b6 100755 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -245,6 +245,7 @@ namespace libtorrent { namespace detail catch (const std::exception& e) { // This will happen if the storage fails to initialize + // for example if one of the files has an invalid filename. session_impl::mutex_t::scoped_lock l(m_ses.m_mutex); mutex::scoped_lock l2(m_mutex);