Changeset 2319
- Timestamp:
- 11/26/07 00:26:45 (14 months ago)
- Location:
- tags/deluge-0.5.6.96/libtorrent/src
- Files:
-
- 5 modified
-
kademlia/dht_tracker.cpp (modified) (1 diff)
-
socks4_stream.cpp (modified) (7 diffs)
-
socks5_stream.cpp (modified) (17 diffs)
-
torrent.cpp (modified) (5 diffs)
-
web_peer_connection.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tags/deluge-0.5.6.96/libtorrent/src/kademlia/dht_tracker.cpp
r2189 r2319 274 274 m_socket.open(ep.protocol()); 275 275 m_socket.bind(ep); 276 m_socket.async_receive_from(asio::buffer(&m_in_buf[m_buffer][0] 277 , m_in_buf[m_buffer].size()), m_remote_endpoint[m_buffer] 278 , m_strand.wrap(bind(&dht_tracker::on_receive, self(), _1, _2))); 276 279 } 277 280 -
tags/deluge-0.5.6.96/libtorrent/src/socks4_stream.cpp
r634 r2319 44 44 { 45 45 (*h)(e); 46 close(); 46 asio::error_code ec; 47 close(ec); 47 48 return; 48 49 } … … 55 56 { 56 57 asio::error_code ec = asio::error::operation_not_supported; 57 (*h)(e );58 close( );58 (*h)(ec); 59 close(ec); 59 60 return; 60 61 } … … 69 70 { 70 71 (*h)(e); 71 close(); 72 asio::error_code ec; 73 close(ec); 72 74 return; 73 75 } … … 94 96 { 95 97 (*h)(e); 96 close(); 98 asio::error_code ec; 99 close(ec); 97 100 return; 98 101 } … … 108 111 { 109 112 (*h)(e); 110 close(); 113 asio::error_code ec; 114 close(ec); 111 115 return; 112 116 } … … 120 124 if (reply_version != 0) 121 125 { 122 (*h)(asio::error::operation_not_supported); 123 close(); 126 asio::error_code ec = asio::error::operation_not_supported; 127 (*h)(ec); 128 close(ec); 124 129 return; 125 130 } … … 141 146 } 142 147 (*h)(ec); 143 close( );148 close(ec); 144 149 } 145 150 -
tags/deluge-0.5.6.96/libtorrent/src/socks5_stream.cpp
r1919 r2319 45 45 { 46 46 (*h)(e); 47 close(); 47 asio::error_code ec; 48 close(ec); 48 49 return; 49 50 } … … 58 59 { 59 60 (*h)(e); 60 close(); 61 asio::error_code ec; 62 close(ec); 61 63 return; 62 64 } … … 87 89 { 88 90 (*h)(e); 89 close(); 91 asio::error_code ec; 92 close(ec); 90 93 return; 91 94 } … … 101 104 { 102 105 (*h)(e); 103 close(); 106 asio::error_code ec; 107 close(ec); 104 108 return; 105 109 } … … 114 118 { 115 119 (*h)(asio::error::operation_not_supported); 116 close(); 120 asio::error_code ec; 121 close(ec); 117 122 return; 118 123 } … … 127 132 { 128 133 (*h)(asio::error::operation_not_supported); 129 close(); 134 asio::error_code ec; 135 close(ec); 130 136 return; 131 137 } … … 145 151 { 146 152 (*h)(asio::error::operation_not_supported); 147 close(); 153 asio::error_code ec; 154 close(ec); 148 155 return; 149 156 } … … 156 163 { 157 164 (*h)(e); 158 close(); 165 asio::error_code ec; 166 close(ec); 159 167 return; 160 168 } … … 171 179 { 172 180 (*h)(e); 173 close(); 181 asio::error_code ec; 182 close(ec); 174 183 return; 175 184 } … … 184 193 { 185 194 (*h)(asio::error::operation_not_supported); 186 close(); 195 asio::error_code ec; 196 close(ec); 187 197 return; 188 198 } … … 191 201 { 192 202 (*h)(asio::error::operation_not_supported); 193 close(); 203 asio::error_code ec; 204 close(ec); 194 205 return; 195 206 } … … 223 234 { 224 235 (*h)(e); 225 close(); 236 asio::error_code ec; 237 close(ec); 226 238 return; 227 239 } … … 237 249 { 238 250 (*h)(e); 239 close(); 251 asio::error_code ec; 252 close(ec); 240 253 return; 241 254 } … … 249 262 { 250 263 (*h)(asio::error::operation_not_supported); 251 close(); 264 asio::error_code ec; 265 close(ec); 252 266 return; 253 267 } … … 268 282 } 269 283 (*h)(e); 270 close(); 284 asio::error_code ec; 285 close(ec); 271 286 return; 272 287 } … … 292 307 { 293 308 (*h)(asio::error::operation_not_supported); 294 close(); 309 asio::error_code ec; 310 close(ec); 295 311 return; 296 312 } … … 306 322 { 307 323 (*h)(e); 308 close(); 324 asio::error_code ec; 325 close(ec); 309 326 return; 310 327 } -
tags/deluge-0.5.6.96/libtorrent/src/torrent.cpp
r2272 r2319 288 288 bool torrent::should_announce_dht() const 289 289 { 290 if (m_ses.m_listen_sockets.empty()) return false; 291 292 if (!m_ses.m_dht) return false; 290 293 // don't announce private torrents 291 294 if (m_torrent_file->is_valid() && m_torrent_file->priv()) return false; … … 435 438 436 439 // announce with the local discovery service 437 m_ses.announce_lsd(m_torrent_file->info_hash()); 440 if (!m_paused) 441 m_ses.announce_lsd(m_torrent_file->info_hash()); 438 442 } 439 443 else … … 445 449 446 450 #ifndef TORRENT_DISABLE_DHT 451 if (m_paused) return; 447 452 if (!m_ses.m_dht) return; 448 453 ptime now = time_now(); … … 450 455 { 451 456 m_last_dht_announce = now; 452 // TODO: There should be a way to abort an announce operation on the dht.453 // when the torrent is destructed454 457 if (m_ses.m_listen_sockets.empty()) return; 455 458 m_ses.m_dht->announce(m_torrent_file->info_hash() … … 2251 2254 #ifndef TORRENT_DISABLE_DHT 2252 2255 // only start the announce if we want to announce with the dht 2253 if (should_announce_dht())2254 {2255 if (m_abort) return;2256 ptime now = time_now(); 2257 if (should_announce_dht() && now - m_last_dht_announce > minutes(14)) 2258 { 2256 2259 // force the DHT to reannounce 2257 m_last_dht_announce = time_now() - minutes(15);2260 m_last_dht_announce = now; 2258 2261 boost::weak_ptr<torrent> self(shared_from_this()); 2259 m_ announce_timer.expires_from_now(seconds(1));2260 m_announce_timer.async_wait(m_ses.m_strand.wrap(2261 bind(&torrent::on_announce_disp, self, _1)));2262 m_ses.m_dht->announce(m_torrent_file->info_hash() 2263 , m_ses.m_listen_sockets.front().external_port 2264 , m_ses.m_strand.wrap(bind(&torrent::on_dht_announce_response_disp, self, _1))); 2262 2265 } 2263 2266 #endif -
tags/deluge-0.5.6.96/libtorrent/src/web_peer_connection.cpp
r1919 r2319 307 307 namespace 308 308 { 309 bool range_contains(peer_request const& range, peer_request const& req) 310 { 311 return range.start <= req.start 312 && range.start + range.length >= req.start + req.length; 309 bool range_contains(peer_request const& range, peer_request const& req, int piece_size) 310 { 311 size_type range_start = size_type(range.piece) * piece_size + range.start; 312 size_type req_start = size_type(req.piece) * piece_size + req.start; 313 return range_start <= req_start 314 && range_start + range.length >= req_start + req.length; 313 315 } 314 316 } … … 471 473 } 472 474 475 // std::cerr << "REQUESTS: m_requests: " << m_requests.size() 476 // << " file_requests: " << m_file_requests.size() << std::endl; 477 473 478 torrent_info const& info = t->torrent_file(); 474 479 … … 481 486 482 487 peer_request front_request = m_requests.front(); 483 488 /* 484 489 size_type rs = size_type(in_range.piece) * info.piece_length() + in_range.start; 485 490 size_type re = rs + in_range.length; 486 491 size_type fs = size_type(front_request.piece) * info.piece_length() + front_request.start; 487 492 size_type fe = fs + front_request.length; 488 if (fs < rs || fe > re) 489 {490 throw std::runtime_error("invalid range in HTTP response");491 }492 493 494 std::cerr << "RANGE: r = (" << rs << ", " << re << " ) " 495 "f = (" << fs << ", " << fe << ") " 496 "file_index = " << file_index << " received_body = " << m_received_body << std::endl; 497 */ 493 498 // skip the http header and the blocks we've already read. The 494 499 // http_body.begin is now in sync with the request at the front … … 505 510 > front_request.start + int(m_piece.size()); 506 511 512 if (!range_overlaps_request) 513 { 514 throw std::runtime_error("invalid range in HTTP response"); 515 } 516 507 517 // if the request is contained in the range (i.e. the entire request 508 518 // fits in the range) we should not start a partial piece, since we soon 509 519 // will receive enough to call incoming_piece() and pass the read buffer 510 520 // directly (in the next loop below). 511 if (range_overlaps_request && !range_contains(in_range, front_request ))521 if (range_overlaps_request && !range_contains(in_range, front_request, info.piece_length())) 512 522 { 513 523 // the start of the next block to receive is stored … … 550 560 // report all received blocks to the bittorrent engine 551 561 while (!m_requests.empty() 552 && range_contains(in_range, m_requests.front() )562 && range_contains(in_range, m_requests.front(), info.piece_length()) 553 563 && recv_buffer.left() >= m_requests.front().length) 554 564 {
