3 Copyright (c) 2003, Arvid Norberg
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
10 * Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 * Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in
14 the documentation and/or other materials provided with the distribution.
15 * Neither the name of the author nor the names of its
16 contributors may be used to endorse or promote products derived
17 from this software without specific prior written permission.
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 POSSIBILITY OF SUCH DAMAGE.
33 #ifndef TORRENT_PEER_CONNECTION_HPP_INCLUDED
34 #define TORRENT_PEER_CONNECTION_HPP_INCLUDED
42 #include "libtorrent/debug.hpp"
45 #pragma warning(push, 1)
48 #include <boost/smart_ptr.hpp>
49 #include <boost/weak_ptr.hpp>
50 #include <boost/noncopyable.hpp>
51 #include <boost/array.hpp>
52 #include <boost/optional.hpp>
53 #include <boost/cstdint.hpp>
54 #include <boost/pool/pool.hpp>
60 #include "libtorrent/buffer.hpp"
61 #include "libtorrent/socket.hpp"
62 #include "libtorrent/peer_id.hpp"
63 #include "libtorrent/storage.hpp"
64 #include "libtorrent/stat.hpp"
65 #include "libtorrent/alert.hpp"
66 #include "libtorrent/torrent_handle.hpp"
67 #include "libtorrent/torrent.hpp"
68 #include "libtorrent/peer_request.hpp"
69 #include "libtorrent/piece_block_progress.hpp"
70 #include "libtorrent/config.hpp"
71 #include "libtorrent/session.hpp"
72 #include "libtorrent/bandwidth_limit.hpp"
73 #include "libtorrent/policy.hpp"
74 #include "libtorrent/socket_type.hpp"
75 #include "libtorrent/intrusive_ptr_base.hpp"
76 #include "libtorrent/assert.hpp"
77 #include "libtorrent/chained_buffer.hpp"
78 #include "libtorrent/disk_buffer_holder.hpp"
79 #include "libtorrent/bitfield.hpp"
93 pending_block(piece_block
const& b
): skipped(0), block(b
) {}
95 // the number of times the request
96 // has been skipped by out of order blocks
102 has_block(piece_block
const& b
): block(b
) {}
103 piece_block
const& block
;
104 bool operator()(pending_block
const& pb
) const
105 { return pb
.block
== block
; }
108 class TORRENT_EXPORT peer_connection
109 : public intrusive_ptr_base
<peer_connection
>
110 , public boost::noncopyable
112 friend class invariant_access
;
122 // this is the constructor where the we are the active part.
123 // The peer_conenction should handshake and verify that the
124 // other end has the correct id
126 aux::session_impl
& ses
127 , boost::weak_ptr
<torrent
> t
128 , boost::shared_ptr
<socket_type
> s
129 , tcp::endpoint
const& remote
130 , policy::peer
* peerinfo
);
132 // with this constructor we have been contacted and we still don't
133 // know which torrent the connection belongs to
135 aux::session_impl
& ses
136 , boost::shared_ptr
<socket_type
> s
137 , tcp::endpoint
const& remote
138 , policy::peer
* peerinfo
);
140 // this function is called after it has been constructed and properly
141 // reference counted. It is safe to call self() in this function
142 // and schedule events with references to itself (that is not safe to
143 // do in the constructor).
144 virtual void start();
146 virtual ~peer_connection();
148 void set_peer_info(policy::peer
* pi
)
149 { m_peer_info
= pi
; }
151 policy::peer
* peer_info_struct() const
152 { return m_peer_info
; }
154 enum peer_speed_t
{ slow
, medium
, fast
};
155 peer_speed_t
peer_speed();
157 void send_allowed_set();
159 #ifndef TORRENT_DISABLE_EXTENSIONS
160 void add_extension(boost::shared_ptr
<peer_plugin
>);
163 // this function is called once the torrent associated
164 // with this peer connection has retrieved the meta-
165 // data. If the torrent was spawned with metadata
166 // this is called from the constructor.
169 // this is called when the metadata is retrieved
170 // and the files has been checked
171 virtual void on_metadata() {}
173 void set_upload_limit(int limit
);
174 void set_download_limit(int limit
);
176 int upload_limit() const { return m_upload_limit
; }
177 int download_limit() const { return m_download_limit
; }
179 int prefer_whole_pieces() const
181 if (on_parole()) return 1;
182 return m_prefer_whole_pieces
;
185 bool on_parole() const
186 { return peer_info_struct() && peer_info_struct()->on_parole
; }
188 void prefer_whole_pieces(int num
)
189 { m_prefer_whole_pieces
= num
; }
191 bool request_large_blocks() const
192 { return m_request_large_blocks
; }
194 void request_large_blocks(bool b
)
195 { m_request_large_blocks
= b
; }
197 void set_priority(int p
)
200 void fast_reconnect(bool r
);
201 bool fast_reconnect() const { return m_fast_reconnect
; }
203 // this adds an announcement in the announcement queue
204 // it will let the peer know that we have the given piece
205 void announce_piece(int index
);
207 // tells if this connection has data it want to send
208 // and has enough upload bandwidth quota left to send it.
209 bool can_write() const;
210 bool can_read() const;
212 bool is_seed() const;
214 void set_upload_only(bool u
) { m_upload_only
= u
; }
215 bool upload_only() const { return m_upload_only
; }
217 // will send a keep-alive message to the peer
220 peer_id
const& pid() const { return m_peer_id
; }
221 void set_pid(const peer_id
& pid
) { m_peer_id
= pid
; }
222 bool has_piece(int i
) const;
224 std::deque
<pending_block
> const& download_queue() const;
225 std::deque
<piece_block
> const& request_queue() const;
226 std::deque
<peer_request
> const& upload_queue() const;
228 bool is_interesting() const { return m_interesting
; }
229 bool is_choked() const { return m_choked
; }
231 bool is_peer_interested() const { return m_peer_interested
; }
232 bool has_peer_choked() const { return m_peer_choked
; }
234 void update_interest();
236 virtual void get_peer_info(peer_info
& p
) const;
238 // returns the torrent this connection is a part of
239 // may be zero if the connection is an incoming connection
240 // and it hasn't received enough information to determine
241 // which torrent it should be associated with
242 boost::weak_ptr
<torrent
> associated_torrent() const
243 { return m_torrent
; }
245 const stat
& statistics() const { return m_statistics
; }
246 void add_stat(size_type downloaded
, size_type uploaded
);
248 void calc_ip_overhead();
250 // is called once every second by the main loop
251 void second_tick(float tick_interval
);
253 void timeout_requests();
255 boost::shared_ptr
<socket_type
> get_socket() const { return m_socket
; }
256 tcp::endpoint
const& remote() const { return m_remote
; }
258 bitfield
const& get_bitfield() const;
259 std::vector
<int> const& allowed_fast();
260 std::vector
<int> const& suggested_pieces() const { return m_suggested_pieces
; }
262 ptime
connected_time() const { return m_connect
; }
263 ptime
last_received() const { return m_last_receive
; }
266 // this will cause this peer_connection to be disconnected.
267 void disconnect(char const* message
, int error
= 0);
268 bool is_disconnecting() const { return m_disconnecting
; }
270 // this is called when the connection attempt has succeeded
271 // and the peer_connection is supposed to set m_connecting
272 // to false, and stop monitor writability
273 void on_connection_complete(error_code
const& e
);
275 // returns true if this connection is still waiting to
276 // finish the connection attempt
277 bool is_connecting() const { return m_connecting
; }
279 // returns true if the socket of this peer hasn't been
280 // attempted to connect yet (i.e. it's queued for
281 // connection attempt).
282 bool is_queued() const { return m_queued
; }
284 // called when it's time for this peer_conncetion to actually
285 // initiate the tcp connection. This may be postponed until
286 // the library isn't using up the limitation of half-open
288 void connect(int ticket
);
290 // This is called for every peer right after the upload
291 // bandwidth has been distributed among them
292 // It will reset the used bandwidth to 0.
293 void reset_upload_quota();
296 size_type
total_free_upload() const;
297 void add_free_upload(size_type free_upload
);
300 void received_valid_data(int index
);
301 void received_invalid_data(int index
);
303 size_type
share_diff() const;
305 // a connection is local if it was initiated by us.
306 // if it was an incoming connection, it is remote
307 bool is_local() const { return m_active
; }
309 bool on_local_network() const;
310 bool ignore_bandwidth_limits() const
311 { return m_ignore_bandwidth_limits
; }
313 bool failed() const { return m_failed
; }
315 int desired_queue_size() const { return m_desired_queue_size
; }
317 // compares this connection against the given connection
318 // for which one is more eligible for an unchoke.
319 // returns true if this is more eligible
320 bool unchoke_compare(boost::intrusive_ptr
<peer_connection
const> const& p
) const;
322 // resets the byte counters that are used to measure
323 // the number of bytes transferred within unchoke cycles
324 void reset_choke_counters();
326 // if this peer connection is useless (neither party is
327 // interested in the other), disconnect it
328 void disconnect_if_redundant();
330 #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
331 boost::shared_ptr
<logger
> m_logger
;
334 // the message handlers are called
335 // each time a recv() returns some new
336 // data, the last time it will be called
337 // is when the entire packet has been
338 // received, then it will no longer
339 // be called. i.e. most handlers need
340 // to check how much of the packet they
341 // have received before any processing
342 void incoming_keepalive();
343 void incoming_choke();
344 void incoming_unchoke();
345 void incoming_interested();
346 void incoming_not_interested();
347 void incoming_have(int piece_index
);
348 void incoming_bitfield(bitfield
const& bits
);
349 void incoming_request(peer_request
const& r
);
350 void incoming_piece(peer_request
const& p
, disk_buffer_holder
& data
);
351 void incoming_piece(peer_request
const& p
, char const* data
);
352 void incoming_piece_fragment();
353 void incoming_cancel(peer_request
const& r
);
355 void incoming_dht_port(int listen_port
);
357 void incoming_reject_request(peer_request
const& r
);
358 void incoming_have_all();
359 void incoming_have_none();
360 void incoming_allowed_fast(int index
);
361 void incoming_suggest(int index
);
363 // the following functions appends messages
364 // to the send buffer
367 void send_interested();
368 void send_not_interested();
372 // adds a block to the request queue
373 void add_request(piece_block
const& b
);
374 // removes a block from the request queue or download queue
375 // sends a cancel message if appropriate
376 // refills the request queue, and possibly ignoring pieces requested
377 // by peers in the ignore list (to avoid recursion)
378 void cancel_request(piece_block
const& b
);
379 void send_block_requests();
381 int max_assignable_bandwidth(int channel
) const
382 { return m_bandwidth_limit
[channel
].max_assignable(); }
384 int bandwidth_throttle(int channel
) const
385 { return m_bandwidth_limit
[channel
].throttle(); }
387 void assign_bandwidth(int channel
, int amount
);
388 void expire_bandwidth(int channel
, int amount
);
391 void check_invariant() const;
396 // is true until we can be sure that the other end
397 // speaks our protocol (be it bittorrent or http).
398 virtual bool in_handshake() const = 0;
400 // returns the block currently being
401 // downloaded. And the progress of that
402 // block. If the peer isn't downloading
403 // a piece for the moment, the boost::optional
405 virtual boost::optional
<piece_block_progress
>
406 downloading_piece_progress() const
408 #ifdef TORRENT_VERBOSE_LOGGING
409 (*m_logger
) << "downloading_piece_progress() dispatched to the base class!\n";
411 return boost::optional
<piece_block_progress
>();
414 // these functions are virtual to let bt_peer_connection hook into them
415 // and encrypt the content
416 enum message_type_flags
{ message_type_request
= 1 };
417 virtual void send_buffer(char const* begin
, int size
, int flags
= 0);
418 virtual buffer::interval
allocate_send_buffer(int size
);
419 virtual void setup_send();
421 template <class Destructor
>
422 void append_send_buffer(char* buffer
, int size
, Destructor
const& destructor
)
424 m_send_buffer
.append_buffer(buffer
, size
, size
, destructor
);
426 m_ses
.m_buffer_usage_logger
<< log_time() << " append_send_buffer: " << size
<< std::endl
;
427 m_ses
.log_buffer_usage();
431 #ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
432 void set_country(char const* c
)
434 TORRENT_ASSERT(strlen(c
) == 2);
438 bool has_country() const { return m_country
[0] != 0; }
441 int send_buffer_size() const
442 { return m_send_buffer
.size(); }
444 int send_buffer_capacity() const
445 { return m_send_buffer
.capacity(); }
447 int packet_size() const { return m_packet_size
; }
449 bool packet_finished() const
450 { return m_packet_size
<= m_recv_pos
; }
456 // upload and download channel state
457 // enum from peer_info::bw_state
458 char m_channel_state
[2];
462 virtual void get_specific_peer_info(peer_info
& p
) const = 0;
464 virtual void write_choke() = 0;
465 virtual void write_unchoke() = 0;
466 virtual void write_interested() = 0;
467 virtual void write_not_interested() = 0;
468 virtual void write_request(peer_request
const& r
) = 0;
469 virtual void write_cancel(peer_request
const& r
) = 0;
470 virtual void write_have(int index
) = 0;
471 virtual void write_keepalive() = 0;
472 virtual void write_piece(peer_request
const& r
, disk_buffer_holder
& buffer
) = 0;
474 virtual void write_reject_request(peer_request
const& r
) = 0;
475 virtual void write_allow_fast(int piece
) = 0;
477 virtual void on_connected() = 0;
478 virtual void on_tick() {}
480 virtual void on_receive(error_code
const& error
481 , std::size_t bytes_transferred
) = 0;
482 virtual void on_sent(error_code
const& error
483 , std::size_t bytes_transferred
) = 0;
485 #ifndef TORRENT_DISABLE_ENCRYPTION
486 buffer::interval
wr_recv_buffer()
488 TORRENT_ASSERT(!m_disk_recv_buffer
);
489 TORRENT_ASSERT(m_disk_recv_buffer_size
== 0);
490 if (m_recv_buffer
.empty()) return buffer::interval(0,0);
491 return buffer::interval(&m_recv_buffer
[0]
492 , &m_recv_buffer
[0] + m_recv_pos
);
495 std::pair
<buffer::interval
, buffer::interval
> wr_recv_buffers(int bytes
);
498 buffer::const_interval
receive_buffer() const
500 if (m_recv_buffer
.empty()) return buffer::const_interval(0,0);
501 return buffer::const_interval(&m_recv_buffer
[0]
502 , &m_recv_buffer
[0] + m_recv_pos
);
505 bool allocate_disk_receive_buffer(int disk_buffer_size
);
506 char* release_disk_receive_buffer();
507 bool has_disk_receive_buffer() const { return m_disk_recv_buffer
; }
508 void cut_receive_buffer(int size
, int packet_size
);
509 void reset_recv_buffer(int packet_size
);
511 void setup_receive();
513 void attach_to_torrent(sha1_hash
const& ih
);
515 bool verify_piece(peer_request
const& p
) const;
517 // the bandwidth channels, upload and download
518 // keeps track of the current quotas
519 bandwidth_limit m_bandwidth_limit
[num_channels
];
521 // statistics about upload and download speeds
522 // and total amount of uploads and downloads for
526 // a back reference to the session
527 // the peer belongs to.
528 aux::session_impl
& m_ses
;
530 // called from the main loop when this connection has any
532 void on_send_data(error_code
const& error
533 , std::size_t bytes_transferred
);
534 void on_receive_data(error_code
const& error
535 , std::size_t bytes_transferred
);
537 // this is the limit on the number of outstanding requests
538 // we have to this peer. This is initialized to the settings
539 // in the session_settings structure. But it may be lowered
540 // if the peer is known to require a smaller limit (like BitComet).
541 // or if the extended handshake sets a limit.
542 // web seeds also has a limit on the queue size.
543 int m_max_out_request_queue
;
545 void set_timeout(int s
) { m_timeout
= s
; }
547 #ifndef TORRENT_DISABLE_EXTENSIONS
548 typedef std::list
<boost::shared_ptr
<peer_plugin
> > extension_list_t
;
549 extension_list_t m_extensions
;
552 #ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
553 // in case the session settings is set
554 // to resolve countries, this is set to
555 // the two character country code this
561 boost::intrusive_ptr
<peer_connection
> self()
563 TORRENT_ASSERT(!m_in_constructor
);
564 return intrusive_ptr_base
<peer_connection
>::self();
570 void fill_send_buffer();
571 void on_disk_read_complete(int ret
, disk_io_job
const& j
, peer_request r
);
572 void on_disk_write_complete(int ret
, disk_io_job
const& j
573 , peer_request r
, boost::shared_ptr
<torrent
> t
);
575 // the time when we last got a part of a
576 // piece packet from this peer
578 // the time we sent a request to
579 // this peer the last time
580 ptime m_last_request
;
581 // the time we received the last
582 // piece request from the peer
583 ptime m_last_incoming_request
;
584 // the time when we unchoked this peer
585 ptime m_last_unchoke
;
588 ptime m_last_receive
;
591 // the time when the first entry in the
592 // request queue was requested, increased
593 // for each entry that is popped from the
594 // download queue. Used for request timeout
597 // if the timeout is extended for the outstanding
598 // requests, this is the number of seconds it was
600 int m_timeout_extend
;
602 // a timestamp when the remote download rate
604 ptime m_remote_dl_update
;
606 // the time when async_connect was called
607 // or when the incoming connection was established
610 // the time when this peer sent us a not_interested message
612 ptime m_became_uninterested
;
614 // the time when we sent a not_interested message to
615 // this peer the last time.
616 ptime m_became_uninteresting
;
618 // the amount of data this peer has been given
619 // as free upload. This is distributed from
620 // peers from which we get free download
621 // this will be negative on a peer from which
622 // we get free download, and positive on peers
623 // that we give the free upload, to keep the balance.
624 size_type m_free_upload
;
626 // the total payload download bytes
627 // at the last unchoke cycle. This is used to
628 // measure the number of bytes transferred during
629 // an unchoke cycle, to unchoke peers the more bytes
631 size_type m_downloaded_at_last_unchoke
;
633 #ifndef TORRENT_DISABLE_GEO_IP
634 std::string m_inet_as_name
;
637 buffer m_recv_buffer
;
639 // if this peer is receiving a piece, this
640 // points to a disk buffer that the data is
641 // read into. This eliminates a memcopy from
642 // the receive buffer into the disk buffer
643 disk_buffer_holder m_disk_recv_buffer
;
645 chained_buffer m_send_buffer
;
647 boost::shared_ptr
<socket_type
> m_socket
;
648 // this is the peer we're actually talking to
649 // it may not necessarily be the peer we're
650 // connected to, in case we use a proxy
651 tcp::endpoint m_remote
;
653 // this is the torrent this connection is
654 // associated with. If the connection is an
655 // incoming conncetion, this is set to zero
656 // until the info_hash is received. Then it's
657 // set to the torrent it belongs to.
658 boost::weak_ptr
<torrent
> m_torrent
;
663 // the pieces the other end have
664 bitfield m_have_piece
;
666 // the queue of requests we have got
668 std::deque
<peer_request
> m_requests
;
670 // the blocks we have reserved in the piece
671 // picker and will request from this peer.
672 std::deque
<piece_block
> m_request_queue
;
674 // the queue of blocks we have requested
676 std::deque
<pending_block
> m_download_queue
;
678 // the pieces we will send to the peer
679 // if requested (regardless of choke state)
680 std::set
<int> m_accept_fast
;
682 // the pieces the peer will send us if
683 // requested (regardless of choke state)
684 std::vector
<int> m_allowed_fast
;
686 // pieces that has been suggested to be
687 // downloaded from this peer
688 std::vector
<int> m_suggested_pieces
;
690 // a list of byte offsets inside the send buffer
691 // the piece requests
692 std::vector
<int> m_requests_in_buffer
;
694 // the number of pieces this peer
695 // has. Must be the same as
696 // std::count(m_have_piece.begin(),
697 // m_have_piece.end(), true)
700 // the timeout in seconds
703 // the size (in bytes) of the bittorrent message
704 // we're currently receiving
707 // the number of bytes of the bittorrent payload
708 // we've received so far
711 int m_disk_recv_buffer_size
;
713 // the number of bytes we are currently reading
714 // from disk, that will be added to the send
715 // buffer as soon as they complete
718 // the number of invalid piece-requests
719 // we have got from this peer. If the request
720 // queue gets empty, and there have been
721 // invalid requests, we can assume the
722 // peer is waiting for those pieces.
723 // we can then clear its download queue
724 // by sending choke, unchoke.
725 int m_num_invalid_requests
;
727 // this is the priority with which this peer gets
728 // download bandwidth quota assigned to it.
732 int m_download_limit
;
734 // this peer's peer info struct. This may
735 // be 0, in case the connection is incoming
736 // and hasn't been added to a torrent yet.
737 policy::peer
* m_peer_info
;
739 // this is a measurement of how fast the peer
740 // it allows some variance without changing
741 // back and forth between states
742 peer_speed_t m_speed
;
744 // the ticket id from the connection queue.
745 // This is used to identify the connection
746 // so that it can be removed from the queue
747 // once the connection completes
748 int m_connection_ticket
;
750 // bytes downloaded since last second
751 // timer timeout; used for determining
752 // approx download rate
753 int m_remote_bytes_dled
;
755 // approximate peer download rate
756 int m_remote_dl_rate
;
758 // the number of bytes send to the disk-io
759 // thread that hasn't yet been completely written.
760 int m_outstanding_writing_bytes
;
762 // max transfer rates seen on this peer
763 int m_download_rate_peak
;
764 int m_upload_rate_peak
;
766 // estimated round trip time to this peer
767 // based on the time from when async_connect
768 // was called to when on_connection_complete
769 // was called. The rtt is specified in milliseconds
770 boost::uint16_t m_rtt
;
772 // if set to non-zero, this peer will always prefer
773 // to request entire n pieces, rather than blocks.
774 // where n is the value of this variable.
775 // if it is 0, the download rate limit setting
776 // will be used to determine if whole pieces
778 boost::uint8_t m_prefer_whole_pieces
;
780 // the number of request we should queue up
781 // at the remote end.
782 boost::uint8_t m_desired_queue_size
;
784 // if this is true, the disconnection
785 // timestamp is not updated when the connection
786 // is closed. This means the time until we can
787 // reconnect to this peer is shorter, and likely
789 bool m_fast_reconnect
:1;
791 // is true if it was we that connected to the peer
792 // and false if we got an incoming connection
793 // could be considered: true = local, false = remote
796 // other side says that it's interested in downloading
798 bool m_peer_interested
:1;
800 // the other side has told us that it won't send anymore
801 // data to us for a while
802 bool m_peer_choked
:1;
804 // the peer has pieces we are interested in
805 bool m_interesting
:1;
807 // we have choked the upload to the peer
810 // this is set to true if the connection timed
811 // out or closed the connection. In that
812 // case we will not try to reconnect to
816 // if this is set to true, the peer will not
817 // request bandwidth from the limiter, but instead
818 // just send and receive as much as possible.
819 bool m_ignore_bandwidth_limits
:1;
821 // this is set to true when a have_all
822 // message is received. This information
823 // is used to fill the bitmask in init()
826 // this is true if this connection has been added
827 // to the list of connections that will be closed.
828 bool m_disconnecting
:1;
830 // this is true until this socket has become
831 // writable for the first time (i.e. the
832 // connection completed). While connecting
833 // the timeout will not be triggered. This is
834 // because windows XP SP2 may delay connection
835 // attempts, which means that the connection
836 // may not even have been attempted when the
837 // time out is reached.
840 // This is true until connect is called on the
841 // peer_connection's socket. It is false on incoming
845 // if this is true, the blocks picked by the piece
846 // picker will be merged before passed to the
847 // request function. i.e. subsequent blocks are
848 // merged into larger blocks. This is used by
849 // the http-downloader, to request whole pieces
851 bool m_request_large_blocks
:1;
853 // set to true when this peer is only uploading
854 bool m_upload_only
:1;
856 // set to true when a piece request times out. The
857 // result is that the desired pending queue size
861 // this is set to true once the bitfield is received
862 bool m_bitfield_received
:1;
866 bool m_in_constructor
:1;
867 bool m_disconnect_started
:1;
872 #endif // TORRENT_PEER_CONNECTION_HPP_INCLUDED