Browse Source

Fixed sync loss bug

master
Dirk Engling 11 years ago
parent
commit
bb8439c69d
  1. 21
      proxy.c

21
proxy.c

@ -1,7 +1,7 @@
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever.
$Id: proxy.c,v 1.12 2010/08/14 15:22:20 erdgeist Exp $ */
$Id: proxy.c,v 1.13 2010/08/15 01:59:09 erdgeist Exp $ */
/* System */
#include <stdint.h>
@ -603,17 +603,16 @@ static void * streamsync_worker( void * args ) {
/* Address torrents members */
ot_peerlist *peer_list = ( ((ot_torrent*)(torrents_list->data))[tor_offset] ).peer_list;
switch( peer_list->peer_count ) {
case 2: count_two++; break;
case 1: count_one++; break;
case 0: break;
default:
count_peers += peer_list->peer_count;
count_def += 1 + ( peer_list->peer_count >> 8 );
case 2: count_two++; break;
case 1: count_one++; break;
case 0: break;
default: count_def++;
count_peers += peer_list->peer_count;
}
}
/* Maximal memory requirement: max 3 blocks, max torrents * 20 + max peers * 7 */
mem = 3 * ( 4 + 1 + 1 + 2 ) + ( count_one + count_two ) * 19 + count_def * ( 19 + 6 ) +
mem = 3 * ( 4 + 1 + 1 + 2 ) + ( count_one + count_two ) * 19 + count_def * ( 19 + 8 ) +
( count_one + 2 * count_two + count_peers ) * 7;
fprintf( stderr, "Mem: %zd\n", mem );
@ -781,7 +780,6 @@ static void process_indata( proxy_peer * peer ) {
printf( "type: %hhu, prefix: %02X, torrentcount: %zd\n", peer->packet_type, peer->packet_tprefix, peer->packet_tcount );
}
next_torrent:
/* Ensure size for a minimal torrent block */
if( data + sizeof(ot_hash) + OT_IP_SIZE + 3 > dataend ) break;
@ -800,14 +798,11 @@ next_torrent:
/* Ensure enough data being read to hold all peers */
if( data + (OT_IP_SIZE + 3) * peers > dataend ) break;
printf( "peers: %zd\n", peers );
while( peers-- ) {
livesync_proxytell( peer->packet_tprefix, hash, data );
data += OT_IP_SIZE + 3;
}
if( --peer->packet_tcount )
goto next_torrent;
--peer->packet_tcount;
}
consumed = data - peer->indata;

Loading…
Cancel
Save