streamlined class footprint by reducing padding
This commit is contained in:
parent
c5d61667b3
commit
c460704a5f
|
@ -552,9 +552,6 @@ namespace libtorrent
|
|||
void on_disk_write_complete(int ret, disk_io_job const& j
|
||||
, peer_request r, boost::shared_ptr<torrent> t);
|
||||
|
||||
// the timeout in seconds
|
||||
int m_timeout;
|
||||
|
||||
// the time when we last got a part of a
|
||||
// piece packet from this peer
|
||||
ptime m_last_piece;
|
||||
|
@ -567,28 +564,54 @@ namespace libtorrent
|
|||
// the time when we unchoked this peer
|
||||
ptime m_last_unchoke;
|
||||
|
||||
int m_packet_size;
|
||||
int m_recv_pos;
|
||||
// timeouts
|
||||
ptime m_last_receive;
|
||||
ptime m_last_sent;
|
||||
|
||||
// a timestamp when the remote download rate
|
||||
// was last updated
|
||||
ptime m_remote_dl_update;
|
||||
|
||||
// the time when async_connect was called
|
||||
ptime m_connect;
|
||||
|
||||
// the time when this peer sent us a not_interested message
|
||||
// the last time.
|
||||
ptime m_became_uninterested;
|
||||
|
||||
// the time when we sent a not_interested message to
|
||||
// this peer the last time.
|
||||
ptime m_became_uninteresting;
|
||||
|
||||
// the amount of data this peer has been given
|
||||
// as free upload. This is distributed from
|
||||
// peers from which we get free download
|
||||
// this will be negative on a peer from which
|
||||
// we get free download, and positive on peers
|
||||
// that we give the free upload, to keep the balance.
|
||||
size_type m_free_upload;
|
||||
|
||||
// the total payload download bytes
|
||||
// at the last unchoke cycle. This is used to
|
||||
// measure the number of bytes transferred during
|
||||
// an unchoke cycle, to unchoke peers the more bytes
|
||||
// they sent us
|
||||
size_type m_downloaded_at_last_unchoke;
|
||||
|
||||
#ifndef TORRENT_DISABLE_GEO_IP
|
||||
std::string m_inet_as_name;
|
||||
#endif
|
||||
|
||||
buffer m_recv_buffer;
|
||||
|
||||
// if this peer is receiving a piece, this
|
||||
// points to a disk buffer that the data is
|
||||
// read into. This eliminates a memcopy from
|
||||
// the receive buffer into the disk buffer
|
||||
int m_disk_recv_buffer_size;
|
||||
disk_buffer_holder m_disk_recv_buffer;
|
||||
|
||||
chained_buffer m_send_buffer;
|
||||
|
||||
// the number of bytes we are currently reading
|
||||
// from disk, that will be added to the send
|
||||
// buffer as soon as they complete
|
||||
int m_reading_bytes;
|
||||
|
||||
// timeouts
|
||||
ptime m_last_receive;
|
||||
ptime m_last_sent;
|
||||
|
||||
boost::shared_ptr<socket_type> m_socket;
|
||||
// this is the peer we're actually talking to
|
||||
// it may not necessarily be the peer we're
|
||||
|
@ -601,54 +624,12 @@ namespace libtorrent
|
|||
// until the info_hash is received. Then it's
|
||||
// set to the torrent it belongs to.
|
||||
boost::weak_ptr<torrent> m_torrent;
|
||||
// is true if it was we that connected to the peer
|
||||
// and false if we got an incoming connection
|
||||
// could be considered: true = local, false = remote
|
||||
bool m_active;
|
||||
|
||||
// remote peer's id
|
||||
peer_id m_peer_id;
|
||||
|
||||
// other side says that it's interested in downloading
|
||||
// from us.
|
||||
bool m_peer_interested;
|
||||
|
||||
// the other side has told us that it won't send anymore
|
||||
// data to us for a while
|
||||
bool m_peer_choked;
|
||||
|
||||
// the peer has pieces we are interested in
|
||||
bool m_interesting;
|
||||
|
||||
// we have choked the upload to the peer
|
||||
bool m_choked;
|
||||
|
||||
// this is set to true if the connection timed
|
||||
// out or closed the connection. In that
|
||||
// case we will not try to reconnect to
|
||||
// this peer
|
||||
bool m_failed;
|
||||
|
||||
// if this is set to true, the peer will not
|
||||
// request bandwidth from the limiter, but instead
|
||||
// just send and receive as much as possible.
|
||||
bool m_ignore_bandwidth_limits;
|
||||
|
||||
// the pieces the other end have
|
||||
std::vector<bool> m_have_piece;
|
||||
// this is set to true when a have_all
|
||||
// message is received. This information
|
||||
// is used to fill the bitmask in init()
|
||||
bool m_have_all;
|
||||
|
||||
// set to true when this peer is only uploading
|
||||
bool m_upload_only;
|
||||
|
||||
// the number of pieces this peer
|
||||
// has. Must be the same as
|
||||
// std::count(m_have_piece.begin(),
|
||||
// m_have_piece.end(), true)
|
||||
int m_num_pieces;
|
||||
|
||||
// the queue of requests we have got
|
||||
// from this peer
|
||||
|
@ -662,25 +643,42 @@ namespace libtorrent
|
|||
// from this peer
|
||||
std::deque<piece_block> m_download_queue;
|
||||
|
||||
// the number of request we should queue up
|
||||
// at the remote end.
|
||||
int m_desired_queue_size;
|
||||
// the pieces we will send to the peer
|
||||
// if requested (regardless of choke state)
|
||||
std::set<int> m_accept_fast;
|
||||
|
||||
// the amount of data this peer has been given
|
||||
// as free upload. This is distributed from
|
||||
// peers from which we get free download
|
||||
// this will be negative on a peer from which
|
||||
// we get free download, and positive on peers
|
||||
// that we give the free upload, to keep the balance.
|
||||
size_type m_free_upload;
|
||||
// the pieces the peer will send us if
|
||||
// requested (regardless of choke state)
|
||||
std::vector<int> m_allowed_fast;
|
||||
|
||||
// if this is true, this peer is assumed to handle all piece
|
||||
// requests in fifo order. All skipped blocks are re-requested
|
||||
// immediately instead of having a looser requirement
|
||||
// where blocks can be sent out of order. The default is to
|
||||
// allow non-fifo order.
|
||||
bool m_assume_fifo;
|
||||
// pieces that has been suggested to be
|
||||
// downloaded from this peer
|
||||
std::vector<int> m_suggested_pieces;
|
||||
|
||||
// the number of pieces this peer
|
||||
// has. Must be the same as
|
||||
// std::count(m_have_piece.begin(),
|
||||
// m_have_piece.end(), true)
|
||||
int m_num_pieces;
|
||||
|
||||
// the timeout in seconds
|
||||
int m_timeout;
|
||||
|
||||
// the size (in bytes) of the bittorrent message
|
||||
// we're currently receiving
|
||||
int m_packet_size;
|
||||
|
||||
// the number of bytes of the bittorrent payload
|
||||
// we've received so far
|
||||
int m_recv_pos;
|
||||
|
||||
int m_disk_recv_buffer_size;
|
||||
|
||||
// the number of bytes we are currently reading
|
||||
// from disk, that will be added to the send
|
||||
// buffer as soon as they complete
|
||||
int m_reading_bytes;
|
||||
|
||||
// the number of invalid piece-requests
|
||||
// we have got from this peer. If the request
|
||||
// queue gets empty, and there have been
|
||||
|
@ -690,49 +688,6 @@ namespace libtorrent
|
|||
// by sending choke, unchoke.
|
||||
int m_num_invalid_requests;
|
||||
|
||||
// this is true if this connection has been added
|
||||
// to the list of connections that will be closed.
|
||||
bool m_disconnecting;
|
||||
|
||||
// the time when this peer sent us a not_interested message
|
||||
// the last time.
|
||||
ptime m_became_uninterested;
|
||||
|
||||
// the time when we sent a not_interested message to
|
||||
// this peer the last time.
|
||||
ptime m_became_uninteresting;
|
||||
|
||||
// this is true until this socket has become
|
||||
// writable for the first time (i.e. the
|
||||
// connection completed). While connecting
|
||||
// the timeout will not be triggered. This is
|
||||
// because windows XP SP2 may delay connection
|
||||
// attempts, which means that the connection
|
||||
// may not even have been attempted when the
|
||||
// time out is reached.
|
||||
bool m_connecting;
|
||||
|
||||
// This is true until connect is called on the
|
||||
// peer_connection's socket. It is false on incoming
|
||||
// connections.
|
||||
bool m_queued;
|
||||
|
||||
// if set to non-zero, this peer will always prefer
|
||||
// to request entire n pieces, rather than blocks.
|
||||
// where n is the value of this variable.
|
||||
// if it is 0, the download rate limit setting
|
||||
// will be used to determine if whole pieces
|
||||
// are preferred.
|
||||
int m_prefer_whole_pieces;
|
||||
|
||||
// if this is true, the blocks picked by the piece
|
||||
// picker will be merged before passed to the
|
||||
// request function. i.e. subsequent blocks are
|
||||
// merged into larger blocks. This is used by
|
||||
// the http-downloader, to request whole pieces
|
||||
// at a time.
|
||||
bool m_request_large_blocks;
|
||||
|
||||
// this is the priority with which this peer gets
|
||||
// download bandwidth quota assigned to it.
|
||||
int m_priority;
|
||||
|
@ -764,60 +719,114 @@ namespace libtorrent
|
|||
// approximate peer download rate
|
||||
int m_remote_dl_rate;
|
||||
|
||||
// a timestamp when the remote download rate
|
||||
// was last updated
|
||||
ptime m_remote_dl_update;
|
||||
|
||||
// the pieces we will send to the peer
|
||||
// if requested (regardless of choke state)
|
||||
std::set<int> m_accept_fast;
|
||||
|
||||
// the pieces the peer will send us if
|
||||
// requested (regardless of choke state)
|
||||
std::vector<int> m_allowed_fast;
|
||||
|
||||
// pieces that has been suggested to be
|
||||
// downloaded from this peer
|
||||
std::vector<int> m_suggested_pieces;
|
||||
|
||||
// the number of bytes send to the disk-io
|
||||
// thread that hasn't yet been completely written.
|
||||
int m_outstanding_writing_bytes;
|
||||
|
||||
// max transfer rates seen on this peer
|
||||
int m_download_rate_peak;
|
||||
int m_upload_rate_peak;
|
||||
|
||||
// estimated round trip time to this peer
|
||||
// based on the time from when async_connect
|
||||
// was called to when on_connection_complete
|
||||
// was called. The rtt is specified in milliseconds
|
||||
boost::uint16_t m_rtt;
|
||||
|
||||
// if set to non-zero, this peer will always prefer
|
||||
// to request entire n pieces, rather than blocks.
|
||||
// where n is the value of this variable.
|
||||
// if it is 0, the download rate limit setting
|
||||
// will be used to determine if whole pieces
|
||||
// are preferred.
|
||||
boost::uint8_t m_prefer_whole_pieces;
|
||||
|
||||
// the number of request we should queue up
|
||||
// at the remote end.
|
||||
boost::uint8_t m_desired_queue_size;
|
||||
|
||||
// if this is true, the disconnection
|
||||
// timestamp is not updated when the connection
|
||||
// is closed. This means the time until we can
|
||||
// reconnect to this peer is shorter, and likely
|
||||
// immediate.
|
||||
bool m_fast_reconnect;
|
||||
bool m_fast_reconnect:1;
|
||||
|
||||
// the time when async_connect was called
|
||||
ptime m_connect;
|
||||
// is true if it was we that connected to the peer
|
||||
// and false if we got an incoming connection
|
||||
// could be considered: true = local, false = remote
|
||||
bool m_active:1;
|
||||
|
||||
// estimated round trip time to this peer
|
||||
// based on the time from when async_connect
|
||||
// was called to when on_connection_complete
|
||||
// was called. The rtt is specified in milliseconds
|
||||
int m_rtt;
|
||||
// other side says that it's interested in downloading
|
||||
// from us.
|
||||
bool m_peer_interested:1;
|
||||
|
||||
// the total payload download bytes
|
||||
// at the last unchoke cycle. This is used to
|
||||
// measure the number of bytes transferred during
|
||||
// an unchoke cycle, to unchoke peers the more bytes
|
||||
// they sent us
|
||||
size_type m_downloaded_at_last_unchoke;
|
||||
// the other side has told us that it won't send anymore
|
||||
// data to us for a while
|
||||
bool m_peer_choked:1;
|
||||
|
||||
#ifndef TORRENT_DISABLE_GEO_IP
|
||||
std::string m_inet_as_name;
|
||||
#endif
|
||||
// the peer has pieces we are interested in
|
||||
bool m_interesting:1;
|
||||
|
||||
// max transfer rates seen on this peer
|
||||
int m_download_rate_peak;
|
||||
int m_upload_rate_peak;
|
||||
// we have choked the upload to the peer
|
||||
bool m_choked:1;
|
||||
|
||||
// this is set to true if the connection timed
|
||||
// out or closed the connection. In that
|
||||
// case we will not try to reconnect to
|
||||
// this peer
|
||||
bool m_failed:1;
|
||||
|
||||
// if this is set to true, the peer will not
|
||||
// request bandwidth from the limiter, but instead
|
||||
// just send and receive as much as possible.
|
||||
bool m_ignore_bandwidth_limits:1;
|
||||
|
||||
// this is set to true when a have_all
|
||||
// message is received. This information
|
||||
// is used to fill the bitmask in init()
|
||||
bool m_have_all:1;
|
||||
|
||||
// if this is true, this peer is assumed to handle all piece
|
||||
// requests in fifo order. All skipped blocks are re-requested
|
||||
// immediately instead of having a looser requirement
|
||||
// where blocks can be sent out of order. The default is to
|
||||
// allow non-fifo order.
|
||||
bool m_assume_fifo:1;
|
||||
|
||||
// this is true if this connection has been added
|
||||
// to the list of connections that will be closed.
|
||||
bool m_disconnecting:1;
|
||||
|
||||
// this is true until this socket has become
|
||||
// writable for the first time (i.e. the
|
||||
// connection completed). While connecting
|
||||
// the timeout will not be triggered. This is
|
||||
// because windows XP SP2 may delay connection
|
||||
// attempts, which means that the connection
|
||||
// may not even have been attempted when the
|
||||
// time out is reached.
|
||||
bool m_connecting:1;
|
||||
|
||||
// This is true until connect is called on the
|
||||
// peer_connection's socket. It is false on incoming
|
||||
// connections.
|
||||
bool m_queued:1;
|
||||
|
||||
// if this is true, the blocks picked by the piece
|
||||
// picker will be merged before passed to the
|
||||
// request function. i.e. subsequent blocks are
|
||||
// merged into larger blocks. This is used by
|
||||
// the http-downloader, to request whole pieces
|
||||
// at a time.
|
||||
bool m_request_large_blocks:1;
|
||||
|
||||
// set to true when this peer is only uploading
|
||||
bool m_upload_only:1;
|
||||
|
||||
#ifndef NDEBUG
|
||||
public:
|
||||
bool m_in_constructor;
|
||||
bool m_in_constructor:1;
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
|
|
@ -593,34 +593,33 @@ namespace libtorrent
|
|||
|
||||
void update_peer_interest(bool was_finished);
|
||||
|
||||
policy m_policy;
|
||||
|
||||
// total time we've been available on this torrent
|
||||
// does not count when the torrent is stopped or paused
|
||||
time_duration m_active_time;
|
||||
|
||||
// total time we've been available as a seed on this torrent
|
||||
// does not count when the torrent is stopped or paused
|
||||
time_duration m_seeding_time;
|
||||
|
||||
// all time totals of uploaded and downloaded payload
|
||||
// stored in resume data
|
||||
size_type m_total_uploaded;
|
||||
size_type m_total_downloaded;
|
||||
|
||||
// if this torrent is running, this was the time
|
||||
// when it was started. This is used to have a
|
||||
// bias towards keeping seeding torrents that
|
||||
// recently was started, to avoid oscillation
|
||||
ptime m_started;
|
||||
|
||||
boost::intrusive_ptr<torrent_info> m_torrent_file;
|
||||
|
||||
// is set to true when the torrent has
|
||||
// been aborted.
|
||||
bool m_abort;
|
||||
|
||||
// is true if this torrent has been paused
|
||||
bool m_paused;
|
||||
// this is true from the time when the torrent was
|
||||
// paused to the time should_request() is called
|
||||
bool m_just_paused;
|
||||
|
||||
// if this is true, libtorrent may pause and resume
|
||||
// this torrent depending on queuing rules. Torrents
|
||||
// started with auto_managed flag set may be added in
|
||||
// a paused state in case there are no available
|
||||
// slots.
|
||||
bool m_auto_managed;
|
||||
|
||||
tracker_request::event_t m_event;
|
||||
|
||||
void parse_response(const entry& e, std::vector<peer_entry>& peer_list);
|
||||
|
||||
// the size of a request block
|
||||
// each piece is divided into these
|
||||
// blocks when requested
|
||||
int m_block_size;
|
||||
|
||||
// if this pointer is 0, the torrent is in
|
||||
// a state where the metadata hasn't been
|
||||
// received yet.
|
||||
|
@ -649,18 +648,6 @@ namespace libtorrent
|
|||
// the time of next tracker request
|
||||
ptime m_next_request;
|
||||
|
||||
// -----------------------------
|
||||
// DATA FROM TRACKER RESPONSE
|
||||
|
||||
// the number number of seconds between requests
|
||||
// from the tracker
|
||||
int m_duration;
|
||||
|
||||
// the scrape data from the tracker response, this
|
||||
// is optional and may be -1.
|
||||
int m_complete;
|
||||
int m_incomplete;
|
||||
|
||||
#ifndef NDEBUG
|
||||
public:
|
||||
#endif
|
||||
|
@ -681,21 +668,14 @@ namespace libtorrent
|
|||
// resolving the address for
|
||||
std::set<std::string> m_resolving_web_seeds;
|
||||
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
typedef std::list<boost::shared_ptr<torrent_plugin> > extension_list_t;
|
||||
extension_list_t m_extensions;
|
||||
#endif
|
||||
|
||||
// used to resolve the names of web seeds
|
||||
mutable tcp::resolver m_host_resolver;
|
||||
|
||||
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||
// this is true while there is a country
|
||||
// resolution in progress. To avoid flodding
|
||||
// the DNS request queue, only one ip is resolved
|
||||
// at a time.
|
||||
mutable bool m_resolving_country;
|
||||
|
||||
// this is true if the user has enabled
|
||||
// country resolution in this torrent
|
||||
bool m_resolve_countries;
|
||||
#endif
|
||||
|
||||
// this announce timer is used both
|
||||
// by Local service discovery and
|
||||
// by the DHT.
|
||||
|
@ -737,41 +717,9 @@ namespace libtorrent
|
|||
std::vector<announce_entry> m_trackers;
|
||||
// this is an index into m_trackers
|
||||
|
||||
int m_last_working_tracker;
|
||||
int m_currently_trying_tracker;
|
||||
// the number of connection attempts that has
|
||||
// failed in a row, this is currently used to
|
||||
// determine the timeout until next try.
|
||||
int m_failed_trackers;
|
||||
|
||||
// this is a counter that is decreased every
|
||||
// second, and when it reaches 0, the policy::pulse()
|
||||
// is called and the time scaler is reset to 10.
|
||||
int m_time_scaler;
|
||||
|
||||
// the bitmask that says which pieces we have
|
||||
std::vector<bool> m_have_pieces;
|
||||
|
||||
// the number of pieces we have. The same as
|
||||
// std::accumulate(m_have_pieces.begin(),
|
||||
// m_have_pieces.end(), 0)
|
||||
int m_num_pieces;
|
||||
|
||||
// in case the piece picker hasn't been constructed
|
||||
// when this settings is set, this variable will keep
|
||||
// its value until the piece picker is created
|
||||
bool m_sequential_download;
|
||||
|
||||
// is false by default and set to
|
||||
// true when the first tracker reponse
|
||||
// is received
|
||||
bool m_got_tracker_response;
|
||||
|
||||
// the upload/download ratio that each peer
|
||||
// tries to maintain.
|
||||
// 0 is infinite
|
||||
float m_ratio;
|
||||
|
||||
// the number of bytes that has been
|
||||
// downloaded that failed the hash-test
|
||||
size_type m_total_failed_bytes;
|
||||
|
@ -791,25 +739,9 @@ namespace libtorrent
|
|||
|
||||
// the state of this torrent (queued, checking, downloading)
|
||||
torrent_status::state_t m_state;
|
||||
float m_progress;
|
||||
|
||||
entry m_resume_data;
|
||||
|
||||
// defaults to 16 kiB, but can be set by the user
|
||||
// when creating the torrent
|
||||
const int m_default_block_size;
|
||||
|
||||
// this is set to false as long as the connections
|
||||
// of this torrent hasn't been initialized. If we
|
||||
// have metadata from the start, connections are
|
||||
// initialized immediately, if we didn't have metadata,
|
||||
// they are initialized right after files_checked().
|
||||
// valid_resume_data() will return false as long as
|
||||
// the connections aren't initialized, to avoid
|
||||
// them from altering the piece-picker before it
|
||||
// has been initialized with files_checked().
|
||||
bool m_connections_initialized;
|
||||
|
||||
// if the torrent is started without metadata, it may
|
||||
// still be given a name until the metadata is received
|
||||
// once the metadata is received this field will no
|
||||
|
@ -820,6 +752,18 @@ namespace libtorrent
|
|||
|
||||
storage_constructor_type m_storage_constructor;
|
||||
|
||||
float m_progress;
|
||||
|
||||
// the number of pieces we have. The same as
|
||||
// std::accumulate(m_have_pieces.begin(),
|
||||
// m_have_pieces.end(), 0)
|
||||
int m_num_pieces;
|
||||
|
||||
// the upload/download ratio that each peer
|
||||
// tries to maintain.
|
||||
// 0 is infinite
|
||||
float m_ratio;
|
||||
|
||||
// the maximum number of uploads for this torrent
|
||||
int m_max_uploads;
|
||||
|
||||
|
@ -829,14 +773,18 @@ namespace libtorrent
|
|||
// the maximum number of connections for this torrent
|
||||
int m_max_connections;
|
||||
|
||||
#ifndef NDEBUG
|
||||
bool m_files_checked;
|
||||
#endif
|
||||
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
typedef std::list<boost::shared_ptr<torrent_plugin> > extension_list_t;
|
||||
extension_list_t m_extensions;
|
||||
#endif
|
||||
// the size of a request block
|
||||
// each piece is divided into these
|
||||
// blocks when requested
|
||||
int m_block_size;
|
||||
|
||||
// -----------------------------
|
||||
// DATA FROM TRACKER RESPONSE
|
||||
|
||||
// the scrape data from the tracker response, this
|
||||
// is optional and may be -1.
|
||||
int m_complete;
|
||||
int m_incomplete;
|
||||
|
||||
#ifndef NDEBUG
|
||||
// this is the amount downloaded when this torrent
|
||||
|
@ -858,30 +806,84 @@ namespace libtorrent
|
|||
// torrent object, these points are called connect_points.
|
||||
int m_deficit_counter;
|
||||
|
||||
policy m_policy;
|
||||
// the number number of seconds between requests
|
||||
// from the tracker
|
||||
boost::int16_t m_duration;
|
||||
|
||||
// the sequence number for this torrent, this is a
|
||||
// monotonically increasing number for each added torrent
|
||||
int m_sequence_number;
|
||||
boost::int16_t m_sequence_number;
|
||||
|
||||
// total time we've been available on this torrent
|
||||
// does not count when the torrent is stopped or paused
|
||||
time_duration m_active_time;
|
||||
// the index to the last tracker that worked
|
||||
boost::int8_t m_last_working_tracker;
|
||||
|
||||
// total time we've been available as a seed on this torrent
|
||||
// does not count when the torrent is stopped or paused
|
||||
time_duration m_seeding_time;
|
||||
// the tracker that is currently (or was last)
|
||||
// tried
|
||||
boost::int8_t m_currently_trying_tracker;
|
||||
|
||||
// all time totals of uploaded and downloaded payload
|
||||
// stored in resume data
|
||||
size_type m_total_uploaded;
|
||||
size_type m_total_downloaded;
|
||||
// the number of connection attempts that has
|
||||
// failed in a row, this is currently used to
|
||||
// determine the timeout until next try.
|
||||
boost::int8_t m_failed_trackers;
|
||||
|
||||
// if this torrent is running, this was the time
|
||||
// when it was started. This is used to have a
|
||||
// bias towards keeping seeding torrents that
|
||||
// recently was started, to avoid oscillation
|
||||
ptime m_started;
|
||||
// this is a counter that is decreased every
|
||||
// second, and when it reaches 0, the policy::pulse()
|
||||
// is called and the time scaler is reset to 10.
|
||||
boost::int8_t m_time_scaler;
|
||||
|
||||
// is set to true when the torrent has
|
||||
// been aborted.
|
||||
bool m_abort:1;
|
||||
|
||||
// is true if this torrent has been paused
|
||||
bool m_paused:1;
|
||||
// this is true from the time when the torrent was
|
||||
// paused to the time should_request() is called
|
||||
bool m_just_paused:1;
|
||||
|
||||
// if this is true, libtorrent may pause and resume
|
||||
// this torrent depending on queuing rules. Torrents
|
||||
// started with auto_managed flag set may be added in
|
||||
// a paused state in case there are no available
|
||||
// slots.
|
||||
bool m_auto_managed:1;
|
||||
|
||||
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||
// this is true while there is a country
|
||||
// resolution in progress. To avoid flodding
|
||||
// the DNS request queue, only one ip is resolved
|
||||
// at a time.
|
||||
mutable bool m_resolving_country:1;
|
||||
|
||||
// this is true if the user has enabled
|
||||
// country resolution in this torrent
|
||||
bool m_resolve_countries:1;
|
||||
#endif
|
||||
|
||||
// in case the piece picker hasn't been constructed
|
||||
// when this settings is set, this variable will keep
|
||||
// its value until the piece picker is created
|
||||
bool m_sequential_download:1;
|
||||
|
||||
// is false by default and set to
|
||||
// true when the first tracker reponse
|
||||
// is received
|
||||
bool m_got_tracker_response:1;
|
||||
|
||||
// this is set to false as long as the connections
|
||||
// of this torrent hasn't been initialized. If we
|
||||
// have metadata from the start, connections are
|
||||
// initialized immediately, if we didn't have metadata,
|
||||
// they are initialized right after files_checked().
|
||||
// valid_resume_data() will return false as long as
|
||||
// the connections aren't initialized, to avoid
|
||||
// them from altering the piece-picker before it
|
||||
// has been initialized with files_checked().
|
||||
bool m_connections_initialized:1;
|
||||
|
||||
#ifndef NDEBUG
|
||||
bool m_files_checked:1;
|
||||
#endif
|
||||
};
|
||||
|
||||
inline ptime torrent::next_announce() const
|
||||
|
|
|
@ -73,42 +73,28 @@ namespace libtorrent
|
|||
#endif
|
||||
m_ses(ses)
|
||||
, m_max_out_request_queue(m_ses.settings().max_out_request_queue)
|
||||
, m_timeout(m_ses.settings().peer_timeout)
|
||||
, m_last_piece(time_now())
|
||||
, m_last_request(time_now())
|
||||
, m_last_incoming_request(min_time())
|
||||
, m_last_unchoke(min_time())
|
||||
, m_packet_size(0)
|
||||
, m_recv_pos(0)
|
||||
, m_disk_recv_buffer_size(0)
|
||||
, m_disk_recv_buffer(ses, 0)
|
||||
, m_reading_bytes(0)
|
||||
, m_last_receive(time_now())
|
||||
, m_last_sent(time_now())
|
||||
, m_remote_dl_update(time_now())
|
||||
, m_became_uninterested(time_now())
|
||||
, m_became_uninteresting(time_now())
|
||||
, m_free_upload(0)
|
||||
, m_downloaded_at_last_unchoke(0)
|
||||
, m_disk_recv_buffer(ses, 0)
|
||||
, m_socket(s)
|
||||
, m_remote(endp)
|
||||
, m_torrent(tor)
|
||||
, m_active(true)
|
||||
, m_peer_interested(false)
|
||||
, m_peer_choked(true)
|
||||
, m_interesting(false)
|
||||
, m_choked(true)
|
||||
, m_failed(false)
|
||||
, m_ignore_bandwidth_limits(false)
|
||||
, m_have_all(false)
|
||||
, m_upload_only(false)
|
||||
, m_num_pieces(0)
|
||||
, m_desired_queue_size(2)
|
||||
, m_free_upload(0)
|
||||
, m_assume_fifo(false)
|
||||
, m_timeout(m_ses.settings().peer_timeout)
|
||||
, m_packet_size(0)
|
||||
, m_recv_pos(0)
|
||||
, m_disk_recv_buffer_size(0)
|
||||
, m_reading_bytes(0)
|
||||
, m_num_invalid_requests(0)
|
||||
, m_disconnecting(false)
|
||||
, m_became_uninterested(time_now())
|
||||
, m_became_uninteresting(time_now())
|
||||
, m_connecting(true)
|
||||
, m_queued(true)
|
||||
, m_prefer_whole_pieces(false)
|
||||
, m_request_large_blocks(false)
|
||||
, m_priority(1)
|
||||
, m_upload_limit(bandwidth_limit::inf)
|
||||
, m_download_limit(bandwidth_limit::inf)
|
||||
|
@ -117,13 +103,27 @@ namespace libtorrent
|
|||
, m_connection_ticket(-1)
|
||||
, m_remote_bytes_dled(0)
|
||||
, m_remote_dl_rate(0)
|
||||
, m_remote_dl_update(time_now())
|
||||
, m_outstanding_writing_bytes(0)
|
||||
, m_fast_reconnect(false)
|
||||
, m_rtt(0)
|
||||
, m_downloaded_at_last_unchoke(0)
|
||||
, m_download_rate_peak(0)
|
||||
, m_upload_rate_peak(0)
|
||||
, m_rtt(0)
|
||||
, m_prefer_whole_pieces(0)
|
||||
, m_desired_queue_size(2)
|
||||
, m_fast_reconnect(false)
|
||||
, m_active(true)
|
||||
, m_peer_interested(false)
|
||||
, m_peer_choked(true)
|
||||
, m_interesting(false)
|
||||
, m_choked(true)
|
||||
, m_failed(false)
|
||||
, m_ignore_bandwidth_limits(false)
|
||||
, m_have_all(false)
|
||||
, m_assume_fifo(false)
|
||||
, m_disconnecting(false)
|
||||
, m_connecting(true)
|
||||
, m_queued(true)
|
||||
, m_request_large_blocks(false)
|
||||
, m_upload_only(false)
|
||||
#ifndef NDEBUG
|
||||
, m_in_constructor(true)
|
||||
#endif
|
||||
|
@ -174,41 +174,27 @@ namespace libtorrent
|
|||
#endif
|
||||
m_ses(ses)
|
||||
, m_max_out_request_queue(m_ses.settings().max_out_request_queue)
|
||||
, m_timeout(m_ses.settings().peer_timeout)
|
||||
, m_last_piece(time_now())
|
||||
, m_last_request(time_now())
|
||||
, m_last_incoming_request(min_time())
|
||||
, m_last_unchoke(min_time())
|
||||
, m_last_receive(time_now())
|
||||
, m_last_sent(time_now())
|
||||
, m_remote_dl_update(time_now())
|
||||
, m_became_uninterested(time_now())
|
||||
, m_became_uninteresting(time_now())
|
||||
, m_free_upload(0)
|
||||
, m_downloaded_at_last_unchoke(0)
|
||||
, m_disk_recv_buffer(ses, 0)
|
||||
, m_socket(s)
|
||||
, m_remote(endp)
|
||||
, m_num_pieces(0)
|
||||
, m_timeout(m_ses.settings().peer_timeout)
|
||||
, m_packet_size(0)
|
||||
, m_recv_pos(0)
|
||||
, m_disk_recv_buffer_size(0)
|
||||
, m_disk_recv_buffer(ses, 0)
|
||||
, m_reading_bytes(0)
|
||||
, m_last_receive(time_now())
|
||||
, m_last_sent(time_now())
|
||||
, m_socket(s)
|
||||
, m_remote(endp)
|
||||
, m_active(false)
|
||||
, m_peer_interested(false)
|
||||
, m_peer_choked(true)
|
||||
, m_interesting(false)
|
||||
, m_choked(true)
|
||||
, m_failed(false)
|
||||
, m_ignore_bandwidth_limits(false)
|
||||
, m_have_all(false)
|
||||
, m_upload_only(false)
|
||||
, m_num_pieces(0)
|
||||
, m_desired_queue_size(2)
|
||||
, m_free_upload(0)
|
||||
, m_assume_fifo(false)
|
||||
, m_num_invalid_requests(0)
|
||||
, m_disconnecting(false)
|
||||
, m_became_uninterested(time_now())
|
||||
, m_became_uninteresting(time_now())
|
||||
, m_connecting(false)
|
||||
, m_queued(false)
|
||||
, m_prefer_whole_pieces(false)
|
||||
, m_request_large_blocks(false)
|
||||
, m_priority(1)
|
||||
, m_upload_limit(bandwidth_limit::inf)
|
||||
, m_download_limit(bandwidth_limit::inf)
|
||||
|
@ -217,13 +203,27 @@ namespace libtorrent
|
|||
, m_connection_ticket(-1)
|
||||
, m_remote_bytes_dled(0)
|
||||
, m_remote_dl_rate(0)
|
||||
, m_remote_dl_update(time_now())
|
||||
, m_outstanding_writing_bytes(0)
|
||||
, m_fast_reconnect(false)
|
||||
, m_rtt(0)
|
||||
, m_downloaded_at_last_unchoke(0)
|
||||
, m_download_rate_peak(0)
|
||||
, m_upload_rate_peak(0)
|
||||
, m_rtt(0)
|
||||
, m_prefer_whole_pieces(0)
|
||||
, m_desired_queue_size(2)
|
||||
, m_fast_reconnect(false)
|
||||
, m_active(false)
|
||||
, m_peer_interested(false)
|
||||
, m_peer_choked(true)
|
||||
, m_interesting(false)
|
||||
, m_choked(true)
|
||||
, m_failed(false)
|
||||
, m_ignore_bandwidth_limits(false)
|
||||
, m_have_all(false)
|
||||
, m_assume_fifo(false)
|
||||
, m_disconnecting(false)
|
||||
, m_connecting(false)
|
||||
, m_queued(false)
|
||||
, m_request_large_blocks(false)
|
||||
, m_upload_only(false)
|
||||
#ifndef NDEBUG
|
||||
, m_in_constructor(true)
|
||||
#endif
|
||||
|
|
|
@ -211,6 +211,11 @@ namespace aux {
|
|||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||
m_logger = create_log("main_session", listen_port(), false);
|
||||
(*m_logger) << time_now_string() << "\n";
|
||||
|
||||
(*m_logger) << "sizeof(torrent): " << sizeof(torrent) << "\n";
|
||||
(*m_logger) << "sizeof(peer_connection): " << sizeof(peer_connection) << "\n";
|
||||
(*m_logger) << "sizeof(bt_peer_connection): " << sizeof(bt_peer_connection) << "\n";
|
||||
(*m_logger) << "sizeof(policy::peer): " << sizeof(policy::peer) << "\n";
|
||||
#endif
|
||||
|
||||
#ifdef TORRENT_STATS
|
||||
|
|
135
src/torrent.cpp
135
src/torrent.cpp
|
@ -96,20 +96,6 @@ namespace
|
|||
, tracker_failed_max = 5
|
||||
};
|
||||
|
||||
int calculate_block_size(const torrent_info& i, int default_block_size)
|
||||
{
|
||||
if (default_block_size < 1024) default_block_size = 1024;
|
||||
|
||||
// if pieces are too small, adjust the block size
|
||||
if (i.piece_length() < default_block_size)
|
||||
{
|
||||
return i.piece_length();
|
||||
}
|
||||
|
||||
// otherwise, go with the default
|
||||
return default_block_size;
|
||||
}
|
||||
|
||||
struct find_peer_by_ip
|
||||
{
|
||||
find_peer_by_ip(tcp::endpoint const& a, const torrent* t)
|
||||
|
@ -161,23 +147,17 @@ namespace libtorrent
|
|||
, entry const* resume_data
|
||||
, int seq
|
||||
, bool auto_managed)
|
||||
: m_torrent_file(tf)
|
||||
, m_abort(false)
|
||||
, m_paused(paused)
|
||||
, m_just_paused(false)
|
||||
, m_auto_managed(auto_managed)
|
||||
: m_policy(this)
|
||||
, m_active_time(seconds(0))
|
||||
, m_seeding_time(seconds(0))
|
||||
, m_total_uploaded(0)
|
||||
, m_total_downloaded(0)
|
||||
, m_started(time_now())
|
||||
, m_torrent_file(tf)
|
||||
, m_event(tracker_request::started)
|
||||
, m_block_size(0)
|
||||
, m_storage(0)
|
||||
, m_next_request(time_now())
|
||||
, m_duration(1800)
|
||||
, m_complete(-1)
|
||||
, m_incomplete(-1)
|
||||
, m_host_resolver(ses.m_io_service)
|
||||
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||
, m_resolving_country(false)
|
||||
, m_resolve_countries(false)
|
||||
#endif
|
||||
, m_announce_timer(ses.m_io_service)
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
, m_last_dht_announce(time_now() - minutes(15))
|
||||
|
@ -185,36 +165,41 @@ namespace libtorrent
|
|||
, m_ses(ses)
|
||||
, m_picker(0)
|
||||
, m_trackers(m_torrent_file->trackers())
|
||||
, m_last_working_tracker(-1)
|
||||
, m_currently_trying_tracker(0)
|
||||
, m_failed_trackers(0)
|
||||
, m_time_scaler(0)
|
||||
, m_num_pieces(0)
|
||||
, m_sequential_download(false)
|
||||
, m_got_tracker_response(false)
|
||||
, m_ratio(0.f)
|
||||
, m_total_failed_bytes(0)
|
||||
, m_total_redundant_bytes(0)
|
||||
, m_net_interface(net_interface.address(), 0)
|
||||
, m_save_path(complete(save_path))
|
||||
, m_storage_mode(storage_mode)
|
||||
, m_state(torrent_status::queued_for_checking)
|
||||
, m_progress(0.f)
|
||||
, m_default_block_size(block_size)
|
||||
, m_connections_initialized(true)
|
||||
, m_settings(ses.settings())
|
||||
, m_storage_constructor(sc)
|
||||
, m_progress(0.f)
|
||||
, m_num_pieces(0)
|
||||
, m_ratio(0.f)
|
||||
, m_max_uploads((std::numeric_limits<int>::max)())
|
||||
, m_num_uploads(0)
|
||||
, m_max_connections((std::numeric_limits<int>::max)())
|
||||
, m_block_size(block_size)
|
||||
, m_complete(-1)
|
||||
, m_incomplete(-1)
|
||||
, m_deficit_counter(0)
|
||||
, m_policy(this)
|
||||
, m_duration(1800)
|
||||
, m_sequence_number(seq)
|
||||
, m_active_time(seconds(0))
|
||||
, m_seeding_time(seconds(0))
|
||||
, m_total_uploaded(0)
|
||||
, m_total_downloaded(0)
|
||||
, m_started(time_now())
|
||||
, m_last_working_tracker(-1)
|
||||
, m_currently_trying_tracker(0)
|
||||
, m_failed_trackers(0)
|
||||
, m_time_scaler(0)
|
||||
, m_abort(false)
|
||||
, m_paused(paused)
|
||||
, m_just_paused(false)
|
||||
, m_auto_managed(auto_managed)
|
||||
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||
, m_resolving_country(false)
|
||||
, m_resolve_countries(false)
|
||||
#endif
|
||||
, m_sequential_download(false)
|
||||
, m_got_tracker_response(false)
|
||||
, m_connections_initialized(true)
|
||||
{
|
||||
if (resume_data) m_resume_data = *resume_data;
|
||||
#ifndef NDEBUG
|
||||
|
@ -236,59 +221,58 @@ namespace libtorrent
|
|||
, entry const* resume_data
|
||||
, int seq
|
||||
, bool auto_managed)
|
||||
: m_torrent_file(new torrent_info(info_hash))
|
||||
, m_abort(false)
|
||||
, m_paused(paused)
|
||||
, m_just_paused(false)
|
||||
, m_auto_managed(auto_managed)
|
||||
: m_policy(this)
|
||||
, m_active_time(seconds(0))
|
||||
, m_seeding_time(seconds(0))
|
||||
, m_total_uploaded(0)
|
||||
, m_total_downloaded(0)
|
||||
, m_started(time_now())
|
||||
, m_torrent_file(new torrent_info(info_hash))
|
||||
, m_event(tracker_request::started)
|
||||
, m_block_size(0)
|
||||
, m_storage(0)
|
||||
, m_next_request(time_now())
|
||||
, m_duration(1800)
|
||||
, m_complete(-1)
|
||||
, m_incomplete(-1)
|
||||
, m_host_resolver(ses.m_io_service)
|
||||
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||
, m_resolving_country(false)
|
||||
, m_resolve_countries(false)
|
||||
#endif
|
||||
, m_announce_timer(ses.m_io_service)
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
, m_last_dht_announce(time_now() - minutes(15))
|
||||
#endif
|
||||
, m_ses(ses)
|
||||
, m_picker(0)
|
||||
, m_last_working_tracker(-1)
|
||||
, m_currently_trying_tracker(0)
|
||||
, m_failed_trackers(0)
|
||||
, m_time_scaler(0)
|
||||
, m_num_pieces(0)
|
||||
, m_sequential_download(false)
|
||||
, m_got_tracker_response(false)
|
||||
, m_ratio(0.f)
|
||||
, m_total_failed_bytes(0)
|
||||
, m_total_redundant_bytes(0)
|
||||
, m_net_interface(net_interface.address(), 0)
|
||||
, m_save_path(complete(save_path))
|
||||
, m_storage_mode(storage_mode)
|
||||
, m_state(torrent_status::queued_for_checking)
|
||||
, m_progress(0.f)
|
||||
, m_default_block_size(block_size)
|
||||
, m_connections_initialized(false)
|
||||
, m_settings(ses.settings())
|
||||
, m_storage_constructor(sc)
|
||||
, m_progress(0.f)
|
||||
, m_num_pieces(0)
|
||||
, m_ratio(0.f)
|
||||
, m_max_uploads((std::numeric_limits<int>::max)())
|
||||
, m_num_uploads(0)
|
||||
, m_max_connections((std::numeric_limits<int>::max)())
|
||||
, m_block_size(block_size)
|
||||
, m_complete(-1)
|
||||
, m_incomplete(-1)
|
||||
, m_deficit_counter(0)
|
||||
, m_policy(this)
|
||||
, m_duration(1800)
|
||||
, m_sequence_number(seq)
|
||||
, m_active_time(seconds(0))
|
||||
, m_seeding_time(seconds(0))
|
||||
, m_total_uploaded(0)
|
||||
, m_total_downloaded(0)
|
||||
, m_started(time_now())
|
||||
, m_last_working_tracker(-1)
|
||||
, m_currently_trying_tracker(0)
|
||||
, m_failed_trackers(0)
|
||||
, m_time_scaler(0)
|
||||
, m_abort(false)
|
||||
, m_paused(paused)
|
||||
, m_just_paused(false)
|
||||
, m_auto_managed(auto_managed)
|
||||
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||
, m_resolving_country(false)
|
||||
, m_resolve_countries(false)
|
||||
#endif
|
||||
, m_sequential_download(false)
|
||||
, m_got_tracker_response(false)
|
||||
, m_connections_initialized(false)
|
||||
{
|
||||
if (resume_data) m_resume_data = *resume_data;
|
||||
#ifndef NDEBUG
|
||||
|
@ -428,7 +412,6 @@ namespace libtorrent
|
|||
, m_save_path, m_ses.m_files, m_ses.m_disk_thread, m_storage_constructor
|
||||
, m_storage_mode);
|
||||
m_storage = m_owning_storage.get();
|
||||
m_block_size = calculate_block_size(*m_torrent_file, m_default_block_size);
|
||||
m_picker.reset(new piece_picker(
|
||||
m_torrent_file->piece_length() / m_block_size
|
||||
, int((m_torrent_file->total_size()+m_block_size-1)/m_block_size)));
|
||||
|
@ -3031,7 +3014,7 @@ namespace libtorrent
|
|||
if ((unsigned)m_currently_trying_tracker >= m_trackers.size())
|
||||
{
|
||||
int delay = tracker_retry_delay_min
|
||||
+ (std::min)(m_failed_trackers, (int)tracker_failed_max)
|
||||
+ (std::min)(int(m_failed_trackers), int(tracker_failed_max))
|
||||
* (tracker_retry_delay_max - tracker_retry_delay_min)
|
||||
/ tracker_failed_max;
|
||||
|
||||
|
|
Loading…
Reference in New Issue