diff options
| author | Onur Gündüz <ogunduz@gmail.com> | 2026-06-24 02:29:52 +0200 |
|---|---|---|
| committer | Onur Gündüz <ogunduz@gmail.com> | 2026-06-24 02:29:52 +0200 |
| commit | dc29ac64a203a954161026ad5f6288df201e11ad (patch) | |
| tree | 019f84f6a15b53b6134d75ef7f539f986a918fda /tools/server/server.c | |
| parent | cb85a499f3d5178a752c85063bf9ff277ca3a71e (diff) | |
| download | ffwd-dc29ac64a203a954161026ad5f6288df201e11ad.tar.gz ffwd-dc29ac64a203a954161026ad5f6288df201e11ad.zip | |
server: fix tokenizer data race under concurrency
Diffstat (limited to 'tools/server/server.c')
| -rw-r--r-- | tools/server/server.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/tools/server/server.c b/tools/server/server.c index 7a71a1f..f18d264 100644 --- a/tools/server/server.c +++ b/tools/server/server.c @@ -106,13 +106,10 @@ void dispatch_request(client *c) { j->auth = c->req.auth ? xstrdup(c->req.auth) : NULL; j->created_ns = nstime(); client_incref(c); - /* Tokenize off the worker when the pipeline is already busy so it overlaps - * in-flight work; tokenize inline on the worker when idle to avoid a - * queue hand-off that single-stream requests gain nothing from. */ - if (server_has_backlog(c->srv)) - enqueue_raw_job(j); - else - enqueue_job(j); + /* All requests go through the tokenizer thread. Tokenization must run on a + * single thread because the model tokenizer is shared mutable state; letting + * the worker also tokenize would race it. */ + enqueue_raw_job(j); } static void accept_cb(aeEventLoop *loop, int fd, void *clientData, int mask) { |
