snowyu / libtorrent

Automatically exported from code.google.com/p/libtorrent
Other
1 stars 0 forks source link

Error 'torrent file is not a dictionary' on the start of download #586

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. make libtorrent::session session
2. session.add_torrent(<torrent> with more than 25 000 files)
3. after 10-15 sec. download will be interrupted with error 'torrent file is 
not a dictionary'

What is the expected output? What do you see instead?
Downloading will be continued successfully.

What version of the product are you using? On what operating system?
libtorrent 0.16.15 on Win7 Ultimate SP1

Please provide any additional information below.
With following patch it bug can be resolved:

+++ http_connection.cpp Thu Feb 27 16:24:21 2014
@@ -49,7 +49,10 @@

 namespace libtorrent {

-enum { max_bottled_buffer = 2 * 1024 * 1024 };
+enum { max_bottled_buffer = 5 * 1024 * 1024 };
+
+#define RECV_BUFFER_INCREMENT 65536
+#define REQUEST_SIZE 4096

 http_connection::http_connection(io_service& ios, connection_queue& cc
    , http_handler const& handler, bool bottled
@@ -149,7 +152,7 @@
    bool ssl = false;
    if (protocol == "https") ssl = true;

-   char request[2048];
+   char request[REQUEST_SIZE];
    char* end = request + sizeof(request);
    char* ptr = request;

@@ -850,7 +853,18 @@
    }

    if (int(m_recvbuffer.size()) == m_read_pos)
-       m_recvbuffer.resize((std::min)(m_read_pos + 2048, int(max_bottled_buffer)));
+   {
+       int new_size = m_read_pos;
+       if (new_size < RECV_BUFFER_INCREMENT)
+       {
+           new_size = RECV_BUFFER_INCREMENT;
+       }
+       else
+       {
+           new_size += RECV_BUFFER_INCREMENT;
+       }
+       m_recvbuffer.resize((std::min)(new_size, int(max_bottled_buffer)));
+   }
    if (m_read_pos == max_bottled_buffer)
    {
        callback(asio::error::eof);

Original issue reported on code.google.com by andrewhu...@gmail.com on 27 Feb 2014 at 2:07

GoogleCodeExporter commented 9 years ago
Is that really a problem of the number of files or a problem with pieces sizes 
greater than 2MB?

Original comment by webmas...@massaroddel.de on 28 Feb 2014 at 4:42

GoogleCodeExporter commented 9 years ago
the change is in http_connection, so it looks like the .torrent file is 
downloaded from an HTTP url. is that right?

session::add_torrent is passed a URL, not a file path, is that correct?

if so, the more files the torrent contains, the larger it will be, and you 
would need to increase the max size for "bottled" http downloads.

Original comment by arvid.no...@gmail.com on 28 Feb 2014 at 5:13

GoogleCodeExporter commented 9 years ago
Seems like a real problem is a size of .torrent file (than it greater than 2 
MB), and I think it depends on amount of number of files.

Original comment by andrewhu...@gmail.com on 28 Feb 2014 at 7:39

GoogleCodeExporter commented 9 years ago
Yes, i'm using url for passing torrent in the session::add_torrent.

"if so, the more files the torrent contains, the larger it will be, and you 
would need to increase the max size for "bottled" http downloads."
You are absolutely correct.

Original comment by andrewhu...@gmail.com on 28 Feb 2014 at 7:42

GoogleCodeExporter commented 9 years ago
fixed in RC_0_16 and trunk.

Original comment by arvid.no...@gmail.com on 3 Mar 2014 at 12:09