summaryrefslogtreecommitdiff
path: root/trackerlogic.c
diff options
context:
space:
mode:
Diffstat (limited to 'trackerlogic.c')
-rw-r--r--trackerlogic.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/trackerlogic.c b/trackerlogic.c
index e4dc3a6..2b4e91d 100644
--- a/trackerlogic.c
+++ b/trackerlogic.c
@@ -23,6 +23,7 @@
23#include "ot_clean.h" 23#include "ot_clean.h"
24#include "ot_accesslist.h" 24#include "ot_accesslist.h"
25#include "ot_fullscrape.h" 25#include "ot_fullscrape.h"
26#include "ot_sync.h"
26 27
27void free_peerlist( ot_peerlist *peer_list ) { 28void free_peerlist( ot_peerlist *peer_list ) {
28 size_t i; 29 size_t i;
@@ -204,16 +205,6 @@ size_t return_peers_for_torrent( ot_hash *hash, size_t amount, char *reply, int
204 return r - reply; 205 return r - reply;
205} 206}
206 207
207/* Release memory we allocated too much */
208void fix_mmapallocation( void *buf, size_t old_alloc, size_t new_alloc ) {
209 int page_size = getpagesize();
210 size_t old_pages = 1 + old_alloc / page_size;
211 size_t new_pages = 1 + new_alloc / page_size;
212
213 if( old_pages != new_pages )
214 munmap( ((char*)buf) + new_pages * page_size, old_alloc - new_pages * page_size );
215}
216
217/* Fetches scrape info for a specific torrent */ 208/* Fetches scrape info for a specific torrent */
218size_t return_udp_scrape_for_torrent( ot_hash *hash, char *reply ) { 209size_t return_udp_scrape_for_torrent( ot_hash *hash, char *reply ) {
219 int exactmatch; 210 int exactmatch;
@@ -326,7 +317,9 @@ int trackerlogic_init( const char * const serverdir ) {
326 mutex_init( ); 317 mutex_init( );
327 clean_init( ); 318 clean_init( );
328 fullscrape_init( ); 319 fullscrape_init( );
329 320#ifdef WANT_TRACKER_SYNC
321 sync_init( );
322#endif
330 return 0; 323 return 0;
331} 324}
332 325
@@ -348,7 +341,10 @@ void trackerlogic_deinit( void ) {
348 } 341 }
349 342
350 /* Deinitialise background worker threads */ 343 /* Deinitialise background worker threads */
351 fullscrape_init( ); 344#ifdef WANT_TRACKER_SYNC
345 sync_deinit( );
346#endif
347 fullscrape_deinit( );
352 clean_deinit( ); 348 clean_deinit( );
353 mutex_deinit( ); 349 mutex_deinit( );
354} 350}