summaryrefslogtreecommitdiff
path: root/trackerlogic.c
diff options
context:
space:
mode:
Diffstat (limited to 'trackerlogic.c')
-rw-r--r--trackerlogic.c41
1 files changed, 0 insertions, 41 deletions
diff --git a/trackerlogic.c b/trackerlogic.c
index 846b54e..7f28903 100644
--- a/trackerlogic.c
+++ b/trackerlogic.c
@@ -226,47 +226,6 @@ void fix_mmapallocation( void *buf, size_t old_alloc, size_t new_alloc ) {
226 munmap( ((char*)buf) + new_pages * page_size, old_alloc - new_pages * page_size ); 226 munmap( ((char*)buf) + new_pages * page_size, old_alloc - new_pages * page_size );
227} 227}
228 228
229/* Fetch full scrape info for all torrents */
230size_t return_fullscrape_for_tracker( char **reply ) {
231 size_t torrent_count = 0, j;
232 size_t allocated, replysize;
233 ot_vector *torrents_list;
234 int bucket;
235 char *r;
236
237 for( bucket=0; bucket<OT_BUCKET_COUNT; ++bucket ) {
238 ot_vector *torrents_list = mutex_bucket_lock( bucket );
239 torrent_count += torrents_list->size;
240 mutex_bucket_unlock( bucket );
241 }
242
243 /* one extra for pro- and epilogue */
244 allocated = 100*(1+torrent_count);
245 if( !( r = *reply = mmap( NULL, allocated, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0 ) ) ) return 0;
246
247 memmove( r, "d5:filesd", 9 ); r += 9;
248 for( bucket=0; bucket<OT_BUCKET_COUNT; ++bucket ) {
249 torrents_list = mutex_bucket_lock( bucket );
250 for( j=0; j<torrents_list->size; ++j ) {
251 ot_peerlist *peer_list = ( ((ot_torrent*)(torrents_list->data))[j] ).peer_list;
252 ot_hash *hash =&( ((ot_torrent*)(torrents_list->data))[j] ).hash;
253 if( peer_list->peer_count || peer_list->down_count ) {
254 *r++='2'; *r++='0'; *r++=':';
255 memmove( r, hash, 20 ); r+=20;
256 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 );
257 }
258 }
259 mutex_bucket_unlock( bucket );
260 }
261
262 *r++='e'; *r++='e';
263
264 replysize = ( r - *reply );
265 fix_mmapallocation( *reply, allocated, replysize );
266
267 return replysize;
268}
269
270/* Fetches scrape info for a specific torrent */ 229/* Fetches scrape info for a specific torrent */
271size_t return_udp_scrape_for_torrent( ot_hash *hash, char *reply ) { 230size_t return_udp_scrape_for_torrent( ot_hash *hash, char *reply ) {
272 int exactmatch; 231 int exactmatch;