diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-04-03 01:40:39 +0200 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-04-03 01:40:39 +0200 |
| commit | e4eb716d2688f5c2d4615d79ad5f4f1eb50a9343 (patch) | |
| tree | 5612056173478fecaad0a030195b6ed2f399df4d | |
| parent | b20b0b89264e9d28ab873b8b1cc9ba73cdb58aeb (diff) | |
turn all int offsets into size_t
| -rw-r--r-- | opentracker.c | 11 | ||||
| -rw-r--r-- | ot_accesslist.c | 12 | ||||
| -rw-r--r-- | ot_clean.c | 6 | ||||
| -rw-r--r-- | ot_fullscrape.c | 6 | ||||
| -rw-r--r-- | ot_http.c | 18 | ||||
| -rw-r--r-- | ot_http.h | 2 | ||||
| -rw-r--r-- | ot_iovec.c | 21 | ||||
| -rw-r--r-- | ot_iovec.h | 12 | ||||
| -rw-r--r-- | ot_mutex.c | 12 | ||||
| -rw-r--r-- | ot_mutex.h | 4 | ||||
| -rw-r--r-- | ot_stats.c | 29 | ||||
| -rw-r--r-- | ot_sync.c | 8 | ||||
| -rw-r--r-- | ot_vector.c | 8 | ||||
| -rw-r--r-- | ot_vector.h | 2 | ||||
| -rw-r--r-- | proxy.c | 6 | ||||
| -rw-r--r-- | trackerlogic.c | 16 | ||||
| -rw-r--r-- | trackerlogic.h | 2 |
17 files changed, 87 insertions, 88 deletions
diff --git a/opentracker.c b/opentracker.c index 14e9989..f63db72 100644 --- a/opentracker.c +++ b/opentracker.c | |||
| @@ -281,7 +281,8 @@ static void *server_mainloop(void *args) { | |||
| 281 | struct ot_workstruct ws; | 281 | struct ot_workstruct ws; |
| 282 | time_t next_timeout_check = g_now_seconds + OT_CLIENT_TIMEOUT_CHECKINTERVAL; | 282 | time_t next_timeout_check = g_now_seconds + OT_CLIENT_TIMEOUT_CHECKINTERVAL; |
| 283 | struct iovec *iovector; | 283 | struct iovec *iovector; |
| 284 | int iovec_entries, is_partial; | 284 | size_t iovec_entries; |
| 285 | int is_partial; | ||
| 285 | 286 | ||
| 286 | (void)args; | 287 | (void)args; |
| 287 | 288 | ||
| @@ -444,7 +445,7 @@ int parse_configfile(char *config_filename) { | |||
| 444 | #if defined(WANT_RESTRICT_STATS) || defined(WANT_IP_FROM_PROXY) || defined(WANT_SYNC_LIVE) | 445 | #if defined(WANT_RESTRICT_STATS) || defined(WANT_IP_FROM_PROXY) || defined(WANT_SYNC_LIVE) |
| 445 | ot_net tmpnet; | 446 | ot_net tmpnet; |
| 446 | #endif | 447 | #endif |
| 447 | int bound = 0; | 448 | int bound = 0; |
| 448 | 449 | ||
| 449 | accesslist_filehandle = fopen(config_filename, "r"); | 450 | accesslist_filehandle = fopen(config_filename, "r"); |
| 450 | 451 | ||
| @@ -566,15 +567,15 @@ void load_state(const char *const state_filename) { | |||
| 566 | 567 | ||
| 567 | /* We do ignore anything that is not of the form "^[:xdigit:]:\d+:\d+" */ | 568 | /* We do ignore anything that is not of the form "^[:xdigit:]:\d+:\d+" */ |
| 568 | while (fgets(inbuf, sizeof(inbuf), state_filehandle)) { | 569 | while (fgets(inbuf, sizeof(inbuf), state_filehandle)) { |
| 569 | int i; | 570 | size_t i; |
| 570 | for (i = 0; i < (int)sizeof(ot_hash); ++i) { | 571 | for (i = 0; i < sizeof(ot_hash); ++i) { |
| 571 | int eger = 16 * scan_fromhex(inbuf[2 * i]) + scan_fromhex(inbuf[1 + 2 * i]); | 572 | int eger = 16 * scan_fromhex(inbuf[2 * i]) + scan_fromhex(inbuf[1 + 2 * i]); |
| 572 | if (eger < 0) | 573 | if (eger < 0) |
| 573 | continue; | 574 | continue; |
| 574 | infohash[i] = eger; | 575 | infohash[i] = eger; |
| 575 | } | 576 | } |
| 576 | 577 | ||
| 577 | if (i != (int)sizeof(ot_hash)) | 578 | if (i != sizeof(ot_hash)) |
| 578 | continue; | 579 | continue; |
| 579 | i *= 2; | 580 | i *= 2; |
| 580 | 581 | ||
diff --git a/ot_accesslist.c b/ot_accesslist.c index 4b88c40..253fe95 100644 --- a/ot_accesslist.c +++ b/ot_accesslist.c | |||
| @@ -129,8 +129,8 @@ static void accesslist_readfile(void) { | |||
| 129 | 129 | ||
| 130 | /* We do ignore anything that is not of the form "^[:xdigit:]{40}[^:xdigit:].*" */ | 130 | /* We do ignore anything that is not of the form "^[:xdigit:]{40}[^:xdigit:].*" */ |
| 131 | while (read_offs <= map_end) { | 131 | while (read_offs <= map_end) { |
| 132 | int i; | 132 | size_t i; |
| 133 | for (i = 0; i < (int)sizeof(ot_hash); ++i) { | 133 | for (i = 0; i < sizeof(ot_hash); ++i) { |
| 134 | int eger1 = scan_fromhex((unsigned char)read_offs[2 * i]); | 134 | int eger1 = scan_fromhex((unsigned char)read_offs[2 * i]); |
| 135 | int eger2 = scan_fromhex((unsigned char)read_offs[1 + 2 * i]); | 135 | int eger2 = scan_fromhex((unsigned char)read_offs[1 + 2 * i]); |
| 136 | if (eger1 < 0 || eger2 < 0) | 136 | if (eger1 < 0 || eger2 < 0) |
| @@ -262,7 +262,7 @@ static void *accesslist_adddel_worker(char *fifoname, ot_accesslist *_Atomic | |||
| 262 | 262 | ||
| 263 | while ((linelen = getline(&line, &linecap, fifo)) > 0) { | 263 | while ((linelen = getline(&line, &linecap, fifo)) > 0) { |
| 264 | ot_hash info_hash; | 264 | ot_hash info_hash; |
| 265 | int i; | 265 | size_t i; |
| 266 | 266 | ||
| 267 | printf("Got line %*s", (int)linelen, line); | 267 | printf("Got line %*s", (int)linelen, line); |
| 268 | /* We do ignore anything that is not of the form "^[:xdigit:]{40}[^:xdigit:].*" | 268 | /* We do ignore anything that is not of the form "^[:xdigit:]{40}[^:xdigit:].*" |
| @@ -270,7 +270,7 @@ static void *accesslist_adddel_worker(char *fifoname, ot_accesslist *_Atomic | |||
| 270 | if (linelen < 41) | 270 | if (linelen < 41) |
| 271 | continue; | 271 | continue; |
| 272 | 272 | ||
| 273 | for (i = 0; i < (int)sizeof(ot_hash); ++i) { | 273 | for (i = 0; i < sizeof(ot_hash); ++i) { |
| 274 | int eger1 = scan_fromhex((unsigned char)line[2 * i]); | 274 | int eger1 = scan_fromhex((unsigned char)line[2 * i]); |
| 275 | int eger2 = scan_fromhex((unsigned char)line[1 + 2 * i]); | 275 | int eger2 = scan_fromhex((unsigned char)line[1 + 2 * i]); |
| 276 | if (eger1 < 0 || eger2 < 0) | 276 | if (eger1 < 0 || eger2 < 0) |
| @@ -511,7 +511,7 @@ int proxylist_check_proxy(const ot_ip6 proxy, const ot_ip6 address) { | |||
| 511 | 511 | ||
| 512 | static ot_net g_admin_nets[OT_ADMINIP_MAX]; | 512 | static ot_net g_admin_nets[OT_ADMINIP_MAX]; |
| 513 | static ot_permissions g_admin_nets_permissions[OT_ADMINIP_MAX]; | 513 | static ot_permissions g_admin_nets_permissions[OT_ADMINIP_MAX]; |
| 514 | static unsigned int g_admin_nets_count = 0; | 514 | static size_t g_admin_nets_count = 0; |
| 515 | 515 | ||
| 516 | int accesslist_bless_net(ot_net *net, ot_permissions permissions) { | 516 | int accesslist_bless_net(ot_net *net, ot_permissions permissions) { |
| 517 | if (g_admin_nets_count >= OT_ADMINIP_MAX) | 517 | if (g_admin_nets_count >= OT_ADMINIP_MAX) |
| @@ -553,7 +553,7 @@ int accesslist_bless_net(ot_net *net, ot_permissions permissions) { | |||
| 553 | } | 553 | } |
| 554 | 554 | ||
| 555 | int accesslist_is_blessed(ot_ip6 ip, ot_permissions permissions) { | 555 | int accesslist_is_blessed(ot_ip6 ip, ot_permissions permissions) { |
| 556 | unsigned int i; | 556 | size_t i; |
| 557 | for (i = 0; i < g_admin_nets_count; ++i) | 557 | for (i = 0; i < g_admin_nets_count; ++i) |
| 558 | if (address_in_net(ip, g_admin_nets + i) && (g_admin_nets_permissions[i] & permissions)) | 558 | if (address_in_net(ip, g_admin_nets + i) && (g_admin_nets_permissions[i] & permissions)) |
| 559 | return 1; | 559 | return 1; |
| @@ -20,7 +20,7 @@ | |||
| 20 | #include "trackerlogic.h" | 20 | #include "trackerlogic.h" |
| 21 | 21 | ||
| 22 | /* Returns amount of removed peers */ | 22 | /* Returns amount of removed peers */ |
| 23 | static ssize_t clean_single_bucket(ot_peer *peers, size_t peer_count, size_t peer_size, time_t timedout, int *removed_seeders) { | 23 | static ssize_t clean_single_bucket(ot_peer *peers, size_t peer_count, size_t peer_size, time_t timedout, size_t *removed_seeders) { |
| 24 | ot_peer *last_peer = peers + peer_count * peer_size, *insert_point; | 24 | ot_peer *last_peer = peers + peer_count * peer_size, *insert_point; |
| 25 | 25 | ||
| 26 | /* Two scan modes: unless there is one peer removed, just increase ot_peertime */ | 26 | /* Two scan modes: unless there is one peer removed, just increase ot_peertime */ |
| @@ -50,7 +50,7 @@ static ssize_t clean_single_bucket(ot_peer *peers, size_t peer_count, size_t pee | |||
| 50 | int clean_single_peer_list(ot_peerlist *peer_list, size_t peer_size) { | 50 | int clean_single_peer_list(ot_peerlist *peer_list, size_t peer_size) { |
| 51 | ot_vector *peer_vector = &peer_list->peers; | 51 | ot_vector *peer_vector = &peer_list->peers; |
| 52 | time_t timedout = (time_t)(g_now_minutes - peer_list->base); | 52 | time_t timedout = (time_t)(g_now_minutes - peer_list->base); |
| 53 | int num_buckets = 1, removed_seeders = 0; | 53 | size_t num_buckets = 1, removed_seeders = 0; |
| 54 | 54 | ||
| 55 | /* No need to clean empty torrent */ | 55 | /* No need to clean empty torrent */ |
| 56 | if (!timedout) | 56 | if (!timedout) |
| @@ -111,7 +111,7 @@ int clean_single_torrent(ot_torrent *torrent) { | |||
| 111 | static void *clean_worker(void *args) { | 111 | static void *clean_worker(void *args) { |
| 112 | (void)args; | 112 | (void)args; |
| 113 | while (1) { | 113 | while (1) { |
| 114 | int bucket = OT_BUCKET_COUNT; | 114 | size_t bucket = OT_BUCKET_COUNT; |
| 115 | while (bucket--) { | 115 | while (bucket--) { |
| 116 | ot_vector *torrents_list = mutex_bucket_lock(bucket); | 116 | ot_vector *torrents_list = mutex_bucket_lock(bucket); |
| 117 | size_t toffs; | 117 | size_t toffs; |
diff --git a/ot_fullscrape.c b/ot_fullscrape.c index 6fd6d1c..7a8cca6 100644 --- a/ot_fullscrape.c +++ b/ot_fullscrape.c | |||
| @@ -149,8 +149,8 @@ static char * fullscrape_write_one( ot_tasktype mode, char *r, ot_torrent *torre | |||
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | static void fullscrape_make(int taskid, ot_tasktype mode) { | 151 | static void fullscrape_make(int taskid, ot_tasktype mode) { |
| 152 | int bucket; | 152 | size_t bucket; |
| 153 | char *r, *re; | 153 | char *r, *re; |
| 154 | struct iovec iovector = {NULL, 0}; | 154 | struct iovec iovector = {NULL, 0}; |
| 155 | 155 | ||
| 156 | /* Setup return vector... */ | 156 | /* Setup return vector... */ |
| @@ -212,7 +212,7 @@ static void fullscrape_make(int taskid, ot_tasktype mode) { | |||
| 212 | #ifdef WANT_COMPRESSION_GZIP | 212 | #ifdef WANT_COMPRESSION_GZIP |
| 213 | 213 | ||
| 214 | static void fullscrape_make_gzip(int taskid, ot_tasktype mode) { | 214 | static void fullscrape_make_gzip(int taskid, ot_tasktype mode) { |
| 215 | int bucket; | 215 | size_t bucket; |
| 216 | char *r; | 216 | char *r; |
| 217 | struct iovec iovector = {NULL, 0}; | 217 | struct iovec iovector = {NULL, 0}; |
| 218 | int zres; | 218 | int zres; |
| @@ -141,13 +141,12 @@ ssize_t http_issue_error(const int64 sock, struct ot_workstruct *ws, int code) { | |||
| 141 | return ws->reply_size = -2; | 141 | return ws->reply_size = -2; |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | ssize_t http_sendiovecdata(const int64 sock, struct ot_workstruct *ws, int iovec_entries, struct iovec *iovector, int is_partial) { | 144 | ssize_t http_sendiovecdata(const int64 sock, struct ot_workstruct *ws, size_t iovec_entries, struct iovec *iovector, int is_partial) { |
| 145 | struct http_data *cookie = io_getcookie(sock); | 145 | struct http_data *cookie = io_getcookie(sock); |
| 146 | io_batch *current; | 146 | io_batch *current; |
| 147 | char *header; | 147 | char *header; |
| 148 | const char *encoding = ""; | 148 | const char *encoding = ""; |
| 149 | int i; | 149 | size_t i, header_size, size = iovec_length(&iovec_entries, (const struct iovec **)&iovector); |
| 150 | size_t header_size, size = iovec_length(&iovec_entries, (const struct iovec **)&iovector); | ||
| 151 | tai6464 t; | 150 | tai6464 t; |
| 152 | 151 | ||
| 153 | /* No cookie? Bad socket. Leave. */ | 152 | /* No cookie? Bad socket. Leave. */ |
| @@ -203,7 +202,7 @@ ssize_t http_sendiovecdata(const int64 sock, struct ot_workstruct *ws, int iovec | |||
| 203 | iob_addbuf_free(current, header, header_size); | 202 | iob_addbuf_free(current, header, header_size); |
| 204 | 203 | ||
| 205 | /* Split huge iovectors into separate io_batches */ | 204 | /* Split huge iovectors into separate io_batches */ |
| 206 | for (i = 0; i < iovec_entries; ++i) { | 205 | for (i = 0; i < (size_t)iovec_entries; ++i) { |
| 207 | /* If the current batch's limit is reached, try to reallocate a new batch to work on */ | 206 | /* If the current batch's limit is reached, try to reallocate a new batch to work on */ |
| 208 | if (current->bytesleft > OT_BATCH_LIMIT) { | 207 | if (current->bytesleft > OT_BATCH_LIMIT) { |
| 209 | io_batch *new_batch = realloc(cookie->batch, (cookie->batches + 1) * sizeof(io_batch)); | 208 | io_batch *new_batch = realloc(cookie->batch, (cookie->batches + 1) * sizeof(io_batch)); |
| @@ -426,8 +425,9 @@ static ssize_t http_handle_fullscrape(const int64 sock, struct ot_workstruct *ws | |||
| 426 | static ssize_t http_handle_scrape(const int64 sock, struct ot_workstruct *ws, char *read_ptr) { | 425 | static ssize_t http_handle_scrape(const int64 sock, struct ot_workstruct *ws, char *read_ptr) { |
| 427 | static const ot_keywords keywords_scrape[] = {{"info_hash", 1}, {NULL, -3}}; | 426 | static const ot_keywords keywords_scrape[] = {{"info_hash", 1}, {NULL, -3}}; |
| 428 | 427 | ||
| 429 | ot_hash *multiscrape_buf = (ot_hash *)ws->request; | 428 | ot_hash *multiscrape_buf = (ot_hash *)ws->request; |
| 430 | int scanon = 1, numwant = 0; | 429 | int scanon = 1; |
| 430 | size_t numwant = 0; | ||
| 431 | 431 | ||
| 432 | /* This is to hack around stupid clients that send "scrape ?info_hash" */ | 432 | /* This is to hack around stupid clients that send "scrape ?info_hash" */ |
| 433 | if (read_ptr[-1] != '?') { | 433 | if (read_ptr[-1] != '?') { |
| @@ -502,7 +502,8 @@ static ot_keywords keywords_announce[] = {{"port", 1}, {"left", 2}, {"event", | |||
| 502 | {"peer_id", 9}, {NULL, -3}}; | 502 | {"peer_id", 9}, {NULL, -3}}; |
| 503 | static ot_keywords keywords_announce_event[] = {{"completed", 1}, {"stopped", 2}, {NULL, -3}}; | 503 | static ot_keywords keywords_announce_event[] = {{"completed", 1}, {"stopped", 2}, {NULL, -3}}; |
| 504 | static ssize_t http_handle_announce(const int64 sock, struct ot_workstruct *ws, char *read_ptr) { | 504 | static ssize_t http_handle_announce(const int64 sock, struct ot_workstruct *ws, char *read_ptr) { |
| 505 | int numwant, tmp, scanon; | 505 | size_t numwant; |
| 506 | int tmp, scanon; | ||
| 506 | unsigned short port = 0; | 507 | unsigned short port = 0; |
| 507 | char *write_ptr; | 508 | char *write_ptr; |
| 508 | ssize_t len; | 509 | ssize_t len; |
| @@ -578,8 +579,9 @@ static ssize_t http_handle_announce(const int64 sock, struct ot_workstruct * | |||
| 578 | break; | 579 | break; |
| 579 | case 4: /* matched "numwant" */ | 580 | case 4: /* matched "numwant" */ |
| 580 | len = scan_urlencoded_query(&read_ptr, write_ptr = read_ptr, SCAN_SEARCHPATH_VALUE); | 581 | len = scan_urlencoded_query(&read_ptr, write_ptr = read_ptr, SCAN_SEARCHPATH_VALUE); |
| 581 | if ((len <= 0) || scan_fixed_int(write_ptr, len, &numwant)) | 582 | if ((len <= 0) || scan_fixed_int(write_ptr, len, &tmp)) |
| 582 | HTTPERROR_400_PARAM; | 583 | HTTPERROR_400_PARAM; |
| 584 | numwant = tmp; | ||
| 583 | if (numwant < 0) | 585 | if (numwant < 0) |
| 584 | numwant = 50; | 586 | numwant = 50; |
| 585 | if (numwant > 200) | 587 | if (numwant > 200) |
| @@ -24,7 +24,7 @@ struct http_data { | |||
| 24 | }; | 24 | }; |
| 25 | 25 | ||
| 26 | ssize_t http_handle_request(const int64 s, struct ot_workstruct *ws); | 26 | ssize_t http_handle_request(const int64 s, struct ot_workstruct *ws); |
| 27 | ssize_t http_sendiovecdata(const int64 s, struct ot_workstruct *ws, int iovec_entries, struct iovec *iovector, int is_partial); | 27 | ssize_t http_sendiovecdata(const int64 s, struct ot_workstruct *ws, size_t iovec_entries, struct iovec *iovector, int is_partial); |
| 28 | ssize_t http_issue_error(const int64 s, struct ot_workstruct *ws, int code); | 28 | ssize_t http_issue_error(const int64 s, struct ot_workstruct *ws, int code); |
| 29 | 29 | ||
| 30 | extern char *g_stats_path; | 30 | extern char *g_stats_path; |
| @@ -14,9 +14,9 @@ | |||
| 14 | /* Opentracker */ | 14 | /* Opentracker */ |
| 15 | #include "ot_iovec.h" | 15 | #include "ot_iovec.h" |
| 16 | 16 | ||
| 17 | void *iovec_increase(int *iovec_entries, struct iovec **iovector, size_t new_alloc) { | 17 | void *iovec_increase(size_t *iovec_entries, struct iovec **iovector, size_t new_alloc) { |
| 18 | void *new_data; | 18 | void *new_data; |
| 19 | int new_entries = 1 + *iovec_entries; | 19 | size_t new_entries = 1 + *iovec_entries; |
| 20 | struct iovec *new_vec = realloc(*iovector, new_entries * sizeof(struct iovec)); | 20 | struct iovec *new_vec = realloc(*iovector, new_entries * sizeof(struct iovec)); |
| 21 | 21 | ||
| 22 | if (!new_vec) | 22 | if (!new_vec) |
| @@ -35,8 +35,8 @@ void *iovec_increase(int *iovec_entries, struct iovec **iovector, size_t new_all | |||
| 35 | return new_data; | 35 | return new_data; |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | void *iovec_append(int *iovec_entries, struct iovec **iovector, struct iovec *append_iovector) { | 38 | void *iovec_append(size_t *iovec_entries, struct iovec **iovector, struct iovec *append_iovector) { |
| 39 | int new_entries = *iovec_entries + 1; | 39 | size_t new_entries = *iovec_entries + 1; |
| 40 | struct iovec *new_vec = realloc(*iovector, new_entries * sizeof(struct iovec)); | 40 | struct iovec *new_vec = realloc(*iovector, new_entries * sizeof(struct iovec)); |
| 41 | if (!new_vec) | 41 | if (!new_vec) |
| 42 | return NULL; | 42 | return NULL; |
| @@ -54,15 +54,15 @@ void *iovec_append(int *iovec_entries, struct iovec **iovector, struct iovec *ap | |||
| 54 | return new_vec; | 54 | return new_vec; |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | void iovec_free(int *iovec_entries, struct iovec **iovector) { | 57 | void iovec_free(size_t *iovec_entries, struct iovec **iovector) { |
| 58 | int i; | 58 | size_t i; |
| 59 | for (i = 0; i < *iovec_entries; ++i) | 59 | for (i = 0; i < *iovec_entries; ++i) |
| 60 | free(((*iovector)[i]).iov_base); | 60 | free(((*iovector)[i]).iov_base); |
| 61 | *iovector = NULL; | 61 | *iovector = NULL; |
| 62 | *iovec_entries = 0; | 62 | *iovec_entries = 0; |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | void iovec_fixlast(int *iovec_entries, struct iovec **iovector, void *last_ptr) { | 65 | void iovec_fixlast(size_t *iovec_entries, struct iovec **iovector, void *last_ptr) { |
| 66 | if (*iovec_entries) { | 66 | if (*iovec_entries) { |
| 67 | char *base = (char *)((*iovector)[*iovec_entries - 1]).iov_base; | 67 | char *base = (char *)((*iovector)[*iovec_entries - 1]).iov_base; |
| 68 | size_t new_alloc = ((char *)last_ptr) - base; | 68 | size_t new_alloc = ((char *)last_ptr) - base; |
| @@ -72,7 +72,7 @@ void iovec_fixlast(int *iovec_entries, struct iovec **iovector, void *last_ptr) | |||
| 72 | } | 72 | } |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | void *iovec_fix_increase_or_free(int *iovec_entries, struct iovec **iovector, void *last_ptr, size_t new_alloc) { | 75 | void *iovec_fix_increase_or_free(size_t *iovec_entries, struct iovec **iovector, void *last_ptr, size_t new_alloc) { |
| 76 | void *new_data; | 76 | void *new_data; |
| 77 | 77 | ||
| 78 | iovec_fixlast(iovec_entries, iovector, last_ptr); | 78 | iovec_fixlast(iovec_entries, iovector, last_ptr); |
| @@ -83,9 +83,8 @@ void *iovec_fix_increase_or_free(int *iovec_entries, struct iovec **iovector, vo | |||
| 83 | return new_data; | 83 | return new_data; |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | size_t iovec_length(const int *iovec_entries, const struct iovec **iovector) { | 86 | size_t iovec_length(const size_t *iovec_entries, const struct iovec **iovector) { |
| 87 | size_t length = 0; | 87 | size_t i, length = 0; |
| 88 | int i; | ||
| 89 | for (i = 0; i < *iovec_entries; ++i) | 88 | for (i = 0; i < *iovec_entries; ++i) |
| 90 | length += ((*iovector)[i]).iov_len; | 89 | length += ((*iovector)[i]).iov_len; |
| 91 | return length; | 90 | return length; |
| @@ -8,13 +8,13 @@ | |||
| 8 | 8 | ||
| 9 | #include <sys/uio.h> | 9 | #include <sys/uio.h> |
| 10 | 10 | ||
| 11 | void *iovec_increase(int *iovec_entries, struct iovec **iovector, size_t new_alloc); | 11 | void *iovec_increase(size_t *iovec_entries, struct iovec **iovector, size_t new_alloc); |
| 12 | void *iovec_append(int *iovec_entries, struct iovec **iovector, struct iovec *append_iovector); | 12 | void *iovec_append(size_t *iovec_entries, struct iovec **iovector, struct iovec *append_iovector); |
| 13 | void iovec_fixlast(int *iovec_entries, struct iovec **iovector, void *last_ptr); | 13 | void iovec_fixlast(size_t *iovec_entries, struct iovec **iovector, void *last_ptr); |
| 14 | void iovec_free(int *iovec_entries, struct iovec **iovector); | 14 | void iovec_free(size_t *iovec_entries, struct iovec **iovector); |
| 15 | 15 | ||
| 16 | size_t iovec_length(const int *iovec_entries, const struct iovec **iovector); | 16 | size_t iovec_length(const size_t *iovec_entries, const struct iovec **iovector); |
| 17 | 17 | ||
| 18 | void *iovec_fix_increase_or_free(int *iovec_entries, struct iovec **iovector, void *last_ptr, size_t new_alloc); | 18 | void *iovec_fix_increase_or_free(size_t *iovec_entries, struct iovec **iovector, void *last_ptr, size_t new_alloc); |
| 19 | 19 | ||
| 20 | #endif | 20 | #endif |
| @@ -56,7 +56,7 @@ struct ot_task { | |||
| 56 | ot_taskid taskid; | 56 | ot_taskid taskid; |
| 57 | ot_tasktype tasktype; | 57 | ot_tasktype tasktype; |
| 58 | int64 sock; | 58 | int64 sock; |
| 59 | int iovec_entries; | 59 | size_t iovec_entries; |
| 60 | struct iovec *iovec; | 60 | struct iovec *iovec; |
| 61 | struct ot_task *next; | 61 | struct ot_task *next; |
| 62 | }; | 62 | }; |
| @@ -105,7 +105,7 @@ void mutex_workqueue_canceltask(int64 sock) { | |||
| 105 | if ((*task)->sock == sock) { | 105 | if ((*task)->sock == sock) { |
| 106 | struct iovec *iovec = (*task)->iovec; | 106 | struct iovec *iovec = (*task)->iovec; |
| 107 | struct ot_task *ptask = *task; | 107 | struct ot_task *ptask = *task; |
| 108 | int i; | 108 | size_t i; |
| 109 | 109 | ||
| 110 | /* Free task's iovec */ | 110 | /* Free task's iovec */ |
| 111 | for (i = 0; i < (*task)->iovec_entries; ++i) | 111 | for (i = 0; i < (*task)->iovec_entries; ++i) |
| @@ -167,7 +167,7 @@ void mutex_workqueue_pushsuccess(ot_taskid taskid) { | |||
| 167 | pthread_mutex_unlock(&tasklist_mutex); | 167 | pthread_mutex_unlock(&tasklist_mutex); |
| 168 | } | 168 | } |
| 169 | 169 | ||
| 170 | int mutex_workqueue_pushresult(ot_taskid taskid, int iovec_entries, struct iovec *iovec) { | 170 | int mutex_workqueue_pushresult(ot_taskid taskid, size_t iovec_entries, struct iovec *iovec) { |
| 171 | struct ot_task *task; | 171 | struct ot_task *task; |
| 172 | const char byte = 'o'; | 172 | const char byte = 'o'; |
| 173 | 173 | ||
| @@ -219,7 +219,7 @@ int mutex_workqueue_pushchunked(ot_taskid taskid, struct iovec *iovec) { | |||
| 219 | return task ? 0 : -1; | 219 | return task ? 0 : -1; |
| 220 | } | 220 | } |
| 221 | 221 | ||
| 222 | int64 mutex_workqueue_popresult(int *iovec_entries, struct iovec **iovec, int *is_partial) { | 222 | int64 mutex_workqueue_popresult(size_t *iovec_entries, struct iovec **iovec, int *is_partial) { |
| 223 | struct ot_task **task; | 223 | struct ot_task **task; |
| 224 | int64 sock = -1; | 224 | int64 sock = -1; |
| 225 | 225 | ||
| @@ -254,7 +254,7 @@ int64 mutex_workqueue_popresult(int *iovec_entries, struct iovec **iovec, int *i | |||
| 254 | } | 254 | } |
| 255 | 255 | ||
| 256 | void mutex_init() { | 256 | void mutex_init() { |
| 257 | int i; | 257 | size_t i; |
| 258 | pthread_mutex_init(&tasklist_mutex, NULL); | 258 | pthread_mutex_init(&tasklist_mutex, NULL); |
| 259 | pthread_cond_init(&tasklist_being_filled, NULL); | 259 | pthread_cond_init(&tasklist_being_filled, NULL); |
| 260 | for (i = 0; i < OT_BUCKET_COUNT; ++i) | 260 | for (i = 0; i < OT_BUCKET_COUNT; ++i) |
| @@ -263,7 +263,7 @@ void mutex_init() { | |||
| 263 | } | 263 | } |
| 264 | 264 | ||
| 265 | void mutex_deinit() { | 265 | void mutex_deinit() { |
| 266 | int i; | 266 | size_t i; |
| 267 | for (i = 0; i < OT_BUCKET_COUNT; ++i) | 267 | for (i = 0; i < OT_BUCKET_COUNT; ++i) |
| 268 | pthread_mutex_destroy(bucket_mutex + i); | 268 | pthread_mutex_destroy(bucket_mutex + i); |
| 269 | pthread_mutex_destroy(&tasklist_mutex); | 269 | pthread_mutex_destroy(&tasklist_mutex); |
| @@ -73,8 +73,8 @@ int mutex_workqueue_pushtask(int64 sock, ot_tasktype tasktype) | |||
| 73 | void mutex_workqueue_canceltask(int64 sock); | 73 | void mutex_workqueue_canceltask(int64 sock); |
| 74 | void mutex_workqueue_pushsuccess(ot_taskid taskid); | 74 | void mutex_workqueue_pushsuccess(ot_taskid taskid); |
| 75 | ot_taskid mutex_workqueue_poptask(ot_tasktype *tasktype); | 75 | ot_taskid mutex_workqueue_poptask(ot_tasktype *tasktype); |
| 76 | int mutex_workqueue_pushresult(ot_taskid taskid, int iovec_entries, struct iovec *iovector); | 76 | int mutex_workqueue_pushresult(ot_taskid taskid, size_t iovec_entries, struct iovec *iovector); |
| 77 | int mutex_workqueue_pushchunked(ot_taskid taskid, struct iovec *iovec); | 77 | int mutex_workqueue_pushchunked(ot_taskid taskid, struct iovec *iovec); |
| 78 | int64 mutex_workqueue_popresult(int *iovec_entries, struct iovec **iovector, int *is_partial); | 78 | int64 mutex_workqueue_popresult(size_t *iovec_entries, struct iovec **iovector, int *is_partial); |
| 79 | 79 | ||
| 80 | #endif | 80 | #endif |
| @@ -38,7 +38,7 @@ | |||
| 38 | #endif | 38 | #endif |
| 39 | 39 | ||
| 40 | /* Forward declaration */ | 40 | /* Forward declaration */ |
| 41 | static void stats_make(int *iovec_entries, struct iovec **iovector, ot_tasktype mode); | 41 | static void stats_make(size_t *iovec_entries, struct iovec **iovector, ot_tasktype mode); |
| 42 | #define OT_STATS_TMPSIZE 8192 | 42 | #define OT_STATS_TMPSIZE 8192 |
| 43 | 43 | ||
| 44 | /* Clumsy counters... to be rethought */ | 44 | /* Clumsy counters... to be rethought */ |
| @@ -113,7 +113,7 @@ static int stat_increase_network_count(stats_network_node **pnode, int depth, ui | |||
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | static int stats_shift_down_network_count(stats_network_node **node, int depth, int shift) { | 115 | static int stats_shift_down_network_count(stats_network_node **node, int depth, int shift) { |
| 116 | int i, rest = 0; | 116 | size_t i, rest = 0; |
| 117 | 117 | ||
| 118 | if (!*node) | 118 | if (!*node) |
| 119 | return 0; | 119 | return 0; |
| @@ -134,8 +134,7 @@ static int stats_shift_down_network_count(stats_network_node **node, int depth, | |||
| 134 | 134 | ||
| 135 | static size_t stats_get_highscore_networks(stats_network_node *node, int depth, ot_ip6 node_value, size_t *scores, ot_ip6 *networks, int network_count, | 135 | static size_t stats_get_highscore_networks(stats_network_node *node, int depth, ot_ip6 node_value, size_t *scores, ot_ip6 *networks, int network_count, |
| 136 | int limit) { | 136 | int limit) { |
| 137 | size_t score = 0; | 137 | size_t i, score = 0; |
| 138 | int i; | ||
| 139 | 138 | ||
| 140 | if (!node) | 139 | if (!node) |
| 141 | return 0; | 140 | return 0; |
| @@ -195,7 +194,7 @@ static size_t stats_return_busy_networks(char *reply, stats_network_node *tree, | |||
| 195 | ot_ip6 networks[amount]; | 194 | ot_ip6 networks[amount]; |
| 196 | ot_ip6 node_value; | 195 | ot_ip6 node_value; |
| 197 | size_t scores[amount]; | 196 | size_t scores[amount]; |
| 198 | int i; | 197 | size_t i; |
| 199 | char *r = reply; | 198 | char *r = reply; |
| 200 | 199 | ||
| 201 | memset(scores, 0, sizeof(scores)); | 200 | memset(scores, 0, sizeof(scores)); |
| @@ -225,8 +224,7 @@ static size_t stats_return_busy_networks(char *reply, stats_network_node *tree, | |||
| 225 | static size_t stats_slash24s_txt(char *reply, size_t amount) { | 224 | static size_t stats_slash24s_txt(char *reply, size_t amount) { |
| 226 | stats_network_node *slash24s_network_counters_root = NULL; | 225 | stats_network_node *slash24s_network_counters_root = NULL; |
| 227 | char *r = reply; | 226 | char *r = reply; |
| 228 | int bucket; | 227 | size_t i, bucket, peer_size = OT_PEER_SIZE4; |
| 229 | size_t i, peer_size = OT_PEER_SIZE4; | ||
| 230 | 228 | ||
| 231 | for (bucket = 0; bucket < OT_BUCKET_COUNT; ++bucket) { | 229 | for (bucket = 0; bucket < OT_BUCKET_COUNT; ++bucket) { |
| 232 | ot_vector *torrents_list = mutex_bucket_lock(bucket); | 230 | ot_vector *torrents_list = mutex_bucket_lock(bucket); |
| @@ -318,11 +316,10 @@ typedef struct { | |||
| 318 | } ot_record; | 316 | } ot_record; |
| 319 | 317 | ||
| 320 | /* Fetches stats from tracker */ | 318 | /* Fetches stats from tracker */ |
| 321 | size_t stats_top_txt(char *reply, int amount) { | 319 | size_t stats_top_txt(char *reply, size_t amount) { |
| 322 | size_t j; | 320 | size_t j, idx, bucket; |
| 323 | ot_record top100s[100], top100c[100], top100l[100]; | 321 | ot_record top100s[100], top100c[100], top100l[100]; |
| 324 | char *r = reply, hex_out[42]; | 322 | char *r = reply, hex_out[42]; |
| 325 | int idx, bucket; | ||
| 326 | 323 | ||
| 327 | if (amount > 100) | 324 | if (amount > 100) |
| 328 | amount = 100; | 325 | amount = 100; |
| @@ -368,15 +365,15 @@ size_t stats_top_txt(char *reply, int amount) { | |||
| 368 | return 0; | 365 | return 0; |
| 369 | } | 366 | } |
| 370 | 367 | ||
| 371 | r += sprintf(r, "Top %d torrents by peers:\n", amount); | 368 | r += sprintf(r, "Top %zd torrents by peers:\n", amount); |
| 372 | for (idx = 0; idx < amount; ++idx) | 369 | for (idx = 0; idx < amount; ++idx) |
| 373 | if (top100c[idx].val) | 370 | if (top100c[idx].val) |
| 374 | r += sprintf(r, "\t%zd\t%s\n", top100c[idx].val, to_hex(hex_out, top100c[idx].hash)); | 371 | r += sprintf(r, "\t%zd\t%s\n", top100c[idx].val, to_hex(hex_out, top100c[idx].hash)); |
| 375 | r += sprintf(r, "Top %d torrents by seeds:\n", amount); | 372 | r += sprintf(r, "Top %zd torrents by seeds:\n", amount); |
| 376 | for (idx = 0; idx < amount; ++idx) | 373 | for (idx = 0; idx < amount; ++idx) |
| 377 | if (top100s[idx].val) | 374 | if (top100s[idx].val) |
| 378 | r += sprintf(r, "\t%zd\t%s\n", top100s[idx].val, to_hex(hex_out, top100s[idx].hash)); | 375 | r += sprintf(r, "\t%zd\t%s\n", top100s[idx].val, to_hex(hex_out, top100s[idx].hash)); |
| 379 | r += sprintf(r, "Top %d torrents by leechers:\n", amount); | 376 | r += sprintf(r, "Top %zd torrents by leechers:\n", amount); |
| 380 | for (idx = 0; idx < amount; ++idx) | 377 | for (idx = 0; idx < amount; ++idx) |
| 381 | if (top100l[idx].val) | 378 | if (top100l[idx].val) |
| 382 | r += sprintf(r, "\t%zd\t%s\n", top100l[idx].val, to_hex(hex_out, top100l[idx].hash)); | 379 | r += sprintf(r, "\t%zd\t%s\n", top100l[idx].val, to_hex(hex_out, top100l[idx].hash)); |
| @@ -477,7 +474,7 @@ static size_t stats_return_numwants(char *reply) { | |||
| 477 | #endif | 474 | #endif |
| 478 | 475 | ||
| 479 | #ifdef WANT_FULLLOG_NETWORKS | 476 | #ifdef WANT_FULLLOG_NETWORKS |
| 480 | static void stats_return_fulllog(int *iovec_entries, struct iovec **iovector, char *r) { | 477 | static void stats_return_fulllog(size_t *iovec_entries, struct iovec **iovector, char *r) { |
| 481 | ot_log *loglist = g_logchain_first, *llnext; | 478 | ot_log *loglist = g_logchain_first, *llnext; |
| 482 | char *re = r + OT_STATS_TMPSIZE; | 479 | char *re = r + OT_STATS_TMPSIZE; |
| 483 | 480 | ||
| @@ -591,7 +588,7 @@ size_t return_stats_for_tracker(char *reply, int mode, int format) { | |||
| 591 | } | 588 | } |
| 592 | } | 589 | } |
| 593 | 590 | ||
| 594 | static void stats_make(int *iovec_entries, struct iovec **iovector, ot_tasktype mode) { | 591 | static void stats_make(size_t *iovec_entries, struct iovec **iovector, ot_tasktype mode) { |
| 595 | char *r; | 592 | char *r; |
| 596 | 593 | ||
| 597 | *iovec_entries = 0; | 594 | *iovec_entries = 0; |
| @@ -757,7 +754,7 @@ void stats_cleanup() { | |||
| 757 | } | 754 | } |
| 758 | 755 | ||
| 759 | static void *stats_worker(void *args) { | 756 | static void *stats_worker(void *args) { |
| 760 | int iovec_entries; | 757 | size_t iovec_entries; |
| 761 | struct iovec *iovector; | 758 | struct iovec *iovector; |
| 762 | 759 | ||
| 763 | (void)args; | 760 | (void)args; |
| @@ -72,9 +72,9 @@ int add_changeset_to_tracker(uint8_t *data, size_t len) { | |||
| 72 | /* Proposed output format | 72 | /* Proposed output format |
| 73 | d4:syncd20:<info_hash>8*N:(xxxxyyyy)*Nee | 73 | d4:syncd20:<info_hash>8*N:(xxxxyyyy)*Nee |
| 74 | */ | 74 | */ |
| 75 | static void sync_make(int *iovec_entries, struct iovec **iovector) { | 75 | static void sync_make(size_t *iovec_entries, struct iovec **iovector) { |
| 76 | int bucket; | 76 | size_t bucket; |
| 77 | char *r, *re; | 77 | char *r, *re; |
| 78 | 78 | ||
| 79 | /* Setup return vector... */ | 79 | /* Setup return vector... */ |
| 80 | *iovec_entries = 0; | 80 | *iovec_entries = 0; |
| @@ -140,7 +140,7 @@ static void sync_make(int *iovec_entries, struct iovec **iovector) { | |||
| 140 | It grabs tasks from mutex_tasklist and delivers results back | 140 | It grabs tasks from mutex_tasklist and delivers results back |
| 141 | */ | 141 | */ |
| 142 | static void *sync_worker(void *args) { | 142 | static void *sync_worker(void *args) { |
| 143 | int iovec_entries; | 143 | size_t iovec_entries; |
| 144 | struct iovec *iovector; | 144 | struct iovec *iovector; |
| 145 | 145 | ||
| 146 | args = args; | 146 | args = args; |
diff --git a/ot_vector.c b/ot_vector.c index 2acfbef..d068999 100644 --- a/ot_vector.c +++ b/ot_vector.c | |||
| @@ -45,7 +45,7 @@ void *binary_search(const void *const key, const void *base, const size_t member | |||
| 45 | return (void *)base; | 45 | return (void *)base; |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | static uint8_t vector_hash_peer(ot_peer const *peer, size_t compare_size, int bucket_count) { | 48 | static uint8_t vector_hash_peer(ot_peer const *peer, size_t compare_size, size_t bucket_count) { |
| 49 | unsigned int hash = 5381; | 49 | unsigned int hash = 5381; |
| 50 | uint8_t *p = (uint8_t *)peer; | 50 | uint8_t *p = (uint8_t *)peer; |
| 51 | while (compare_size--) | 51 | while (compare_size--) |
| @@ -172,7 +172,7 @@ void vector_remove_torrent(ot_vector *vector, ot_torrent *match) { | |||
| 172 | } | 172 | } |
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | void vector_clean_list(ot_vector *vector, int num_buckets) { | 175 | void vector_clean_list(ot_vector *vector, size_t num_buckets) { |
| 176 | while (num_buckets--) | 176 | while (num_buckets--) |
| 177 | free(vector[num_buckets].data); | 177 | free(vector[num_buckets].data); |
| 178 | free(vector); | 178 | free(vector); |
| @@ -180,7 +180,7 @@ void vector_clean_list(ot_vector *vector, int num_buckets) { | |||
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | void vector_redistribute_buckets(ot_peerlist *peer_list, size_t peer_size) { | 182 | void vector_redistribute_buckets(ot_peerlist *peer_list, size_t peer_size) { |
| 183 | int tmp, bucket, bucket_size_new, num_buckets_new, num_buckets_old = 1; | 183 | size_t tmp, bucket, bucket_size_new, num_buckets_new, num_buckets_old = 1; |
| 184 | ot_vector *bucket_list_new, *bucket_list_old = &peer_list->peers; | 184 | ot_vector *bucket_list_new, *bucket_list_old = &peer_list->peers; |
| 185 | int (*sort_func)(const void *, const void *) = peer_size == OT_PEER_SIZE6 ? &vector_compare_peer6 : &vector_compare_peer4; | 185 | int (*sort_func)(const void *, const void *) = peer_size == OT_PEER_SIZE6 ? &vector_compare_peer6 : &vector_compare_peer4; |
| 186 | 186 | ||
| @@ -229,7 +229,7 @@ void vector_redistribute_buckets(ot_peerlist *peer_list, size_t peer_size) { | |||
| 229 | /* Now sort them into the correct bucket */ | 229 | /* Now sort them into the correct bucket */ |
| 230 | for (bucket = 0; bucket < num_buckets_old; ++bucket) { | 230 | for (bucket = 0; bucket < num_buckets_old; ++bucket) { |
| 231 | ot_peer *peers_old = bucket_list_old[bucket].data; | 231 | ot_peer *peers_old = bucket_list_old[bucket].data; |
| 232 | int peer_count_old = bucket_list_old[bucket].size; | 232 | size_t peer_count_old = bucket_list_old[bucket].size; |
| 233 | while (peer_count_old--) { | 233 | while (peer_count_old--) { |
| 234 | ot_vector *bucket_dest = bucket_list_new; | 234 | ot_vector *bucket_dest = bucket_list_new; |
| 235 | if (num_buckets_new > 1) | 235 | if (num_buckets_new > 1) |
diff --git a/ot_vector.h b/ot_vector.h index 8d41452..2618363 100644 --- a/ot_vector.h +++ b/ot_vector.h | |||
| @@ -31,6 +31,6 @@ void vector_remove_torrent(ot_vector *vector, ot_torrent *match); | |||
| 31 | /* For ot_clean.c */ | 31 | /* For ot_clean.c */ |
| 32 | void vector_redistribute_buckets(ot_peerlist *peer_list, size_t peer_size); | 32 | void vector_redistribute_buckets(ot_peerlist *peer_list, size_t peer_size); |
| 33 | void vector_fixup_peers(ot_vector *vector, size_t peer_size); | 33 | void vector_fixup_peers(ot_vector *vector, size_t peer_size); |
| 34 | void vector_clean_list(ot_vector *vector, int num_buckets); | 34 | void vector_clean_list(ot_vector *vector, size_t num_buckets); |
| 35 | 35 | ||
| 36 | #endif | 36 | #endif |
| @@ -276,12 +276,12 @@ void reset_info_block(proxy_peer *peer) { | |||
| 276 | * Multiple connections to/from the same ip are okay, if tracker_id doesn't match | 276 | * Multiple connections to/from the same ip are okay, if tracker_id doesn't match |
| 277 | * Reconnect attempts occur only twice a minute | 277 | * Reconnect attempts occur only twice a minute |
| 278 | */ | 278 | */ |
| 279 | static int g_connection_count; | 279 | static size_t g_connection_count; |
| 280 | static ot_time g_connection_reconn; | 280 | static ot_time g_connection_reconn; |
| 281 | static proxy_peer g_connections[MAX_PEERS]; | 281 | static proxy_peer g_connections[MAX_PEERS]; |
| 282 | 282 | ||
| 283 | static void handle_reconnects(void) { | 283 | static void handle_reconnects(void) { |
| 284 | int i; | 284 | size_t i; |
| 285 | for (i = 0; i < g_connection_count; ++i) | 285 | for (i = 0; i < g_connection_count; ++i) |
| 286 | if (PROXYPEER_NEEDSCONNECT(g_connections[i].state)) { | 286 | if (PROXYPEER_NEEDSCONNECT(g_connections[i].state)) { |
| 287 | int64 newfd = socket_tcp6(); | 287 | int64 newfd = socket_tcp6(); |
| @@ -625,7 +625,7 @@ int main(int argc, char **argv) { | |||
| 625 | static void *streamsync_worker(void *args) { | 625 | static void *streamsync_worker(void *args) { |
| 626 | (void)args; | 626 | (void)args; |
| 627 | while (1) { | 627 | while (1) { |
| 628 | int bucket; | 628 | size_t bucket; |
| 629 | /* For each bucket... */ | 629 | /* For each bucket... */ |
| 630 | for (bucket = 0; bucket < OT_BUCKET_COUNT; ++bucket) { | 630 | for (bucket = 0; bucket < OT_BUCKET_COUNT; ++bucket) { |
| 631 | /* Get exclusive access to that bucket */ | 631 | /* Get exclusive access to that bucket */ |
diff --git a/trackerlogic.c b/trackerlogic.c index 04df544..1e25ec8 100644 --- a/trackerlogic.c +++ b/trackerlogic.c | |||
| @@ -195,7 +195,7 @@ size_t add_peer_to_torrent_and_return_peers(PROTO_FLAG proto, struct ot_workstru | |||
| 195 | } | 195 | } |
| 196 | 196 | ||
| 197 | static size_t return_peers_all(ot_peerlist *peer_list, size_t peer_size, char *reply) { | 197 | static size_t return_peers_all(ot_peerlist *peer_list, size_t peer_size, char *reply) { |
| 198 | unsigned int bucket, num_buckets = 1; | 198 | size_t bucket, num_buckets = 1; |
| 199 | ot_vector *bucket_list = &peer_list->peers; | 199 | ot_vector *bucket_list = &peer_list->peers; |
| 200 | size_t compare_size = OT_PEER_COMPARE_SIZE_FROM_PEER_SIZE(peer_size); | 200 | size_t compare_size = OT_PEER_COMPARE_SIZE_FROM_PEER_SIZE(peer_size); |
| 201 | size_t result = compare_size * peer_list->peer_count; | 201 | size_t result = compare_size * peer_list->peer_count; |
| @@ -224,7 +224,7 @@ static size_t return_peers_all(ot_peerlist *peer_list, size_t peer_size, char *r | |||
| 224 | } | 224 | } |
| 225 | 225 | ||
| 226 | static size_t return_peers_selection(struct ot_workstruct *ws, ot_peerlist *peer_list, size_t peer_size, size_t amount, char *reply) { | 226 | static size_t return_peers_selection(struct ot_workstruct *ws, ot_peerlist *peer_list, size_t peer_size, size_t amount, char *reply) { |
| 227 | unsigned int bucket_offset, bucket_index = 0, num_buckets = 1; | 227 | size_t bucket_offset, bucket_index = 0, num_buckets = 1; |
| 228 | ot_vector *bucket_list = &peer_list->peers; | 228 | ot_vector *bucket_list = &peer_list->peers; |
| 229 | unsigned int shifted_pc = peer_list->peer_count; | 229 | unsigned int shifted_pc = peer_list->peer_count; |
| 230 | unsigned int shifted_step = 0; | 230 | unsigned int shifted_step = 0; |
| @@ -403,9 +403,10 @@ size_t return_udp_scrape_for_torrent(ot_hash const hash, char *reply) { | |||
| 403 | } | 403 | } |
| 404 | 404 | ||
| 405 | /* Fetches scrape info for a specific torrent */ | 405 | /* Fetches scrape info for a specific torrent */ |
| 406 | size_t return_tcp_scrape_for_torrent(ot_hash const *hash_list, int amount, char *reply) { | 406 | size_t return_tcp_scrape_for_torrent(ot_hash const *hash_list, size_t amount, char *reply) { |
| 407 | char *r = reply; | 407 | char *r = reply; |
| 408 | int exactmatch, i; | 408 | int exactmatch; |
| 409 | size_t i; | ||
| 409 | 410 | ||
| 410 | r += sprintf(r, "d5:filesd"); | 411 | r += sprintf(r, "d5:filesd"); |
| 411 | 412 | ||
| @@ -489,8 +490,7 @@ size_t remove_peer_from_torrent(PROTO_FLAG proto, struct ot_workstruct *ws) { | |||
| 489 | } | 490 | } |
| 490 | 491 | ||
| 491 | void iterate_all_torrents(int (*for_each)(ot_torrent *torrent, uintptr_t data), uintptr_t data) { | 492 | void iterate_all_torrents(int (*for_each)(ot_torrent *torrent, uintptr_t data), uintptr_t data) { |
| 492 | int bucket; | 493 | size_t bucket, j; |
| 493 | size_t j; | ||
| 494 | 494 | ||
| 495 | for (bucket = 0; bucket < OT_BUCKET_COUNT; ++bucket) { | 495 | for (bucket = 0; bucket < OT_BUCKET_COUNT; ++bucket) { |
| 496 | ot_vector *torrents_list = mutex_bucket_lock(bucket); | 496 | ot_vector *torrents_list = mutex_bucket_lock(bucket); |
| @@ -569,8 +569,8 @@ void trackerlogic_init() { | |||
| 569 | } | 569 | } |
| 570 | 570 | ||
| 571 | void trackerlogic_deinit(void) { | 571 | void trackerlogic_deinit(void) { |
| 572 | int bucket, delta_torrentcount = 0; | 572 | int delta_torrentcount = 0; |
| 573 | size_t j; | 573 | size_t bucket, j; |
| 574 | 574 | ||
| 575 | /* Free all torrents... */ | 575 | /* Free all torrents... */ |
| 576 | for (bucket = 0; bucket < OT_BUCKET_COUNT; ++bucket) { | 576 | for (bucket = 0; bucket < OT_BUCKET_COUNT; ++bucket) { |
diff --git a/trackerlogic.h b/trackerlogic.h index 022184d..88d9a11 100644 --- a/trackerlogic.h +++ b/trackerlogic.h | |||
| @@ -194,7 +194,7 @@ void exerr(char *message); | |||
| 194 | otherwise it is released in return_peers_for_torrent */ | 194 | otherwise it is released in return_peers_for_torrent */ |
| 195 | size_t add_peer_to_torrent_and_return_peers(PROTO_FLAG proto, struct ot_workstruct *ws, size_t amount); | 195 | size_t add_peer_to_torrent_and_return_peers(PROTO_FLAG proto, struct ot_workstruct *ws, size_t amount); |
| 196 | size_t remove_peer_from_torrent(PROTO_FLAG proto, struct ot_workstruct *ws); | 196 | size_t remove_peer_from_torrent(PROTO_FLAG proto, struct ot_workstruct *ws); |
| 197 | size_t return_tcp_scrape_for_torrent(ot_hash const *hash_list, int amount, char *reply); | 197 | size_t return_tcp_scrape_for_torrent(ot_hash const *hash_list, size_t amount, char *reply); |
| 198 | size_t return_udp_scrape_for_torrent(ot_hash const hash, char *reply); | 198 | size_t return_udp_scrape_for_torrent(ot_hash const hash, char *reply); |
| 199 | void add_torrent_from_saved_state(ot_hash const hash, ot_time base, size_t down_count); | 199 | void add_torrent_from_saved_state(ot_hash const hash, ot_time base, size_t down_count); |
| 200 | #ifdef _DEBUG_RANDOMTORRENTS | 200 | #ifdef _DEBUG_RANDOMTORRENTS |
