~ubuntu-branches/ubuntu/maverick/libtorrent-rasterbar/maverick

« back to all changes in this revision

Viewing changes to src/peer_connection.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Cristian Greco
  • Date: 2009-05-13 12:08:59 UTC
  • mfrom: (3.2.2 sid)
  • Revision ID: james.westby@ubuntu.com-20090513120859-b5qqlwi43aai3pq3
Tags: 0.14.3-1
* New Upstream Version
  - new package libtorrent-rasterbar3 (bump up library soname).
* debian/control:
  - add Vcs-* stuff (switch to git-buildpackage) and bump up
    Standards-Version to 3.8.1 (no changes required);
  - build-depends on debhelper (>= 7.0.50) and use override_dh_command;
  - move -dbg package to the new 'debug' section;
  - build-depends on autotools-dev and overwrite config.{sub,guess} with a
    recent version in debian/rules.
  - build-depends on quilt and python-docutils:
    + debian/patches/fix_html_docs.patch: fix html documentation for offline
      browsing and add another missing doc file;
    + rebuild docs at build time in debian/rules;
* debian/example.makefile: install a simple makefile for example programs
  included in -doc package.
* debian/rules, debian/python-libtorrent.install: don't rely on hardcoded
  python version, use --install-layout=deb when building python bindings,
  and install to '*-packages' instead of 'site-packages' (this should
  prepare for python2.6 and minimize Ubuntu diff).

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
#endif
77
77
                  m_ses(ses)
78
78
                , m_max_out_request_queue(m_ses.settings().max_out_request_queue)
 
79
                , m_work(ses.m_io_service)
79
80
                , m_last_piece(time_now())
80
81
                , m_last_request(time_now())
81
82
                , m_last_incoming_request(min_time())
184
185
#endif
185
186
                  m_ses(ses)
186
187
                , m_max_out_request_queue(m_ses.settings().max_out_request_queue)
 
188
                , m_work(ses.m_io_service)
187
189
                , m_last_piece(time_now())
188
190
                , m_last_request(time_now())
189
191
                , m_last_incoming_request(min_time())
808
810
                                        && p.piece == ti.num_pieces()-1
809
811
                                        && p.start + p.length == ti.piece_size(p.piece))
810
812
                                || (m_request_large_blocks
811
 
                                        && p.length <= ti.piece_length() * m_prefer_whole_pieces == 0 ?
812
 
                                        1 : m_prefer_whole_pieces))
 
813
                                        && p.length <= ti.piece_length() * (m_prefer_whole_pieces == 0 ?
 
814
                                        1 : m_prefer_whole_pieces)))
813
815
                        && p.piece * size_type(ti.piece_length()) + p.start + p.length
814
816
                                <= ti.total_size()
815
817
                        && (p.start % t->block_size() == 0);
1713
1715
                        if (t->alerts().should_post<unwanted_block_alert>())
1714
1716
                        {
1715
1717
                                t->alerts().post_alert(unwanted_block_alert(t->get_handle(), m_remote
1716
 
                                                , m_peer_id, block_finished.block_index, block_finished.piece_index));
 
1718
                                        , m_peer_id, block_finished.block_index, block_finished.piece_index));
1717
1719
                        }
1718
1720
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
1719
1721
                        (*m_logger) << " *** The block we just got was not in the "
1749
1751
                                        m_ses.m_alerts.post_alert(request_dropped_alert(t->get_handle()
1750
1752
                                                , remote(), pid(), qe.block.block_index, qe.block.piece_index));
1751
1753
                                picker.abort_download(qe.block);
1752
 
                                TORRENT_ASSERT(m_download_queue.begin() + i != b);
 
1754
                                TORRENT_ASSERT(m_download_queue[block_index] == pending_b);
1753
1755
                                m_download_queue.erase(m_download_queue.begin() + i);
1754
1756
                                --i;
1755
1757
                                --block_index;
2410
2412
                        for (extension_list_t::iterator i = m_extensions.begin()
2411
2413
                                , end(m_extensions.end()); i != end; ++i)
2412
2414
                        {
2413
 
                                if (handled = (*i)->write_request(r)) break;
 
2415
                                if ((handled = (*i)->write_request(r))) break;
2414
2416
                        }
2415
2417
                        if (is_disconnecting()) return;
2416
2418
                        if (!handled)
 
2419
#endif
2417
2420
                        {
2418
2421
                                write_request(r);
2419
2422
                                m_last_request = time_now();
2420
2423
                        }
2421
 
#else
2422
 
                        write_request(r);
2423
 
                        m_last_request = time_now();
2424
 
#endif
2425
2424
 
2426
2425
#ifdef TORRENT_VERBOSE_LOGGING
2427
2426
                        (*m_logger) << time_now_string()
2752
2751
                return m_disk_recv_buffer.release();
2753
2752
        }
2754
2753
        
 
2754
        // size = the packet size to remove from the receive buffer
 
2755
        // packet_size = the next packet size to receive in the buffer
2755
2756
        void peer_connection::cut_receive_buffer(int size, int packet_size)
2756
2757
        {
2757
2758
                INVARIANT_CHECK;
3243
3244
                {
3244
3245
#ifdef TORRENT_VERBOSE_LOGGING
3245
3246
                        (*m_logger) << time_now_string() << " *** CANNOT WRITE ["
3246
 
                                " quota: " << m_bandwidth_limit[download_channel].quota_left() <<
 
3247
                                " quota: " << m_bandwidth_limit[upload_channel].quota_left() <<
3247
3248
                                " ignore: " << (m_ignore_bandwidth_limits?"yes":"no") <<
3248
3249
                                " buf: " << m_send_buffer.size() <<
3249
3250
                                " connecting: " << (m_connecting?"yes":"no") <<
3667
3668
                        return;
3668
3669
                }
3669
3670
 
3670
 
                m_socket->open(t->get_interface().protocol(), ec);
 
3671
                m_socket->open(m_remote.protocol(), ec);
3671
3672
                if (ec)
3672
3673
                {
3673
3674
                        disconnect(ec.message().c_str());
3698
3699
                        bind_interface.port(m_ses.next_port());
3699
3700
                }
3700
3701
 
 
3702
                // if we're not binding to a specific interface, bind
 
3703
                // to the same protocol family as the target endpoint
 
3704
                if (is_any(bind_interface.address()))
 
3705
                {
 
3706
                        if (m_remote.address().is_v4())
 
3707
                                bind_interface.address(address_v4::any());
 
3708
                        else
 
3709
                                bind_interface.address(address_v6::any());
 
3710
                }
 
3711
 
3701
3712
                m_socket->bind(bind_interface, ec);
3702
3713
                if (ec)
3703
3714
                {