summaryrefslogtreecommitdiff
path: root/proxy.c
diff options
context:
space:
mode:
Diffstat (limited to 'proxy.c')
-rw-r--r--proxy.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/proxy.c b/proxy.c
index 6e39de7..7472baa 100644
--- a/proxy.c
+++ b/proxy.c
@@ -603,17 +603,16 @@ static void * streamsync_worker( void * args ) {
603 /* Address torrents members */ 603 /* Address torrents members */
604 ot_peerlist *peer_list = ( ((ot_torrent*)(torrents_list->data))[tor_offset] ).peer_list; 604 ot_peerlist *peer_list = ( ((ot_torrent*)(torrents_list->data))[tor_offset] ).peer_list;
605 switch( peer_list->peer_count ) { 605 switch( peer_list->peer_count ) {
606 case 2: count_two++; break; 606 case 2: count_two++; break;
607 case 1: count_one++; break; 607 case 1: count_one++; break;
608 case 0: break; 608 case 0: break;
609 default: 609 default: count_def++;
610 count_peers += peer_list->peer_count; 610 count_peers += peer_list->peer_count;
611 count_def += 1 + ( peer_list->peer_count >> 8 );
612 } 611 }
613 } 612 }
614 613
615 /* Maximal memory requirement: max 3 blocks, max torrents * 20 + max peers * 7 */ 614 /* Maximal memory requirement: max 3 blocks, max torrents * 20 + max peers * 7 */
616 mem = 3 * ( 4 + 1 + 1 + 2 ) + ( count_one + count_two ) * 19 + count_def * ( 19 + 6 ) + 615 mem = 3 * ( 4 + 1 + 1 + 2 ) + ( count_one + count_two ) * 19 + count_def * ( 19 + 8 ) +
617 ( count_one + 2 * count_two + count_peers ) * 7; 616 ( count_one + 2 * count_two + count_peers ) * 7;
618 617
619 fprintf( stderr, "Mem: %zd\n", mem ); 618 fprintf( stderr, "Mem: %zd\n", mem );
@@ -781,7 +780,6 @@ static void process_indata( proxy_peer * peer ) {
781printf( "type: %hhu, prefix: %02X, torrentcount: %zd\n", peer->packet_type, peer->packet_tprefix, peer->packet_tcount ); 780printf( "type: %hhu, prefix: %02X, torrentcount: %zd\n", peer->packet_type, peer->packet_tprefix, peer->packet_tcount );
782 } 781 }
783 782
784next_torrent:
785 /* Ensure size for a minimal torrent block */ 783 /* Ensure size for a minimal torrent block */
786 if( data + sizeof(ot_hash) + OT_IP_SIZE + 3 > dataend ) break; 784 if( data + sizeof(ot_hash) + OT_IP_SIZE + 3 > dataend ) break;
787 785
@@ -800,14 +798,11 @@ next_torrent:
800 /* Ensure enough data being read to hold all peers */ 798 /* Ensure enough data being read to hold all peers */
801 if( data + (OT_IP_SIZE + 3) * peers > dataend ) break; 799 if( data + (OT_IP_SIZE + 3) * peers > dataend ) break;
802 800
803printf( "peers: %zd\n", peers );
804
805 while( peers-- ) { 801 while( peers-- ) {
806 livesync_proxytell( peer->packet_tprefix, hash, data ); 802 livesync_proxytell( peer->packet_tprefix, hash, data );
807 data += OT_IP_SIZE + 3; 803 data += OT_IP_SIZE + 3;
808 } 804 }
809 if( --peer->packet_tcount ) 805 --peer->packet_tcount;
810 goto next_torrent;
811 } 806 }
812 807
813 consumed = data - peer->indata; 808 consumed = data - peer->indata;