summaryrefslogtreecommitdiff
path: root/src/ot_workqueue.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/ot_workqueue.h')
-rw-r--r--src/ot_workqueue.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/ot_workqueue.h b/src/ot_workqueue.h
new file mode 100644
index 0000000..82ae29b
--- /dev/null
+++ b/src/ot_workqueue.h
@@ -0,0 +1,74 @@
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
16typedef 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_SLASH24S = 0x0103,
33 TASK_STATS_TOP10 = 0x0104,
34 TASK_STATS_TOP100 = 0x0105,
35 TASK_STATS_EVERYTHING = 0x0106,
36 TASK_STATS_WOODPECKERS = 0x0108,
37
38 TASK_FULLSCRAPE = 0x0200, /* Default mode */
39 TASK_FULLSCRAPE_TPB_BINARY = 0x0201,
40 TASK_FULLSCRAPE_TPB_ASCII = 0x0202,
41 TASK_FULLSCRAPE_TPB_ASCII_PLUS = 0x0203,
42 TASK_FULLSCRAPE_TPB_URLENCODED = 0x0204,
43 TASK_FULLSCRAPE_TRACKERSTATE = 0x0205,
44
45 TASK_DMEM = 0x0300,
46
47 TASK_DONE = 0x0f00,
48 TASK_DONE_PARTIAL = 0x0f01,
49
50 TASK_FLAG_GZIP = 0x1000,
51 TASK_FLAG_BZIP2 = 0x2000,
52 TASK_FLAG_ZSTD = 0x4000,
53 TASK_FLAG_CHUNKED = 0x8000,
54
55 TASK_TASK_MASK = 0x0fff,
56 TASK_CLASS_MASK = 0x0f00,
57 TASK_FLAGS_MASK = 0xf000
58} ot_tasktype;
59
60typedef unsigned long ot_taskid;
61
62int workqueue_pushtask(int64_t sock, ot_tasktype tasktype);
63void workqueue_canceltask(int64_t sock);
64void workqueue_pushsuccess(ot_taskid taskid);
65ot_taskid workqueue_poptask(ot_tasktype *tasktype);
66int workqueue_pushresult(ot_taskid taskid, size_t iovec_entries, struct iovec *iovector);
67int workqueue_pushchunked(ot_taskid taskid, struct iovec *iovec);
68int64_t workqueue_popresult(size_t *iovec_entries, struct iovec **iovector, int *is_partial);
69
70void workqueue_init(void);
71void workqueue_deinit(void);
72void workqueue_wakeall(void);
73
74#endif