diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 728c59ddf..fbc195ce6 100755 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -169,7 +169,7 @@ int main(int argc, char* argv[]) { std::vector handles; session s(6881, "E\x1"); - s.set_upload_rate_limit(10240); +// s.set_upload_rate_limit(20 * 1024); s.set_http_settings(settings); for (int i = 0; i < argc-1; ++i) { diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 3f5da2085..19440fe12 100755 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -156,7 +156,7 @@ libtorrent::peer_connection::peer_connection( libtorrent::peer_connection::~peer_connection() { - m_receiving_piece.close(); + m_selector.remove(m_socket); if (m_torrent) m_torrent->remove_peer(this); } @@ -942,7 +942,7 @@ void libtorrent::peer_connection::send_data() // only add new piece-chunks if the send buffer is small enough // otherwise there will be no end to how large it will be! - // TODO: make ths a bit better. Don't always read the entire + // TODO: make this a bit better. Don't always read the entire // requested block. Have a limit of how much of the requested // block is actually read at a time. while (!m_requests.empty() diff --git a/src/session.cpp b/src/session.cpp index 4d6831aa9..dcd6b5534 100755 --- a/src/session.cpp +++ b/src/session.cpp @@ -167,8 +167,10 @@ namespace libtorrent eh_initializer(); #ifndef NDEBUG m_logger = create_log("main session"); -#endif + try + { +#endif boost::shared_ptr listener(new socket(socket::tcp, false)); int max_port = m_listen_port + 9; @@ -282,7 +284,7 @@ namespace libtorrent // TODO: add some possibility to filter IP:s boost::shared_ptr c( new peer_connection(this, m_selector, s)); - if (m_upload_rate != -1) c->set_send_quota(100); + if (m_upload_rate != -1) c->set_send_quota(0); m_connections.insert(std::make_pair(s, c)); m_selector.monitor_readability(s); m_selector.monitor_errors(s); @@ -437,9 +439,13 @@ namespace libtorrent m_tracker_manager.queue_request( i->second->generate_tracker_request(m_listen_port)); i->second->close_all_connections(); +#ifndef NDEBUG + sha1_hash i_hash = i->second->torrent_file().info_hash(); +#endif std::map >::iterator j = i; ++i; m_torrents.erase(j); + assert(m_torrents.find(i_hash) == m_torrents.end()); continue; } else if (i->second->should_request()) @@ -474,6 +480,22 @@ namespace libtorrent t.nsec += 1000000; boost::thread::sleep(t); } + +#ifndef NDEBUG + } + catch(std::bad_cast& e) + { + std::cerr << e.what() << "\n"; + } + catch(std::exception& e) + { + std::cerr << e.what() << "\n"; + } + catch(...) + { + std::cerr << "error!\n"; + } +#endif } @@ -602,7 +624,7 @@ namespace libtorrent void session::set_upload_rate_limit(int bytes_per_second) { - assert(bytes_per_second > 0); + assert(bytes_per_second > 0 || bytes_per_second == -1); boost::mutex::scoped_lock l(m_impl.m_mutex); m_impl.m_upload_rate = bytes_per_second; if (m_impl.m_upload_rate != -1 || !m_impl.m_connections.empty()) diff --git a/src/torrent.cpp b/src/torrent.cpp index a11290477..8e76b25b8 100755 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -347,7 +347,7 @@ namespace libtorrent , this , s , id)); - if (m_ses->m_upload_rate != -1) c->set_send_quota(100); + if (m_ses->m_upload_rate != -1) c->set_send_quota(0); detail::session_impl::connection_map::iterator p = m_ses->m_connections.insert(std::make_pair(s, c)).first; attach_peer(boost::get_pointer(p->second));