diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-03 02:45:55 +0100 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-03 02:45:55 +0100 |
| commit | 253432c918dacc8bfd5d9a6a46c45a9dc682c7ec (patch) | |
| tree | e51bdde6bffa5e6107a74d10c27585b35f44f917 /src | |
| parent | 0fcf290ba2db320287163f142a83da0f9fe48b77 (diff) | |
Diffstat (limited to 'src')
| -rw-r--r-- | src/opentracker.c | 2 | ||||
| -rw-r--r-- | src/ot_livesync.c | 12 | ||||
| -rw-r--r-- | src/ot_worker.c | 2 | ||||
| -rw-r--r-- | src/trackerlogic.c | 6 | ||||
| -rw-r--r-- | src/trackerlogic.h | 2 |
5 files changed, 15 insertions, 9 deletions
diff --git a/src/opentracker.c b/src/opentracker.c index 14b817e..60a6d8c 100644 --- a/src/opentracker.c +++ b/src/opentracker.c | |||
| @@ -109,7 +109,7 @@ static void *server_mainloop(void *args) { | |||
| 109 | 109 | ||
| 110 | (void)args; | 110 | (void)args; |
| 111 | 111 | ||
| 112 | if (workstruct_init(&ws) == -1) | 112 | if (workstruct_init(&ws, G_INBUF_SIZE) == -1) |
| 113 | panic("Initializing worker failed"); | 113 | panic("Initializing worker failed"); |
| 114 | 114 | ||
| 115 | while (g_opentracker_running) { | 115 | while (g_opentracker_running) { |
diff --git a/src/ot_livesync.c b/src/ot_livesync.c index 083fe1a..18dae0d 100644 --- a/src/ot_livesync.c +++ b/src/ot_livesync.c | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | /* System */ | 4 | /* System */ |
| 5 | #include <arpa/inet.h> | 5 | #include <arpa/inet.h> |
| 6 | #include <pthread.h> | 6 | #include <pthread.h> |
| 7 | #include <stdio.h> | ||
| 7 | #include <stdlib.h> | 8 | #include <stdlib.h> |
| 8 | #include <string.h> | 9 | #include <string.h> |
| 9 | #include <sys/socket.h> | 10 | #include <sys/socket.h> |
| @@ -200,9 +201,12 @@ static void *livesync_worker(void *args) { | |||
| 200 | 201 | ||
| 201 | (void)args; | 202 | (void)args; |
| 202 | 203 | ||
| 203 | /* Initialize our "thread local storage" */ | 204 | if (workstruct_init(&ws, LIVESYNC_INCOMING_BUFFSIZE) == -1) { |
| 204 | ws.inbuf = ws.request = malloc(LIVESYNC_INCOMING_BUFFSIZE); | 205 | fprintf(stderr, "Warning: live sync could not get its buffers and will not run.\n"); |
| 205 | ws.outbuf = ws.reply = 0; | 206 | atomic_store(&thread_left, 1); |
| 207 | return NULL; | ||
| 208 | } | ||
| 209 | ws.request = ws.inbuf; | ||
| 206 | 210 | ||
| 207 | while (g_opentracker_running) { | 211 | while (g_opentracker_running) { |
| 208 | uint32_t packet_type; | 212 | uint32_t packet_type; |
| @@ -233,7 +237,7 @@ static void *livesync_worker(void *args) { | |||
| 233 | } | 237 | } |
| 234 | } | 238 | } |
| 235 | 239 | ||
| 236 | free(ws.inbuf); | 240 | workstruct_deinit(&ws); |
| 237 | atomic_store(&thread_left, 1); | 241 | atomic_store(&thread_left, 1); |
| 238 | return NULL; | 242 | return NULL; |
| 239 | } | 243 | } |
diff --git a/src/ot_worker.c b/src/ot_worker.c index 432d272..ef50945 100644 --- a/src/ot_worker.c +++ b/src/ot_worker.c | |||
| @@ -20,7 +20,7 @@ static size_t g_worker_count; | |||
| 20 | static void *worker_trampoline(void *args) { | 20 | static void *worker_trampoline(void *args) { |
| 21 | struct ot_worker *me = args; | 21 | struct ot_worker *me = args; |
| 22 | 22 | ||
| 23 | if (workstruct_init(&me->ws) == -1) | 23 | if (workstruct_init(&me->ws, G_INBUF_SIZE) == -1) |
| 24 | fprintf(stderr, "Warning: a worker could not get its buffers and will not run.\n"); | 24 | fprintf(stderr, "Warning: a worker could not get its buffers and will not run.\n"); |
| 25 | else { | 25 | else { |
| 26 | me->run(me); | 26 | me->run(me); |
diff --git a/src/trackerlogic.c b/src/trackerlogic.c index 9565090..8e30a48 100644 --- a/src/trackerlogic.c +++ b/src/trackerlogic.c | |||
| @@ -567,9 +567,11 @@ void trackerlogic_init(void) { | |||
| 567 | stats_init(); | 567 | stats_init(); |
| 568 | } | 568 | } |
| 569 | 569 | ||
| 570 | int workstruct_init(struct ot_workstruct *ws) { | 570 | /* Live sync reads whole packets rather than requests and wants a larger |
| 571 | inbuf than the request path does, hence the size. */ | ||
| 572 | int workstruct_init(struct ot_workstruct *ws, size_t inbuf_size) { | ||
| 571 | memset(ws, 0, sizeof(*ws)); | 573 | memset(ws, 0, sizeof(*ws)); |
| 572 | ws->inbuf = malloc(G_INBUF_SIZE); | 574 | ws->inbuf = malloc(inbuf_size); |
| 573 | ws->outbuf = malloc(G_OUTBUF_SIZE); | 575 | ws->outbuf = malloc(G_OUTBUF_SIZE); |
| 574 | #ifdef _DEBUG_HTTPERROR | 576 | #ifdef _DEBUG_HTTPERROR |
| 575 | ws->debugbuf = malloc(G_DEBUGBUF_SIZE); | 577 | ws->debugbuf = malloc(G_DEBUGBUF_SIZE); |
diff --git a/src/trackerlogic.h b/src/trackerlogic.h index 7292d36..692b6af 100644 --- a/src/trackerlogic.h +++ b/src/trackerlogic.h | |||
| @@ -242,7 +242,7 @@ struct ot_workstruct { | |||
| 242 | /* Everything a thread that serves requests needs for itself. Set up and torn | 242 | /* Everything a thread that serves requests needs for itself. Set up and torn |
| 243 | down in one place so that a new kind of worker cannot miss a piece. | 243 | down in one place so that a new kind of worker cannot miss a piece. |
| 244 | Returns -1 if the buffers could not be had. */ | 244 | Returns -1 if the buffers could not be had. */ |
| 245 | int workstruct_init(struct ot_workstruct *ws); | 245 | int workstruct_init(struct ot_workstruct *ws, size_t inbuf_size); |
| 246 | void workstruct_deinit(struct ot_workstruct *ws); | 246 | void workstruct_deinit(struct ot_workstruct *ws); |
| 247 | 247 | ||
| 248 | /* | 248 | /* |
