disk IO thread error handling

This commit is contained in:
Arvid Norberg 2008-04-13 21:26:57 +00:00
parent 2b55d7ebe5
commit 644d3aa66c
2 changed files with 239 additions and 219 deletions

View File

@ -770,6 +770,11 @@ namespace libtorrent
#ifndef BOOST_NO_EXCEPTIONS
try {
#endif
switch (j.action)
{
case disk_io_job::read:
{
std::string const& error_string = j.storage->error();
if (!error_string.empty())
{
@ -780,13 +785,8 @@ namespace libtorrent
j.error_file = j.storage->error_file();
j.storage->clear_error();
ret = -1;
break;
}
else
{
switch (j.action)
{
case disk_io_job::read:
{
#ifdef TORRENT_DISK_STATS
m_log << log_time() << " read " << j.buffer_size << std::endl;
#endif
@ -835,6 +835,18 @@ namespace libtorrent
}
case disk_io_job::write:
{
std::string const& error_string = j.storage->error();
if (!error_string.empty())
{
#ifndef NDEBUG
std::cout << "ERROR: '" << error_string << "' " << j.error_file << std::endl;
#endif
j.str = error_string;
j.error_file = j.storage->error_file();
j.storage->clear_error();
ret = -1;
break;
}
#ifdef TORRENT_DISK_STATS
m_log << log_time() << " write " << j.buffer_size << std::endl;
#endif
@ -1053,7 +1065,6 @@ namespace libtorrent
break;
}
}
}
#ifndef BOOST_NO_EXCEPTIONS
} catch (std::exception& e)
{

View File

@ -1390,10 +1390,19 @@ namespace libtorrent
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
if (alerts().should_post(alert::warning))
{
char const* msg;
if (j.resume_data)
{
write_resume_data(*j.resume_data);
msg = "resume data generated";
}
else
{
msg = j.str.c_str();
}
alerts().post_alert(save_resume_data_alert(j.resume_data
, get_handle(), "resume data generated"));
, get_handle(), msg));
}
}