summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Resch <andrewresch@gmail.com>2009-01-17 22:03:36 +0000
committerAndrew Resch <andrewresch@gmail.com>2009-01-17 22:03:36 +0000
commit5672db086a24fd5e45e74f923882e91eafb4fef2 (patch)
tree33400c0ec90a758eb1da304d12f62a8601c666fb
parentadbe77647acb79d73e2536abe803308fab67e9b7 (diff)
downloaddeluge-5672db086a24fd5e45e74f923882e91eafb4fef2.tar.gz
deluge-5672db086a24fd5e45e74f923882e91eafb4fef2.tar.bz2
deluge-5672db086a24fd5e45e74f923882e91eafb4fef2.zip
lt sync 3187
-rw-r--r--libtorrent/include/libtorrent/version.hpp1
-rw-r--r--libtorrent/src/assert.cpp5
-rwxr-xr-xlibtorrent/src/identify_client.cpp7
-rwxr-xr-xlibtorrent/src/storage.cpp29
-rwxr-xr-xlibtorrent/src/torrent.cpp2
5 files changed, 38 insertions, 6 deletions
diff --git a/libtorrent/include/libtorrent/version.hpp b/libtorrent/include/libtorrent/version.hpp
index ac6cadf3a..ee376cc21 100644
--- a/libtorrent/include/libtorrent/version.hpp
+++ b/libtorrent/include/libtorrent/version.hpp
@@ -37,5 +37,6 @@ POSSIBILITY OF SUCH DAMAGE.
#define LIBTORRENT_VERSION_MINOR 14
#define LIBTORRENT_VERSION "0.14.2.0"
+#define LIBTORRENT_REVISION "$Rev: 3169 $"
#endif
diff --git a/libtorrent/src/assert.cpp b/libtorrent/src/assert.cpp
index 26307a95b..b98201d95 100644
--- a/libtorrent/src/assert.cpp
+++ b/libtorrent/src/assert.cpp
@@ -86,6 +86,7 @@ std::string demangle(char const* name)
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
+#include "libtorrent/version.hpp"
// execinfo.h is available in the MacOS X 10.5 SDK.
#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 "
"http://code.rasterbar.com/libtorrent/newticket\n"
"Please include the following information:\n\n"
+ "version: " LIBTORRENT_VERSION "\n"
+ "%s\n"
"file: '%s'\n"
"line: %d\n"
"function: %s\n"
- "expression: %s\n", file, line, function, expr);
+ "expression: %s\n", LIBTORRENT_REVISION, file, line, function, expr);
print_backtrace("stack:");
diff --git a/libtorrent/src/identify_client.cpp b/libtorrent/src/identify_client.cpp
index 9eb0fd3c9..1b0b3be67 100755
--- a/libtorrent/src/identify_client.cpp
+++ b/libtorrent/src/identify_client.cpp
@@ -53,9 +53,14 @@ namespace
using namespace libtorrent;
+ bool is_digit(char c)
+ {
+ return c >= '0' && c <= '9';
+ }
+
int decode_digit(char c)
{
- if (std::isdigit(c)) return c - '0';
+ if (is_digit(c)) return c - '0';
return unsigned(c) - 'A' + 10;
}
diff --git a/libtorrent/src/storage.cpp b/libtorrent/src/storage.cpp
index 82402629f..905ee1da7 100755
--- a/libtorrent/src/storage.cpp
+++ b/libtorrent/src/storage.cpp
@@ -970,15 +970,26 @@ namespace libtorrent
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
- if (actual_read > 0) buf_pos += actual_read;
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);
return -1;
}
+ if (actual_read > 0) buf_pos += actual_read;
std::memset(buf + buf_pos, 0, size - buf_pos);
return size;
}
@@ -1111,12 +1122,24 @@ namespace libtorrent
error_code 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);
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;
buf_pos += write_bytes;
TORRENT_ASSERT(buf_pos >= 0);
diff --git a/libtorrent/src/torrent.cpp b/libtorrent/src/torrent.cpp
index efb97a77d..0f6ee3f18 100755
--- a/libtorrent/src/torrent.cpp
+++ b/libtorrent/src/torrent.cpp
@@ -1174,7 +1174,7 @@ namespace libtorrent
const std::vector<piece_picker::downloading_piece>& dl_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 =
dl_queue.begin(); i != dl_queue.end(); ++i)