diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-10-31 16:34:30 +0100 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-10-31 16:34:30 +0100 |
| commit | 0bd368691eb0d9051725d76b2a3721bb902c919b (patch) | |
| tree | 7a74fc73d9e591d4a48d0c7b1d5806a710999852 /opentracker.c | |
| parent | 4d030871c004c917458b5e1c296edcfc689a2e66 (diff) | |
Make the mainloop behave like every worker by claiming and releasing a socket being worked on
Diffstat (limited to 'opentracker.c')
| -rw-r--r-- | opentracker.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/opentracker.c b/opentracker.c index e5efff5..6e073e9 100644 --- a/opentracker.c +++ b/opentracker.c | |||
| @@ -137,12 +137,14 @@ static void *server_mainloop(void *args) { | |||
| 137 | else if ((intptr_t)cookie == FLAG_SELFPIPE) | 137 | else if ((intptr_t)cookie == FLAG_SELFPIPE) |
| 138 | while (read((int)sock, ws.inbuf, G_INBUF_SIZE) > 0) | 138 | while (read((int)sock, ws.inbuf, G_INBUF_SIZE) > 0) |
| 139 | ; | 139 | ; |
| 140 | else { | 140 | else if (fdstate_claim((int)sock, ready[i].generation)) { |
| 141 | if (ready[i].what & EVENT_IN) | 141 | if (ready[i].what & EVENT_IN) |
| 142 | tcp_read(sock, &ws); | 142 | tcp_read(sock, &ws); |
| 143 | /* The read may have closed it, so look again before writing */ | 143 | /* The read may have closed it, so look again before writing */ |
| 144 | if ((ready[i].what & EVENT_OUT) && fdstate_generation((int)sock) == ready[i].generation) | 144 | if ((ready[i].what & EVENT_OUT) && fdstate_generation((int)sock) == ready[i].generation) |
| 145 | tcp_write(sock); | 145 | tcp_write(sock); |
| 146 | if (fdstate_generation((int)sock) == ready[i].generation) | ||
| 147 | fdstate_release((int)sock); | ||
| 146 | } | 148 | } |
| 147 | } | 149 | } |
| 148 | 150 | ||
