diff options
Diffstat (limited to 'trackerlogic.c')
| -rw-r--r-- | trackerlogic.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/trackerlogic.c b/trackerlogic.c index 94ec71a..a76064e 100644 --- a/trackerlogic.c +++ b/trackerlogic.c | |||
| @@ -48,12 +48,16 @@ void add_torrent_from_saved_state(ot_hash const hash, ot_time base, size_t down_ | |||
| 48 | ot_torrent *torrent; | 48 | ot_torrent *torrent; |
| 49 | ot_vector *torrents_list = mutex_bucket_lock_by_hash(hash); | 49 | ot_vector *torrents_list = mutex_bucket_lock_by_hash(hash); |
| 50 | 50 | ||
| 51 | if (!accesslist_hashisvalid(hash)) | 51 | if (!accesslist_hashisvalid(hash)) { |
| 52 | return mutex_bucket_unlock_by_hash(hash, 0); | 52 | mutex_bucket_unlock_by_hash(hash, 0); |
| 53 | return; | ||
| 54 | } | ||
| 53 | 55 | ||
| 54 | torrent = vector_find_or_insert(torrents_list, (void *)hash, sizeof(ot_torrent), OT_HASH_COMPARE_SIZE, &exactmatch); | 56 | torrent = vector_find_or_insert(torrents_list, (void *)hash, sizeof(ot_torrent), OT_HASH_COMPARE_SIZE, &exactmatch); |
| 55 | if (!torrent || exactmatch) | 57 | if (!torrent || exactmatch) { |
| 56 | return mutex_bucket_unlock_by_hash(hash, 0); | 58 | mutex_bucket_unlock_by_hash(hash, 0); |
| 59 | return; | ||
| 60 | } | ||
| 57 | 61 | ||
| 58 | /* Create a new torrent entry, then */ | 62 | /* Create a new torrent entry, then */ |
| 59 | memset(torrent, 0, sizeof(ot_torrent)); | 63 | memset(torrent, 0, sizeof(ot_torrent)); |
| @@ -61,7 +65,8 @@ void add_torrent_from_saved_state(ot_hash const hash, ot_time base, size_t down_ | |||
| 61 | 65 | ||
| 62 | if (!(torrent->peer_list6 = malloc(sizeof(ot_peerlist))) || !(torrent->peer_list4 = malloc(sizeof(ot_peerlist)))) { | 66 | if (!(torrent->peer_list6 = malloc(sizeof(ot_peerlist))) || !(torrent->peer_list4 = malloc(sizeof(ot_peerlist)))) { |
| 63 | vector_remove_torrent(torrents_list, torrent); | 67 | vector_remove_torrent(torrents_list, torrent); |
| 64 | return mutex_bucket_unlock_by_hash(hash, 0); | 68 | mutex_bucket_unlock_by_hash(hash, 0); |
| 69 | return; | ||
| 65 | } | 70 | } |
| 66 | 71 | ||
| 67 | memset(torrent->peer_list6, 0, sizeof(ot_peerlist)); | 72 | memset(torrent->peer_list6, 0, sizeof(ot_peerlist)); |
| @@ -71,7 +76,7 @@ void add_torrent_from_saved_state(ot_hash const hash, ot_time base, size_t down_ | |||
| 71 | torrent->peer_list6->down_count = down_count; | 76 | torrent->peer_list6->down_count = down_count; |
| 72 | torrent->peer_list4->down_count = down_count; | 77 | torrent->peer_list4->down_count = down_count; |
| 73 | 78 | ||
| 74 | return mutex_bucket_unlock_by_hash(hash, 1); | 79 | mutex_bucket_unlock_by_hash(hash, 1); |
| 75 | } | 80 | } |
| 76 | 81 | ||
| 77 | size_t add_peer_to_torrent_and_return_peers(PROTO_FLAG proto, struct ot_workstruct *ws, size_t amount) { | 82 | size_t add_peer_to_torrent_and_return_peers(PROTO_FLAG proto, struct ot_workstruct *ws, size_t amount) { |
