diff options
Diffstat (limited to 'trackerlogic.c')
-rw-r--r-- | trackerlogic.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/trackerlogic.c b/trackerlogic.c index 756ed0f..47548fa 100644 --- a/trackerlogic.c +++ b/trackerlogic.c | |||
@@ -15,6 +15,7 @@ | |||
15 | /* Libowfat */ | 15 | /* Libowfat */ |
16 | #include "scan.h" | 16 | #include "scan.h" |
17 | #include "byte.h" | 17 | #include "byte.h" |
18 | #include "io.h" | ||
18 | 19 | ||
19 | /* Opentracker */ | 20 | /* Opentracker */ |
20 | #include "trackerlogic.h" | 21 | #include "trackerlogic.h" |
@@ -163,9 +164,9 @@ size_t return_peers_for_torrent( ot_hash *hash, size_t amount, char *reply, int | |||
163 | if( is_tcp ) | 164 | if( is_tcp ) |
164 | r += sprintf( r, "d8:completei%zde10:incompletei%zde8:intervali%ie5:peers%zd:", peer_list->seed_count, peer_list->peer_count-peer_list->seed_count, OT_CLIENT_REQUEST_INTERVAL_RANDOM, 6*amount ); | 165 | r += sprintf( r, "d8:completei%zde10:incompletei%zde8:intervali%ie5:peers%zd:", peer_list->seed_count, peer_list->peer_count-peer_list->seed_count, OT_CLIENT_REQUEST_INTERVAL_RANDOM, 6*amount ); |
165 | else { | 166 | else { |
166 | *(ot_dword*)(r+0) = htonl( OT_CLIENT_REQUEST_INTERVAL_RANDOM ); | 167 | *(uint32_t*)(r+0) = htonl( OT_CLIENT_REQUEST_INTERVAL_RANDOM ); |
167 | *(ot_dword*)(r+4) = htonl( peer_list->peer_count ); | 168 | *(uint32_t*)(r+4) = htonl( peer_list->peer_count ); |
168 | *(ot_dword*)(r+8) = htonl( peer_list->seed_count ); | 169 | *(uint32_t*)(r+8) = htonl( peer_list->seed_count ); |
169 | r += 12; | 170 | r += 12; |
170 | } | 171 | } |
171 | 172 | ||
@@ -216,7 +217,7 @@ size_t return_udp_scrape_for_torrent( ot_hash *hash, char *reply ) { | |||
216 | if( !exactmatch ) { | 217 | if( !exactmatch ) { |
217 | memset( reply, 0, 12); | 218 | memset( reply, 0, 12); |
218 | } else { | 219 | } else { |
219 | ot_dword *r = (ot_dword*) reply; | 220 | uint32_t *r = (uint32_t*) reply; |
220 | 221 | ||
221 | if( clean_single_torrent( torrent ) ) { | 222 | if( clean_single_torrent( torrent ) ) { |
222 | vector_remove_torrent( torrents_list, torrent ); | 223 | vector_remove_torrent( torrents_list, torrent ); |
@@ -273,8 +274,8 @@ size_t remove_peer_from_torrent( ot_hash *hash, ot_peer *peer, char *reply, int | |||
273 | return sprintf( reply, "d8:completei0e10:incompletei0e8:intervali%ie5:peers0:e", OT_CLIENT_REQUEST_INTERVAL_RANDOM ); | 274 | return sprintf( reply, "d8:completei0e10:incompletei0e8:intervali%ie5:peers0:e", OT_CLIENT_REQUEST_INTERVAL_RANDOM ); |
274 | 275 | ||
275 | /* Create fake packet to satisfy parser on the other end */ | 276 | /* Create fake packet to satisfy parser on the other end */ |
276 | ((ot_dword*)reply)[2] = htonl( OT_CLIENT_REQUEST_INTERVAL_RANDOM ); | 277 | ((uint32_t*)reply)[2] = htonl( OT_CLIENT_REQUEST_INTERVAL_RANDOM ); |
277 | ((ot_dword*)reply)[3] = ((ot_dword*)reply)[4] = 0; | 278 | ((uint32_t*)reply)[3] = ((uint32_t*)reply)[4] = 0; |
278 | return (size_t)20; | 279 | return (size_t)20; |
279 | } | 280 | } |
280 | 281 | ||
@@ -299,9 +300,9 @@ exit_loop: | |||
299 | } | 300 | } |
300 | 301 | ||
301 | /* else { Handle UDP reply */ | 302 | /* else { Handle UDP reply */ |
302 | ((ot_dword*)reply)[2] = htonl( OT_CLIENT_REQUEST_INTERVAL_RANDOM ); | 303 | ((uint32_t*)reply)[2] = htonl( OT_CLIENT_REQUEST_INTERVAL_RANDOM ); |
303 | ((ot_dword*)reply)[3] = peer_list->peer_count - peer_list->seed_count; | 304 | ((uint32_t*)reply)[3] = peer_list->peer_count - peer_list->seed_count; |
304 | ((ot_dword*)reply)[4] = peer_list->seed_count; | 305 | ((uint32_t*)reply)[4] = peer_list->seed_count; |
305 | 306 | ||
306 | mutex_bucket_unlock_by_hash( hash ); | 307 | mutex_bucket_unlock_by_hash( hash ); |
307 | return (size_t)20; | 308 | return (size_t)20; |
@@ -322,6 +323,7 @@ int trackerlogic_init( const char * const serverdir ) { | |||
322 | #ifdef WANT_TRACKER_SYNC | 323 | #ifdef WANT_TRACKER_SYNC |
323 | sync_init( ); | 324 | sync_init( ); |
324 | #endif | 325 | #endif |
326 | stats_init( ); | ||
325 | return 0; | 327 | return 0; |
326 | } | 328 | } |
327 | 329 | ||
@@ -343,6 +345,7 @@ void trackerlogic_deinit( void ) { | |||
343 | } | 345 | } |
344 | 346 | ||
345 | /* Deinitialise background worker threads */ | 347 | /* Deinitialise background worker threads */ |
348 | stats_deinit( ); | ||
346 | #ifdef WANT_TRACKER_SYNC | 349 | #ifdef WANT_TRACKER_SYNC |
347 | sync_deinit( ); | 350 | sync_deinit( ); |
348 | #endif | 351 | #endif |