diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-12 22:28:39 +0100 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-12 22:28:39 +0100 |
| commit | bfef6800268cdcf0b9118d89f1ce7c3541bd0309 (patch) | |
| tree | c43a44135953914a42dfe9666e85552fa4a35d17 | |
| parent | 530d3ee20a06f2a128b1eddaf2398011d3f1d119 (diff) | |
| -rw-r--r-- | src/ot_fdstate.c | 12 | ||||
| -rw-r--r-- | src/ot_fdstate.h | 8 | ||||
| -rw-r--r-- | src/ot_stats.c | 2 | ||||
| -rw-r--r-- | src/trackerlogic.h | 2 |
4 files changed, 12 insertions, 12 deletions
diff --git a/src/ot_fdstate.c b/src/ot_fdstate.c index 8e4bd89..bbb25d2 100644 --- a/src/ot_fdstate.c +++ b/src/ot_fdstate.c | |||
| @@ -24,7 +24,7 @@ enum { FD_FREE, FD_IDLE, FD_BUSY, FD_CLOSING }; | |||
| 24 | typedef struct { | 24 | typedef struct { |
| 25 | _Atomic uint64_t state; | 25 | _Atomic uint64_t state; |
| 26 | _Atomic(void *) cookie; | 26 | _Atomic(void *) cookie; |
| 27 | _Atomic ot_time expiry; | 27 | _Atomic unsigned long expiry; |
| 28 | } ot_fdslot; | 28 | } ot_fdslot; |
| 29 | 29 | ||
| 30 | /* A descriptor the kernel can hand out is below the limit it was handed out | 30 | /* A descriptor the kernel can hand out is below the limit it was handed out |
| @@ -72,7 +72,7 @@ static ot_fdslot *fdstate_slot(int fd) { | |||
| 72 | return g_slots + fd; | 72 | return g_slots + fd; |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | uint32_t fdstate_open(int fd, void *cookie, ot_time expiry) { | 75 | uint32_t fdstate_open(int fd, void *cookie, unsigned long expiry) { |
| 76 | ot_fdslot *slot = fdstate_slot(fd); | 76 | ot_fdslot *slot = fdstate_slot(fd); |
| 77 | uint64_t word; | 77 | uint64_t word; |
| 78 | 78 | ||
| @@ -132,10 +132,10 @@ void fdstate_release(int fd) { | |||
| 132 | atomic_store_explicit(&slot->state, FD_SET_ST(word, FD_IDLE), memory_order_release); | 132 | atomic_store_explicit(&slot->state, FD_SET_ST(word, FD_IDLE), memory_order_release); |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | int fdstate_claim_expired(int fd, ot_time now) { | 135 | int fdstate_claim_expired(int fd, unsigned long now) { |
| 136 | ot_fdslot *slot = fdstate_slot(fd); | 136 | ot_fdslot *slot = fdstate_slot(fd); |
| 137 | uint64_t word; | 137 | uint64_t word; |
| 138 | ot_time expiry; | 138 | unsigned long expiry; |
| 139 | 139 | ||
| 140 | if (!slot) | 140 | if (!slot) |
| 141 | return 0; | 141 | return 0; |
| @@ -168,7 +168,7 @@ void fdstate_close(int fd) { | |||
| 168 | atomic_store_explicit(&slot->state, FD_WORD(FD_GEN(word) + 1, FD_FREE), memory_order_release); | 168 | atomic_store_explicit(&slot->state, FD_WORD(FD_GEN(word) + 1, FD_FREE), memory_order_release); |
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | int fdstate_next_expired(ot_time now, int *cursor) { | 171 | int fdstate_next_expired(unsigned long now, int *cursor) { |
| 172 | size_t highest = atomic_load_explicit(&g_slot_highest, memory_order_relaxed); | 172 | size_t highest = atomic_load_explicit(&g_slot_highest, memory_order_relaxed); |
| 173 | 173 | ||
| 174 | for (; (size_t)*cursor <= highest; ++*cursor) | 174 | for (; (size_t)*cursor <= highest; ++*cursor) |
| @@ -194,7 +194,7 @@ void fdstate_set_cookie(int fd, void *cookie) { | |||
| 194 | atomic_store_explicit(&slot->cookie, cookie, memory_order_release); | 194 | atomic_store_explicit(&slot->cookie, cookie, memory_order_release); |
| 195 | } | 195 | } |
| 196 | 196 | ||
| 197 | void fdstate_set_expiry(int fd, ot_time expiry) { | 197 | void fdstate_set_expiry(int fd, unsigned long expiry) { |
| 198 | ot_fdslot *slot = fdstate_slot(fd); | 198 | ot_fdslot *slot = fdstate_slot(fd); |
| 199 | 199 | ||
| 200 | if (slot) | 200 | if (slot) |
diff --git a/src/ot_fdstate.h b/src/ot_fdstate.h index 60fe070..20f469d 100644 --- a/src/ot_fdstate.h +++ b/src/ot_fdstate.h | |||
| @@ -27,7 +27,7 @@ size_t fdstate_slots(void); | |||
| 27 | 27 | ||
| 28 | /* Take a freshly accepted descriptor into the table and return the | 28 | /* Take a freshly accepted descriptor into the table and return the |
| 29 | generation to quote when asking for it back. expiry of 0 never expires. */ | 29 | generation to quote when asking for it back. expiry of 0 never expires. */ |
| 30 | uint32_t fdstate_open(int fd, void *cookie, ot_time expiry); | 30 | uint32_t fdstate_open(int fd, void *cookie, unsigned long expiry); |
| 31 | 31 | ||
| 32 | /* Which generation a descriptor currently carries, to check an event that | 32 | /* Which generation a descriptor currently carries, to check an event that |
| 33 | was handed out earlier against the connection living there now. */ | 33 | was handed out earlier against the connection living there now. */ |
| @@ -40,7 +40,7 @@ void fdstate_release(int fd); | |||
| 40 | 40 | ||
| 41 | /* The cleaner's side of the same thing: takes the descriptor only if nobody | 41 | /* The cleaner's side of the same thing: takes the descriptor only if nobody |
| 42 | is working on it and it really has expired. Never waits. */ | 42 | is working on it and it really has expired. Never waits. */ |
| 43 | int fdstate_claim_expired(int fd, ot_time now); | 43 | int fdstate_claim_expired(int fd, unsigned long now); |
| 44 | 44 | ||
| 45 | /* Give the descriptor up. The generation is bumped here, which has to happen | 45 | /* Give the descriptor up. The generation is bumped here, which has to happen |
| 46 | before close(2) so that the kernel cannot reissue the number while events | 46 | before close(2) so that the kernel cannot reissue the number while events |
| @@ -50,13 +50,13 @@ void fdstate_close(int fd); | |||
| 50 | /* Walks the table for descriptors that have expired, handing back one at a | 50 | /* Walks the table for descriptors that have expired, handing back one at a |
| 51 | time until it returns -1. The cursor belongs to the caller, so several | 51 | time until it returns -1. The cursor belongs to the caller, so several |
| 52 | sweepers can run without sharing anything. */ | 52 | sweepers can run without sharing anything. */ |
| 53 | int fdstate_next_expired(ot_time now, int *cursor); | 53 | int fdstate_next_expired(unsigned long now, int *cursor); |
| 54 | 54 | ||
| 55 | /* Both only valid while the caller holds the descriptor. */ | 55 | /* Both only valid while the caller holds the descriptor. */ |
| 56 | void *fdstate_cookie(int fd); | 56 | void *fdstate_cookie(int fd); |
| 57 | 57 | ||
| 58 | /* Hand the slot a different cookie, for a connection whose state has moved */ | 58 | /* Hand the slot a different cookie, for a connection whose state has moved */ |
| 59 | void fdstate_set_cookie(int fd, void *cookie); | 59 | void fdstate_set_cookie(int fd, void *cookie); |
| 60 | void fdstate_set_expiry(int fd, ot_time expiry); | 60 | void fdstate_set_expiry(int fd, unsigned long expiry); |
| 61 | 61 | ||
| 62 | #endif | 62 | #endif |
diff --git a/src/ot_stats.c b/src/ot_stats.c index ba780d3..95f3cff 100644 --- a/src/ot_stats.c +++ b/src/ot_stats.c | |||
| @@ -83,7 +83,7 @@ static void counters_total(unsigned long long *total) { | |||
| 83 | pthread_mutex_unlock(&g_counter_mutex); | 83 | pthread_mutex_unlock(&g_counter_mutex); |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | #define COUNT(index, by) atomic_fetch_add_explicit(ws->counters + (index), (unsigned long long)(by), memory_order_relaxed) | 86 | #define COUNT(index, by) atomic_fetch_add_explicit(ws->counters + (index), (unsigned long)(by), memory_order_relaxed) |
| 87 | 87 | ||
| 88 | static const char *ot_failed_request_names[] = { | 88 | static const char *ot_failed_request_names[] = { |
| 89 | "302 Redirect", "400 Parse Error", "400 Invalid Parameter", "400 Invalid Parameter (compact=0)", "400 Not Modest", | 89 | "302 Redirect", "400 Parse Error", "400 Invalid Parameter", "400 Invalid Parameter (compact=0)", "400 Not Modest", |
diff --git a/src/trackerlogic.h b/src/trackerlogic.h index dd8a48c..4086b23 100644 --- a/src/trackerlogic.h +++ b/src/trackerlogic.h | |||
| @@ -221,7 +221,7 @@ enum { | |||
| 221 | }; | 221 | }; |
| 222 | 222 | ||
| 223 | /* One statistic. Used when workers report stats to their workstruct */ | 223 | /* One statistic. Used when workers report stats to their workstruct */ |
| 224 | typedef _Atomic unsigned long long ot_counter; | 224 | typedef _Atomic unsigned long ot_counter; |
| 225 | 225 | ||
| 226 | /* What each thread counts for itself. The two runs at the end are indexed by | 226 | /* What each thread counts for itself. The two runs at the end are indexed by |
| 227 | the http error code and by the age in minutes of a renewed peer */ | 227 | the http error code and by the age in minutes of a renewed peer */ |
