Browse Source

Fix: auto increment in += is not a post increment...

master
Dirk Engling 13 years ago
parent
commit
32edd0dff8
  1. 12
      ot_fullscrape.c
  2. 11
      ot_livesync.c
  3. 14
      trackerlogic.c

12
ot_fullscrape.c

@ -165,8 +165,7 @@ static void fullscrape_make( int *iovec_entries, struct iovec **iovector, ot_tas
/* push hash as bencoded string */
*r++='2'; *r++='0'; *r++=':';
for(i=0;i<20;i+=4) WRITE32(r+=4,0,READ32(hash,i));
for(i=0;i<20;i+=4) WRITE32(r,i,READ32(hash,i)); r+=20;
/* push rest of the scrape string */
r += sprintf( r, "d8:completei%zde10:downloadedi%zde10:incompletei%zdee", peer_list->seed_count, peer_list->down_count, peer_list->peer_count-peer_list->seed_count );
@ -176,9 +175,10 @@ static void fullscrape_make( int *iovec_entries, struct iovec **iovector, ot_tas
r += sprintf( r, ":%zd:%zd\n", peer_list->seed_count, peer_list->peer_count-peer_list->seed_count );
break;
case TASK_FULLSCRAPE_TPB_BINARY:
for(i=0;i<20;i+=4) WRITE32(r+=4,0,READ32(hash,i));
*(uint32_t*)(r+=4) = htonl( (uint32_t) peer_list->seed_count );
*(uint32_t*)(r+=4) = htonl( (uint32_t)( peer_list->peer_count-peer_list->seed_count) );
for(i=0;i<20;i+=4) WRITE32(r,i,READ32(hash,i)); r+=20;
*(uint32_t*)(r+0) = htonl( (uint32_t) peer_list->seed_count );
*(uint32_t*)(r+4) = htonl( (uint32_t)( peer_list->peer_count-peer_list->seed_count) );
r+=8;
break;
case TASK_FULLSCRAPE_TPB_URLENCODED:
r += fmt_urlencoded( r, (char *)*hash, 20 );
@ -235,4 +235,4 @@ static void fullscrape_make( int *iovec_entries, struct iovec **iovector, ot_tas
}
#endif
const char *g_version_fullscrape_c = "$Source: /home/cvsroot/opentracker/ot_fullscrape.c,v $: $Revision: 1.27 $\n";
const char *g_version_fullscrape_c = "$Source: /home/cvsroot/opentracker/ot_fullscrape.c,v $: $Revision: 1.28 $\n";

11
ot_livesync.c

@ -101,10 +101,11 @@ static void livesync_issuepacket( ) {
/* Inform live sync about whats going on. */
void livesync_tell( ot_hash * const info_hash, const ot_peer * const peer ) {
int i;
for(i=0;i<20;i+=4) WRITE32(livesync_outbuffer_pos+=4,0,READ32(info_hash,i));
WRITE32(livesync_outbuffer_pos+=4,0,READ32(peer,0));
WRITE32(livesync_outbuffer_pos+=4,0,READ32(peer,4));
for(i=0;i<20;i+=4) WRITE32(livesync_outbuffer_pos,i,READ32(info_hash,i));
WRITE32(livesync_outbuffer_pos,20,READ32(peer,0));
WRITE32(livesync_outbuffer_pos,24,READ32(peer,4));
livesync_outbuffer_pos += 28;
if( livesync_outbuffer_pos >= livesync_outbuffer_highwater )
livesync_issuepacket();
}
@ -171,4 +172,4 @@ static void * livesync_worker( void * args ) {
}
#endif
const char *g_version_livesync_c = "$Source: /home/cvsroot/opentracker/ot_livesync.c,v $: $Revision: 1.9 $\n";
const char *g_version_livesync_c = "$Source: /home/cvsroot/opentracker/ot_livesync.c,v $: $Revision: 1.10 $\n";

14
trackerlogic.c

@ -164,8 +164,9 @@ static size_t return_peers_all( ot_peerlist *peer_list, char *reply ) {
ot_peer * peers = (ot_peer*)bucket_list[bucket].data;
size_t peer_count = bucket_list[bucket].size;
while( peer_count-- ) {
WRITE32(r+=4,0,READ32(peers,0));
WRITE16(r+=2,0,READ16(peers++,4));
WRITE32(r,0,READ32(peers,0));
WRITE16(r,4,READ16(peers++,4));
r+=6;
}
}
@ -208,8 +209,9 @@ static size_t return_peers_selection( ot_peerlist *peer_list, size_t amount, cha
bucket_index = ( bucket_index + 1 ) % num_buckets;
}
peer = ((ot_peer*)bucket_list[bucket_index].data) + bucket_offset;
WRITE32(r+=4,0,READ32(peer,0));
WRITE16(r+=2,0,READ16(peer,4));
WRITE32(r,0,READ32(peer,0));
WRITE16(r,4,READ16(peer,4));
r+=6;
}
return r - reply;
}
@ -294,7 +296,7 @@ size_t return_tcp_scrape_for_torrent( ot_hash *hash_list, int amount, char *repl
} else {
int j;
*r++='2';*r++='0';*r++=':';
for(j=0;j<20;j+=4) WRITE32(r+=4,0,READ32(hash,j));
for(j=0;j<20;j+=4) WRITE32(r,j,READ32(hash,j)); r += 20;
r += sprintf( r, "d8:completei%zde10:downloadedi%zde10:incompletei%zdee",
torrent->peer_list->seed_count, torrent->peer_list->down_count, torrent->peer_list->peer_count-torrent->peer_list->seed_count );
}
@ -399,4 +401,4 @@ void trackerlogic_deinit( void ) {
mutex_deinit( );
}
const char *g_version_trackerlogic_c = "$Source: /home/cvsroot/opentracker/trackerlogic.c,v $: $Revision: 1.116 $\n";
const char *g_version_trackerlogic_c = "$Source: /home/cvsroot/opentracker/trackerlogic.c,v $: $Revision: 1.117 $\n";
Loading…
Cancel
Save