*** empty log message ***
This commit is contained in:
parent
1eaa0877c8
commit
fd9fba2964
|
@ -140,6 +140,21 @@ namespace libtorrent
|
||||||
torrent_handle handle;
|
torrent_handle handle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO: document and test
|
||||||
|
struct file_error_alert: alert
|
||||||
|
{
|
||||||
|
file_error_alert(
|
||||||
|
const torrent_handle& h
|
||||||
|
, const std::string& msg)
|
||||||
|
: alert(alert::fatal, msg)
|
||||||
|
, handle(h)
|
||||||
|
{}
|
||||||
|
|
||||||
|
virtual std::auto_ptr<alert> clone() const
|
||||||
|
{ return std::auto_ptr<alert>(new file_error_alert(*this)); }
|
||||||
|
|
||||||
|
torrent_handle handle;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/entry.hpp"
|
#include "libtorrent/entry.hpp"
|
||||||
#include "libtorrent/alert_types.hpp"
|
#include "libtorrent/alert_types.hpp"
|
||||||
#include "libtorrent/invariant_check.hpp"
|
#include "libtorrent/invariant_check.hpp"
|
||||||
|
#include "libtorrent/file.hpp"
|
||||||
|
|
||||||
#if defined(_MSC_VER) && _MSC_VER < 1300
|
#if defined(_MSC_VER) && _MSC_VER < 1300
|
||||||
namespace std
|
namespace std
|
||||||
|
@ -419,7 +420,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
listener->listen(m_listen_port, 5);
|
listener->listen(m_listen_port, 5);
|
||||||
}
|
}
|
||||||
catch(std::exception&)
|
catch (std::exception&)
|
||||||
{
|
{
|
||||||
if (m_listen_port > max_port)
|
if (m_listen_port > max_port)
|
||||||
throw;
|
throw;
|
||||||
|
@ -517,7 +518,21 @@ namespace libtorrent
|
||||||
assert(p->second->get_socket()->is_writable());
|
assert(p->second->get_socket()->is_writable());
|
||||||
p->second->send_data();
|
p->second->send_data();
|
||||||
}
|
}
|
||||||
catch(std::exception& e)
|
catch (file_error& e)
|
||||||
|
{
|
||||||
|
if (m_alerts.should_post(alert::fatal))
|
||||||
|
{
|
||||||
|
m_alerts.post_alert(
|
||||||
|
file_error_alert(
|
||||||
|
p->second->associated_torrent()->get_handle()
|
||||||
|
, e.what()));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_selector.remove(*i);
|
||||||
|
m_connections.erase(p);
|
||||||
|
assert(m_selector.count_read_monitors() == m_connections.size() + 1);
|
||||||
|
}
|
||||||
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
// the connection wants to disconnect for some reason,
|
// the connection wants to disconnect for some reason,
|
||||||
// remove it from the connection-list
|
// remove it from the connection-list
|
||||||
|
@ -583,7 +598,21 @@ namespace libtorrent
|
||||||
// (*m_logger) << "readable: " << p->first->sender().as_string() << "\n";
|
// (*m_logger) << "readable: " << p->first->sender().as_string() << "\n";
|
||||||
p->second->receive_data();
|
p->second->receive_data();
|
||||||
}
|
}
|
||||||
catch(std::exception& e)
|
catch (file_error& e)
|
||||||
|
{
|
||||||
|
if (m_alerts.should_post(alert::fatal))
|
||||||
|
{
|
||||||
|
m_alerts.post_alert(
|
||||||
|
file_error_alert(
|
||||||
|
p->second->associated_torrent()->get_handle()
|
||||||
|
, e.what()));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_selector.remove(*i);
|
||||||
|
m_connections.erase(p);
|
||||||
|
assert(m_selector.count_read_monitors() == m_connections.size() + 1);
|
||||||
|
}
|
||||||
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
if (m_alerts.should_post(alert::debug))
|
if (m_alerts.should_post(alert::debug))
|
||||||
{
|
{
|
||||||
|
@ -720,15 +749,15 @@ namespace libtorrent
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
}
|
}
|
||||||
catch(std::bad_cast& e)
|
catch (std::bad_cast& e)
|
||||||
{
|
{
|
||||||
std::cerr << e.what() << "\n";
|
std::cerr << e.what() << "\n";
|
||||||
}
|
}
|
||||||
catch(std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
std::cerr << e.what() << "\n";
|
std::cerr << e.what() << "\n";
|
||||||
}
|
}
|
||||||
catch(...)
|
catch (...)
|
||||||
{
|
{
|
||||||
std::cerr << "error!\n";
|
std::cerr << "error!\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1100,7 +1100,6 @@ namespace libtorrent
|
||||||
|
|
||||||
// take one of the other matching pieces
|
// take one of the other matching pieces
|
||||||
// that hasn't already been assigned
|
// that hasn't already been assigned
|
||||||
std::sort(matching_pieces.begin(), matching_pieces.end());
|
|
||||||
int other_piece = -1;
|
int other_piece = -1;
|
||||||
for (std::vector<int>::iterator i = matching_pieces.begin();
|
for (std::vector<int>::iterator i = matching_pieces.begin();
|
||||||
i != matching_pieces.end();
|
i != matching_pieces.end();
|
||||||
|
@ -1122,16 +1121,29 @@ namespace libtorrent
|
||||||
m_slot_to_piece[other_slot] = unassigned;
|
m_slot_to_piece[other_slot] = unassigned;
|
||||||
m_free_slots.push_back(other_slot);
|
m_free_slots.push_back(other_slot);
|
||||||
}
|
}
|
||||||
|
assert(m_piece_to_slot[piece_index] != current_slot);
|
||||||
|
assert(m_piece_to_slot[piece_index] >= 0);
|
||||||
|
m_piece_to_slot[piece_index] = has_no_slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
have_pieces[piece_index] = true;
|
have_pieces[piece_index] = true;
|
||||||
return piece_index;
|
return piece_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::sort(matching_pieces.begin(), matching_pieces.end());
|
// find a matching piece that hasn't
|
||||||
const int piece_index = matching_pieces.back();
|
// already been assigned
|
||||||
have_pieces[piece_index] = true;
|
int free_piece = -1;
|
||||||
return piece_index;
|
for (std::vector<int>::iterator i = matching_pieces.begin();
|
||||||
|
i != matching_pieces.end();
|
||||||
|
++i)
|
||||||
|
{
|
||||||
|
if (have_pieces[*i]) continue;
|
||||||
|
free_piece = *i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (free_piece >= 0) have_pieces[free_piece] = true;
|
||||||
|
return free_piece;
|
||||||
}
|
}
|
||||||
|
|
||||||
void piece_manager::impl::check_pieces(
|
void piece_manager::impl::check_pieces(
|
||||||
|
@ -1239,6 +1251,9 @@ namespace libtorrent
|
||||||
|
|
||||||
if (piece_index >= 0)
|
if (piece_index >= 0)
|
||||||
{
|
{
|
||||||
|
assert(m_slot_to_piece[current_slot] == unallocated);
|
||||||
|
assert(m_piece_to_slot[piece_index] == has_no_slot);
|
||||||
|
|
||||||
// the slot was identified as piece 'piece_index'
|
// the slot was identified as piece 'piece_index'
|
||||||
m_piece_to_slot[piece_index] = current_slot;
|
m_piece_to_slot[piece_index] = current_slot;
|
||||||
m_slot_to_piece[current_slot] = piece_index;
|
m_slot_to_piece[current_slot] = piece_index;
|
||||||
|
|
Loading…
Reference in New Issue