diff --git a/libtorrent/include/libtorrent/peer_info.hpp b/libtorrent/include/libtorrent/peer_info.hpp index b07acffd4..e65f33a18 100755 --- a/libtorrent/include/libtorrent/peer_info.hpp +++ b/libtorrent/include/libtorrent/peer_info.hpp @@ -96,8 +96,10 @@ namespace libtorrent // time since last download or upload time_duration last_active; - // the size of the send buffer for this peer + // the size of the send buffer for this peer, in bytes int send_buffer_size; + // the number bytes that's actually used of the send buffer + int used_send_buffer; // the number of failed hashes for this peer int num_hashfails; diff --git a/libtorrent/src/peer_connection.cpp b/libtorrent/src/peer_connection.cpp index b87553c5d..fa9bb4b9c 100755 --- a/libtorrent/src/peer_connection.cpp +++ b/libtorrent/src/peer_connection.cpp @@ -2073,7 +2073,8 @@ namespace libtorrent bool peer_connection::on_local_network() const { - if (libtorrent::is_local(m_remote.address())) return true; + if (libtorrent::is_local(m_remote.address()) + || is_loopback(m_remote.address())) return true; return false; } @@ -2156,6 +2157,7 @@ namespace libtorrent } p.send_buffer_size = m_send_buffer.capacity(); + p.used_send_buffer = m_send_buffer.size(); } void peer_connection::cut_receive_buffer(int size, int packet_size) diff --git a/libtorrent/src/storage.cpp b/libtorrent/src/storage.cpp index 07878e7ee..2f3c7e7f9 100755 --- a/libtorrent/src/storage.cpp +++ b/libtorrent/src/storage.cpp @@ -452,15 +452,19 @@ namespace libtorrent // the directory exists. if (file_iter->size == 0) { - file(m_save_path / file_iter->path, file::out); + try { + file(m_save_path / file_iter->path, file::out); + } catch (std::exception&) {} continue; } - if (allocate_files) - { - m_files.open_file(this, m_save_path / file_iter->path, file::in | file::out) - ->set_size(file_iter->size); - } + try { + if (allocate_files) + { + m_files.open_file(this, m_save_path / file_iter->path, file::in | file::out) + ->set_size(file_iter->size); + } + } catch (std::exception&) {} } // close files that were opened in write mode m_files.release(this);