diff options
| -rw-r--r-- | DESIGN | 39 | ||||
| -rw-r--r-- | Makefile | 191 | ||||
| -rw-r--r-- | Mk/gzip.mk (renamed from Makefile.gzip) | 2 | ||||
| -rw-r--r-- | Mk/proxy.mk | 25 | ||||
| -rw-r--r-- | Mk/release.mk | 27 | ||||
| -rw-r--r-- | Mk/tests.mk | 72 | ||||
| -rw-r--r-- | Mk/zstd.mk (renamed from Makefile.zstd) | 2 | ||||
| -rw-r--r-- | README_v6 | 1 | ||||
| -rw-r--r-- | man1/opentracker.1 | 6 | ||||
| -rw-r--r-- | man5/opentracker.conf.5 (renamed from man4/opentracker.conf.4) | 2 | ||||
| -rw-r--r-- | ot_clean.h | 21 | ||||
| -rw-r--r-- | src/opentracker.c (renamed from opentracker.c) | 4 | ||||
| -rw-r--r-- | src/ot_accesslist.c (renamed from ot_accesslist.c) | 4 | ||||
| -rw-r--r-- | src/ot_accesslist.h (renamed from ot_accesslist.h) | 4 | ||||
| -rw-r--r-- | src/ot_batch.c (renamed from ot_batch.c) | 4 | ||||
| -rw-r--r-- | src/ot_batch.h (renamed from ot_batch.h) | 4 | ||||
| -rw-r--r-- | src/ot_buf.c (renamed from ot_buf.c) | 4 | ||||
| -rw-r--r-- | src/ot_buf.h (renamed from ot_buf.h) | 4 | ||||
| -rw-r--r-- | src/ot_clean.c (renamed from ot_clean.c) | 42 | ||||
| -rw-r--r-- | src/ot_clean.h | 28 | ||||
| -rw-r--r-- | src/ot_config.c (renamed from ot_config.c) | 4 | ||||
| -rw-r--r-- | src/ot_config.h (renamed from ot_config.h) | 4 | ||||
| -rw-r--r-- | src/ot_event.c (renamed from ot_event.c) | 4 | ||||
| -rw-r--r-- | src/ot_event.h (renamed from ot_event.h) | 4 | ||||
| -rw-r--r-- | src/ot_fdstate.c (renamed from ot_fdstate.c) | 4 | ||||
| -rw-r--r-- | src/ot_fdstate.h (renamed from ot_fdstate.h) | 4 | ||||
| -rw-r--r-- | src/ot_fmt.c (renamed from ot_fmt.c) | 4 | ||||
| -rw-r--r-- | src/ot_fmt.h (renamed from ot_fmt.h) | 4 | ||||
| -rw-r--r-- | src/ot_fullscrape.c (renamed from ot_fullscrape.c) | 4 | ||||
| -rw-r--r-- | src/ot_fullscrape.h (renamed from ot_fullscrape.h) | 4 | ||||
| -rw-r--r-- | src/ot_hex.c (renamed from ot_hex.c) | 4 | ||||
| -rw-r--r-- | src/ot_hex.h (renamed from ot_hex.h) | 4 | ||||
| -rw-r--r-- | src/ot_http.c (renamed from ot_http.c) | 4 | ||||
| -rw-r--r-- | src/ot_http.h (renamed from ot_http.h) | 4 | ||||
| -rw-r--r-- | src/ot_iovec.c (renamed from ot_iovec.c) | 4 | ||||
| -rw-r--r-- | src/ot_iovec.h (renamed from ot_iovec.h) | 4 | ||||
| -rw-r--r-- | src/ot_ip.c (renamed from ot_ip.c) | 4 | ||||
| -rw-r--r-- | src/ot_ip.h (renamed from ot_ip.h) | 4 | ||||
| -rw-r--r-- | src/ot_livesync.c (renamed from ot_livesync.c) | 4 | ||||
| -rw-r--r-- | src/ot_livesync.h (renamed from ot_livesync.h) | 4 | ||||
| -rw-r--r-- | src/ot_mutex.c (renamed from ot_mutex.c) | 4 | ||||
| -rw-r--r-- | src/ot_mutex.h (renamed from ot_mutex.h) | 4 | ||||
| -rw-r--r-- | src/ot_random.c (renamed from ot_random.c) | 4 | ||||
| -rw-r--r-- | src/ot_random.h (renamed from ot_random.h) | 4 | ||||
| -rw-r--r-- | src/ot_rijndael.c (renamed from ot_rijndael.c) | 0 | ||||
| -rw-r--r-- | src/ot_rijndael.h (renamed from ot_rijndael.h) | 4 | ||||
| -rw-r--r-- | src/ot_scan.c (renamed from ot_scan.c) | 4 | ||||
| -rw-r--r-- | src/ot_scan.h (renamed from ot_scan.h) | 4 | ||||
| -rw-r--r-- | src/ot_socket.c (renamed from ot_socket.c) | 4 | ||||
| -rw-r--r-- | src/ot_socket.h (renamed from ot_socket.h) | 4 | ||||
| -rw-r--r-- | src/ot_stats.c (renamed from ot_stats.c) | 6 | ||||
| -rw-r--r-- | src/ot_stats.h (renamed from ot_stats.h) | 4 | ||||
| -rw-r--r-- | src/ot_tcp.c (renamed from ot_tcp.c) | 4 | ||||
| -rw-r--r-- | src/ot_tcp.h (renamed from ot_tcp.h) | 4 | ||||
| -rw-r--r-- | src/ot_udp.c (renamed from ot_udp.c) | 4 | ||||
| -rw-r--r-- | src/ot_udp.h (renamed from ot_udp.h) | 4 | ||||
| -rw-r--r-- | src/ot_urlencoded.c (renamed from ot_urlencoded.c) | 4 | ||||
| -rw-r--r-- | src/ot_urlencoded.h (renamed from ot_urlencoded.h) | 4 | ||||
| -rw-r--r-- | src/ot_vector.c (renamed from ot_vector.c) | 4 | ||||
| -rw-r--r-- | src/ot_vector.h (renamed from ot_vector.h) | 4 | ||||
| -rw-r--r-- | src/ot_worker.c (renamed from ot_worker.c) | 4 | ||||
| -rw-r--r-- | src/ot_worker.h (renamed from ot_worker.h) | 4 | ||||
| -rw-r--r-- | src/ot_workqueue.c (renamed from ot_workqueue.c) | 4 | ||||
| -rw-r--r-- | src/ot_workqueue.h (renamed from ot_workqueue.h) | 4 | ||||
| -rw-r--r-- | src/proxy.c (renamed from proxy.c) | 4 | ||||
| -rw-r--r-- | src/trackerlogic.c (renamed from trackerlogic.c) | 4 | ||||
| -rw-r--r-- | src/trackerlogic.h (renamed from trackerlogic.h) | 9 | ||||
| -rw-r--r-- | tests/integration/test_stats.py | 6 | ||||
| -rw-r--r-- | tests/runner.c | 4 | ||||
| -rw-r--r-- | tests/stubs.c | 4 | ||||
| -rw-r--r-- | tests/sync_daemon.pl (renamed from sync_daemon.pl) | 0 | ||||
| -rw-r--r-- | tests/t_accesslist.c | 4 | ||||
| -rw-r--r-- | tests/t_batch.c | 4 | ||||
| -rw-r--r-- | tests/t_buf.c | 4 | ||||
| -rw-r--r-- | tests/t_event.c | 4 | ||||
| -rw-r--r-- | tests/t_fdstate.c | 4 | ||||
| -rw-r--r-- | tests/t_fmt.c | 4 | ||||
| -rw-r--r-- | tests/t_hex.c | 4 | ||||
| -rw-r--r-- | tests/t_iovec.c | 4 | ||||
| -rw-r--r-- | tests/t_ip.c | 4 | ||||
| -rw-r--r-- | tests/t_mutex.c | 6 | ||||
| -rw-r--r-- | tests/t_random.c | 4 | ||||
| -rw-r--r-- | tests/t_scan.c | 4 | ||||
| -rw-r--r-- | tests/t_socket.c | 4 | ||||
| -rw-r--r-- | tests/t_trackerlogic.c | 4 | ||||
| -rw-r--r-- | tests/t_urlencoded.c | 4 | ||||
| -rw-r--r-- | tests/t_vector.c | 4 | ||||
| -rw-r--r-- | tests/t_workqueue.c | 4 | ||||
| -rw-r--r-- | tests/test.c | 4 | ||||
| -rw-r--r-- | tests/test.h | 4 |
90 files changed, 352 insertions, 417 deletions
| @@ -16,7 +16,7 @@ A connection carries one request and closes. Keep-alive works and is rarely | |||
| 16 | asked for. | 16 | asked for. |
| 17 | 17 | ||
| 18 | Statistics are approximate on purpose. Counters are per thread and summed | 18 | Statistics are approximate on purpose. Counters are per thread and summed |
| 19 | when read, so a /stats read can under-report once. Nothing drifts. | 19 | when read, so a /stats read can under-report once. |
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | Decisions | 22 | Decisions |
| @@ -60,9 +60,44 @@ connections, the filter serves more requests than no filter, not fewer, so it | |||
| 60 | is not the denial of service vector that FreeBSD-SA-02:26 once described. | 60 | is not the denial of service vector that FreeBSD-SA-02:26 once described. |
| 61 | 61 | ||
| 62 | 62 | ||
| 63 | The torrent table is split into 2^OT_BUCKET_COUNT_BITS buckets, 1024 by | ||
| 64 | default, set from the Makefile. Inserting a torrent opens a slot in a sorted | ||
| 65 | vector, so the bytes moved grow with the bucket's occupancy. Insert cost per | ||
| 66 | torrent, Linux: | ||
| 67 | |||
| 68 | 2^10 2^12 2^14 2^16 | ||
| 69 | 200k 466 ns 439 ns | ||
| 70 | 1M 834 ns 579 ns 529 ns | ||
| 71 | 4M 2348 ns 1163 ns 770 ns 674 ns | ||
| 72 | |||
| 73 | Re-announcing an existing torrent moves by under ten per cent over the same | ||
| 74 | range, so the cost is paid while the torrent population is built and not in | ||
| 75 | steady state. Below a few hundred thousand torrents there is nothing to win. | ||
| 76 | 2^14 captures most of the gain for two per cent more resident memory. | ||
| 77 | |||
| 78 | The cleaner's wake rate does not follow the bucket count. A cap of ten wakes | ||
| 79 | a second sets the sleep, and a wake cleans as many buckets as it must to | ||
| 80 | finish a sweep in OT_CLEAN_INTERVAL_MINUTES. At the default bucket count that | ||
| 81 | is one bucket every 117 ms. | ||
| 82 | |||
| 83 | |||
| 63 | Paths not taken | 84 | Paths not taken |
| 64 | --------------- | 85 | --------------- |
| 65 | 86 | ||
| 87 | A keyed hash for the bucket index. Info hashes are SHA-1 output and already | ||
| 88 | uniform, so it changes no distribution. It would buy resistance to deliberate | ||
| 89 | bucket flooding and cost the ordering a full scrape depends on: buckets are | ||
| 90 | ordered by hash prefix and sorted within, so walking them emits the sorted | ||
| 91 | dictionary bencode wants, with no sort and no copy. | ||
| 92 | |||
| 93 | Cache line padding for the per-bucket locks and vector headers. The | ||
| 94 | contention it was meant to remove is not there. On glibc, where a 48-byte | ||
| 95 | mutex straddles a line, padding gains 3 to 8 per cent, but gains as much at | ||
| 96 | one thread where no false sharing can exist, and scaling from one to eight | ||
| 97 | threads is identical either way. On FreeBSD, where eight 8-byte mutexes share | ||
| 98 | a line and the risk should be highest, padding is 15 per cent slower at one | ||
| 99 | thread and neutral to 6 per cent slower at four and eight. | ||
| 100 | |||
| 66 | accf_http, the HTTP-aware accept filter. It duplicates a parser the tracker | 101 | accf_http, the HTTP-aware accept filter. It duplicates a parser the tracker |
| 67 | has anyway, puts more kernel code in the path, and holds a connection that | 102 | has anyway, puts more kernel code in the path, and holds a connection that |
| 68 | sends "GET /" and stops, which accf_data hands straight over. | 103 | sends "GET /" and stops, which accf_data hands straight over. |
| @@ -79,8 +114,6 @@ A directory for object files. bmake has no pattern rules and the Makefile | |||
| 79 | builds under FreeBSD's make today. Building each binary in one invocation | 114 | builds under FreeBSD's make today. Building each binary in one invocation |
| 80 | clears the objects out of the tree without giving that up. | 115 | clears the objects out of the tree without giving that up. |
| 81 | 116 | ||
| 82 | A src/ directory. 52 files sharing an ot_ prefix are a module list rather | ||
| 83 | than clutter, and build output was most of what made the tree look crowded. | ||
| 84 | 117 | ||
| 85 | 118 | ||
| 86 | Platform differences that cost us code | 119 | Platform differences that cost us code |
| @@ -1,7 +1,6 @@ | |||
| 1 | # $Id$ | 1 | PREFIX?=/usr/local |
| 2 | |||
| 3 | PREFIX?=.. | ||
| 4 | BINDIR?=$(PREFIX)/bin | 2 | BINDIR?=$(PREFIX)/bin |
| 3 | MANDIR?=$(PREFIX)/share/man | ||
| 5 | STRIP?=strip | 4 | STRIP?=strip |
| 6 | 5 | ||
| 7 | #FEATURES+=-DWANT_V4_ONLY | 6 | #FEATURES+=-DWANT_V4_ONLY |
| @@ -12,16 +11,6 @@ STRIP?=strip | |||
| 12 | #FEATURES+=-DWANT_SYNC_LIVE | 11 | #FEATURES+=-DWANT_SYNC_LIVE |
| 13 | #FEATURES+=-DWANT_IP_FROM_QUERY_STRING | 12 | #FEATURES+=-DWANT_IP_FROM_QUERY_STRING |
| 14 | 13 | ||
| 15 | # If you want gzip support to be compiled in, uncomment the next include. | ||
| 16 | # You can further modify the behaviour by setting DWANT_COMPRESSION_GZIP_ALWAYS | ||
| 17 | # in Makefile.gzip | ||
| 18 | include Makefile.gzip | ||
| 19 | |||
| 20 | # If you want zstd support to be compiled in, uncomment the next include. | ||
| 21 | # You can further modify the behaviour by setting DWANT_COMPRESSION_ZSTD_ALWAYS | ||
| 22 | # in Makefile.zstd | ||
| 23 | #include Makefile.zstd | ||
| 24 | |||
| 25 | #FEATURES+=-DWANT_RESTRICT_STATS | 14 | #FEATURES+=-DWANT_RESTRICT_STATS |
| 26 | #FEATURES+=-DWANT_IP_FROM_PROXY | 15 | #FEATURES+=-DWANT_IP_FROM_PROXY |
| 27 | #FEATURES+=-DWANT_LOG_NUMWANT | 16 | #FEATURES+=-DWANT_LOG_NUMWANT |
| @@ -31,155 +20,71 @@ include Makefile.gzip | |||
| 31 | #FEATURES+=-DWANT_DEV_RANDOM | 20 | #FEATURES+=-DWANT_DEV_RANDOM |
| 32 | FEATURES+=-DWANT_FULLSCRAPE | 21 | FEATURES+=-DWANT_FULLSCRAPE |
| 33 | 22 | ||
| 34 | # opentracker takes its randomness from arc4random, which is part of libc on | 23 | # Buckets the torrent table is split into, as a power of two, 8 to 16. More |
| 35 | # the BSDs, on macOS and on glibc 2.36 and newer. On an older glibc or on musl | 24 | # buckets make inserting a new torrent cheaper and cost memory, which is worth |
| 36 | # it comes from libbsd instead, so uncomment the next include to link it. | 25 | # it for a tracker carrying millions of torrents and not for one carrying |
| 37 | #LDFLAGS+=-lbsd | 26 | # thousands. DESIGN has the measurements. |
| 27 | FEATURES+=-DOT_BUCKET_COUNT_BITS=10 | ||
| 38 | 28 | ||
| 39 | #FEATURES+=-D_DEBUG_HTTPERROR | 29 | #FEATURES+=-D_DEBUG_HTTPERROR |
| 40 | #FEATURES+=-D_DEBUG_RANDOMTORRENTS | 30 | #FEATURES+=-D_DEBUG_RANDOMTORRENTS |
| 41 | 31 | ||
| 42 | VERSION=1.0.0 | 32 | # Compression support, off unless included. Each file carries a second switch |
| 43 | TARBALL_VERSION=test -r .tarball-version && read v < .tarball-version && echo "$$v" | 33 | # to compress even where the client did not ask. |
| 44 | HAVE_GIT=command -v git >/dev/null && test -d .git | 34 | include Mk/gzip.mk |
| 45 | GIT_VERSION=`sh -c '$(TARBALL_VERSION) || { $(HAVE_GIT) && git describe --tags --match "v*" --always --dirty 2>/dev/null; }'` | 35 | #include Mk/zstd.mk |
| 46 | OT_TAG=`sh -c '$(TARBALL_VERSION) || { $(HAVE_GIT) && git describe --tags --match "v*" --exact-match 2>/dev/null; }'` | ||
| 47 | 36 | ||
| 48 | OPTS_debug=-D_DEBUG -g -ggdb # -pg -fprofile-arcs -ftest-coverage | 37 | # arc4random is part of libc on the BSDs, on macOS and on glibc 2.36 and |
| 49 | OPTS_production=-O3 | 38 | # newer. On an older glibc or on musl it comes from libbsd instead. |
| 39 | #OT_LDLIBS+=-lbsd | ||
| 50 | 40 | ||
| 51 | CFLAGS+=-DOT_VERSION=\"$(VERSION)\" -DGIT_VERSION=\"$(GIT_VERSION)\" -DOT_TAG=\"$(OT_TAG)\" -Wall -pipe -pthread -Wextra -Wwrite-strings #-ansi -pedantic | 41 | CFLAGS?=-O3 |
| 52 | LDFLAGS+=-pthread | ||
| 53 | 42 | ||
| 54 | # Record feature flags as a dep to allow rebuild when they change | 43 | OT_CFLAGS+=-Wall -Wextra -Wwrite-strings -pipe -pthread |
| 55 | BUILDSTAMP=.buildstamp | 44 | OT_LDFLAGS+=-pthread |
| 56 | BUILDDEPS=Makefile $(BUILDSTAMP) | ||
| 57 | 45 | ||
| 58 | $(BUILDSTAMP): FORCE | 46 | OPTS_debug=-D_DEBUG -g -ggdb |
| 59 | @echo "$(CFLAGS) $(FEATURES) $(LDFLAGS)" | cmp -s - $@ 2>/dev/null || echo "$(CFLAGS) $(FEATURES) $(LDFLAGS)" > $@ | ||
| 60 | 47 | ||
| 61 | FORCE: | 48 | COMPILE=$(CPPFLAGS) $(OT_CFLAGS) $(FEATURES) |
| 49 | LINK=$(LDFLAGS) $(OT_LDFLAGS) $(LDLIBS) $(OT_LDLIBS) | ||
| 62 | 50 | ||
| 63 | BINARY =opentracker | 51 | BINARY=opentracker |
| 64 | HEADERS=trackerlogic.h ot_urlencoded.h ot_batch.h ot_buf.h ot_event.h ot_fdstate.h ot_fmt.h ot_hex.h ot_ip.h ot_config.h ot_scan.h ot_socket.h ot_tcp.h ot_worker.h ot_workqueue.h ot_mutex.h ot_random.h ot_stats.h ot_vector.h ot_clean.h ot_udp.h ot_iovec.h ot_fullscrape.h ot_accesslist.h ot_http.h ot_livesync.h ot_rijndael.h | 52 | HEADERS=src/trackerlogic.h src/ot_urlencoded.h src/ot_batch.h src/ot_buf.h src/ot_event.h src/ot_fdstate.h src/ot_fmt.h src/ot_hex.h src/ot_ip.h src/ot_config.h src/ot_scan.h src/ot_socket.h src/ot_tcp.h src/ot_worker.h src/ot_workqueue.h src/ot_mutex.h src/ot_random.h src/ot_stats.h src/ot_vector.h src/ot_clean.h src/ot_udp.h src/ot_iovec.h src/ot_fullscrape.h src/ot_accesslist.h src/ot_http.h src/ot_livesync.h src/ot_rijndael.h |
| 65 | SOURCES=opentracker.c trackerlogic.c ot_urlencoded.c ot_batch.c ot_buf.c ot_event.c ot_fdstate.c ot_fmt.c ot_hex.c ot_ip.c ot_config.c ot_scan.c ot_socket.c ot_tcp.c ot_worker.c ot_workqueue.c ot_mutex.c ot_random.c ot_stats.c ot_vector.c ot_clean.c ot_udp.c ot_iovec.c ot_fullscrape.c ot_accesslist.c ot_http.c ot_livesync.c ot_rijndael.c | 53 | SOURCES=src/opentracker.c src/trackerlogic.c src/ot_urlencoded.c src/ot_batch.c src/ot_buf.c src/ot_event.c src/ot_fdstate.c src/ot_fmt.c src/ot_hex.c src/ot_ip.c src/ot_config.c src/ot_scan.c src/ot_socket.c src/ot_tcp.c src/ot_worker.c src/ot_workqueue.c src/ot_mutex.c src/ot_random.c src/ot_stats.c src/ot_vector.c src/ot_clean.c src/ot_udp.c src/ot_iovec.c src/ot_fullscrape.c src/ot_accesslist.c src/ot_http.c src/ot_livesync.c src/ot_rijndael.c |
| 54 | BINARIES=$(BINARY) $(BINARY).debug | ||
| 66 | 55 | ||
| 67 | all: $(BINARY) $(BINARY).debug | 56 | # Everything is built in one go from sources, so there are no object files to |
| 57 | # carry a flag change over into the next build. The stamp holds the flags the | ||
| 58 | # last build used, which covers FEATURES passed in the environment and a moved | ||
| 59 | # HEAD. It is only written when they differ. | ||
| 60 | BUILDSTAMP=.buildstamp | ||
| 61 | BUILDDEPS=Makefile $(BUILDSTAMP) | ||
| 68 | 62 | ||
| 69 | CFLAGS_production = $(CFLAGS) $(OPTS_production) $(FEATURES) | 63 | all: $(BINARY) $(BINARY).debug |
| 70 | CFLAGS_debug = $(CFLAGS) $(OPTS_debug) $(FEATURES) | ||
| 71 | 64 | ||
| 72 | $(BINARY): $(SOURCES) $(HEADERS) $(BUILDDEPS) | 65 | $(BINARY): $(SOURCES) $(HEADERS) $(BUILDDEPS) |
| 73 | $(CC) -o $@ $(CFLAGS_production) $(SOURCES) $(LDFLAGS) | 66 | $(CC) -o $@ $(CFLAGS) $(COMPILE) $(SOURCES) $(LINK) |
| 74 | $(STRIP) $@ | 67 | $(STRIP) $@ |
| 75 | $(BINARY).debug: $(SOURCES) $(HEADERS) $(BUILDDEPS) | ||
| 76 | $(CC) -o $@ $(CFLAGS_debug) $(SOURCES) $(LDFLAGS) | ||
| 77 | |||
| 78 | # The proxy is out of service | ||
| 79 | # | ||
| 80 | # SOURCES_proxy=proxy.c ot_batch.c ot_fdstate.c ot_vector.c ot_mutex.c ot_random.c ot_scan.c ot_ip.c ot_socket.c | ||
| 81 | # CFLAGS_proxy = $(CFLAGS_production) -DWANT_SYNC_LIVE | ||
| 82 | # CFLAGS_proxy_debug = $(CFLAGS_debug) -DWANT_SYNC_LIVE | ||
| 83 | # | ||
| 84 | # proxy: $(SOURCES_proxy) $(HEADERS) $(BUILDDEPS) | ||
| 85 | # $(CC) -o $@ $(CFLAGS_proxy) $(SOURCES_proxy) $(LDFLAGS) | ||
| 86 | # proxy.debug: $(SOURCES_proxy) $(HEADERS) $(BUILDDEPS) | ||
| 87 | # $(CC) -o $@ $(CFLAGS_proxy_debug) $(SOURCES_proxy) $(LDFLAGS) | ||
| 88 | |||
| 89 | # Unit tests. The modules under test are compiled straight into the test | ||
| 90 | # binary, so a test may reach a static function by including the source if it | ||
| 91 | # has to. tests/stubs.c supplies the few symbols those modules reference but | ||
| 92 | # the tests never reach. | ||
| 93 | TESTBIN=tests/runner | ||
| 94 | TEST_SOURCES=tests/runner.c tests/test.c tests/stubs.c tests/t_urlencoded.c tests/t_iovec.c tests/t_vector.c tests/t_random.c tests/t_hex.c tests/t_accesslist.c tests/t_scan.c tests/t_buf.c tests/t_ip.c tests/t_socket.c tests/t_mutex.c tests/t_trackerlogic.c tests/t_workqueue.c tests/t_batch.c tests/t_fdstate.c tests/t_event.c tests/t_fmt.c | ||
| 95 | TEST_UNITS=ot_urlencoded.c ot_fmt.c ot_event.c ot_batch.c ot_fdstate.c ot_buf.c ot_ip.c ot_socket.c ot_iovec.c ot_vector.c ot_random.c ot_hex.c ot_scan.c ot_accesslist.c ot_mutex.c ot_workqueue.c trackerlogic.c | ||
| 96 | TEST_HEADERS=tests/test.h $(HEADERS) | ||
| 97 | # Tests reach code that sits behind feature flags, so the units under test are | ||
| 98 | # built with those features enabled. A test binary is not a production binary. | ||
| 99 | FEATURES_test=$(FEATURES) -DWANT_ACCESSLIST_BLACK -DWANT_SYNC_LIVE | ||
| 100 | CFLAGS_test = $(CFLAGS) -I. -g -O1 $(FEATURES_test) | ||
| 101 | |||
| 102 | $(TESTBIN): $(TEST_SOURCES) $(TEST_UNITS) $(TEST_HEADERS) $(BUILDDEPS) | ||
| 103 | $(CC) -o $@ $(CFLAGS_test) $(TEST_SOURCES) $(TEST_UNITS) | ||
| 104 | |||
| 105 | check: $(TESTBIN) $(BINARY) | ||
| 106 | ./$(TESTBIN) | ||
| 107 | 68 | ||
| 108 | $(TESTBIN).poll: $(TEST_SOURCES) $(TEST_UNITS) $(TEST_HEADERS) $(BUILDDEPS) | 69 | $(BINARY).debug: $(SOURCES) $(HEADERS) $(BUILDDEPS) |
| 109 | $(CC) -o $@ $(CFLAGS_test) -DOT_EVENT_FORCE_POLL $(TEST_SOURCES) $(TEST_UNITS) | 70 | $(CC) -o $@ $(OPTS_debug) $(COMPILE) $(SOURCES) $(LINK) |
| 110 | |||
| 111 | check-poll: $(TESTBIN).poll | ||
| 112 | ./$(TESTBIN).poll ot_event | ||
| 113 | |||
| 114 | # The same unit tests under the sanitizers. Use clang over $(CC) because the | ||
| 115 | # two toolchains do not check the same things | ||
| 116 | # Override CC_sanitize to use another compiler. | ||
| 117 | CC_sanitize?=clang | ||
| 118 | CFLAGS_sanitize=$(CFLAGS_test) -fsanitize=address,undefined -fno-omit-frame-pointer | ||
| 119 | LDFLAGS_sanitize=$(LDFLAGS) -fsanitize=address,undefined | ||
| 120 | |||
| 121 | $(TESTBIN).sanitize: $(TEST_SOURCES) $(TEST_UNITS) $(TEST_HEADERS) $(BUILDDEPS) | ||
| 122 | $(CC_sanitize) -o $@ $(CFLAGS_sanitize) $(TEST_SOURCES) $(TEST_UNITS) $(LDFLAGS_sanitize) | ||
| 123 | |||
| 124 | check-sanitize: $(TESTBIN).sanitize | ||
| 125 | ./$(TESTBIN).sanitize | ||
| 126 | |||
| 127 | # Black box tests: these drive the real binary over the wire, so they cover | ||
| 128 | # the event loop and the parsers working together, which the unit tests | ||
| 129 | # cannot reach. Built with the sanitizers on, so the tracker reports its own | ||
| 130 | # memory errors and the harness turns those into failures. | ||
| 131 | PYTHON?=python3 | ||
| 132 | # The client timeout is cut right down so that tests can reach the expiry | ||
| 133 | # sweep. tests/integration/test_expiry.py mirrors these two numbers. | ||
| 134 | FEATURES_integration=$(FEATURES) -DWANT_IP_FROM_QUERY_STRING -DWANT_ACCESSLIST_BLACK -DWANT_DYNAMIC_ACCESSLIST -DWANT_KEEPALIVE -DOT_CLIENT_TIMEOUT=5 -DOT_CLIENT_TIMEOUT_CHECKINTERVAL=1 | ||
| 135 | CFLAGS_integration=$(CFLAGS) $(OPTS_debug) $(FEATURES_integration) -fsanitize=address,undefined -fno-omit-frame-pointer | ||
| 136 | LDFLAGS_integration=$(LDFLAGS) -fsanitize=address,undefined | ||
| 137 | |||
| 138 | opentracker.integration: $(SOURCES) $(HEADERS) $(BUILDDEPS) | ||
| 139 | $(CC) -o $@ $(CFLAGS_integration) $(SOURCES) $(LDFLAGS_integration) | ||
| 140 | |||
| 141 | check-integration: opentracker.integration | ||
| 142 | OPENTRACKER=./opentracker.integration $(PYTHON) -m unittest discover -s tests/integration | ||
| 143 | |||
| 144 | # The same black box tests against a ThreadSanitizer build | ||
| 145 | CFLAGS_tsan=$(CFLAGS) $(OPTS_debug) $(FEATURES_integration) -fsanitize=thread -fno-omit-frame-pointer | ||
| 146 | LDFLAGS_tsan=$(LDFLAGS) -fsanitize=thread | ||
| 147 | |||
| 148 | opentracker.tsan: $(SOURCES) $(HEADERS) $(BUILDDEPS) | ||
| 149 | $(CC) -o $@ $(CFLAGS_tsan) $(SOURCES) $(LDFLAGS_tsan) | ||
| 150 | |||
| 151 | check-tsan: opentracker.tsan | ||
| 152 | OPENTRACKER=./opentracker.tsan $(PYTHON) -m unittest discover -s tests/integration | ||
| 153 | |||
| 154 | # Everything, cheapest first, so a quick failure comes back quickly. | ||
| 155 | check-all: | ||
| 156 | $(MAKE) check | ||
| 157 | $(MAKE) check-poll | ||
| 158 | $(MAKE) check-sanitize | ||
| 159 | $(MAKE) check-integration | ||
| 160 | $(MAKE) check-tsan | ||
| 161 | |||
| 162 | .PHONY: all FORCE dist check check-poll check-sanitize check-integration check-tsan check-all clean install | ||
| 163 | 71 | ||
| 164 | BINARIES=opentracker opentracker.debug opentracker.integration opentracker.tsan $(TESTBIN) $(TESTBIN).sanitize $(TESTBIN).poll | 72 | $(BUILDSTAMP): FORCE |
| 73 | @echo "$(CFLAGS) $(COMPILE) $(LINK)" | cmp -s - $@ 2>/dev/null || echo "$(CFLAGS) $(COMPILE) $(LINK)" > $@ | ||
| 165 | 74 | ||
| 166 | clean: | 75 | clean: |
| 167 | rm -rf $(BINARIES) $(BINARIES:=.dSYM) $(BUILDSTAMP) *.o *~ | 76 | rm -rf $(BINARIES) $(BINARIES:=.dSYM) $(BUILDSTAMP) *.o *~ src/*.o src/*~ |
| 168 | 77 | ||
| 169 | install: | 78 | install: $(BINARY) |
| 170 | install -m 755 opentracker $(DESTDIR)$(BINDIR) | 79 | install -d $(DESTDIR)$(BINDIR) $(DESTDIR)$(MANDIR)/man1 $(DESTDIR)$(MANDIR)/man5 |
| 80 | install -m 755 $(BINARY) $(DESTDIR)$(BINDIR) | ||
| 81 | install -m 644 man1/opentracker.1 $(DESTDIR)$(MANDIR)/man1 | ||
| 82 | install -m 644 man5/opentracker.conf.5 $(DESTDIR)$(MANDIR)/man5 | ||
| 83 | |||
| 84 | FORCE: | ||
| 171 | 85 | ||
| 172 | # Roll a release: tag it v<something>, then make dist. The commit is written | 86 | .PHONY: all clean install FORCE |
| 173 | # into the tarball, so a build from it reports the same version this checkout | ||
| 174 | # would, without a git to ask. The tarball is HEAD by construction, so the | ||
| 175 | # working tree it was rolled from does not enter into the version. | ||
| 176 | DISTNAME=opentracker-$(VERSION) | ||
| 177 | 87 | ||
| 178 | dist: | 88 | include Mk/tests.mk |
| 179 | @test "`git describe --tags --match 'v*' --exact-match 2>/dev/null`" = "v$(VERSION)" || \ | 89 | include Mk/release.mk |
| 180 | { echo "HEAD must carry the tag v$(VERSION). Tag the release, or correct VERSION."; exit 1; } | 90 | include Mk/proxy.mk |
| 181 | rm -rf $(DISTNAME) $(DISTNAME).tar.gz | ||
| 182 | git archive --format=tar --prefix=$(DISTNAME)/ HEAD | tar -xf - | ||
| 183 | git describe --tags --match "v*" --always > $(DISTNAME)/.tarball-version | ||
| 184 | tar -czf $(DISTNAME).tar.gz $(DISTNAME) | ||
| 185 | rm -rf $(DISTNAME) | ||
diff --git a/Makefile.gzip b/Mk/gzip.mk index 70d6d62..3ae53b3 100644 --- a/Makefile.gzip +++ b/Mk/gzip.mk | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | FEATURES+=-DWANT_COMPRESSION_GZIP | 1 | FEATURES+=-DWANT_COMPRESSION_GZIP |
| 2 | #FEATURES+=-DWANT_COMPRESSION_GZIP_ALWAYS | 2 | #FEATURES+=-DWANT_COMPRESSION_GZIP_ALWAYS |
| 3 | 3 | ||
| 4 | LDFLAGS+=-lz | 4 | OT_LDLIBS+=-lz |
diff --git a/Mk/proxy.mk b/Mk/proxy.mk new file mode 100644 index 0000000..64d18dc --- /dev/null +++ b/Mk/proxy.mk | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | # The proxy relays sync traffic between trackers and between multicast domains | ||
| 2 | # that cannot reach each other. It does not build; see the note at the top of | ||
| 3 | # proxy.c. Scheduled for v1.1.0, when these rules come back. | ||
| 4 | # | ||
| 5 | # LIBOWFAT_HEADERS=$(PREFIX)/libowfat | ||
| 6 | # LIBOWFAT_LIBRARY=$(PREFIX)/libowfat | ||
| 7 | # CFLAGS_libowfat=-I$(LIBOWFAT_HEADERS) | ||
| 8 | # LDFLAGS_libowfat=-L$(LIBOWFAT_LIBRARY) -lowfat | ||
| 9 | # | ||
| 10 | # SOURCES_proxy=src/proxy.c src/ot_batch.c src/ot_fdstate.c src/ot_vector.c src/ot_mutex.c src/ot_random.c src/ot_scan.c src/ot_ip.c src/ot_socket.c | ||
| 11 | # CFLAGS_proxy=$(CFLAGS_production) $(CFLAGS_libowfat) -DWANT_SYNC_LIVE | ||
| 12 | # CFLAGS_proxy_debug=$(CFLAGS_debug) $(CFLAGS_libowfat) -DWANT_SYNC_LIVE | ||
| 13 | # | ||
| 14 | # BINARIES+=proxy proxy.debug | ||
| 15 | # | ||
| 16 | # proxy: $(SOURCES_proxy) $(HEADERS) $(BUILDDEPS) | ||
| 17 | # $(CC) -o $@ $(CFLAGS_proxy) $(SOURCES_proxy) $(LDFLAGS) $(LDFLAGS_libowfat) | ||
| 18 | # proxy.debug: $(SOURCES_proxy) $(HEADERS) $(BUILDDEPS) | ||
| 19 | # $(CC) -o $@ $(CFLAGS_proxy_debug) $(SOURCES_proxy) $(LDFLAGS) $(LDFLAGS_libowfat) | ||
| 20 | |||
| 21 | proxy proxy.debug: | ||
| 22 | @echo "$@ is out of service until v1.1.0, see the note at the top of proxy.c" | ||
| 23 | @false | ||
| 24 | |||
| 25 | .PHONY: proxy proxy.debug | ||
diff --git a/Mk/release.mk b/Mk/release.mk new file mode 100644 index 0000000..5c4afe9 --- /dev/null +++ b/Mk/release.mk | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | # .tarball-version is what dist wrote into the tarball | ||
| 2 | # In a checkout it is absent and git answers instead. A release is always | ||
| 3 | # tagged, so in a tarball both of these are that tag, and the gitweb link | ||
| 4 | # is to it. Between releases there is no tag and the version is the commit. | ||
| 5 | VERSION=1.0.0 | ||
| 6 | |||
| 7 | TARBALL_VERSION=test -r .tarball-version && read v < .tarball-version && echo "$$v" | ||
| 8 | HAVE_GIT=command -v git >/dev/null && test -d .git | ||
| 9 | GIT_VERSION=`sh -c '$(TARBALL_VERSION) || { $(HAVE_GIT) && git describe --tags --match "v*" --always --dirty 2>/dev/null; }'` | ||
| 10 | OT_TAG=`sh -c '$(TARBALL_VERSION) || { $(HAVE_GIT) && git describe --tags --match "v*" --exact-match 2>/dev/null; }'` | ||
| 11 | |||
| 12 | OT_CFLAGS+=-DOT_VERSION=\"$(VERSION)\" -DGIT_VERSION=\"$(GIT_VERSION)\" -DOT_TAG=\"$(OT_TAG)\" | ||
| 13 | |||
| 14 | # Roll a release: tag it v$(VERSION), then make dist. The tarball is HEAD by | ||
| 15 | # construction, so the working tree it was rolled from does not enter into it. | ||
| 16 | DISTNAME=opentracker-$(VERSION) | ||
| 17 | |||
| 18 | dist: | ||
| 19 | @test "`git describe --tags --match 'v*' --exact-match 2>/dev/null`" = "v$(VERSION)" || \ | ||
| 20 | { echo "HEAD must carry the tag v$(VERSION). Tag the release, or correct VERSION."; exit 1; } | ||
| 21 | rm -rf $(DISTNAME) $(DISTNAME).tar.gz | ||
| 22 | git archive --format=tar --prefix=$(DISTNAME)/ HEAD | tar -xf - | ||
| 23 | git describe --tags --match "v*" --always > $(DISTNAME)/.tarball-version | ||
| 24 | tar -czf $(DISTNAME).tar.gz $(DISTNAME) | ||
| 25 | rm -rf $(DISTNAME) | ||
| 26 | |||
| 27 | .PHONY: dist | ||
diff --git a/Mk/tests.mk b/Mk/tests.mk new file mode 100644 index 0000000..46f308b --- /dev/null +++ b/Mk/tests.mk | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | BUILDDEPS+=Mk/tests.mk | ||
| 2 | |||
| 3 | # The modules under test are compiled straight into the test binary, so a test | ||
| 4 | # may reach a static function by including the source. tests/stubs.c supplies | ||
| 5 | # the few symbols those modules reference but the tests never reach. | ||
| 6 | TESTBIN=tests/runner | ||
| 7 | TEST_SOURCES=tests/runner.c tests/test.c tests/stubs.c tests/t_urlencoded.c tests/t_iovec.c tests/t_vector.c tests/t_random.c tests/t_hex.c tests/t_accesslist.c tests/t_scan.c tests/t_buf.c tests/t_ip.c tests/t_socket.c tests/t_mutex.c tests/t_trackerlogic.c tests/t_workqueue.c tests/t_batch.c tests/t_fdstate.c tests/t_event.c tests/t_fmt.c | ||
| 8 | TEST_UNITS=src/ot_urlencoded.c src/ot_fmt.c src/ot_event.c src/ot_batch.c src/ot_fdstate.c src/ot_buf.c src/ot_ip.c src/ot_socket.c src/ot_iovec.c src/ot_vector.c src/ot_random.c src/ot_hex.c src/ot_scan.c src/ot_accesslist.c src/ot_mutex.c src/ot_workqueue.c src/trackerlogic.c | ||
| 9 | TEST_HEADERS=tests/test.h $(HEADERS) | ||
| 10 | |||
| 11 | # A test binary is not a production binary, so it is built with the features | ||
| 12 | # the tests need to reach. | ||
| 13 | FEATURES_test=$(FEATURES) -DWANT_ACCESSLIST_BLACK -DWANT_SYNC_LIVE | ||
| 14 | CFLAGS_test=-Isrc -g -O1 $(CPPFLAGS) $(OT_CFLAGS) $(FEATURES_test) | ||
| 15 | |||
| 16 | # clang over $(CC) because the two toolchains do not check the same things. | ||
| 17 | CC_sanitize?=clang | ||
| 18 | CFLAGS_sanitize=$(CFLAGS_test) -fsanitize=address,undefined -fno-omit-frame-pointer | ||
| 19 | LDFLAGS_sanitize=$(LINK) -fsanitize=address,undefined | ||
| 20 | |||
| 21 | # Black box tests drive the real binary over the wire, so they cover the event | ||
| 22 | # loop and the parsers working together. The client timeout is cut right down | ||
| 23 | # so a test can reach the expiry sweep; tests/integration/test_expiry.py | ||
| 24 | # mirrors these two numbers. | ||
| 25 | PYTHON?=python3 | ||
| 26 | FEATURES_integration=$(FEATURES) -DWANT_IP_FROM_QUERY_STRING -DWANT_ACCESSLIST_BLACK -DWANT_DYNAMIC_ACCESSLIST -DWANT_KEEPALIVE -DOT_CLIENT_TIMEOUT=5 -DOT_CLIENT_TIMEOUT_CHECKINTERVAL=1 | ||
| 27 | CFLAGS_integration=$(OPTS_debug) $(CPPFLAGS) $(OT_CFLAGS) $(FEATURES_integration) -fsanitize=address,undefined -fno-omit-frame-pointer | ||
| 28 | LDFLAGS_integration=$(LINK) -fsanitize=address,undefined | ||
| 29 | CFLAGS_tsan=$(OPTS_debug) $(CPPFLAGS) $(OT_CFLAGS) $(FEATURES_integration) -fsanitize=thread -fno-omit-frame-pointer | ||
| 30 | LDFLAGS_tsan=$(LINK) -fsanitize=thread | ||
| 31 | |||
| 32 | BINARIES+=$(TESTBIN) $(TESTBIN).poll $(TESTBIN).sanitize opentracker.integration opentracker.tsan | ||
| 33 | |||
| 34 | $(TESTBIN): $(TEST_SOURCES) $(TEST_UNITS) $(TEST_HEADERS) $(BUILDDEPS) | ||
| 35 | $(CC) -o $@ $(CFLAGS_test) $(TEST_SOURCES) $(TEST_UNITS) | ||
| 36 | |||
| 37 | $(TESTBIN).poll: $(TEST_SOURCES) $(TEST_UNITS) $(TEST_HEADERS) $(BUILDDEPS) | ||
| 38 | $(CC) -o $@ $(CFLAGS_test) -DOT_EVENT_FORCE_POLL $(TEST_SOURCES) $(TEST_UNITS) | ||
| 39 | |||
| 40 | $(TESTBIN).sanitize: $(TEST_SOURCES) $(TEST_UNITS) $(TEST_HEADERS) $(BUILDDEPS) | ||
| 41 | $(CC_sanitize) -o $@ $(CFLAGS_sanitize) $(TEST_SOURCES) $(TEST_UNITS) $(LDFLAGS_sanitize) | ||
| 42 | |||
| 43 | opentracker.integration: $(SOURCES) $(HEADERS) $(BUILDDEPS) | ||
| 44 | $(CC) -o $@ $(CFLAGS_integration) $(SOURCES) $(LDFLAGS_integration) | ||
| 45 | |||
| 46 | opentracker.tsan: $(SOURCES) $(HEADERS) $(BUILDDEPS) | ||
| 47 | $(CC) -o $@ $(CFLAGS_tsan) $(SOURCES) $(LDFLAGS_tsan) | ||
| 48 | |||
| 49 | check: $(TESTBIN) $(BINARY) | ||
| 50 | ./$(TESTBIN) | ||
| 51 | |||
| 52 | check-poll: $(TESTBIN).poll | ||
| 53 | ./$(TESTBIN).poll ot_event | ||
| 54 | |||
| 55 | check-sanitize: $(TESTBIN).sanitize | ||
| 56 | ./$(TESTBIN).sanitize | ||
| 57 | |||
| 58 | check-integration: opentracker.integration | ||
| 59 | OPENTRACKER=./opentracker.integration $(PYTHON) -m unittest discover -s tests/integration | ||
| 60 | |||
| 61 | check-tsan: opentracker.tsan | ||
| 62 | OPENTRACKER=./opentracker.tsan $(PYTHON) -m unittest discover -s tests/integration | ||
| 63 | |||
| 64 | # Cheapest first, so a quick failure comes back quickly. | ||
| 65 | check-all: | ||
| 66 | $(MAKE) check | ||
| 67 | $(MAKE) check-poll | ||
| 68 | $(MAKE) check-sanitize | ||
| 69 | $(MAKE) check-integration | ||
| 70 | $(MAKE) check-tsan | ||
| 71 | |||
| 72 | .PHONY: check check-poll check-sanitize check-integration check-tsan check-all | ||
diff --git a/Makefile.zstd b/Mk/zstd.mk index 2bb56be..8c1fc40 100644 --- a/Makefile.zstd +++ b/Mk/zstd.mk | |||
| @@ -1,3 +1,3 @@ | |||
| 1 | FEATURES+=-DWANT_COMPRESSION_ZSTD | 1 | FEATURES+=-DWANT_COMPRESSION_ZSTD |
| 2 | #FEATURES+=-DWANT_COMPRESSION_ZSTD_ALWAYS | 2 | #FEATURES+=-DWANT_COMPRESSION_ZSTD_ALWAYS |
| 3 | LDFLAGS+=-lzstd | 3 | OT_LDLIBS+=-lzstd |
diff --git a/README_v6 b/README_v6 deleted file mode 100644 index 7fac79a..0000000 --- a/README_v6 +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | IPv6 is implemented in opentracker now. You can chose whether your tracker runs in v4 or v6 mode in Makefile. YMMV. | ||
diff --git a/man1/opentracker.1 b/man1/opentracker.1 index 489a54c..897584f 100644 --- a/man1/opentracker.1 +++ b/man1/opentracker.1 | |||
| @@ -26,7 +26,7 @@ interfaces. The recommended way to configure opentracker is by providing a | |||
| 26 | config file using the | 26 | config file using the |
| 27 | .Op Fl f Ar config | 27 | .Op Fl f Ar config |
| 28 | option. See | 28 | option. See |
| 29 | .Xr opentracker.conf 4 | 29 | .Xr opentracker.conf 5 |
| 30 | for details. | 30 | for details. |
| 31 | .Pp | 31 | .Pp |
| 32 | .Sh OPTIONS | 32 | .Sh OPTIONS |
| @@ -35,7 +35,7 @@ The following options are available: | |||
| 35 | .It Fl f Ar config | 35 | .It Fl f Ar config |
| 36 | Parse a config file with a list of options. Consecutive command options | 36 | Parse a config file with a list of options. Consecutive command options |
| 37 | will override options from the config file. See | 37 | will override options from the config file. See |
| 38 | .Xr opentracker.conf 4 | 38 | .Xr opentracker.conf 5 |
| 39 | for details. | 39 | for details. |
| 40 | .It Fl i Ar ip-select | 40 | .It Fl i Ar ip-select |
| 41 | Select an ip address that will be used with the next | 41 | Select an ip address that will be used with the next |
| @@ -113,7 +113,7 @@ The | |||
| 113 | config file. | 113 | config file. |
| 114 | .El | 114 | .El |
| 115 | .Sh SEE ALSO | 115 | .Sh SEE ALSO |
| 116 | .Xr opentracker.conf 4 | 116 | .Xr opentracker.conf 5 |
| 117 | .Pp | 117 | .Pp |
| 118 | opentracker documentation | 118 | opentracker documentation |
| 119 | .Lk https://erdgeist.org/arts/software/opentracker | 119 | .Lk https://erdgeist.org/arts/software/opentracker |
diff --git a/man4/opentracker.conf.4 b/man5/opentracker.conf.5 index 239ab88..67e624f 100644 --- a/man4/opentracker.conf.4 +++ b/man5/opentracker.conf.5 | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | .Dd 2026-10-28 | 1 | .Dd 2026-10-28 |
| 2 | .Dt opentracker.conf 4 | 2 | .Dt opentracker.conf 5 |
| 3 | .Os Unix | 3 | .Os Unix |
| 4 | .Sh NAME | 4 | .Sh NAME |
| 5 | .Nm opentracker.conf | 5 | .Nm opentracker.conf |
diff --git a/ot_clean.h b/ot_clean.h deleted file mode 100644 index 1484d82..0000000 --- a/ot_clean.h +++ /dev/null | |||
| @@ -1,21 +0,0 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | ||
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | ||
| 3 | |||
| 4 | $id$ */ | ||
| 5 | |||
| 6 | #ifndef OT_CLEAN_H__ | ||
| 7 | #define OT_CLEAN_H__ | ||
| 8 | |||
| 9 | #include "trackerlogic.h" | ||
| 10 | |||
| 11 | /* The amount of time a clean cycle should take */ | ||
| 12 | #define OT_CLEAN_INTERVAL_MINUTES 2 | ||
| 13 | |||
| 14 | /* So after each bucket wait 1 / OT_BUCKET_COUNT intervals */ | ||
| 15 | #define OT_CLEAN_SLEEP (((OT_CLEAN_INTERVAL_MINUTES) * 60 * 1000000) / (OT_BUCKET_COUNT)) | ||
| 16 | |||
| 17 | void clean_init(void); | ||
| 18 | void clean_deinit(void); | ||
| 19 | int clean_single_torrent(ot_torrent *torrent); | ||
| 20 | |||
| 21 | #endif | ||
diff --git a/opentracker.c b/src/opentracker.c index 644e99c..14b817e 100644 --- a/opentracker.c +++ b/src/opentracker.c | |||
| @@ -1,8 +1,6 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. |
| 3 | Some of the stuff below is stolen from Fefes example libowfat httpd. | 3 | Some of the stuff below is stolen from Fefes example libowfat httpd. */ |
| 4 | |||
| 5 | $Id$ */ | ||
| 6 | 4 | ||
| 7 | /* System */ | 5 | /* System */ |
| 8 | #include <ctype.h> | 6 | #include <ctype.h> |
diff --git a/ot_accesslist.c b/src/ot_accesslist.c index 945ddcf..86f9a7d 100644 --- a/ot_accesslist.c +++ b/src/ot_accesslist.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <pthread.h> | 5 | #include <pthread.h> |
diff --git a/ot_accesslist.h b/src/ot_accesslist.h index ca0e126..68c88dc 100644 --- a/ot_accesslist.h +++ b/src/ot_accesslist.h | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | #ifndef OT_ACCESSLIST_H__ | 4 | #ifndef OT_ACCESSLIST_H__ |
| 7 | #define OT_ACCESSLIST_H__ | 5 | #define OT_ACCESSLIST_H__ |
diff --git a/ot_batch.c b/src/ot_batch.c index 84eb4a8..e4dda0b 100644 --- a/ot_batch.c +++ b/src/ot_batch.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <errno.h> | 5 | #include <errno.h> |
diff --git a/ot_batch.h b/src/ot_batch.h index c855671..910bea7 100644 --- a/ot_batch.h +++ b/src/ot_batch.h | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | #ifndef OT_BATCH_H__ | 4 | #ifndef OT_BATCH_H__ |
| 7 | #define OT_BATCH_H__ | 5 | #define OT_BATCH_H__ |
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <stdlib.h> | 5 | #include <stdlib.h> |
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | #ifndef OT_BUF_H__ | 4 | #ifndef OT_BUF_H__ |
| 7 | #define OT_BUF_H__ | 5 | #define OT_BUF_H__ |
diff --git a/ot_clean.c b/src/ot_clean.c index 77ea239..f181e83 100644 --- a/ot_clean.c +++ b/src/ot_clean.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <errno.h> | 5 | #include <errno.h> |
| @@ -127,26 +125,34 @@ static void clean_sleep(void) { | |||
| 127 | pthread_mutex_unlock(&g_clean_mutex); | 125 | pthread_mutex_unlock(&g_clean_mutex); |
| 128 | } | 126 | } |
| 129 | 127 | ||
| 130 | /* Clean up all peers in current bucket, remove timedout pools and | 128 | /* Clean up all peers in one bucket, remove timedout pools and torrents */ |
| 131 | torrents */ | 129 | static void clean_bucket(size_t bucket) { |
| 130 | ot_vector *torrents_list = mutex_bucket_lock((int)bucket); | ||
| 131 | size_t toffs; | ||
| 132 | int delta_torrentcount = 0; | ||
| 133 | |||
| 134 | for (toffs = 0; toffs < torrents_list->size; ++toffs) { | ||
| 135 | ot_torrent *torrent = ((ot_torrent *)(torrents_list->data)) + toffs; | ||
| 136 | if (clean_single_torrent(torrent)) { | ||
| 137 | vector_remove_torrent(torrents_list, torrent); | ||
| 138 | --delta_torrentcount; | ||
| 139 | --toffs; | ||
| 140 | } | ||
| 141 | } | ||
| 142 | mutex_bucket_unlock((int)bucket, delta_torrentcount); | ||
| 143 | } | ||
| 144 | |||
| 132 | static void *clean_worker(void *args) { | 145 | static void *clean_worker(void *args) { |
| 133 | (void)args; | 146 | (void)args; |
| 134 | while (1) { | 147 | while (1) { |
| 135 | size_t bucket = OT_BUCKET_COUNT; | 148 | size_t bucket = OT_BUCKET_COUNT; |
| 136 | while (bucket--) { | 149 | while (bucket) { |
| 137 | ot_vector *torrents_list = mutex_bucket_lock(bucket); | 150 | size_t todo = bucket < OT_CLEAN_BUCKETS_PER_WAKE ? bucket : OT_CLEAN_BUCKETS_PER_WAKE; |
| 138 | size_t toffs; | 151 | |
| 139 | int delta_torrentcount = 0; | 152 | /* One bucket is locked at a time, however many a wake gets through */ |
| 153 | while (todo--) | ||
| 154 | clean_bucket(--bucket); | ||
| 140 | 155 | ||
| 141 | for (toffs = 0; toffs < torrents_list->size; ++toffs) { | ||
| 142 | ot_torrent *torrent = ((ot_torrent *)(torrents_list->data)) + toffs; | ||
| 143 | if (clean_single_torrent(torrent)) { | ||
| 144 | vector_remove_torrent(torrents_list, torrent); | ||
| 145 | --delta_torrentcount; | ||
| 146 | --toffs; | ||
| 147 | } | ||
| 148 | } | ||
| 149 | mutex_bucket_unlock(bucket, delta_torrentcount); | ||
| 150 | if (!g_opentracker_running) | 156 | if (!g_opentracker_running) |
| 151 | return NULL; | 157 | return NULL; |
| 152 | clean_sleep(); | 158 | clean_sleep(); |
diff --git a/src/ot_clean.h b/src/ot_clean.h new file mode 100644 index 0000000..0592791 --- /dev/null +++ b/src/ot_clean.h | |||
| @@ -0,0 +1,28 @@ | |||
| 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_CLEAN_H__ | ||
| 5 | #define OT_CLEAN_H__ | ||
| 6 | |||
| 7 | #include "trackerlogic.h" | ||
| 8 | |||
| 9 | /* The amount of time a clean cycle should take */ | ||
| 10 | #define OT_CLEAN_INTERVAL_MINUTES 2 | ||
| 11 | |||
| 12 | /* How often the cleaner may wake. A full sweep takes OT_CLEAN_INTERVAL_MINUTES. | ||
| 13 | The clean operations per wake is goverend by OT_BUCKET_COUNT_BITS, | ||
| 14 | set by the Makefile. | ||
| 15 | At the default of 1024 buckets this works out at one bucket every | ||
| 16 | 117 ms. */ | ||
| 17 | #define OT_CLEAN_MAX_WAKES_PER_SECOND 10 | ||
| 18 | |||
| 19 | #define OT_CLEAN_WAKE_BUDGET ((OT_CLEAN_INTERVAL_MINUTES) * 60 * (OT_CLEAN_MAX_WAKES_PER_SECOND)) | ||
| 20 | #define OT_CLEAN_BUCKETS_PER_WAKE (((OT_BUCKET_COUNT) + (OT_CLEAN_WAKE_BUDGET) - 1) / (OT_CLEAN_WAKE_BUDGET)) | ||
| 21 | #define OT_CLEAN_WAKES ((OT_BUCKET_COUNT) / (OT_CLEAN_BUCKETS_PER_WAKE)) | ||
| 22 | #define OT_CLEAN_SLEEP (((OT_CLEAN_INTERVAL_MINUTES) * 60 * 1000000) / (OT_CLEAN_WAKES)) | ||
| 23 | |||
| 24 | void clean_init(void); | ||
| 25 | void clean_deinit(void); | ||
| 26 | int clean_single_torrent(ot_torrent *torrent); | ||
| 27 | |||
| 28 | #endif | ||
diff --git a/ot_config.c b/src/ot_config.c index 5da6642..95136b5 100644 --- a/ot_config.c +++ b/src/ot_config.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <ctype.h> | 5 | #include <ctype.h> |
diff --git a/ot_config.h b/src/ot_config.h index 059573a..79187ee 100644 --- a/ot_config.h +++ b/src/ot_config.h | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | #ifndef OT_CONFIG_H__ | 4 | #ifndef OT_CONFIG_H__ |
| 7 | #define OT_CONFIG_H__ | 5 | #define OT_CONFIG_H__ |
diff --git a/ot_event.c b/src/ot_event.c index 61cc07b..6062f70 100644 --- a/ot_event.c +++ b/src/ot_event.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <errno.h> | 5 | #include <errno.h> |
diff --git a/ot_event.h b/src/ot_event.h index efdefff..cb84ca8 100644 --- a/ot_event.h +++ b/src/ot_event.h | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | #ifndef OT_EVENT_H__ | 4 | #ifndef OT_EVENT_H__ |
| 7 | #define OT_EVENT_H__ | 5 | #define OT_EVENT_H__ |
diff --git a/ot_fdstate.c b/src/ot_fdstate.c index 09daf50..8e4bd89 100644 --- a/ot_fdstate.c +++ b/src/ot_fdstate.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <stdatomic.h> | 5 | #include <stdatomic.h> |
diff --git a/ot_fdstate.h b/src/ot_fdstate.h index 93890d1..60fe070 100644 --- a/ot_fdstate.h +++ b/src/ot_fdstate.h | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | #ifndef OT_FDSTATE_H__ | 4 | #ifndef OT_FDSTATE_H__ |
| 7 | #define OT_FDSTATE_H__ | 5 | #define OT_FDSTATE_H__ |
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <stdarg.h> | 5 | #include <stdarg.h> |
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | #ifndef OT_FMT_H__ | 4 | #ifndef OT_FMT_H__ |
| 7 | #define OT_FMT_H__ | 5 | #define OT_FMT_H__ |
diff --git a/ot_fullscrape.c b/src/ot_fullscrape.c index ae29308..9afad92 100644 --- a/ot_fullscrape.c +++ b/src/ot_fullscrape.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | #ifdef WANT_FULLSCRAPE | 4 | #ifdef WANT_FULLSCRAPE |
| 7 | 5 | ||
diff --git a/ot_fullscrape.h b/src/ot_fullscrape.h index b759a27..8d11cd3 100644 --- a/ot_fullscrape.h +++ b/src/ot_fullscrape.h | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | #ifndef OT_FULLSCRAPE_H__ | 4 | #ifndef OT_FULLSCRAPE_H__ |
| 7 | #define OT_FULLSCRAPE_H__ | 5 | #define OT_FULLSCRAPE_H__ |
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <stdint.h> | 5 | #include <stdint.h> |
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | #ifndef OT_HEX_H__ | 4 | #ifndef OT_HEX_H__ |
| 7 | #define OT_HEX_H__ | 5 | #define OT_HEX_H__ |
diff --git a/ot_http.c b/src/ot_http.c index b243ff6..96b8f4e 100644 --- a/ot_http.c +++ b/src/ot_http.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #define _GNU_SOURCE | 5 | #define _GNU_SOURCE |
diff --git a/ot_http.h b/src/ot_http.h index 9cacd21..fb56c64 100644 --- a/ot_http.h +++ b/src/ot_http.h | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | #ifndef OT_HTTP_H__ | 4 | #ifndef OT_HTTP_H__ |
| 7 | #define OT_HTTP_H__ | 5 | #define OT_HTTP_H__ |
diff --git a/ot_iovec.c b/src/ot_iovec.c index 7e5903f..328f160 100644 --- a/ot_iovec.c +++ b/src/ot_iovec.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <stdlib.h> | 5 | #include <stdlib.h> |
diff --git a/ot_iovec.h b/src/ot_iovec.h index 6f5a1d6..4a8abbb 100644 --- a/ot_iovec.h +++ b/src/ot_iovec.h | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | #ifndef OT_IOVEC_H__ | 4 | #ifndef OT_IOVEC_H__ |
| 7 | #define OT_IOVEC_H__ | 5 | #define OT_IOVEC_H__ |
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <stdint.h> | 5 | #include <stdint.h> |
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | #ifndef OT_IP_H__ | 4 | #ifndef OT_IP_H__ |
| 7 | #define OT_IP_H__ | 5 | #define OT_IP_H__ |
diff --git a/ot_livesync.c b/src/ot_livesync.c index 4a0ede1..083fe1a 100644 --- a/ot_livesync.c +++ b/src/ot_livesync.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <arpa/inet.h> | 5 | #include <arpa/inet.h> |
diff --git a/ot_livesync.h b/src/ot_livesync.h index 4725023..4bd3af0 100644 --- a/ot_livesync.h +++ b/src/ot_livesync.h | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | #ifndef OT_LIVESYNC_H__ | 4 | #ifndef OT_LIVESYNC_H__ |
| 7 | #define OT_LIVESYNC_H__ | 5 | #define OT_LIVESYNC_H__ |
diff --git a/ot_mutex.c b/src/ot_mutex.c index 9b3fd24..884b74c 100644 --- a/ot_mutex.c +++ b/src/ot_mutex.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <arpa/inet.h> | 5 | #include <arpa/inet.h> |
diff --git a/ot_mutex.h b/src/ot_mutex.h index c1218d7..d7ded92 100644 --- a/ot_mutex.h +++ b/src/ot_mutex.h | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | #ifndef OT_MUTEX_H__ | 4 | #ifndef OT_MUTEX_H__ |
| 7 | #define OT_MUTEX_H__ | 5 | #define OT_MUTEX_H__ |
diff --git a/ot_random.c b/src/ot_random.c index 3fae876..43f91bb 100644 --- a/ot_random.c +++ b/src/ot_random.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <stdint.h> | 5 | #include <stdint.h> |
diff --git a/ot_random.h b/src/ot_random.h index 5200dbc..c2d0387 100644 --- a/ot_random.h +++ b/src/ot_random.h | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | #ifndef OT_RANDOM_H__ | 4 | #ifndef OT_RANDOM_H__ |
| 7 | #define OT_RANDOM_H__ | 5 | #define OT_RANDOM_H__ |
diff --git a/ot_rijndael.c b/src/ot_rijndael.c index 3f36bde..3f36bde 100644 --- a/ot_rijndael.c +++ b/src/ot_rijndael.c | |||
diff --git a/ot_rijndael.h b/src/ot_rijndael.h index 54725dc..1235215 100644 --- a/ot_rijndael.h +++ b/src/ot_rijndael.h | |||
| @@ -5,9 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | http://www.cs.ucdavis.edu/~rogaway/ocb/ocb-ref/rijndael-alg-fst.c | 6 | http://www.cs.ucdavis.edu/~rogaway/ocb/ocb-ref/rijndael-alg-fst.c |
| 7 | 7 | ||
| 8 | and modified to work with 128 bits (this is 10 rounds) only. | 8 | and modified to work with 128 bits (this is 10 rounds) only. */ |
| 9 | |||
| 10 | $id$ */ | ||
| 11 | 9 | ||
| 12 | #ifndef OT_RIJNDAEL_H__ | 10 | #ifndef OT_RIJNDAEL_H__ |
| 13 | #define OT_RIJNDAEL_H__ | 11 | #define OT_RIJNDAEL_H__ |
diff --git a/ot_scan.c b/src/ot_scan.c index c4b951a..3b8e87c 100644 --- a/ot_scan.c +++ b/src/ot_scan.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <errno.h> | 5 | #include <errno.h> |
diff --git a/ot_scan.h b/src/ot_scan.h index ca3bbbd..a79ec13 100644 --- a/ot_scan.h +++ b/src/ot_scan.h | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | #ifndef OT_SCAN_H__ | 4 | #ifndef OT_SCAN_H__ |
| 7 | #define OT_SCAN_H__ | 5 | #define OT_SCAN_H__ |
diff --git a/ot_socket.c b/src/ot_socket.c index 48ffc27..79bb01a 100644 --- a/ot_socket.c +++ b/src/ot_socket.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #define _GNU_SOURCE /* accept4 on glibc */ | 5 | #define _GNU_SOURCE /* accept4 on glibc */ |
diff --git a/ot_socket.h b/src/ot_socket.h index 5bbffe1..5c1d840 100644 --- a/ot_socket.h +++ b/src/ot_socket.h | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | #ifndef OT_SOCKET_H__ | 4 | #ifndef OT_SOCKET_H__ |
| 7 | #define OT_SOCKET_H__ | 5 | #define OT_SOCKET_H__ |
diff --git a/ot_stats.c b/src/ot_stats.c index 8771f0c..2d6335b 100644 --- a/ot_stats.c +++ b/src/ot_stats.c | |||
| @@ -1,10 +1,7 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <inttypes.h> | ||
| 8 | #include <pthread.h> | 5 | #include <pthread.h> |
| 9 | #include <stdatomic.h> | 6 | #include <stdatomic.h> |
| 10 | #include <stdio.h> | 7 | #include <stdio.h> |
| @@ -513,7 +510,6 @@ static void stats_return_everything(char **reply, const char *reply_end) { | |||
| 513 | 510 | ||
| 514 | fmt_append(reply, reply_end, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); | 511 | fmt_append(reply, reply_end, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); |
| 515 | fmt_append(reply, reply_end, "<stats>\n"); | 512 | fmt_append(reply, reply_end, "<stats>\n"); |
| 516 | fmt_append(reply, reply_end, " <tracker_id>%" PRIu32 "</tracker_id>\n", g_tracker_id); | ||
| 517 | fmt_append(reply, reply_end, " <uptime>%llu</uptime>\n", (unsigned long long)(time(NULL) - ot_start_time)); | 513 | fmt_append(reply, reply_end, " <uptime>%llu</uptime>\n", (unsigned long long)(time(NULL) - ot_start_time)); |
| 518 | fmt_append(reply, reply_end, " <torrents>\n"); | 514 | fmt_append(reply, reply_end, " <torrents>\n"); |
| 519 | fmt_append(reply, reply_end, " <count_mutex>%zd</count_mutex>\n", mutex_get_torrent_count()); | 515 | fmt_append(reply, reply_end, " <count_mutex>%zd</count_mutex>\n", mutex_get_torrent_count()); |
diff --git a/ot_stats.h b/src/ot_stats.h index f9a9d87..45a547e 100644 --- a/ot_stats.h +++ b/src/ot_stats.h | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | #ifndef OT_STATS_H__ | 4 | #ifndef OT_STATS_H__ |
| 7 | #define OT_STATS_H__ | 5 | #define OT_STATS_H__ |
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <errno.h> | 5 | #include <errno.h> |
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | #ifndef OT_TCP_H__ | 4 | #ifndef OT_TCP_H__ |
| 7 | #define OT_TCP_H__ | 5 | #define OT_TCP_H__ |
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <arpa/inet.h> | 5 | #include <arpa/inet.h> |
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | #ifndef OT_UDP_H__ | 4 | #ifndef OT_UDP_H__ |
| 7 | #define OT_UDP_H__ | 5 | #define OT_UDP_H__ |
diff --git a/ot_urlencoded.c b/src/ot_urlencoded.c index 17f12a4..4109bb5 100644 --- a/ot_urlencoded.c +++ b/src/ot_urlencoded.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* Opentracker */ | 4 | /* Opentracker */ |
| 7 | #include "ot_urlencoded.h" | 5 | #include "ot_urlencoded.h" |
diff --git a/ot_urlencoded.h b/src/ot_urlencoded.h index b6f1208..9882468 100644 --- a/ot_urlencoded.h +++ b/src/ot_urlencoded.h | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | #ifndef SCAN_URLENCODED_QUERY_H__ | 4 | #ifndef SCAN_URLENCODED_QUERY_H__ |
| 7 | #define SCAN_URLENCODED_QUERY_H__ | 5 | #define SCAN_URLENCODED_QUERY_H__ |
diff --git a/ot_vector.c b/src/ot_vector.c index 8310634..ab0566c 100644 --- a/ot_vector.c +++ b/src/ot_vector.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <stddef.h> | 5 | #include <stddef.h> |
diff --git a/ot_vector.h b/src/ot_vector.h index d553956..8a5ba86 100644 --- a/ot_vector.h +++ b/src/ot_vector.h | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | #ifndef OT_VECTOR_H__ | 4 | #ifndef OT_VECTOR_H__ |
| 7 | #define OT_VECTOR_H__ | 5 | #define OT_VECTOR_H__ |
diff --git a/ot_worker.c b/src/ot_worker.c index 97eaeb2..432d272 100644 --- a/ot_worker.c +++ b/src/ot_worker.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <pthread.h> | 5 | #include <pthread.h> |
diff --git a/ot_worker.h b/src/ot_worker.h index ea4f379..4954773 100644 --- a/ot_worker.h +++ b/src/ot_worker.h | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | #ifndef OT_WORKER_H__ | 4 | #ifndef OT_WORKER_H__ |
| 7 | #define OT_WORKER_H__ | 5 | #define OT_WORKER_H__ |
diff --git a/ot_workqueue.c b/src/ot_workqueue.c index aac366c..56a7cd2 100644 --- a/ot_workqueue.c +++ b/src/ot_workqueue.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <pthread.h> | 5 | #include <pthread.h> |
diff --git a/ot_workqueue.h b/src/ot_workqueue.h index 4acd6fd..82ae29b 100644 --- a/ot_workqueue.h +++ b/src/ot_workqueue.h | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | #ifndef OT_WORKQUEUE_H__ | 4 | #ifndef OT_WORKQUEUE_H__ |
| 7 | #define OT_WORKQUEUE_H__ | 5 | #define OT_WORKQUEUE_H__ |
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $Id$ */ | ||
| 5 | 3 | ||
| 6 | /* This relays sync traffic between trackers, and between multicast domains | 4 | /* This relays sync traffic between trackers, and between multicast domains |
| 7 | that have no route to each other, so that no tracker has to reach out to | 5 | that have no route to each other, so that no tracker has to reach out to |
diff --git a/trackerlogic.c b/src/trackerlogic.c index b0b7f4e..9565090 100644 --- a/trackerlogic.c +++ b/src/trackerlogic.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <arpa/inet.h> | 5 | #include <arpa/inet.h> |
diff --git a/trackerlogic.h b/src/trackerlogic.h index 39afece..7292d36 100644 --- a/trackerlogic.h +++ b/src/trackerlogic.h | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | #ifndef OT_TRACKERLOGIC_H__ | 4 | #ifndef OT_TRACKERLOGIC_H__ |
| 7 | #define OT_TRACKERLOGIC_H__ | 5 | #define OT_TRACKERLOGIC_H__ |
| @@ -64,7 +62,12 @@ typedef struct { | |||
| 64 | 62 | ||
| 65 | /* We maintain a list of 1024 pointers to sorted list of ot_torrent structs | 63 | /* We maintain a list of 1024 pointers to sorted list of ot_torrent structs |
| 66 | Sort key is, of course, its hash */ | 64 | Sort key is, of course, its hash */ |
| 65 | /* Set from the Makefile, 8 to 16. More buckets means shorter vectors and a | ||
| 66 | cheaper insert, which only pays for a tracker carrying millions of | ||
| 67 | torrents; see DESIGN. */ | ||
| 68 | #ifndef OT_BUCKET_COUNT_BITS | ||
| 67 | #define OT_BUCKET_COUNT_BITS 10 | 69 | #define OT_BUCKET_COUNT_BITS 10 |
| 70 | #endif | ||
| 68 | 71 | ||
| 69 | #define OT_BUCKET_COUNT (1 << OT_BUCKET_COUNT_BITS) | 72 | #define OT_BUCKET_COUNT (1 << OT_BUCKET_COUNT_BITS) |
| 70 | #define OT_BUCKET_COUNT_SHIFT (32 - OT_BUCKET_COUNT_BITS) | 73 | #define OT_BUCKET_COUNT_SHIFT (32 - OT_BUCKET_COUNT_BITS) |
diff --git a/tests/integration/test_stats.py b/tests/integration/test_stats.py index 74f6d47..088d8a1 100644 --- a/tests/integration/test_stats.py +++ b/tests/integration/test_stats.py | |||
| @@ -66,6 +66,12 @@ class StatsShape(TrackerTestCase): | |||
| 66 | def test_everything_does_not_name_the_build(self): | 66 | def test_everything_does_not_name_the_build(self): |
| 67 | self.assertNotIn(b"opentracker 1", self.tracker.stats("everything")) | 67 | self.assertNotIn(b"opentracker 1", self.tracker.stats("everything")) |
| 68 | 68 | ||
| 69 | def test_everything_does_not_name_the_tracker_id(self): | ||
| 70 | """The id a tracker recognises its own live sync packets by. Knowing | ||
| 71 | it is of no use to a client and of some use to whoever would like a | ||
| 72 | tracker to discard what it is told.""" | ||
| 73 | self.assertNotIn(b"tracker_id", self.tracker.stats("everything")) | ||
| 74 | |||
| 69 | 75 | ||
| 70 | class StatsCount(TrackerTestCase): | 76 | class StatsCount(TrackerTestCase): |
| 71 | def test_the_torrent_count_follows_the_torrents(self): | 77 | def test_the_torrent_count_follows_the_torrents(self): |
diff --git a/tests/runner.c b/tests/runner.c index 97c6d51..ae2565b 100644 --- a/tests/runner.c +++ b/tests/runner.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <stdio.h> | 5 | #include <stdio.h> |
diff --git a/tests/stubs.c b/tests/stubs.c index 5999e2d..f7ac679 100644 --- a/tests/stubs.c +++ b/tests/stubs.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* Stubs for symbols the modules under test reference but never reach along | 4 | /* Stubs for symbols the modules under test reference but never reach along |
| 7 | the paths the tests exercise. If a test ever does reach one, the missing | 5 | the paths the tests exercise. If a test ever does reach one, the missing |
diff --git a/sync_daemon.pl b/tests/sync_daemon.pl index 9e4bdb9..9e4bdb9 100644 --- a/sync_daemon.pl +++ b/tests/sync_daemon.pl | |||
diff --git a/tests/t_accesslist.c b/tests/t_accesslist.c index 9925acd..14321f4 100644 --- a/tests/t_accesslist.c +++ b/tests/t_accesslist.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <stdlib.h> | 5 | #include <stdlib.h> |
diff --git a/tests/t_batch.c b/tests/t_batch.c index 02743f1..5a7ac1e 100644 --- a/tests/t_batch.c +++ b/tests/t_batch.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <fcntl.h> | 5 | #include <fcntl.h> |
diff --git a/tests/t_buf.c b/tests/t_buf.c index dcfb0bb..39c44f1 100644 --- a/tests/t_buf.c +++ b/tests/t_buf.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <stdint.h> | 5 | #include <stdint.h> |
diff --git a/tests/t_event.c b/tests/t_event.c index 1908dc9..5c45089 100644 --- a/tests/t_event.c +++ b/tests/t_event.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <fcntl.h> | 5 | #include <fcntl.h> |
diff --git a/tests/t_fdstate.c b/tests/t_fdstate.c index 421f076..c806dbe 100644 --- a/tests/t_fdstate.c +++ b/tests/t_fdstate.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <pthread.h> | 5 | #include <pthread.h> |
diff --git a/tests/t_fmt.c b/tests/t_fmt.c index bc23ed5..f94102d 100644 --- a/tests/t_fmt.c +++ b/tests/t_fmt.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <string.h> | 5 | #include <string.h> |
diff --git a/tests/t_hex.c b/tests/t_hex.c index a761737..84aeba2 100644 --- a/tests/t_hex.c +++ b/tests/t_hex.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <stdint.h> | 5 | #include <stdint.h> |
diff --git a/tests/t_iovec.c b/tests/t_iovec.c index 2553141..1e8206d 100644 --- a/tests/t_iovec.c +++ b/tests/t_iovec.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <stdlib.h> | 5 | #include <stdlib.h> |
diff --git a/tests/t_ip.c b/tests/t_ip.c index 8d71679..218d3ff 100644 --- a/tests/t_ip.c +++ b/tests/t_ip.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <stdint.h> | 5 | #include <stdint.h> |
diff --git a/tests/t_mutex.c b/tests/t_mutex.c index 7c1463b..c0c41cc 100644 --- a/tests/t_mutex.c +++ b/tests/t_mutex.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <pthread.h> | 5 | #include <pthread.h> |
| @@ -26,7 +24,7 @@ static void hash_for_bucket(ot_hash hash, int bucket) { | |||
| 26 | } | 24 | } |
| 27 | 25 | ||
| 28 | static void case_a_hash_names_its_bucket(void) { | 26 | static void case_a_hash_names_its_bucket(void) { |
| 29 | static const int buckets[] = {0, 1, 2, 17, 511, 512, OT_BUCKET_COUNT - 1}; | 27 | static const int buckets[] = {0, 1, 2, 17, OT_BUCKET_COUNT / 2 - 1, OT_BUCKET_COUNT / 2, OT_BUCKET_COUNT - 1}; |
| 30 | size_t i; | 28 | size_t i; |
| 31 | 29 | ||
| 32 | test_case("a hash is served by the bucket its leading bits name"); | 30 | test_case("a hash is served by the bucket its leading bits name"); |
diff --git a/tests/t_random.c b/tests/t_random.c index 67dedf6..b070c3f 100644 --- a/tests/t_random.c +++ b/tests/t_random.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <stdint.h> | 5 | #include <stdint.h> |
diff --git a/tests/t_scan.c b/tests/t_scan.c index aab4413..05c4a67 100644 --- a/tests/t_scan.c +++ b/tests/t_scan.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <stdint.h> | 5 | #include <stdint.h> |
diff --git a/tests/t_socket.c b/tests/t_socket.c index 20a0c0a..8e917a3 100644 --- a/tests/t_socket.c +++ b/tests/t_socket.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <errno.h> | 5 | #include <errno.h> |
diff --git a/tests/t_trackerlogic.c b/tests/t_trackerlogic.c index d3d8755..f64977f 100644 --- a/tests/t_trackerlogic.c +++ b/tests/t_trackerlogic.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <arpa/inet.h> | 5 | #include <arpa/inet.h> |
diff --git a/tests/t_urlencoded.c b/tests/t_urlencoded.c index 6e0ee31..3b3e6c2 100644 --- a/tests/t_urlencoded.c +++ b/tests/t_urlencoded.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <string.h> | 5 | #include <string.h> |
diff --git a/tests/t_vector.c b/tests/t_vector.c index 6e048e1..f0a9bf7 100644 --- a/tests/t_vector.c +++ b/tests/t_vector.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <stdint.h> | 5 | #include <stdint.h> |
diff --git a/tests/t_workqueue.c b/tests/t_workqueue.c index 13e0b2e..c454e5b 100644 --- a/tests/t_workqueue.c +++ b/tests/t_workqueue.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <stdlib.h> | 5 | #include <stdlib.h> |
diff --git a/tests/test.c b/tests/test.c index 4686369..33f77bd 100644 --- a/tests/test.c +++ b/tests/test.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | /* System */ | 4 | /* System */ |
| 7 | #include <stdarg.h> | 5 | #include <stdarg.h> |
diff --git a/tests/test.h b/tests/test.h index d7296cc..82ec178 100644 --- a/tests/test.h +++ b/tests/test.h | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> |
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ |
| 3 | |||
| 4 | $id$ */ | ||
| 5 | 3 | ||
| 6 | #ifndef OT_TEST_H__ | 4 | #ifndef OT_TEST_H__ |
| 7 | #define OT_TEST_H__ | 5 | #define OT_TEST_H__ |
