diff options
author | erdgeist <> | 2009-03-17 23:57:20 +0000 |
---|---|---|
committer | erdgeist <> | 2009-03-17 23:57:20 +0000 |
commit | c7ed890222939ff9d9a3b575eb83f216ccfebe9e (patch) | |
tree | 09bcb2adbb64b2c3eb53bf20145262d13b258284 /trackerlogic.c | |
parent | a58bce83ad91fa264a79c9a9acc9358bb2aa5661 (diff) |
Fix white spaces
Introduce loading tracker states with -l
Alter tracker state to a human readable form
Diffstat (limited to 'trackerlogic.c')
-rw-r--r-- | trackerlogic.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/trackerlogic.c b/trackerlogic.c index 8ebaa46..1bd8ac7 100644 --- a/trackerlogic.c +++ b/trackerlogic.c | |||
@@ -41,6 +41,33 @@ void free_peerlist( ot_peerlist *peer_list ) { | |||
41 | free( peer_list ); | 41 | free( peer_list ); |
42 | } | 42 | } |
43 | 43 | ||
44 | void add_torrent_from_saved_state( ot_hash hash, ot_time base, size_t down_count ) { | ||
45 | int exactmatch; | ||
46 | ot_torrent *torrent; | ||
47 | ot_vector *torrents_list = mutex_bucket_lock_by_hash( hash ); | ||
48 | |||
49 | if( !accesslist_hashisvalid( hash ) ) | ||
50 | return mutex_bucket_unlock_by_hash( hash, 0 ); | ||
51 | |||
52 | torrent = vector_find_or_insert( torrents_list, (void*)hash, sizeof( ot_torrent ), OT_HASH_COMPARE_SIZE, &exactmatch ); | ||
53 | if( !torrent || exactmatch ) | ||
54 | return mutex_bucket_unlock_by_hash( hash, 0 ); | ||
55 | |||
56 | /* Create a new torrent entry, then */ | ||
57 | memcpy( torrent->hash, hash, sizeof(ot_hash) ); | ||
58 | |||
59 | if( !( torrent->peer_list = malloc( sizeof (ot_peerlist) ) ) ) { | ||
60 | vector_remove_torrent( torrents_list, torrent ); | ||
61 | return mutex_bucket_unlock_by_hash( hash, 0 ); | ||
62 | } | ||
63 | |||
64 | byte_zero( torrent->peer_list, sizeof( ot_peerlist ) ); | ||
65 | torrent->peer_list->base = base; | ||
66 | torrent->peer_list->down_count = down_count; | ||
67 | |||
68 | return mutex_bucket_unlock_by_hash( hash, 1 ); | ||
69 | } | ||
70 | |||
44 | size_t add_peer_to_torrent_and_return_peers( ot_hash hash, ot_peer *peer, PROTO_FLAG proto, size_t amount, char * reply ) { | 71 | size_t add_peer_to_torrent_and_return_peers( ot_hash hash, ot_peer *peer, PROTO_FLAG proto, size_t amount, char * reply ) { |
45 | int exactmatch, delta_torrentcount = 0; | 72 | int exactmatch, delta_torrentcount = 0; |
46 | size_t reply_size; | 73 | size_t reply_size; |
@@ -375,7 +402,7 @@ void trackerlogic_init( ) { | |||
375 | void trackerlogic_deinit( void ) { | 402 | void trackerlogic_deinit( void ) { |
376 | int bucket, delta_torrentcount = 0; | 403 | int bucket, delta_torrentcount = 0; |
377 | size_t j; | 404 | size_t j; |
378 | 405 | ||
379 | /* Free all torrents... */ | 406 | /* Free all torrents... */ |
380 | for(bucket=0; bucket<OT_BUCKET_COUNT; ++bucket ) { | 407 | for(bucket=0; bucket<OT_BUCKET_COUNT; ++bucket ) { |
381 | ot_vector *torrents_list = mutex_bucket_lock( bucket ); | 408 | ot_vector *torrents_list = mutex_bucket_lock( bucket ); |