diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-10-24 20:30:30 +0200 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-10-24 20:30:30 +0200 |
| commit | 96fa1b7327b35cdeca6c77f2fdde906cabc437d8 (patch) | |
| tree | 788e6989072decc9a1d6f4c85ec1c95cd49e4d3d | |
| parent | 6815f7a03324b5326e7b7d155c93caa1af5ea356 (diff) | |
Replace custom int64 with its standardized int64_t type
| -rw-r--r-- | opentracker.c | 16 | ||||
| -rw-r--r-- | ot_fullscrape.c | 2 | ||||
| -rw-r--r-- | ot_fullscrape.h | 2 | ||||
| -rw-r--r-- | ot_http.c | 16 | ||||
| -rw-r--r-- | ot_http.h | 6 | ||||
| -rw-r--r-- | ot_livesync.c | 4 | ||||
| -rw-r--r-- | ot_livesync.h | 2 | ||||
| -rw-r--r-- | ot_mutex.c | 10 | ||||
| -rw-r--r-- | ot_mutex.h | 14 | ||||
| -rw-r--r-- | ot_stats.c | 2 | ||||
| -rw-r--r-- | ot_stats.h | 2 | ||||
| -rw-r--r-- | ot_sync.c | 2 | ||||
| -rw-r--r-- | ot_sync.h | 4 | ||||
| -rw-r--r-- | ot_udp.c | 6 | ||||
| -rw-r--r-- | ot_udp.h | 6 | ||||
| -rw-r--r-- | proxy.c | 26 |
16 files changed, 62 insertions, 58 deletions
diff --git a/opentracker.c b/opentracker.c index 8a39bde..af336aa 100644 --- a/opentracker.c +++ b/opentracker.c | |||
| @@ -156,7 +156,7 @@ static ssize_t header_complete(char *request, ssize_t byte_count) { | |||
| 156 | return 0; | 156 | return 0; |
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | static void handle_dead(const int64 sock) { | 159 | static void handle_dead(const int64_t sock) { |
| 160 | struct http_data *cookie = io_getcookie(sock); | 160 | struct http_data *cookie = io_getcookie(sock); |
| 161 | if (cookie) { | 161 | if (cookie) { |
| 162 | size_t i; | 162 | size_t i; |
| @@ -171,7 +171,7 @@ static void handle_dead(const int64 sock) { | |||
| 171 | io_close(sock); | 171 | io_close(sock); |
| 172 | } | 172 | } |
| 173 | 173 | ||
| 174 | static void handle_read(const int64 sock, struct ot_workstruct *ws) { | 174 | static void handle_read(const int64_t sock, struct ot_workstruct *ws) { |
| 175 | struct http_data *cookie = io_getcookie(sock); | 175 | struct http_data *cookie = io_getcookie(sock); |
| 176 | ssize_t byte_count = io_tryread(sock, ws->inbuf, G_INBUF_SIZE); | 176 | ssize_t byte_count = io_tryread(sock, ws->inbuf, G_INBUF_SIZE); |
| 177 | 177 | ||
| @@ -215,7 +215,7 @@ static void handle_read(const int64 sock, struct ot_workstruct *ws) { | |||
| 215 | } | 215 | } |
| 216 | } | 216 | } |
| 217 | 217 | ||
| 218 | static void handle_write(const int64 sock) { | 218 | static void handle_write(const int64_t sock) { |
| 219 | struct http_data *cookie = io_getcookie(sock); | 219 | struct http_data *cookie = io_getcookie(sock); |
| 220 | size_t i; | 220 | size_t i; |
| 221 | int chunked = 0; | 221 | int chunked = 0; |
| @@ -227,7 +227,7 @@ static void handle_write(const int64 sock) { | |||
| 227 | 227 | ||
| 228 | for (i = 0; i < cookie->batches; ++i) { | 228 | for (i = 0; i < cookie->batches; ++i) { |
| 229 | if (cookie->batch[i].bytesleft) { | 229 | if (cookie->batch[i].bytesleft) { |
| 230 | int64 res = iob_send(sock, cookie->batch + i); | 230 | int64_t res = iob_send(sock, cookie->batch + i); |
| 231 | 231 | ||
| 232 | if (res == -3) { | 232 | if (res == -3) { |
| 233 | handle_dead(sock); | 233 | handle_dead(sock); |
| @@ -250,9 +250,9 @@ static void handle_write(const int64 sock) { | |||
| 250 | handle_dead(sock); | 250 | handle_dead(sock); |
| 251 | } | 251 | } |
| 252 | 252 | ||
| 253 | static void handle_accept(const int64 serversocket) { | 253 | static void handle_accept(const int64_t serversocket) { |
| 254 | struct http_data *cookie; | 254 | struct http_data *cookie; |
| 255 | int64 sock; | 255 | int64_t sock; |
| 256 | ot_ip6 ip; | 256 | ot_ip6 ip; |
| 257 | uint16 port; | 257 | uint16 port; |
| 258 | tai6464 t; | 258 | tai6464 t; |
| @@ -305,7 +305,7 @@ static void *server_mainloop(void *args) { | |||
| 305 | random_bytes(ws.rand48_state, sizeof(ws.rand48_state)); | 305 | random_bytes(ws.rand48_state, sizeof(ws.rand48_state)); |
| 306 | 306 | ||
| 307 | for (;;) { | 307 | for (;;) { |
| 308 | int64 sock; | 308 | int64_t sock; |
| 309 | 309 | ||
| 310 | io_wait(); | 310 | io_wait(); |
| 311 | 311 | ||
| @@ -339,7 +339,7 @@ static void *server_mainloop(void *args) { | |||
| 339 | } | 339 | } |
| 340 | 340 | ||
| 341 | static int64_t ot_try_bind(ot_ip6 ip, uint16_t port, PROTO_FLAG proto) { | 341 | static int64_t ot_try_bind(ot_ip6 ip, uint16_t port, PROTO_FLAG proto) { |
| 342 | int64 sock = proto == FLAG_TCP ? socket_tcp6() : socket_udp6(); | 342 | int64_t sock = proto == FLAG_TCP ? socket_tcp6() : socket_udp6(); |
| 343 | 343 | ||
| 344 | #ifdef _DEBUG | 344 | #ifdef _DEBUG |
| 345 | { | 345 | { |
diff --git a/ot_fullscrape.c b/ot_fullscrape.c index 3d0e2f1..9dcbe68 100644 --- a/ot_fullscrape.c +++ b/ot_fullscrape.c | |||
| @@ -82,7 +82,7 @@ void fullscrape_deinit(void) { | |||
| 82 | pthread_cancel( thread_id ); | 82 | pthread_cancel( thread_id ); |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | void fullscrape_deliver( int64 sock, ot_tasktype tasktype ) { | 85 | void fullscrape_deliver( int64_t sock, ot_tasktype tasktype ) { |
| 86 | mutex_workqueue_pushtask( sock, tasktype ); | 86 | mutex_workqueue_pushtask( sock, tasktype ); |
| 87 | } | 87 | } |
| 88 | 88 | ||
diff --git a/ot_fullscrape.h b/ot_fullscrape.h index 843e039..0e7690c 100644 --- a/ot_fullscrape.h +++ b/ot_fullscrape.h | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | 12 | ||
| 13 | void fullscrape_init(void); | 13 | void fullscrape_init(void); |
| 14 | void fullscrape_deinit(void); | 14 | void fullscrape_deinit(void); |
| 15 | void fullscrape_deliver(int64 sock, ot_tasktype tasktype); | 15 | void fullscrape_deliver(int64_t sock, ot_tasktype tasktype); |
| 16 | 16 | ||
| 17 | #else | 17 | #else |
| 18 | 18 | ||
| @@ -44,7 +44,7 @@ ssize_t g_stats_path_len; | |||
| 44 | 44 | ||
| 45 | enum { SUCCESS_HTTP_HEADER_LENGTH = 80, SUCCESS_HTTP_SIZE_OFF = 17 }; | 45 | enum { SUCCESS_HTTP_HEADER_LENGTH = 80, SUCCESS_HTTP_SIZE_OFF = 17 }; |
| 46 | 46 | ||
| 47 | static void http_senddata(const int64 sock, struct ot_workstruct *ws) { | 47 | static void http_senddata(const int64_t sock, struct ot_workstruct *ws) { |
| 48 | struct http_data *cookie = io_getcookie(sock); | 48 | struct http_data *cookie = io_getcookie(sock); |
| 49 | ssize_t written_size; | 49 | ssize_t written_size; |
| 50 | 50 | ||
| @@ -124,7 +124,7 @@ static void http_senddata(const int64 sock, struct ot_workstruct *ws) { | |||
| 124 | #define HTTPERROR_403_IP return http_issue_error(sock, ws, CODE_HTTPERROR_403_IP) | 124 | #define HTTPERROR_403_IP return http_issue_error(sock, ws, CODE_HTTPERROR_403_IP) |
| 125 | #define HTTPERROR_404 return http_issue_error(sock, ws, CODE_HTTPERROR_404) | 125 | #define HTTPERROR_404 return http_issue_error(sock, ws, CODE_HTTPERROR_404) |
| 126 | #define HTTPERROR_500 return http_issue_error(sock, ws, CODE_HTTPERROR_500) | 126 | #define HTTPERROR_500 return http_issue_error(sock, ws, CODE_HTTPERROR_500) |
| 127 | ssize_t http_issue_error(const int64 sock, struct ot_workstruct *ws, int code) { | 127 | ssize_t http_issue_error(const int64_t sock, struct ot_workstruct *ws, int code) { |
| 128 | char *error_code[] = {"302 Found", "400 Invalid Request", "400 Invalid Request", "400 Invalid Request", "402 Payment Required", | 128 | char *error_code[] = {"302 Found", "400 Invalid Request", "400 Invalid Request", "400 Invalid Request", "402 Payment Required", |
| 129 | "403 Not Modest", "403 Access Denied", "404 Not Found", "500 Internal Server Error"}; | 129 | "403 Not Modest", "403 Access Denied", "404 Not Found", "500 Internal Server Error"}; |
| 130 | char *title = error_code[code]; | 130 | char *title = error_code[code]; |
| @@ -144,7 +144,7 @@ ssize_t http_issue_error(const int64 sock, struct ot_workstruct *ws, int code) { | |||
| 144 | return ws->reply_size = -2; | 144 | return ws->reply_size = -2; |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | ssize_t http_sendiovecdata(const int64 sock, struct ot_workstruct *ws, size_t iovec_entries, struct iovec *iovector, int is_partial) { | 147 | ssize_t http_sendiovecdata(const int64_t sock, struct ot_workstruct *ws, size_t iovec_entries, struct iovec *iovector, int is_partial) { |
| 148 | struct http_data *cookie = io_getcookie(sock); | 148 | struct http_data *cookie = io_getcookie(sock); |
| 149 | io_batch *current; | 149 | io_batch *current; |
| 150 | char *header; | 150 | char *header; |
| @@ -243,7 +243,7 @@ ssize_t http_sendiovecdata(const int64 sock, struct ot_workstruct *ws, size_t io | |||
| 243 | return 0; | 243 | return 0; |
| 244 | } | 244 | } |
| 245 | 245 | ||
| 246 | static ssize_t http_handle_stats(const int64 sock, struct ot_workstruct *ws, char *read_ptr) { | 246 | static ssize_t http_handle_stats(const int64_t sock, struct ot_workstruct *ws, char *read_ptr) { |
| 247 | static const ot_keywords keywords_main[] = {{"mode", 1}, {"format", 2}, {"info_hash", 3}, {NULL, -3}}; | 247 | static const ot_keywords keywords_main[] = {{"mode", 1}, {"format", 2}, {"info_hash", 3}, {NULL, -3}}; |
| 248 | static const ot_keywords keywords_mode[] = {{"peer", TASK_STATS_PEERS}, | 248 | static const ot_keywords keywords_mode[] = {{"peer", TASK_STATS_PEERS}, |
| 249 | {"conn", TASK_STATS_CONNS}, | 249 | {"conn", TASK_STATS_CONNS}, |
| @@ -368,7 +368,7 @@ typedef struct { | |||
| 368 | #endif | 368 | #endif |
| 369 | 369 | ||
| 370 | #ifdef WANT_FULLSCRAPE | 370 | #ifdef WANT_FULLSCRAPE |
| 371 | static ssize_t http_handle_fullscrape(const int64 sock, struct ot_workstruct *ws) { | 371 | static ssize_t http_handle_fullscrape(const int64_t sock, struct ot_workstruct *ws) { |
| 372 | struct http_data *cookie = io_getcookie(sock); | 372 | struct http_data *cookie = io_getcookie(sock); |
| 373 | int format = 0; | 373 | int format = 0; |
| 374 | tai6464 t; | 374 | tai6464 t; |
| @@ -438,7 +438,7 @@ static ssize_t http_handle_fullscrape(const int64 sock, struct ot_workstruct *ws | |||
| 438 | } | 438 | } |
| 439 | #endif | 439 | #endif |
| 440 | 440 | ||
| 441 | static ssize_t http_handle_scrape(const int64 sock, struct ot_workstruct *ws, char *read_ptr) { | 441 | static ssize_t http_handle_scrape(const int64_t sock, struct ot_workstruct *ws, char *read_ptr) { |
| 442 | static const ot_keywords keywords_scrape[] = {{"info_hash", 1}, {NULL, -3}}; | 442 | static const ot_keywords keywords_scrape[] = {{"info_hash", 1}, {NULL, -3}}; |
| 443 | 443 | ||
| 444 | ot_hash *multiscrape_buf = (ot_hash *)ws->request; | 444 | ot_hash *multiscrape_buf = (ot_hash *)ws->request; |
| @@ -517,7 +517,7 @@ static ot_keywords keywords_announce[] = {{"port", 1}, {"left", 2}, {"event", | |||
| 517 | #endif | 517 | #endif |
| 518 | {"peer_id", 9}, {NULL, -3}}; | 518 | {"peer_id", 9}, {NULL, -3}}; |
| 519 | static ot_keywords keywords_announce_event[] = {{"completed", 1}, {"stopped", 2}, {NULL, -3}}; | 519 | static ot_keywords keywords_announce_event[] = {{"completed", 1}, {"stopped", 2}, {NULL, -3}}; |
| 520 | static ssize_t http_handle_announce(const int64 sock, struct ot_workstruct *ws, char *read_ptr) { | 520 | static ssize_t http_handle_announce(const int64_t sock, struct ot_workstruct *ws, char *read_ptr) { |
| 521 | size_t numwant; | 521 | size_t numwant; |
| 522 | int tmp, scanon; | 522 | int tmp, scanon; |
| 523 | unsigned short port = 0; | 523 | unsigned short port = 0; |
| @@ -695,7 +695,7 @@ static ssize_t http_handle_announce(const int64 sock, struct ot_workstruct * | |||
| 695 | return ws->reply_size; | 695 | return ws->reply_size; |
| 696 | } | 696 | } |
| 697 | 697 | ||
| 698 | ssize_t http_handle_request(const int64 sock, struct ot_workstruct *ws) { | 698 | ssize_t http_handle_request(const int64_t sock, struct ot_workstruct *ws) { |
| 699 | ssize_t reply_off, len; | 699 | ssize_t reply_off, len; |
| 700 | char *read_ptr = ws->request, *write_ptr; | 700 | char *read_ptr = ws->request, *write_ptr; |
| 701 | 701 | ||
| @@ -25,9 +25,9 @@ struct http_data { | |||
| 25 | STRUCT_HTTP_FLAG flag; | 25 | STRUCT_HTTP_FLAG flag; |
| 26 | }; | 26 | }; |
| 27 | 27 | ||
| 28 | ssize_t http_handle_request(const int64 s, struct ot_workstruct *ws); | 28 | ssize_t http_handle_request(const int64_t s, struct ot_workstruct *ws); |
| 29 | ssize_t http_sendiovecdata(const int64 s, struct ot_workstruct *ws, size_t iovec_entries, struct iovec *iovector, int is_partial); | 29 | ssize_t http_sendiovecdata(const int64_t s, struct ot_workstruct *ws, size_t iovec_entries, struct iovec *iovector, int is_partial); |
| 30 | ssize_t http_issue_error(const int64 s, struct ot_workstruct *ws, int code); | 30 | ssize_t http_issue_error(const int64_t s, struct ot_workstruct *ws, int code); |
| 31 | 31 | ||
| 32 | extern char *g_stats_path; | 32 | extern char *g_stats_path; |
| 33 | extern ssize_t g_stats_path_len; | 33 | extern ssize_t g_stats_path_len; |
diff --git a/ot_livesync.c b/ot_livesync.c index f6bb28b..8b2dee6 100644 --- a/ot_livesync.c +++ b/ot_livesync.c | |||
| @@ -40,10 +40,10 @@ enum { OT_SYNC_PEER4, OT_SYNC_PEER6 }; | |||
| 40 | static void *livesync_worker(void *args); | 40 | static void *livesync_worker(void *args); |
| 41 | 41 | ||
| 42 | /* For outgoing packets */ | 42 | /* For outgoing packets */ |
| 43 | static int64 g_socket_in = -1; | 43 | static int64_t g_socket_in = -1; |
| 44 | 44 | ||
| 45 | /* For incoming packets */ | 45 | /* For incoming packets */ |
| 46 | static int64 g_socket_out = -1; | 46 | static int64_t g_socket_out = -1; |
| 47 | 47 | ||
| 48 | static pthread_mutex_t g_outbuf_mutex = PTHREAD_MUTEX_INITIALIZER; | 48 | static pthread_mutex_t g_outbuf_mutex = PTHREAD_MUTEX_INITIALIZER; |
| 49 | typedef struct { | 49 | typedef struct { |
diff --git a/ot_livesync.h b/ot_livesync.h index ed710f0..6eca479 100644 --- a/ot_livesync.h +++ b/ot_livesync.h | |||
| @@ -62,7 +62,7 @@ void livesync_tell(struct ot_workstruct *ws); | |||
| 62 | void livesync_ticker(void); | 62 | void livesync_ticker(void); |
| 63 | 63 | ||
| 64 | /* Handle an incoming live sync packet */ | 64 | /* Handle an incoming live sync packet */ |
| 65 | void handle_livesync(const int64 sock); | 65 | void handle_livesync(const int64_t sock); |
| 66 | 66 | ||
| 67 | #else | 67 | #else |
| 68 | 68 | ||
| @@ -62,7 +62,7 @@ size_t mutex_get_torrent_count(void) { return g_torrent_count; } | |||
| 62 | struct ot_task { | 62 | struct ot_task { |
| 63 | ot_taskid taskid; | 63 | ot_taskid taskid; |
| 64 | ot_tasktype tasktype; | 64 | ot_tasktype tasktype; |
| 65 | int64 sock; | 65 | int64_t sock; |
| 66 | size_t iovec_entries; | 66 | size_t iovec_entries; |
| 67 | struct iovec *iovec; | 67 | struct iovec *iovec; |
| 68 | struct ot_task *next; | 68 | struct ot_task *next; |
| @@ -73,7 +73,7 @@ static struct ot_task *tasklist; | |||
| 73 | static pthread_mutex_t tasklist_mutex; | 73 | static pthread_mutex_t tasklist_mutex; |
| 74 | static pthread_cond_t tasklist_being_filled; | 74 | static pthread_cond_t tasklist_being_filled; |
| 75 | 75 | ||
| 76 | int mutex_workqueue_pushtask(int64 sock, ot_tasktype tasktype) { | 76 | int mutex_workqueue_pushtask(int64_t sock, ot_tasktype tasktype) { |
| 77 | struct ot_task **tmptask, *task; | 77 | struct ot_task **tmptask, *task; |
| 78 | 78 | ||
| 79 | task = malloc(sizeof(struct ot_task)); | 79 | task = malloc(sizeof(struct ot_task)); |
| @@ -102,7 +102,7 @@ int mutex_workqueue_pushtask(int64 sock, ot_tasktype tasktype) { | |||
| 102 | return 0; | 102 | return 0; |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | void mutex_workqueue_canceltask(int64 sock) { | 105 | void mutex_workqueue_canceltask(int64_t sock) { |
| 106 | struct ot_task **task; | 106 | struct ot_task **task; |
| 107 | 107 | ||
| 108 | /* Want exclusive access to tasklist */ | 108 | /* Want exclusive access to tasklist */ |
| @@ -227,9 +227,9 @@ int mutex_workqueue_pushchunked(ot_taskid taskid, struct iovec *iovec) { | |||
| 227 | return task ? 0 : -1; | 227 | return task ? 0 : -1; |
| 228 | } | 228 | } |
| 229 | 229 | ||
| 230 | int64 mutex_workqueue_popresult(size_t *iovec_entries, struct iovec **iovec, int *is_partial) { | 230 | int64_t mutex_workqueue_popresult(size_t *iovec_entries, struct iovec **iovec, int *is_partial) { |
| 231 | struct ot_task **task; | 231 | struct ot_task **task; |
| 232 | int64 sock = -1; | 232 | int64_t sock = -1; |
| 233 | 233 | ||
| 234 | *is_partial = 0; | 234 | *is_partial = 0; |
| 235 | 235 | ||
| @@ -69,12 +69,12 @@ typedef enum { | |||
| 69 | 69 | ||
| 70 | typedef unsigned long ot_taskid; | 70 | typedef unsigned long ot_taskid; |
| 71 | 71 | ||
| 72 | int mutex_workqueue_pushtask(int64 sock, ot_tasktype tasktype); | 72 | int mutex_workqueue_pushtask(int64_t sock, ot_tasktype tasktype); |
| 73 | void mutex_workqueue_canceltask(int64 sock); | 73 | void mutex_workqueue_canceltask(int64_t 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, size_t 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(size_t *iovec_entries, struct iovec **iovector, int *is_partial); | 78 | int64_t mutex_workqueue_popresult(size_t *iovec_entries, struct iovec **iovector, int *is_partial); |
| 79 | 79 | ||
| 80 | #endif | 80 | #endif |
| @@ -750,7 +750,7 @@ static void *stats_worker(void *args) { | |||
| 750 | return NULL; | 750 | return NULL; |
| 751 | } | 751 | } |
| 752 | 752 | ||
| 753 | void stats_deliver(int64 sock, int tasktype) { mutex_workqueue_pushtask(sock, tasktype); } | 753 | void stats_deliver(int64_t sock, int tasktype) { mutex_workqueue_pushtask(sock, tasktype); } |
| 754 | 754 | ||
| 755 | static pthread_t thread_id; | 755 | static pthread_t thread_id; |
| 756 | void stats_init(void) { | 756 | void stats_init(void) { |
| @@ -42,7 +42,7 @@ enum { | |||
| 42 | }; | 42 | }; |
| 43 | 43 | ||
| 44 | void stats_issue_event(ot_status_event event, PROTO_FLAG proto, uintptr_t event_data); | 44 | void stats_issue_event(ot_status_event event, PROTO_FLAG proto, uintptr_t event_data); |
| 45 | void stats_deliver(int64 sock, int tasktype); | 45 | void stats_deliver(int64_t sock, int tasktype); |
| 46 | void stats_cleanup(void); | 46 | void stats_cleanup(void); |
| 47 | size_t return_stats_for_tracker(char *reply, int mode, int format); | 47 | size_t return_stats_for_tracker(char *reply, int mode, int format); |
| 48 | size_t stats_return_tracker_version(char *reply); | 48 | size_t stats_return_tracker_version(char *reply); |
| @@ -163,7 +163,7 @@ void sync_deinit( ) { | |||
| 163 | pthread_cancel( thread_id ); | 163 | pthread_cancel( thread_id ); |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | void sync_deliver( int64 socket ) { | 166 | void sync_deliver( int64_t socket ) { |
| 167 | mutex_workqueue_pushtask( socket, TASK_SYNC_OUT ); | 167 | mutex_workqueue_pushtask( socket, TASK_SYNC_OUT ); |
| 168 | } | 168 | } |
| 169 | 169 | ||
| @@ -6,12 +6,14 @@ | |||
| 6 | #ifndef OT_SYNC_H__ | 6 | #ifndef OT_SYNC_H__ |
| 7 | #define OT_SYNC_H__ | 7 | #define OT_SYNC_H__ |
| 8 | 8 | ||
| 9 | #include <stdint.h> | ||
| 10 | |||
| 9 | #ifdef WANT_SYNC_BATCH | 11 | #ifdef WANT_SYNC_BATCH |
| 10 | enum { SYNC_IN, SYNC_OUT }; | 12 | enum { SYNC_IN, SYNC_OUT }; |
| 11 | 13 | ||
| 12 | void sync_init(); | 14 | void sync_init(); |
| 13 | void sync_deinit(); | 15 | void sync_deinit(); |
| 14 | void sync_deliver(int64 socket); | 16 | void sync_deliver(int64_t socket); |
| 15 | 17 | ||
| 16 | int add_changeset_to_tracker(uint8_t *data, size_t len); | 18 | int add_changeset_to_tracker(uint8_t *data, size_t len); |
| 17 | #else | 19 | #else |
| @@ -71,7 +71,7 @@ static void udp_make_connectionid(uint32_t connid[2], const ot_ip6 remoteip, int | |||
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | /* UDP implementation according to http://xbtt.sourceforge.net/udp_tracker_protocol.html */ | 73 | /* UDP implementation according to http://xbtt.sourceforge.net/udp_tracker_protocol.html */ |
| 74 | int handle_udp6(int64 serversocket, struct ot_workstruct *ws) { | 74 | int handle_udp6(int64_t serversocket, struct ot_workstruct *ws) { |
| 75 | ot_ip6 remoteip; | 75 | ot_ip6 remoteip; |
| 76 | uint32_t *inpacket = (uint32_t *)ws->inbuf; | 76 | uint32_t *inpacket = (uint32_t *)ws->inbuf; |
| 77 | uint32_t *outpacket = (uint32_t *)ws->outbuf; | 77 | uint32_t *outpacket = (uint32_t *)ws->outbuf; |
| @@ -203,7 +203,7 @@ int handle_udp6(int64 serversocket, struct ot_workstruct *ws) { | |||
| 203 | } | 203 | } |
| 204 | 204 | ||
| 205 | static void *udp_worker(void *args) { | 205 | static void *udp_worker(void *args) { |
| 206 | int64 sock = (int64)args; | 206 | int64_t sock = (int64_t)args; |
| 207 | struct ot_workstruct ws; | 207 | struct ot_workstruct ws; |
| 208 | memset(&ws, 0, sizeof(ws)); | 208 | memset(&ws, 0, sizeof(ws)); |
| 209 | 209 | ||
| @@ -229,7 +229,7 @@ static void *udp_worker(void *args) { | |||
| 229 | return NULL; | 229 | return NULL; |
| 230 | } | 230 | } |
| 231 | 231 | ||
| 232 | void udp_init(int64 sock, unsigned int worker_count) { | 232 | void udp_init(int64_t sock, unsigned int worker_count) { |
| 233 | pthread_t thread_id; | 233 | pthread_t thread_id; |
| 234 | if (!g_rijndael_round_key[0]) | 234 | if (!g_rijndael_round_key[0]) |
| 235 | udp_generate_rijndael_round_key(); | 235 | udp_generate_rijndael_round_key(); |
| @@ -6,8 +6,10 @@ | |||
| 6 | #ifndef OT_UDP_H__ | 6 | #ifndef OT_UDP_H__ |
| 7 | #define OT_UDP_H__ | 7 | #define OT_UDP_H__ |
| 8 | 8 | ||
| 9 | void udp_init(int64 sock, unsigned int worker_count); | 9 | #include <stdint.h> |
| 10 | |||
| 11 | void udp_init(int64_t sock, unsigned int worker_count); | ||
| 10 | void udp_kickoff(void); | 12 | void udp_kickoff(void); |
| 11 | int handle_udp6(int64 serversocket, struct ot_workstruct *ws); | 13 | int handle_udp6(int64_t serversocket, struct ot_workstruct *ws); |
| 12 | 14 | ||
| 13 | #endif | 15 | #endif |
| @@ -63,11 +63,11 @@ enum { OT_SYNC_PEER4, OT_SYNC_PEER6 }; | |||
| 63 | enum { FLAG_SERVERSOCKET = 1 }; | 63 | enum { FLAG_SERVERSOCKET = 1 }; |
| 64 | 64 | ||
| 65 | /* For incoming packets */ | 65 | /* For incoming packets */ |
| 66 | static int64 g_socket_in = -1; | 66 | static int64_t g_socket_in = -1; |
| 67 | static uint8_t g_inbuffer[LIVESYNC_INCOMING_BUFFSIZE]; | 67 | static uint8_t g_inbuffer[LIVESYNC_INCOMING_BUFFSIZE]; |
| 68 | 68 | ||
| 69 | /* For outgoing packets */ | 69 | /* For outgoing packets */ |
| 70 | static int64 g_socket_out = -1; | 70 | static int64_t g_socket_out = -1; |
| 71 | static uint8_t g_peerbuffer_start[LIVESYNC_OUTGOING_BUFFSIZE_PEERS]; | 71 | static uint8_t g_peerbuffer_start[LIVESYNC_OUTGOING_BUFFSIZE_PEERS]; |
| 72 | static uint8_t *g_peerbuffer_pos; | 72 | static uint8_t *g_peerbuffer_pos; |
| 73 | static uint8_t *g_peerbuffer_highwater = g_peerbuffer_start + LIVESYNC_OUTGOING_BUFFSIZE_PEERS - LIVESYNC_OUTGOING_WATERMARK_PEERS; | 73 | static uint8_t *g_peerbuffer_highwater = g_peerbuffer_start + LIVESYNC_OUTGOING_BUFFSIZE_PEERS - LIVESYNC_OUTGOING_WATERMARK_PEERS; |
| @@ -249,7 +249,7 @@ typedef struct { | |||
| 249 | uint8_t indata[8192 * 16]; /* Any data not processed yet */ | 249 | uint8_t indata[8192 * 16]; /* Any data not processed yet */ |
| 250 | size_t indata_length; /* Length of unprocessed data */ | 250 | size_t indata_length; /* Length of unprocessed data */ |
| 251 | uint32_t tracker_id; /* How the other end greeted */ | 251 | uint32_t tracker_id; /* How the other end greeted */ |
| 252 | int64 fd; /* A file handle, if connected, <= 0 is disconnected (0 initially, -1 else) */ | 252 | int64_t fd; /* A file handle, if connected, <= 0 is disconnected (0 initially, -1 else) */ |
| 253 | io_batch outdata; /* The iobatch containing our sync data */ | 253 | io_batch outdata; /* The iobatch containing our sync data */ |
| 254 | 254 | ||
| 255 | size_t packet_tcount; /* Number of unprocessed torrents in packet we currently receive */ | 255 | size_t packet_tcount; /* Number of unprocessed torrents in packet we currently receive */ |
| @@ -283,7 +283,7 @@ static void handle_reconnects(void) { | |||
| 283 | size_t i; | 283 | size_t i; |
| 284 | for (i = 0; i < g_connection_count; ++i) | 284 | for (i = 0; i < g_connection_count; ++i) |
| 285 | if (PROXYPEER_NEEDSCONNECT(g_connections[i].state)) { | 285 | if (PROXYPEER_NEEDSCONNECT(g_connections[i].state)) { |
| 286 | int64 newfd = socket_tcp6(); | 286 | int64_t newfd = socket_tcp6(); |
| 287 | fprintf(stderr, "(Re)connecting to peer..."); | 287 | fprintf(stderr, "(Re)connecting to peer..."); |
| 288 | if (newfd < 0) | 288 | if (newfd < 0) |
| 289 | continue; /* No socket for you */ | 289 | continue; /* No socket for you */ |
| @@ -308,10 +308,10 @@ static void handle_reconnects(void) { | |||
| 308 | } | 308 | } |
| 309 | 309 | ||
| 310 | /* Handle incoming connection requests, check against whitelist */ | 310 | /* Handle incoming connection requests, check against whitelist */ |
| 311 | static void handle_accept(int64 serversocket) { | 311 | static void handle_accept(int64_t serversocket) { |
| 312 | int64 newfd; | 312 | int64_t newfd; |
| 313 | ot_ip6 ip; | 313 | ot_ip6 ip; |
| 314 | uint16 port; | 314 | uint16 port; |
| 315 | 315 | ||
| 316 | while ((newfd = socket_accept6(serversocket, ip, &port, NULL)) != -1) { | 316 | while ((newfd = socket_accept6(serversocket, ip, &port, NULL)) != -1) { |
| 317 | 317 | ||
| @@ -351,9 +351,9 @@ static void handle_accept(int64 serversocket) { | |||
| 351 | } | 351 | } |
| 352 | 352 | ||
| 353 | /* New sync data on the stream */ | 353 | /* New sync data on the stream */ |
| 354 | static void handle_read(int64 peersocket) { | 354 | static void handle_read(int64_t peersocket) { |
| 355 | int i; | 355 | int i; |
| 356 | int64 datalen; | 356 | int64_t datalen; |
| 357 | uint32_t tracker_id; | 357 | uint32_t tracker_id; |
| 358 | proxy_peer *peer = io_getcookie(peersocket); | 358 | proxy_peer *peer = io_getcookie(peersocket); |
| 359 | 359 | ||
| @@ -420,7 +420,7 @@ static void handle_read(int64 peersocket) { | |||
| 420 | } | 420 | } |
| 421 | 421 | ||
| 422 | /* Can write new sync data to the stream */ | 422 | /* Can write new sync data to the stream */ |
| 423 | static void handle_write(int64 peersocket) { | 423 | static void handle_write(int64_t peersocket) { |
| 424 | proxy_peer *peer = io_getcookie(peersocket); | 424 | proxy_peer *peer = io_getcookie(peersocket); |
| 425 | 425 | ||
| 426 | if (!peer) { | 426 | if (!peer) { |
| @@ -472,7 +472,7 @@ static void handle_write(int64 peersocket) { | |||
| 472 | } | 472 | } |
| 473 | 473 | ||
| 474 | static void server_mainloop() { | 474 | static void server_mainloop() { |
| 475 | int64 sock; | 475 | int64_t sock; |
| 476 | uint32_t packet_type; | 476 | uint32_t packet_type; |
| 477 | 477 | ||
| 478 | /* inlined livesync_init() */ | 478 | /* inlined livesync_init() */ |
| @@ -515,7 +515,7 @@ static void panic(const char *routine) { | |||
| 515 | } | 515 | } |
| 516 | 516 | ||
| 517 | static int64_t ot_try_bind(ot_ip6 ip, uint16_t port) { | 517 | static int64_t ot_try_bind(ot_ip6 ip, uint16_t port) { |
| 518 | int64 sock = socket_tcp6(); | 518 | int64_t sock = socket_tcp6(); |
| 519 | 519 | ||
| 520 | if (socket_bind6_reuse(sock, ip, port, 0) == -1) | 520 | if (socket_bind6_reuse(sock, ip, port, 0) == -1) |
| 521 | panic("socket_bind6_reuse"); | 521 | panic("socket_bind6_reuse"); |
