lt sync 3187

This commit is contained in:
Andrew Resch 2009-01-17 22:03:36 +00:00
commit 40ba6ea2ba
5 changed files with 38 additions and 6 deletions

View file

@ -37,5 +37,6 @@ POSSIBILITY OF SUCH DAMAGE.
#define LIBTORRENT_VERSION_MINOR 14 #define LIBTORRENT_VERSION_MINOR 14
#define LIBTORRENT_VERSION "0.14.2.0" #define LIBTORRENT_VERSION "0.14.2.0"
#define LIBTORRENT_REVISION "$Rev: 3169 $"
#endif #endif

View file

@ -86,6 +86,7 @@ std::string demangle(char const* name)
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <signal.h> #include <signal.h>
#include "libtorrent/version.hpp"
// execinfo.h is available in the MacOS X 10.5 SDK. // execinfo.h is available in the MacOS X 10.5 SDK.
#if (defined __linux__ || (defined __APPLE__ && MAC_OS_X_VERSION_MIN_REQUIRED >= 1050)) #if (defined __linux__ || (defined __APPLE__ && MAC_OS_X_VERSION_MIN_REQUIRED >= 1050))
@ -117,10 +118,12 @@ void assert_fail(char const* expr, int line, char const* file, char const* funct
fprintf(stderr, "assertion failed. Please file a bugreport at " fprintf(stderr, "assertion failed. Please file a bugreport at "
"http://code.rasterbar.com/libtorrent/newticket\n" "http://code.rasterbar.com/libtorrent/newticket\n"
"Please include the following information:\n\n" "Please include the following information:\n\n"
"version: " LIBTORRENT_VERSION "\n"
"%s\n"
"file: '%s'\n" "file: '%s'\n"
"line: %d\n" "line: %d\n"
"function: %s\n" "function: %s\n"
"expression: %s\n", file, line, function, expr); "expression: %s\n", LIBTORRENT_REVISION, file, line, function, expr);
print_backtrace("stack:"); print_backtrace("stack:");

View file

@ -53,9 +53,14 @@ namespace
using namespace libtorrent; using namespace libtorrent;
bool is_digit(char c)
{
return c >= '0' && c <= '9';
}
int decode_digit(char c) int decode_digit(char c)
{ {
if (std::isdigit(c)) return c - '0'; if (is_digit(c)) return c - '0';
return unsigned(c) - 'A' + 10; return unsigned(c) - 'A' + 10;
} }

View file

@ -970,15 +970,26 @@ namespace libtorrent
int actual_read = int(in->read(buf + buf_pos, read_bytes, ec)); int actual_read = int(in->read(buf + buf_pos, read_bytes, ec));
if (read_bytes != actual_read || ec) if (ec)
{
set_error(m_save_path / file_iter->path, ec);
return -1;
}
if (read_bytes != actual_read)
{ {
// the file was not big enough // the file was not big enough
if (actual_read > 0) buf_pos += actual_read;
if (!fill_zero) if (!fill_zero)
{ {
#ifdef TORRENT_WINDOWS
ec = error_code(ERROR_READ_FAULT, get_system_category());
#else
ec = error_code(EIO, get_posix_category());
#endif
set_error(m_save_path / file_iter->path, ec); set_error(m_save_path / file_iter->path, ec);
return -1; return -1;
} }
if (actual_read > 0) buf_pos += actual_read;
std::memset(buf + buf_pos, 0, size - buf_pos); std::memset(buf + buf_pos, 0, size - buf_pos);
return size; return size;
} }
@ -1111,12 +1122,24 @@ namespace libtorrent
error_code ec; error_code ec;
size_type written = out->write(buf + buf_pos, write_bytes, ec); size_type written = out->write(buf + buf_pos, write_bytes, ec);
if (written != write_bytes || ec) if (ec)
{ {
set_error(m_save_path / file_iter->path, ec); set_error(m_save_path / file_iter->path, ec);
return -1; return -1;
} }
if (write_bytes != written)
{
// the file was not big enough
#ifdef TORRENT_WINDOWS
ec = error_code(ERROR_READ_FAULT, get_system_category());
#else
ec = error_code(EIO, get_posix_category());
#endif
set_error(m_save_path / file_iter->path, ec);
return -1;
}
left_to_write -= write_bytes; left_to_write -= write_bytes;
buf_pos += write_bytes; buf_pos += write_bytes;
TORRENT_ASSERT(buf_pos >= 0); TORRENT_ASSERT(buf_pos >= 0);

View file

@ -1174,7 +1174,7 @@ namespace libtorrent
const std::vector<piece_picker::downloading_piece>& dl_queue const std::vector<piece_picker::downloading_piece>& dl_queue
= m_picker->get_download_queue(); = m_picker->get_download_queue();
const int blocks_per_piece = piece_size / m_block_size; const int blocks_per_piece = (piece_size + m_block_size - 1) / m_block_size;
for (std::vector<piece_picker::downloading_piece>::const_iterator i = for (std::vector<piece_picker::downloading_piece>::const_iterator i =
dl_queue.begin(); i != dl_queue.end(); ++i) dl_queue.begin(); i != dl_queue.end(); ++i)