summaryrefslogtreecommitdiff
path: root/ot_fullscrape.c
diff options
context:
space:
mode:
authorerdgeist <>2008-12-06 18:46:00 +0000
committererdgeist <>2008-12-06 18:46:00 +0000
commit08c71627839a9134367db354c8255f7a720e1ff3 (patch)
treeb429abf6b3c26c7f851b522f5d4fb6797ad02d29 /ot_fullscrape.c
parenta4ed31d517f77a21afe12918a9cb256489daac74 (diff)
Renamed OT_FLAG to OT_PEERFLAG to make code easier to read
Introduced READ16/32 and WRITE16/32 makros to abstract loading/storing from unaligned addresses away on cpu's that can actually load/store everywhere Removed all unnecessary memmoves, especially where it only moved 6 bytes in inner loop. I replaced them with WRITE16/32(READ16/32()) makros
Diffstat (limited to 'ot_fullscrape.c')
-rw-r--r--ot_fullscrape.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/ot_fullscrape.c b/ot_fullscrape.c
index dfad640..5f61afd 100644
--- a/ot_fullscrape.c
+++ b/ot_fullscrape.c
@@ -113,7 +113,7 @@ static int fullscrape_increase( int *iovec_entries, struct iovec **iovector,
113} 113}
114 114
115static void fullscrape_make( int *iovec_entries, struct iovec **iovector, ot_tasktype mode ) { 115static void fullscrape_make( int *iovec_entries, struct iovec **iovector, ot_tasktype mode ) {
116 int bucket; 116 int bucket,i;
117 char *r, *re; 117 char *r, *re;
118#ifdef WANT_COMPRESSION_GZIP 118#ifdef WANT_COMPRESSION_GZIP
119 char compress_buffer[OT_SCRAPE_MAXENTRYLEN]; 119 char compress_buffer[OT_SCRAPE_MAXENTRYLEN];
@@ -163,7 +163,7 @@ static void fullscrape_make( int *iovec_entries, struct iovec **iovector, ot_tas
163 163
164 /* push hash as bencoded string */ 164 /* push hash as bencoded string */
165 *r++='2'; *r++='0'; *r++=':'; 165 *r++='2'; *r++='0'; *r++=':';
166 memmove( r, hash, 20 ); r+=20; 166 for(i=0;i<20;i+=4) WRITE32(r+=4,0,READ32(hash,i));
167 167
168 /* push rest of the scrape string */ 168 /* push rest of the scrape string */
169 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 ); 169 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 );
@@ -174,7 +174,7 @@ static void fullscrape_make( int *iovec_entries, struct iovec **iovector, ot_tas
174 r += sprintf( r, ":%zd:%zd\n", peer_list->seed_count, peer_list->peer_count-peer_list->seed_count ); 174 r += sprintf( r, ":%zd:%zd\n", peer_list->seed_count, peer_list->peer_count-peer_list->seed_count );
175 break; 175 break;
176 case TASK_FULLSCRAPE_TPB_BINARY: 176 case TASK_FULLSCRAPE_TPB_BINARY:
177 memmove( r, hash, 20 ); r+=20; 177 for(i=0;i<20;i+=4) WRITE32(r+=4,0,READ32(hash,i));
178 *(uint32_t*)r++ = htonl( (uint32_t)peer_list->seed_count ); 178 *(uint32_t*)r++ = htonl( (uint32_t)peer_list->seed_count );
179 *(uint32_t*)r++ = htonl( (uint32_t)( peer_list->peer_count-peer_list->seed_count) ); 179 *(uint32_t*)r++ = htonl( (uint32_t)( peer_list->peer_count-peer_list->seed_count) );
180 break; 180 break;