diff options
Diffstat (limited to 'src/ot_workqueue.h')
| -rw-r--r-- | src/ot_workqueue.h | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/ot_workqueue.h b/src/ot_workqueue.h new file mode 100644 index 0000000..982292e --- /dev/null +++ b/src/ot_workqueue.h | |||
| @@ -0,0 +1,73 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | ||
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ | ||
| 3 | |||
| 4 | #ifndef OT_WORKQUEUE_H__ | ||
| 5 | #define OT_WORKQUEUE_H__ | ||
| 6 | |||
| 7 | #include <stdint.h> | ||
| 8 | #include <sys/uio.h> | ||
| 9 | |||
| 10 | #include "trackerlogic.h" | ||
| 11 | |||
| 12 | /* Work the tracker hands to a thread of its own: a full scrape or an | ||
| 13 | expensive stats page, which take too long to build while a client waits. | ||
| 14 | The task goes in here, the reply comes back out. */ | ||
| 15 | |||
| 16 | typedef enum { | ||
| 17 | TASK_STATS_CONNS = 0x0001, | ||
| 18 | TASK_STATS_TCP = 0x0002, | ||
| 19 | TASK_STATS_UDP = 0x0003, | ||
| 20 | TASK_STATS_SCRAPE = 0x0004, | ||
| 21 | TASK_STATS_FULLSCRAPE = 0x0005, | ||
| 22 | TASK_STATS_TPB = 0x0006, | ||
| 23 | TASK_STATS_HTTPERRORS = 0x0007, | ||
| 24 | TASK_STATS_RENEW = 0x000a, | ||
| 25 | TASK_STATS_SYNCS = 0x000b, | ||
| 26 | TASK_STATS_COMPLETED = 0x000c, | ||
| 27 | TASK_STATS_NUMWANTS = 0x000d, | ||
| 28 | |||
| 29 | TASK_STATS = 0x0100, /* Mask */ | ||
| 30 | TASK_STATS_TORRENTS = 0x0101, | ||
| 31 | TASK_STATS_PEERS = 0x0102, | ||
| 32 | TASK_STATS_TOP10 = 0x0104, | ||
| 33 | TASK_STATS_TOP100 = 0x0105, | ||
| 34 | TASK_STATS_EVERYTHING = 0x0106, | ||
| 35 | TASK_STATS_WOODPECKERS = 0x0108, | ||
| 36 | |||
| 37 | TASK_FULLSCRAPE = 0x0200, /* Default mode */ | ||
| 38 | TASK_FULLSCRAPE_TPB_BINARY = 0x0201, | ||
| 39 | TASK_FULLSCRAPE_TPB_ASCII = 0x0202, | ||
| 40 | TASK_FULLSCRAPE_TPB_ASCII_PLUS = 0x0203, | ||
| 41 | TASK_FULLSCRAPE_TPB_URLENCODED = 0x0204, | ||
| 42 | TASK_FULLSCRAPE_TRACKERSTATE = 0x0205, | ||
| 43 | |||
| 44 | TASK_DMEM = 0x0300, | ||
| 45 | |||
| 46 | TASK_DONE = 0x0f00, | ||
| 47 | TASK_DONE_PARTIAL = 0x0f01, | ||
| 48 | |||
| 49 | TASK_FLAG_GZIP = 0x1000, | ||
| 50 | TASK_FLAG_BZIP2 = 0x2000, | ||
| 51 | TASK_FLAG_ZSTD = 0x4000, | ||
| 52 | TASK_FLAG_CHUNKED = 0x8000, | ||
| 53 | |||
| 54 | TASK_TASK_MASK = 0x0fff, | ||
| 55 | TASK_CLASS_MASK = 0x0f00, | ||
| 56 | TASK_FLAGS_MASK = 0xf000 | ||
| 57 | } ot_tasktype; | ||
| 58 | |||
| 59 | typedef unsigned long ot_taskid; | ||
| 60 | |||
| 61 | int workqueue_pushtask(int64_t sock, ot_tasktype tasktype); | ||
| 62 | void workqueue_canceltask(int64_t sock); | ||
| 63 | void workqueue_pushsuccess(ot_taskid taskid); | ||
| 64 | ot_taskid workqueue_poptask(ot_tasktype *tasktype); | ||
| 65 | int workqueue_pushresult(ot_taskid taskid, size_t iovec_entries, struct iovec *iovector); | ||
| 66 | int workqueue_pushchunked(ot_taskid taskid, struct iovec *iovec); | ||
| 67 | int64_t workqueue_popresult(size_t *iovec_entries, struct iovec **iovector, int *is_partial, uint32_t *generation); | ||
| 68 | |||
| 69 | void workqueue_init(void); | ||
| 70 | void workqueue_deinit(void); | ||
| 71 | void workqueue_wakeall(void); | ||
| 72 | |||
| 73 | #endif | ||
