Skip to content

fasthttp: process BSD requests outside the kqueue loop#27477

Open
guweigang wants to merge 1 commit into
vlang:masterfrom
guweigang:fix-fasthttp-bsd
Open

fasthttp: process BSD requests outside the kqueue loop#27477
guweigang wants to merge 1 commit into
vlang:masterfrom
guweigang:fix-fasthttp-bsd

Conversation

@guweigang

Copy link
Copy Markdown
Contributor

Summary

This changes the BSD fasthttp backend so complete HTTP requests are dispatched from the kqueue loop to worker threads, while connection close/rearm/write lifecycle operations are posted back to the event-loop thread through a command channel.

The BSD backend previously executed request_handler directly inside the kqueue loop. A handler that performed blocking work, including an HTTP request back to the same server, could prevent the loop from accepting or processing the nested request.

Details

  • track connections that currently have a request being processed
  • remove read/write interest before dispatching a complete request
  • run the request handler asynchronously
  • keep kqueue/client-map mutations on the event-loop thread via loop commands
  • re-enable reads or writes from the loop after the worker finishes preparing the response
  • preserve manual takeover and reusable takeover handling

This keeps each fd owned by only one active request at a time, while avoiding direct kqueue/client-map mutation from worker threads.

Tests

  • v -cc cc -d use_openssl -enable-globals test vlib/fasthttp/fasthttp_test.v

The added regression test starts a fasthttp server and verifies that a handler for /outer can synchronously fetch /inner from the same server.

@guweigang guweigang marked this pull request as ready for review June 17, 2026 07:47
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.

@guweigang

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant